mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-26 05:05:20 +00:00
Redesign: Permissions screen, battery optimization, location sheet (#415)
* update permissions screen design * battery optimization screen * remove init screen * skip init screen on load * skip on load only * location sheet design wip * denser location sheet * location sheet layout fix
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
package com.bitchat.android.onboarding
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
/**
|
||||
* Preference manager for battery optimization skip choice
|
||||
*/
|
||||
object BatteryOptimizationPreferenceManager {
|
||||
private const val PREFS_NAME = "bitchat_settings"
|
||||
private const val KEY_BATTERY_SKIP = "battery_optimization_skipped"
|
||||
|
||||
private val _skipFlow = MutableStateFlow(false)
|
||||
val skipFlow: StateFlow<Boolean> = _skipFlow
|
||||
|
||||
fun init(context: Context) {
|
||||
val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||
val skipped = prefs.getBoolean(KEY_BATTERY_SKIP, false)
|
||||
_skipFlow.value = skipped
|
||||
}
|
||||
|
||||
fun setSkipped(context: Context, skipped: Boolean) {
|
||||
val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||
prefs.edit().putBoolean(KEY_BATTERY_SKIP, skipped).apply()
|
||||
_skipFlow.value = skipped
|
||||
}
|
||||
|
||||
fun isSkipped(context: Context): Boolean {
|
||||
val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||
return prefs.getBoolean(KEY_BATTERY_SKIP, false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user