Merge "Import translations. DO NOT MERGE ANYWHERE" into udc-qpr-dev
diff --git a/src/com/android/customization/model/color/ColorUtils.kt b/src/com/android/customization/model/color/ColorUtils.kt
deleted file mode 100644
index 9d925e1..0000000
--- a/src/com/android/customization/model/color/ColorUtils.kt
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.customization.model.color
-
-import android.content.Context
-import android.content.pm.PackageManager
-import android.content.res.Resources
-import android.os.SystemProperties
-import android.util.Log
-import androidx.annotation.ColorInt
-
-/** Utility to wrap Monet's color extraction */
-object ColorUtils {
- private const val TAG = "ColorUtils"
- private const val MONET_FLAG = "flag_monet"
- private var sSysuiRes: Resources? = null
- private var sFlagId = 0
-
- /** Returns true if color extraction is enabled in systemui. */
- @JvmStatic
- fun isMonetEnabled(context: Context): Boolean {
- var monetEnabled = SystemProperties.getBoolean("persist.systemui.flag_monet", false)
- if (!monetEnabled) {
- if (sSysuiRes == null) {
- try {
- val pm = context.packageManager
- val sysUIInfo =
- pm.getApplicationInfo(
- "com.android.systemui",
- PackageManager.GET_META_DATA or PackageManager.MATCH_SYSTEM_ONLY
- )
- if (sysUIInfo != null) {
- sSysuiRes = pm.getResourcesForApplication(sysUIInfo)
- }
- } catch (e: PackageManager.NameNotFoundException) {
- Log.w(TAG, "Couldn't read color flag, skipping section", e)
- }
- }
- if (sFlagId == 0) {
- sFlagId =
- if (sSysuiRes == null) 0
- else sSysuiRes!!.getIdentifier(MONET_FLAG, "bool", "com.android.systemui")
- }
- if (sFlagId > 0) {
- monetEnabled = sSysuiRes!!.getBoolean(sFlagId)
- }
- }
- return monetEnabled
- }
-
- @JvmStatic
- fun toColorString(@ColorInt color: Int): String {
- return String.format("%06X", 0xFFFFFF and color)
- }
-}
diff --git a/src/com/android/customization/model/color/WallpaperColorResources.java b/src/com/android/customization/model/color/WallpaperColorResources.java
deleted file mode 100644
index dc3b903..0000000
--- a/src/com/android/customization/model/color/WallpaperColorResources.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.customization.model.color;
-
-import android.app.WallpaperColors;
-import android.content.Context;
-import android.util.SparseIntArray;
-import android.widget.RemoteViews.ColorResources;
-
-import com.android.systemui.monet.ColorScheme;
-import com.android.systemui.monet.TonalPalette;
-
-/** A class to override colors in a {@link Context} with wallpaper colors. */
-public class WallpaperColorResources {
-
- private final SparseIntArray mColorOverlay = new SparseIntArray();
-
- public WallpaperColorResources(WallpaperColors wallpaperColors) {
- ColorScheme wallpaperColorScheme = new ColorScheme(wallpaperColors, /* darkTheme= */ false);
- addOverlayColor(wallpaperColorScheme.getNeutral1(), android.R.color.system_neutral1_10);
- addOverlayColor(wallpaperColorScheme.getNeutral2(), android.R.color.system_neutral2_10);
- addOverlayColor(wallpaperColorScheme.getAccent1(), android.R.color.system_accent1_10);
- addOverlayColor(wallpaperColorScheme.getAccent2(), android.R.color.system_accent2_10);
- addOverlayColor(wallpaperColorScheme.getAccent3(), android.R.color.system_accent3_10);
- }
-
- /** Applies the wallpaper color resources to the {@code context}. */
- public void apply(Context context) {
- ColorResources.create(context, mColorOverlay).apply(context);
- }
-
- private void addOverlayColor(TonalPalette colorSchemehue, int firstResourceColorId) {
- int resourceColorId = firstResourceColorId;
- for (int color : colorSchemehue.getAllShades()) {
- mColorOverlay.put(resourceColorId, color);
- resourceColorId++;
- }
- }
-}
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index 3197bf6..80960aa 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -31,6 +31,7 @@
import androidx.lifecycle.ViewModelProvider
import com.android.customization.model.color.ColorCustomizationManager
import com.android.customization.model.color.ColorOptionsProvider
+import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_PRESET
import com.android.customization.model.grid.GridOptionsManager
import com.android.customization.model.grid.data.repository.GridRepositoryImpl
import com.android.customization.model.grid.domain.interactor.GridInteractor
@@ -602,6 +603,12 @@
.also { gridSnapshotRestorer = it }
}
+ override fun isCurrentSelectedColorPreset(context: Context): Boolean {
+ val colorManager =
+ ColorCustomizationManager.getInstance(context, OverlayManagerCompat(context))
+ return COLOR_SOURCE_PRESET == colorManager.currentColorSource
+ }
+
companion object {
@JvmStatic
private val KEY_QUICK_AFFORDANCE_SNAPSHOT_RESTORER =