open full notification settings from talk settings as fallback if dialog for asking direct permission was not shown by android

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2024-11-25 19:29:09 +01:00
parent b1e550b049
commit b63325ae8d
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -1101,16 +1101,14 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
ConversationsListActivity.REQUEST_POST_NOTIFICATIONS_PERMISSION -> { ConversationsListActivity.REQUEST_POST_NOTIFICATIONS_PERMISSION -> {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_DENIED) { if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_DENIED) {
Snackbar.make( try {
binding.root, val intent = Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
context.resources.getString(R.string.nc_settings_notifications_declined_hint), intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
Snackbar.LENGTH_LONG intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
).show() startActivity(intent)
Log.d( } catch (e: Exception) {
TAG, Log.e(TAG, "Failed to open notification settings as fallback", e)
"Notification permission is denied. Either because user denied it when being asked. " + }
"Or permission is already denied and android decided to not offer the dialog."
)
} }
} }
} }