diff --git a/notification/src/main/java/com/remax/notification/newUtil/NotificationUtil.kt b/notification/src/main/java/com/remax/notification/newUtil/NotificationUtil.kt index d2664b7..e7f451b 100644 --- a/notification/src/main/java/com/remax/notification/newUtil/NotificationUtil.kt +++ b/notification/src/main/java/com/remax/notification/newUtil/NotificationUtil.kt @@ -16,6 +16,7 @@ import androidx.core.app.NotificationManagerCompat import com.ama.core.architecture.BaseApp import com.ama.core.architecture.util.permission.PermissionUtil import com.remax.notification.NotifyConst +import com.remax.notification.R class NotificationUtil private constructor() { @@ -394,7 +395,42 @@ class NotificationUtil private constructor() { } + fun showExpandableNotification(notifiConfig: NotificationConfig) { + val notificationId = notifiConfig.notificationId + val channelId = notifiConfig.channelId + val channelName = notifiConfig.channelName + val title = notifiConfig.title + val content = notifiConfig.content + val smallIcon = notifiConfig.smallIcon + val pendingIntent = notifiConfig.intent + val useFullScreenIntent = notifiConfig.useFullScreenIntent + // 1. collapse + val collapsedView = RemoteViews(mContext.packageName, R.layout.layout_notification_withdraw) + collapsedView.setTextViewText(R.id.tvTitle, title) + collapsedView.setTextViewText(R.id.tvDesc, content) + collapsedView.setOnClickPendingIntent(R.id.tvAction, pendingIntent) + + // 2. expand + val expandedView = RemoteViews(mContext.packageName, R.layout.layout_notification_withdraw_big) + collapsedView.setTextViewText(R.id.tvTitle, title) + collapsedView.setTextViewText(R.id.tvDesc, content) + expandedView.setImageViewResource(R.id.ivBottom, R.drawable.vidi_withdraw_bottom) + collapsedView.setOnClickPendingIntent(R.id.tvAction, pendingIntent) + collapsedView.setOnClickPendingIntent(R.id.ivBottom, pendingIntent) + + // 3. build + val builder = NotificationCompat.Builder(mContext, channelId) + .setSmallIcon(smallIcon) + .setCustomContentView(collapsedView) + .setCustomBigContentView(expandedView) + .setStyle(NotificationCompat.DecoratedCustomViewStyle()) + .setPriority(NotificationCompat.PRIORITY_HIGH) + .setAutoCancel(true) + .setContentIntent(pendingIntent) + + showNotification(notificationId, builder.build(), channelName) + } diff --git a/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt b/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt index 0fe80ec..711f923 100644 --- a/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt +++ b/notification/src/main/java/com/remax/notification/timing/NotificationTimingController.kt @@ -353,7 +353,8 @@ class NotificationTimingController private constructor() : LifecycleObserver { val hasClaimedSmallCash = SpUtil.instance().getObject(SpUtil.KEY_NEWBIE_FIRST_WITHDRAW)?.hasClaimReward NotificationDatas.getConfigForType(NOTI_TYPE_BG_WITHDRAW)?.let { it.content = String.format(it.content, if (hasClaimedSmallCash == null || !hasClaimedSmallCash) 0.1 else 50) - NotificationUtil.getInstance().showHeadsUpNotification(it) + //NotificationUtil.getInstance().showHeadsUpNotification(it) + NotificationUtil.getInstance().showExpandableNotification(it) NotificationRecorder.saveLastNotifyShowTime(notifyType, DateUtil.getCurTimeMs()) } diff --git a/notification/src/main/res/layout/layout_notification_withdraw.xml b/notification/src/main/res/layout/layout_notification_withdraw.xml index d6ead62..ce73dff 100644 --- a/notification/src/main/res/layout/layout_notification_withdraw.xml +++ b/notification/src/main/res/layout/layout_notification_withdraw.xml @@ -1,47 +1,38 @@ + android:padding="12dp" + android:orientation="vertical"> + + android:orientation="horizontal"> + + android:textSize="14sp" /> + android:textSize="12sp" /> - - + \ No newline at end of file diff --git a/notification/src/main/res/layout/layout_notification_withdraw_big.xml b/notification/src/main/res/layout/layout_notification_withdraw_big.xml index 91c4ffe..9982d75 100644 --- a/notification/src/main/res/layout/layout_notification_withdraw_big.xml +++ b/notification/src/main/res/layout/layout_notification_withdraw_big.xml @@ -1,47 +1,38 @@ + android:padding="12dp" + android:orientation="vertical"> + + android:orientation="horizontal"> + + android:textSize="14sp" /> + android:textSize="12sp" /> - + - - - + android:layout_marginTop="12dp" + android:layout_marginHorizontal="12dp" + android:background="#FFF"> + + + \ No newline at end of file diff --git a/notification/src/main/res/layout/notification_collapsed.xml b/notification/src/main/res/layout/notification_collapsed.xml new file mode 100644 index 0000000..ce73dff --- /dev/null +++ b/notification/src/main/res/layout/notification_collapsed.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/notification/src/main/res/layout/notification_expanded.xml b/notification/src/main/res/layout/notification_expanded.xml new file mode 100644 index 0000000..9982d75 --- /dev/null +++ b/notification/src/main/res/layout/notification_expanded.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file