diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsFragment.kt index 830377d06..e2b0d3058 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/notifications/NotificationsSettingsFragment.kt @@ -104,7 +104,7 @@ class NotificationsSettingsFragment : DSLSettingsFragment(R.string.preferences__ summary = DSLSettingsText.from(R.string.preferences__change_sound_and_vibration), isEnabled = state.messageNotificationsState.notificationsEnabled, onClick = { - NotificationChannels.getInstance().openChannelSettings(NotificationChannels.getInstance().messagesChannel, null) + NotificationChannels.getInstance().openChannelSettings(requireActivity(), NotificationChannels.getInstance().messagesChannel, null) } ) } else { diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/conversation/sounds/custom/CustomNotificationsSettingsFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/conversation/sounds/custom/CustomNotificationsSettingsFragment.kt index 9395b3ebd..146f04168 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/conversation/sounds/custom/CustomNotificationsSettingsFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/conversation/sounds/custom/CustomNotificationsSettingsFragment.kt @@ -91,7 +91,7 @@ class CustomNotificationsSettingsFragment : DSLSettingsFragment(R.string.CustomN title = DSLSettingsText.from(R.string.CustomNotificationsDialogFragment__customize), summary = DSLSettingsText.from(R.string.CustomNotificationsDialogFragment__change_sound_and_vibration), isEnabled = state.controlsEnabled, - onClick = { NotificationChannels.getInstance().openChannelSettings(state.recipient!!.notificationChannel!!, ConversationUtil.getShortcutId(state.recipient)) } + onClick = { NotificationChannels.getInstance().openChannelSettings(requireActivity(), state.recipient!!.notificationChannel!!, ConversationUtil.getShortcutId(state.recipient)) } ) } else { clickPref( diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ui/error/EnableCallNotificationSettingsDialog.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ui/error/EnableCallNotificationSettingsDialog.java index 9ac6b113f..2c558e0cc 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ui/error/EnableCallNotificationSettingsDialog.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ui/error/EnableCallNotificationSettingsDialog.java @@ -184,7 +184,7 @@ public final class EnableCallNotificationSettingsDialog extends DialogFragment { } private void showNotificationChannelSettings() { - NotificationChannels.getInstance().openChannelSettings(NotificationChannels.CALLS, null); + NotificationChannels.getInstance().openChannelSettings(requireActivity(), NotificationChannels.CALLS, null); } private void showAppSettings() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java index 6811c28f4..ec86b6894 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationChannels.java @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.notifications; import android.annotation.TargetApi; +import android.app.Activity; import android.app.Application; import android.app.NotificationChannel; import android.app.NotificationChannelGroup; @@ -127,7 +128,7 @@ public class NotificationChannels { /** * Navigates the user to the system settings for the desired notification channel. */ - public void openChannelSettings(@NonNull String channelId, @Nullable String conversationId) { + public void openChannelSettings(@NonNull Activity activityContext, @NonNull String channelId, @Nullable String conversationId) { if (!supported()) { return; } @@ -139,10 +140,10 @@ public class NotificationChannels { if (conversationId != null && Build.VERSION.SDK_INT >= CONVERSATION_SUPPORT_VERSION) { intent.putExtra(Settings.EXTRA_CONVERSATION_ID, conversationId); } - context.startActivity(intent); + activityContext.startActivity(intent); } catch (ActivityNotFoundException e) { Log.w(TAG, "Channel settings activity not found", e); - Toast.makeText(context, R.string.NotificationChannels__no_activity_available_to_open_notification_channel_settings, Toast.LENGTH_SHORT).show(); + Toast.makeText(activityContext, R.string.NotificationChannels__no_activity_available_to_open_notification_channel_settings, Toast.LENGTH_SHORT).show(); } }