Loading bliss/src/foundation/e/bliss/multimode/MultiModeController.kt +6 −27 Original line number Diff line number Diff line Loading @@ -8,11 +8,8 @@ package foundation.e.bliss.multimode import android.content.Context import android.content.SharedPreferences import android.content.res.Resources import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.LauncherPrefs import com.android.launcher3.R import com.android.launcher3.model.data.AppInfo import com.android.launcher3.util.Executors.MODEL_EXECUTOR import foundation.e.bliss.BaseController Loading Loading @@ -69,8 +66,7 @@ class MultiModeController(val context: Context, val monitor: LauncherAppMonitor) } init { sharedPreferences = LauncherPrefs.getPrefs(context.createDeviceProtectedStorageContext()) resources = context.resources prefs = LauncherPrefs.get(context) monitor.registerCallback(mAppMonitorCallback) } Loading @@ -88,31 +84,14 @@ class MultiModeController(val context: Context, val monitor: LauncherAppMonitor) companion object { private const val TAG = "MultiModeController" @JvmField var sharedPreferences: SharedPreferences? = null @JvmField var resources: Resources? = null private fun throwIfControllerNotInit() { val launcherAppMonitor = LauncherAppMonitor.getInstanceNoCreate() if (launcherAppMonitor == null || launcherAppMonitor.multiModeController == null) { throw RuntimeException("MultiModeController is not init.") } } private lateinit var prefs: LauncherPrefs @JvmStatic val isSingleLayerMode: Boolean get() { throwIfControllerNotInit() return sharedPreferences!!.getBoolean( BlissPrefs.PREF_SINGLE_LAYER_MODE, resources!!.getBoolean(R.bool.default_single_mode) ) } val isSingleLayerMode get() = prefs.get(LauncherPrefs.IS_SINGLE_LAYER_ENABLED) @JvmStatic val isNotifCountEnabled: Boolean get() { throwIfControllerNotInit() return sharedPreferences!!.getBoolean(BlissPrefs.PREF_NOTIF_COUNT, true) } val isNotifCountEnabled get() = prefs.get(LauncherPrefs.IS_NOTIF_COUNT_ENABLED) } } src/com/android/launcher3/LauncherPrefs.kt +15 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import androidx.annotation.VisibleForTesting import com.android.launcher3.LauncherFiles.DEVICE_PREFERENCES_KEY import com.android.launcher3.LauncherFiles.SHARED_PREFERENCES_KEY import com.android.launcher3.util.MainThreadInitializedObject import foundation.e.bliss.preferences.BlissPrefs /** * Use same context for shared preferences, so that we use a single cached instance Loading Loading @@ -260,6 +261,20 @@ class LauncherPrefs(private val encryptedContext: Context) { isBootAware = true ) @JvmField val IS_NOTIF_COUNT_ENABLED = ConstantItem( BlissPrefs.PREF_NOTIF_COUNT, isBackedUp = true, defaultValue = true, isBootAware = true) @JvmField val IS_SINGLE_LAYER_ENABLED = ConstantItem( BlissPrefs.PREF_SINGLE_LAYER_MODE, isBackedUp = true, defaultValue = true, isBootAware = true) @VisibleForTesting @JvmStatic fun <T> backedUpItem( Loading Loading
bliss/src/foundation/e/bliss/multimode/MultiModeController.kt +6 −27 Original line number Diff line number Diff line Loading @@ -8,11 +8,8 @@ package foundation.e.bliss.multimode import android.content.Context import android.content.SharedPreferences import android.content.res.Resources import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.LauncherPrefs import com.android.launcher3.R import com.android.launcher3.model.data.AppInfo import com.android.launcher3.util.Executors.MODEL_EXECUTOR import foundation.e.bliss.BaseController Loading Loading @@ -69,8 +66,7 @@ class MultiModeController(val context: Context, val monitor: LauncherAppMonitor) } init { sharedPreferences = LauncherPrefs.getPrefs(context.createDeviceProtectedStorageContext()) resources = context.resources prefs = LauncherPrefs.get(context) monitor.registerCallback(mAppMonitorCallback) } Loading @@ -88,31 +84,14 @@ class MultiModeController(val context: Context, val monitor: LauncherAppMonitor) companion object { private const val TAG = "MultiModeController" @JvmField var sharedPreferences: SharedPreferences? = null @JvmField var resources: Resources? = null private fun throwIfControllerNotInit() { val launcherAppMonitor = LauncherAppMonitor.getInstanceNoCreate() if (launcherAppMonitor == null || launcherAppMonitor.multiModeController == null) { throw RuntimeException("MultiModeController is not init.") } } private lateinit var prefs: LauncherPrefs @JvmStatic val isSingleLayerMode: Boolean get() { throwIfControllerNotInit() return sharedPreferences!!.getBoolean( BlissPrefs.PREF_SINGLE_LAYER_MODE, resources!!.getBoolean(R.bool.default_single_mode) ) } val isSingleLayerMode get() = prefs.get(LauncherPrefs.IS_SINGLE_LAYER_ENABLED) @JvmStatic val isNotifCountEnabled: Boolean get() { throwIfControllerNotInit() return sharedPreferences!!.getBoolean(BlissPrefs.PREF_NOTIF_COUNT, true) } val isNotifCountEnabled get() = prefs.get(LauncherPrefs.IS_NOTIF_COUNT_ENABLED) } }
src/com/android/launcher3/LauncherPrefs.kt +15 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import androidx.annotation.VisibleForTesting import com.android.launcher3.LauncherFiles.DEVICE_PREFERENCES_KEY import com.android.launcher3.LauncherFiles.SHARED_PREFERENCES_KEY import com.android.launcher3.util.MainThreadInitializedObject import foundation.e.bliss.preferences.BlissPrefs /** * Use same context for shared preferences, so that we use a single cached instance Loading Loading @@ -260,6 +261,20 @@ class LauncherPrefs(private val encryptedContext: Context) { isBootAware = true ) @JvmField val IS_NOTIF_COUNT_ENABLED = ConstantItem( BlissPrefs.PREF_NOTIF_COUNT, isBackedUp = true, defaultValue = true, isBootAware = true) @JvmField val IS_SINGLE_LAYER_ENABLED = ConstantItem( BlissPrefs.PREF_SINGLE_LAYER_MODE, isBackedUp = true, defaultValue = true, isBootAware = true) @VisibleForTesting @JvmStatic fun <T> backedUpItem( Loading