diff --git a/lawnchair/src/app/lawnchair/LawnchairLauncher.kt b/lawnchair/src/app/lawnchair/LawnchairLauncher.kt index c4026c90d3..3046dc6b0d 100644 --- a/lawnchair/src/app/lawnchair/LawnchairLauncher.kt +++ b/lawnchair/src/app/lawnchair/LawnchairLauncher.kt @@ -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() && diff --git a/lawnchair/src/app/lawnchair/preferences2/PreferenceManager2.kt b/lawnchair/src/app/lawnchair/preferences2/PreferenceManager2.kt index 53e2676c1b..6d6af7f0a8 100644 --- a/lawnchair/src/app/lawnchair/preferences2/PreferenceManager2.kt +++ b/lawnchair/src/app/lawnchair/preferences2/PreferenceManager2.kt @@ -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",