mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 15:25:20 +00:00
Prevent quit notification from reappearing (#530)
* shutdown sequence * Prevent quit notification from reappearing * Restrict force-finish broadcast * Cancel quit shutdown on relaunch
This commit is contained in:
@@ -63,15 +63,46 @@ class MainActivity : OrientationAwareActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private val forceFinishReceiver = object : android.content.BroadcastReceiver() {
|
||||
override fun onReceive(context: android.content.Context, intent: android.content.Intent) {
|
||||
if (intent.action == com.bitchat.android.util.AppConstants.UI.ACTION_FORCE_FINISH) {
|
||||
android.util.Log.i("MainActivity", "Received force finish broadcast, closing UI")
|
||||
finishAffinity()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// Register receiver for force finish signal from shutdown coordinator
|
||||
val filter = android.content.IntentFilter(com.bitchat.android.util.AppConstants.UI.ACTION_FORCE_FINISH)
|
||||
if (android.os.Build.VERSION.SDK_INT >= 33) {
|
||||
registerReceiver(
|
||||
forceFinishReceiver,
|
||||
filter,
|
||||
com.bitchat.android.util.AppConstants.UI.PERMISSION_FORCE_FINISH,
|
||||
null,
|
||||
android.content.Context.RECEIVER_NOT_EXPORTED
|
||||
)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
registerReceiver(
|
||||
forceFinishReceiver,
|
||||
filter,
|
||||
com.bitchat.android.util.AppConstants.UI.PERMISSION_FORCE_FINISH,
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
// Check if this is a quit request from the notification
|
||||
if (intent.getBooleanExtra("ACTION_QUIT_APP", false)) {
|
||||
android.util.Log.d("MainActivity", "Quit request received in onCreate, finishing activity")
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
com.bitchat.android.service.AppShutdownCoordinator.cancelPendingShutdown()
|
||||
|
||||
// Enable edge-to-edge display for modern Android look
|
||||
enableEdgeToEdge()
|
||||
@@ -646,6 +677,8 @@ class MainActivity : OrientationAwareActivity() {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
com.bitchat.android.service.AppShutdownCoordinator.cancelPendingShutdown()
|
||||
|
||||
// Handle notification intents when app is already running
|
||||
if (mainViewModel.onboardingState.value == OnboardingState.COMPLETE) {
|
||||
@@ -759,6 +792,8 @@ class MainActivity : OrientationAwareActivity() {
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
try { unregisterReceiver(forceFinishReceiver) } catch (_: Exception) { }
|
||||
|
||||
// Cleanup location status manager
|
||||
try {
|
||||
locationStatusManager.cleanup()
|
||||
|
||||
Reference in New Issue
Block a user