diff --git a/tools/adb/notification.sh b/tools/adb/notification.sh index 3c3c76c787..7d2b55dc9e 100755 --- a/tools/adb/notification.sh +++ b/tools/adb/notification.sh @@ -2,7 +2,7 @@ ## From https://developer.android.com/develop/ui/views/notifications/notification-permission#test -PACKAGE_NAME=im.vector.app.debug +PACKAGE_NAME=de.spiritcroc.riotx.debug # App is newly installed on a device that runs Android 13 or higher: diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index a4dd00f74a..6bb6549ee9 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -129,11 +129,13 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver get() = ViewModelProvider(this, viewModelFactory) fun VectorViewModel<*, *, T>.observeViewEvents( + logTag: String? = null, observer: (T) -> Unit, ) { val tag = this@VectorBaseActivity::class.simpleName.toString() lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.RESUMED) { + logTag?.let { Timber.tag(it).i("observeViewEvents resumed - ${System.identityHashCode(this)}") } viewEvents .stream(tag) .collect { diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index 14a188ca8d..24ff0046e4 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -255,7 +255,8 @@ class HomeActivity : } } - homeActivityViewModel.observeViewEvents { + Timber.tag("SC_NP_DBG").i("Starting home event observation") + homeActivityViewModel.observeViewEvents("SC_NP_DBG") { when (it) { is HomeActivityViewEvents.AskPasswordToInitCrossSigning -> handleAskPasswordToInitCrossSigning(it) is HomeActivityViewEvents.CurrentSessionNotVerified -> handleOnNewSession(it) @@ -291,6 +292,7 @@ class HomeActivity : } private fun handleShowNotificationDialog() { + Timber.tag("SC_NP_DBG").i("handleShowNotificationDialog") notificationPermissionManager.eventuallyRequestPermission(this, postPermissionLauncher) } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index 8fb370c833..a25ffc5298 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -118,6 +118,7 @@ class HomeActivityViewModel @AssistedInject constructor( private fun initialize() { if (isInitialized) return + Timber.tag("SC_NP_DBG").i("Initialize homeActivity ${System.identityHashCode(this)}") isInitialized = true // Ensure Session is syncing ensureSessionSyncingUseCase.execute() @@ -189,6 +190,7 @@ class HomeActivityViewModel @AssistedInject constructor( if (!didAskUser) { _viewEvents.post(HomeActivityViewEvents.ShowAnalyticsOptIn) } else { + Timber.tag("SC_NP_DBG").i("didAskUser -> ask for notif permission") _viewEvents.post(HomeActivityViewEvents.ShowNotificationDialog) } } @@ -210,6 +212,7 @@ class HomeActivityViewModel @AssistedInject constructor( } } } else { + Timber.tag("SC_NP_DBG").i("no analytics -> ask for notif permission") _viewEvents.post(HomeActivityViewEvents.ShowNotificationDialog) } } diff --git a/vector/src/main/java/im/vector/app/features/home/NotificationPermissionManager.kt b/vector/src/main/java/im/vector/app/features/home/NotificationPermissionManager.kt index 2e820cf84e..f5f7568f20 100644 --- a/vector/src/main/java/im/vector/app/features/home/NotificationPermissionManager.kt +++ b/vector/src/main/java/im/vector/app/features/home/NotificationPermissionManager.kt @@ -50,6 +50,7 @@ class NotificationPermissionManager @Inject constructor( ) { if (!sdkIntProvider.isAtLeast(Build.VERSION_CODES.TIRAMISU)) return if (!vectorPreferences.areNotificationEnabledForDevice() && !ignorePreference) return + timber.log.Timber.tag("SC_NP_DBG").i("Checking notification permission") checkPermissions( listOf(Manifest.permission.POST_NOTIFICATIONS), activity,