File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
app/src/main/java/org/thoughtcrime/securesms Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -52,12 +52,12 @@ class NotificationsPreferenceFragment : CorrectedPreferenceFragment() {
5252 @Inject
5353 lateinit var prefs: TextSecurePreferences
5454
55- var showWhitelistEnableDialog by mutableStateOf(false )
56- var showWhitelistDisableDialog by mutableStateOf(false )
55+ private var showWhitelistEnableDialog by mutableStateOf(false )
56+ private var showWhitelistDisableDialog by mutableStateOf(false )
5757
58- var whiteListControl: SwitchPreferenceCompat ? = null
58+ private var whiteListControl: SwitchPreferenceCompat ? = null
5959
60- private val composeView by lazy { ComposeView (requireContext()) }
60+ private var composeView: ComposeView ? = null
6161
6262 override fun onCreateView (
6363 inflater : LayoutInflater ,
@@ -82,6 +82,7 @@ class NotificationsPreferenceFragment : CorrectedPreferenceFragment() {
8282 )
8383 )
8484
85+ composeView = ComposeView (requireContext())
8586 wrapper.addView(
8687 composeView,
8788 FrameLayout .LayoutParams (
@@ -98,7 +99,7 @@ class NotificationsPreferenceFragment : CorrectedPreferenceFragment() {
9899 super .onViewCreated(view, savedInstanceState)
99100
100101 // set up compose content
101- composeView.apply {
102+ composeView? .apply {
102103 setViewCompositionStrategy(
103104 ViewCompositionStrategy .DisposeOnViewTreeLifecycleDestroyed
104105 )
Original file line number Diff line number Diff line change @@ -107,7 +107,16 @@ fun Activity.requestDozeWhitelist() {
107107 startActivity(intent) // shows the system dialog for this specific app
108108 } catch (_: ActivityNotFoundException ) {
109109 // Fallback to the general settings list
110- startActivity(Intent (Settings .ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS ))
110+ try {
111+ val intent = Intent (Settings .ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS )
112+ startActivity(intent)
113+ } catch (_: ActivityNotFoundException ) {
114+ try {
115+ startActivity(Intent (Settings .ACTION_SETTINGS ))
116+ } catch (_: ActivityNotFoundException ) {
117+ Toast .makeText(this , R .string.errorGeneric, Toast .LENGTH_LONG ).show()
118+ }
119+ }
111120 }
112121}
113122
You can’t perform that action at this time.
0 commit comments