Using the system color extraction logic instead of inbuild logic
> Moving the inbuild color extraction logic to the aosp flavor
Bug: 79111591
Change-Id: I766b0397da7224b424cd5f309cedf635d60a5e0f
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index c76ad83..ac38906 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -19,6 +19,7 @@
-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
package="com.android.launcher3" >
<uses-sdk android:targetSdkVersion="28" android:minSdkVersion="28"/>
@@ -70,6 +71,12 @@
<action android:name="android.content.action.SEARCH_INDEXABLES_PROVIDER" />
</intent-filter>
</provider>
+
+
+ <service
+ android:name="com.android.launcher3.uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
+ tools:node="remove" />
+
</application>
</manifest>
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index 120d6f9..398bd3c 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/src/com/android/launcher3/uioverrides/WallpaperColorInfo.java b/quickstep/src/com/android/launcher3/uioverrides/WallpaperColorInfo.java
new file mode 100644
index 0000000..8218517
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/WallpaperColorInfo.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2018 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.launcher3.uioverrides;
+
+import static android.app.WallpaperManager.FLAG_SYSTEM;
+
+import android.annotation.TargetApi;
+import android.app.WallpaperColors;
+import android.app.WallpaperManager;
+import android.app.WallpaperManager.OnColorsChangedListener;
+import android.content.Context;
+import android.os.Build;
+import android.os.Handler;
+import android.os.Looper;
+
+import com.android.systemui.shared.system.TonalCompat;
+import com.android.systemui.shared.system.TonalCompat.ExtractionInfo;
+
+import java.util.ArrayList;
+
+@TargetApi(Build.VERSION_CODES.P)
+public class WallpaperColorInfo implements OnColorsChangedListener {
+
+ private static final Object sInstanceLock = new Object();
+ private static WallpaperColorInfo sInstance;
+
+ public static WallpaperColorInfo getInstance(Context context) {
+ synchronized (sInstanceLock) {
+ if (sInstance == null) {
+ sInstance = new WallpaperColorInfo(context.getApplicationContext());
+ }
+ return sInstance;
+ }
+ }
+
+ private final ArrayList<OnChangeListener> mListeners = new ArrayList<>();
+ private final WallpaperManager mWallpaperManager;
+ private final TonalCompat mTonalCompat;
+
+ private ExtractionInfo mExtractionInfo;
+
+ private OnChangeListener[] mTempListeners = new OnChangeListener[0];
+
+ private WallpaperColorInfo(Context context) {
+ mWallpaperManager = context.getSystemService(WallpaperManager.class);
+ mTonalCompat = new TonalCompat(context);
+
+ mWallpaperManager.addOnColorsChangedListener(this, new Handler(Looper.getMainLooper()));
+ update(mWallpaperManager.getWallpaperColors(FLAG_SYSTEM));
+ }
+
+ public int getMainColor() {
+ return mExtractionInfo.mainColor;
+ }
+
+ public int getSecondaryColor() {
+ return mExtractionInfo.secondaryColor;
+ }
+
+ public boolean isDark() {
+ return mExtractionInfo.supportsDarkTheme;
+ }
+
+ public boolean supportsDarkText() {
+ return mExtractionInfo.supportsDarkText;
+ }
+
+ @Override
+ public void onColorsChanged(WallpaperColors colors, int which) {
+ if ((which & FLAG_SYSTEM) != 0) {
+ update(colors);
+ notifyChange();
+ }
+ }
+
+ private void update(WallpaperColors wallpaperColors) {
+ mExtractionInfo = mTonalCompat.extractDarkColors(wallpaperColors);
+ }
+
+ public void addOnChangeListener(OnChangeListener listener) {
+ mListeners.add(listener);
+ }
+
+ public void removeOnChangeListener(OnChangeListener listener) {
+ mListeners.remove(listener);
+ }
+
+ private void notifyChange() {
+ // Create a new array to avoid concurrent modification when the activity destroys itself.
+ mTempListeners = mListeners.toArray(mTempListeners);
+ for (OnChangeListener listener : mTempListeners) {
+ if (listener != null) {
+ listener.onExtractedColorsChanged(this);
+ }
+ }
+ }
+
+ public interface OnChangeListener {
+ void onExtractedColorsChanged(WallpaperColorInfo wallpaperColorInfo);
+ }
+}