Skip to content

Commit 82ec8ab

Browse files
committed
PR feedback
1 parent fe46296 commit 82ec8ab

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

app/src/main/java/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff 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
)

app/src/main/java/org/thoughtcrime/securesms/ui/Util.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)