持久化通知

This commit is contained in:
renhaoting 2025-12-19 15:46:56 +08:00
parent 8d3b2a6d03
commit d392527e4d
20 changed files with 276 additions and 236 deletions

View File

@ -39,7 +39,17 @@
</activity>
<activity android:name="com.gamedog.vididin.main.MainActivity" android:screenOrientation="portrait" android:exported="true" android:launchMode="singleTask" />
<activity
android:name="com.gamedog.vididin.main.MainActivity"
android:screenOrientation="portrait" android:exported="true"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="com.remax.notification.ACTION_OPEN_APP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.gamedog.vididin.login.LoginActivity" android:exported="false" />
<activity android:name="com.gamedog.vididin.features.benefit.BenefitActivity" android:exported="false" />
<activity android:name="com.gamedog.vididin.features.zero.ZeroBuyActivity" android:exported="false" />

View File

@ -4,7 +4,6 @@ object VidiConst {
/**
* Varous type for watching Ad
*/
@ -64,6 +63,12 @@ object VidiConst {
//------------------------ Statistics ----------------------------
const val STATISTICS_APP_OPEN = "app_open"
const val STATISTICS_NOTIFI_CLICK = "Notific_Click"
const val STATISTICS_NOTIFI_ENTER = "Notific_Enter"
}

View File

@ -328,6 +328,9 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
SpUtil.instance().putInt(SpUtil.KEY_GUIDE_HAS_SHOW, 4)
}
override fun onDestroy() {
super.onDestroy()
}
private fun showGuide() {
HighlightPro.with(this@WithDrawActivity)

View File

@ -15,10 +15,12 @@ import androidx.lifecycle.lifecycleScope
import com.ama.core.architecture.appBase.AppViewsActivity
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
import com.ama.core.architecture.ext.toast
import com.ama.core.architecture.util.AndroidUtil
import com.ama.core.architecture.util.SpUtil
import com.ama.core.architecture.util.bindViewPager2
import com.ama.core.architecture.util.setCommonNavigator
import com.ama.core.architecture.util.setDataOrAdapter
import com.blankj.utilcode.util.ActivityUtils
import com.vididin.real.money.game.R
import com.gamedog.vididin.VidiConst
import com.gamedog.vididin.VididinEvents
@ -28,7 +30,16 @@ import com.gamedog.vididin.main.fragments.task.DailySignSuccessDialog
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
import com.gamedog.vididin.manager.DateChangeReceiver
import com.gamedog.vididin.manager.NotificationController
import com.gamedog.vididin.router.Router
import com.remax.base.report.DataReportManager
import com.remax.base.utils.ActivityLauncher
import com.remax.notification.builder.LANDING_NOTIFICATION_ACTION
import com.remax.notification.builder.LANDING_NOTIFICATION_CONTENT
import com.remax.notification.builder.LANDING_NOTIFICATION_FROM
import com.remax.notification.builder.LANDING_NOTIFICATION_TITLE
import com.remax.notification.check.NotificationCheckController
import com.remax.notification.config.PushContent
import com.remax.notification.controller.NotificationLandingController
import com.remax.notification.service.NotificationKeepAliveServiceManager
import dagger.hilt.android.AndroidEntryPoint
import kotlin.getValue
@ -133,6 +144,9 @@ class MainActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabS
NotificationKeepAliveServiceManager.startKeepAliveService(this@MainActivity)
}
})
handleNotificationAction()
reportStatistics(intent, true)
}
@ -155,10 +169,126 @@ class MainActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnTabS
navigatorAdapter.setIsDarkFont(isDarkFont)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
handleNotificationAction()
reportStatistics(intent, true)
}
fun switchTab(itemIndex: Int) {
binding.viewPager2.setCurrentItem(itemIndex, false)
}
private fun handleNotificationAction() {
if (NotificationLandingController.isFromNotification(intent)) {
when (intent.getIntExtra(LANDING_NOTIFICATION_ACTION, -1)) {
PushContent.ACTION_TYPE_SCREENSHOT_CLEAN -> {
//TYPE_PHOTO_SHOT.jumpTo(this@HomeActivity)
}
PushContent.ACTION_TYPE_RECOVERED_FILES -> {
/*checkPermissionAndExecute(activityLauncher!!) {
val intent = Intent(this, TabLayoutActivity::class.java)
startActivity(intent)
}*/
}
PushContent.ACTION_TYPE_GAME -> {
AndroidUtil.openUrl(VidiConst.URL_GAME)
}
PushContent.ACTION_TYPE_GOLD -> {
switchTab(1)
}
PushContent.ACTION_TYPE_WITHDRAW -> {
Router.Withdraw.startActivity(this)
}
PushContent.ACTION_TYPE_BOX -> {
Router.Benefit.startActivity(this)
}
}
NotificationLandingController.clearNotificationParameters(intent)
}
}
private fun reportStatistics(intent: Intent, isFromNewIntent: Boolean) {
// AppOpen
DataReportManager.reportData(
VidiConst.STATISTICS_APP_OPEN,
mapOf(
"type" to if (ActivityUtils.isActivityExistsInStack(MainActivity::class.java)) "hot_open" else "cold_open",
"position" to if (intent.hasExtra(LANDING_NOTIFICATION_FROM)) intent.getStringExtra(
LANDING_NOTIFICATION_FROM).orEmpty().ifBlank { "other" } else "other"
))
// Notific_Click
if (intent.hasExtra(LANDING_NOTIFICATION_FROM)) {
val notifyFrom = intent.getStringExtra(LANDING_NOTIFICATION_FROM).orEmpty()
DataReportManager.reportData(
VidiConst.STATISTICS_NOTIFI_CLICK, mapOf(
"Notific_Type" to when (notifyFrom) {
NotificationCheckController.NotificationType.UNLOCK.string -> 1
NotificationCheckController.NotificationType.BACKGROUND.string -> 1
NotificationCheckController.NotificationType.KEEPALIVE.string -> 1
NotificationCheckController.NotificationType.FCM.string -> 3
NotificationCheckController.NotificationType.RESIDENT.string -> 4
else -> 4
},
"Notific_Position" to when (intent.getStringExtra(LANDING_NOTIFICATION_FROM).orEmpty()) {
NotificationCheckController.NotificationType.RESIDENT.string -> 2
else -> 1
},
"Notific_Priority" to when (intent.getStringExtra(LANDING_NOTIFICATION_FROM).orEmpty()) {
NotificationCheckController.NotificationType.RESIDENT.string -> "PRIORITY_DEFAULT"
else -> "PRIORITY_MAX"
},
"event_id" to when (intent.getStringExtra(LANDING_NOTIFICATION_FROM).orEmpty()) {
NotificationCheckController.NotificationType.RESIDENT.string -> "permanent"
else -> "customer_general_style"
},
"title" to intent.getStringExtra(LANDING_NOTIFICATION_TITLE).orEmpty(),
"text" to intent.getStringExtra(LANDING_NOTIFICATION_CONTENT).orEmpty(),
"from_background" to /*!ActivityUtils.isActivityExistsInStack(HomeActivity::class.java)*/isFromNewIntent
)
)
DataReportManager.reportData(
VidiConst.STATISTICS_NOTIFI_ENTER, mapOf(
"Notific_Type" to when (intent.getStringExtra(LANDING_NOTIFICATION_FROM).orEmpty()) {
NotificationCheckController.NotificationType.UNLOCK.string -> 1
NotificationCheckController.NotificationType.BACKGROUND.string -> 1
NotificationCheckController.NotificationType.KEEPALIVE.string -> 1
NotificationCheckController.NotificationType.FCM.string -> 3
NotificationCheckController.NotificationType.RESIDENT.string -> 4
else -> 4
},
"Notific_Position" to when (intent.getStringExtra(LANDING_NOTIFICATION_FROM).orEmpty()) {
NotificationCheckController.NotificationType.RESIDENT.string -> 2
else -> 1
},
"Notific_Priority" to when (intent.getStringExtra(LANDING_NOTIFICATION_FROM).orEmpty()) {
NotificationCheckController.NotificationType.RESIDENT.string -> "PRIORITY_DEFAULT"
else -> "PRIORITY_MAX"
},
"event_id" to when (intent.getStringExtra(LANDING_NOTIFICATION_FROM).orEmpty()) {
NotificationCheckController.NotificationType.RESIDENT.string -> "permanent"
else -> "customer_general_style"
},
"title" to intent.getStringExtra(LANDING_NOTIFICATION_TITLE).orEmpty(),
"text" to intent.getStringExtra(LANDING_NOTIFICATION_CONTENT).orEmpty(),
)
)
}
}
companion object {
internal fun startActivity(activity: Activity) {

View File

@ -24,7 +24,9 @@ import kotlin.random.Random
enum class NotificationType {
GENERAL,
RESIDENT, RESIDENT_RESTORED, RESIDENT_RESTORED_FILE,
WIDGET_SCREENSHOT_CLEAN,WIDGET_PHOTO_RECOVERY,WIDGET_PHOTO_DOCUMENT
WIDGET_SCREENSHOT_CLEAN,WIDGET_PHOTO_RECOVERY,WIDGET_PHOTO_DOCUMENT,
// new
RESIDENT_GOLD, RESIDENT_WITHDRAW, RESIDENT_BOX, RESIDENT_GAME,
}
val type2notificationId = mapOf(
@ -35,6 +37,13 @@ val type2notificationId = mapOf(
NotificationType.WIDGET_SCREENSHOT_CLEAN to 10004,
NotificationType.WIDGET_PHOTO_RECOVERY to 10005,
NotificationType.WIDGET_PHOTO_DOCUMENT to 10006,
// new
NotificationType.RESIDENT_GOLD to 20001,
NotificationType.RESIDENT_WITHDRAW to 20002,
NotificationType.RESIDENT_BOX to 20003,
NotificationType.RESIDENT_GAME to 20004,
)
val LANDING_NOTIFICATION_ID = "landing_notification_id"
@ -281,47 +290,33 @@ class ResidentModelManger {
context.packageName,
R.layout.layout_notification_resident_12,
R.layout.layout_notification_resident
)
.setViewVisible(R.id.ivPoint, shouldShowRedPoint(context))
.setTextViewText(
R.id.files,
StringUtils.getString(
R.string.noti_restore_file_count,
getRecoveredFileCount(context).toString()
)
)
.setTextViewText(
R.id.restored,
StringUtils.getString(
R.string.noti_restored
)
)
.setTextViewText(
R.id.restore_file,
StringUtils.getString(
R.string.noti_restore_file
)
)
).setOnClickPendingIntent(
R.id.resident_gold, entryPointPendingIntent(context,
type2notificationId[NotificationType.RESIDENT_GOLD] ?: 0
) {
it.putExtra(LANDING_NOTIFICATION_ACTION, PushContent.ACTION_TYPE_GOLD)
it.putExtra(LANDING_NOTIFICATION_FROM, NotificationCheckController.NotificationType.RESIDENT.string)
})
.setOnClickPendingIntent(
R.id.llRestored, entryPointPendingIntent(
context,
type2notificationId[NotificationType.RESIDENT_RESTORED] ?: 0
R.id.resident_withdraw, entryPointPendingIntent(context,
type2notificationId[NotificationType.RESIDENT_WITHDRAW] ?: 0
) {
it.putExtra(
LANDING_NOTIFICATION_ACTION,
PushContent.ACTION_TYPE_RECOVERED_FILES
)
it.putExtra(LANDING_NOTIFICATION_ACTION, PushContent.ACTION_TYPE_WITHDRAW)
it.putExtra(LANDING_NOTIFICATION_FROM, NotificationCheckController.NotificationType.RESIDENT.string)
})
.setOnClickPendingIntent(
R.id.llRestoreFiles, entryPointPendingIntent(
context,
type2notificationId[NotificationType.RESIDENT_RESTORED_FILE] ?: 0
R.id.resident_box, entryPointPendingIntent(context,
type2notificationId[NotificationType.RESIDENT_BOX] ?: 0
) {
it.putExtra(
LANDING_NOTIFICATION_ACTION,
PushContent.ACTION_TYPE_DOCUMENT_RECOVERY
)
it.putExtra(LANDING_NOTIFICATION_ACTION, PushContent.ACTION_TYPE_BOX)
it.putExtra(LANDING_NOTIFICATION_FROM, NotificationCheckController.NotificationType.RESIDENT.string)
})
.setOnClickPendingIntent(
R.id.resident_game, entryPointPendingIntent(context,
type2notificationId[NotificationType.RESIDENT_GAME] ?: 0
) {
it.putExtra(LANDING_NOTIFICATION_ACTION, PushContent.ACTION_TYPE_GAME)
it.putExtra(LANDING_NOTIFICATION_FROM, NotificationCheckController.NotificationType.RESIDENT.string)
})
.build()

View File

@ -56,6 +56,13 @@ data class PushContent(
const val ACTION_TYPE_SCREENSHOT_CLEAN = 5 // 跳转截图清理 界面
const val ACTION_TYPE_RECOVERED_FILES = 6 // 跳转已恢复文件列表 界面
// new ---
const val ACTION_TYPE_GOLD = 101
const val ACTION_TYPE_WITHDRAW = 102
const val ACTION_TYPE_BOX = 103
const val ACTION_TYPE_GAME = 104
/**
* 根据动作类型获取对应的图标类型
*/

View File

@ -11,7 +11,6 @@ import com.remax.notification.controller.NotificationTriggerController
import com.remax.notification.timing.NotificationTimingController
import com.remax.notification.check.NotificationCheckController
import com.remax.notification.service.NotificationKeepAliveService
import com.remax.notification.service.NotificationKeepAliveServiceManager
import com.remax.notification.utils.ResetAtMidnightController
import com.remax.notification.utils.NotiLogger

View File

@ -40,28 +40,12 @@ class NotificationRemoteViewsBuilder(
return this
}
fun setImageViewBitmap(viewId: Int, bitmap: Bitmap): NotificationRemoteViewsBuilder {
remoteViews.setImageViewBitmap(viewId, bitmap)
return this
}
fun setImageViewUri(viewId: Int, uri: Uri): NotificationRemoteViewsBuilder {
remoteViews.setImageViewUri(viewId, uri)
return this
}
fun setOnClickPendingIntent(viewId: Int, pendingIntent: PendingIntent): NotificationRemoteViewsBuilder {
remoteViews.setOnClickPendingIntent(viewId, pendingIntent)
return this
}
fun setProgressBar(
viewId: Int, max: Int, progress: Int, indeterminate: Boolean
): NotificationRemoteViewsBuilder {
remoteViews.setProgressBar(viewId, max, progress, indeterminate)
return this
}
fun build(): RemoteViews {
return remoteViews
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -1,109 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_height="50dp"
android:background="@drawable/noti_bg_r16_white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingHorizontal="12dp">
tools:ignore="ResourceName">
<FrameLayout
android:id="@+id/llRestored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/resident_gold"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/noti_bg_r8_green"
android:paddingHorizontal="12dp"
android:paddingVertical="7dp">
android:scaleType="fitCenter"
android:src="@drawable/vidi_task_gold"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="34dp"
android:layout_height="34dp"
android:src="@drawable/ic_resident_restored" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|end"
android:orientation="vertical">
<TextView
android:id="@+id/restored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/noti_restored"
android:textColor="#fff"
android:textSize="12sp" />
<TextView
android:id="@+id/files"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:text="@string/noti_restore_file_count"
android:textColor="#fff"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<FrameLayout
android:layout_width="13dp"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/llRestoreFiles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/resident_withdraw"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/noti_bg_r8_blue">
android:scaleType="fitCenter"
android:src="@drawable/vidi_task_cash"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="12dp"
android:paddingVertical="7dp">
<ImageView
android:id="@+id/resident_box"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/vidi_benefit_item_ongoing"
/>
<ImageView
android:layout_width="34dp"
android:layout_height="34dp"
android:src="@drawable/ic_resident_restore" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|end">
<TextView
android:id="@+id/restore_file"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/noti_restore_file"
android:textColor="#fff"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/ivPoint"
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_gravity="end"
android:src="@drawable/ic_resident_tip" />
</FrameLayout>
<ImageView
android:id="@+id/resident_game"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/vidi_task_act_game"
/>
<ImageView
android:id="@+id/resident_close"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:layout_gravity="top"
android:scaleType="fitCenter"
android:src="@drawable/vidi_icon_close"
/>
</LinearLayout>

View File

@ -3,106 +3,63 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="50dp"
android:background="@drawable/noti_bg_r16_white"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="horizontal"
tools:ignore="ResourceName">
<FrameLayout
android:id="@+id/llRestored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/resident_gold"
android:layout_width="0dp"
android:layout_height="match_parent"
android:clickable="true"
android:layout_weight="1"
android:background="@drawable/noti_bg_r8_green"
android:paddingHorizontal="12dp"
android:paddingVertical="7dp">
android:scaleType="fitCenter"
android:src="@drawable/vidi_task_gold"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="34dp"
android:layout_height="34dp"
android:src="@drawable/ic_resident_restored" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|end"
android:orientation="vertical">
<TextView
android:id="@+id/restored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/noti_restored"
android:textColor="#fff"
android:textSize="12sp" />
<TextView
android:id="@+id/files"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:text="@string/noti_restore_file_count"
android:textColor="#fff"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<FrameLayout
android:layout_width="13dp"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/llRestoreFiles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/resident_withdraw"
android:layout_width="0dp"
android:layout_height="match_parent"
android:clickable="true"
android:layout_weight="1"
android:background="@drawable/noti_bg_r8_blue">
android:scaleType="fitCenter"
android:src="@drawable/vidi_task_cash"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="12dp"
android:paddingVertical="7dp">
<ImageView
android:id="@+id/resident_box"
android:layout_width="0dp"
android:layout_height="match_parent"
android:clickable="true"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/vidi_benefit_item_ongoing"
/>
<ImageView
android:layout_width="34dp"
android:layout_height="34dp"
android:src="@drawable/ic_resident_restore" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|end">
<TextView
android:id="@+id/restore_file"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/noti_restore_file"
android:textColor="#fff"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/ivPoint"
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_gravity="end"
android:src="@drawable/ic_resident_tip" />
</FrameLayout>
<ImageView
android:id="@+id/resident_game"
android:layout_width="0dp"
android:layout_height="match_parent"
android:clickable="true"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="@drawable/vidi_task_act_game"
/>
<ImageView
android:id="@+id/resident_close"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_weight="1"
android:layout_gravity="top"
android:scaleType="fitCenter"
android:src="@drawable/vidi_icon_close"
/>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB