Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f195f9eb authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

feat: Use bootaware launcherpref

parent acc9725c
Loading
Loading
Loading
Loading
+6 −27
Original line number Diff line number Diff line
@@ -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
@@ -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)
    }

@@ -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)
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -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
@@ -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(