mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-11 06:44:00 +00:00
Init IconShape in prefs
This commit is contained in:
@@ -56,7 +56,6 @@ import app.lawnchair.util.isPackageInstalled
|
||||
import com.android.launcher3.*
|
||||
import com.android.launcher3.allapps.AllAppsContainerView
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider
|
||||
import com.android.launcher3.graphics.IconShape
|
||||
import com.android.launcher3.popup.SystemShortcut
|
||||
import com.android.launcher3.statemanager.StateManager
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher
|
||||
@@ -224,14 +223,6 @@ class LawnchairLauncher : QuickstepLauncher(), LifecycleOwner,
|
||||
systemUiController.updateUiState(UI_STATE_BASE_WINDOW, isWorkspaceDarkText || darkStatusBar)
|
||||
}
|
||||
|
||||
preferenceManager2.iconShape.onEach(launchIn = lifecycleScope) { iconShape ->
|
||||
CustomAdaptiveIconDrawable.sInitialized = true
|
||||
CustomAdaptiveIconDrawable.sMaskId = iconShape.getHashString()
|
||||
CustomAdaptiveIconDrawable.sMask = iconShape.getMaskPath()
|
||||
IconShape.init(this)
|
||||
invariantDeviceProfile.onPreferencesChanged(this)
|
||||
}
|
||||
|
||||
// Handle update from version 12 Alpha 4 to version 12 Alpha 5.
|
||||
if (
|
||||
prefs.themedIcons.get() &&
|
||||
|
||||
@@ -28,18 +28,22 @@ import androidx.datastore.preferences.core.stringSetPreferencesKey
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import app.lawnchair.data.iconoverride.IconOverrideRepository
|
||||
import app.lawnchair.font.FontCache
|
||||
import app.lawnchair.icons.CustomAdaptiveIconDrawable
|
||||
import app.lawnchair.icons.shape.IconShape
|
||||
import app.lawnchair.icons.shape.IconShapeManager
|
||||
import app.lawnchair.qsb.providers.QsbSearchProvider
|
||||
import app.lawnchair.theme.color.ColorOption
|
||||
import com.android.launcher3.InvariantDeviceProfile
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.graphics.IconShape as L3IconShape
|
||||
import com.android.launcher3.Utilities
|
||||
import com.android.launcher3.util.DynamicResource
|
||||
import com.android.launcher3.util.MainThreadInitializedObject
|
||||
import com.patrykmichalik.preferencemanager.PreferenceManager
|
||||
import com.patrykmichalik.preferencemanager.firstBlocking
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import app.lawnchair.preferences.PreferenceManager as LawnchairPreferenceManager
|
||||
|
||||
@@ -251,6 +255,23 @@ class PreferenceManager2(private val context: Context) : PreferenceManager {
|
||||
onSet = { reloadHelper.reloadGrid() },
|
||||
)
|
||||
|
||||
init {
|
||||
initializeIconShape(iconShape.firstBlocking())
|
||||
iconShape.get()
|
||||
.onEach { shape ->
|
||||
val idp = InvariantDeviceProfile.INSTANCE.get(context)
|
||||
initializeIconShape(shape)
|
||||
L3IconShape.init(context)
|
||||
idp.onPreferencesChanged(context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initializeIconShape(shape: IconShape) {
|
||||
CustomAdaptiveIconDrawable.sInitialized = true
|
||||
CustomAdaptiveIconDrawable.sMaskId = shape.getHashString()
|
||||
CustomAdaptiveIconDrawable.sMask = shape.getMaskPath()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val Context.preferencesDataStore by preferencesDataStore(
|
||||
name = "preferences",
|
||||
|
||||
Reference in New Issue
Block a user