Removing dependency on wallpaper colors and using theme resources
Bug: 184676715
Test: Manual
Change-Id: Ie9a9a784c4a8a8cd484bfd8ea463deedcd4deed6
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 4c5f9f2..2c76e52 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -18,8 +18,12 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION;
+import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import android.app.ActivityOptions;
+import android.app.WallpaperColors;
+import android.app.WallpaperManager;
+import android.app.WallpaperManager.OnColorsChangedListener;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@@ -54,7 +58,6 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.touch.ItemClickHandler;
-import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
@@ -68,8 +71,9 @@
/**
* Extension of BaseActivity allowing support for drag-n-drop
*/
+@SuppressWarnings("NewApi")
public abstract class BaseDraggingActivity extends BaseActivity
- implements WallpaperColorInfo.OnChangeListener, DisplayInfoChangeListener {
+ implements OnColorsChangedListener, DisplayInfoChangeListener {
private static final String TAG = "BaseDraggingActivity";
@@ -89,13 +93,15 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
mIsSafeModeEnabled = TraceHelper.allowIpcs("isSafeMode",
() -> getPackageManager().isSafeMode());
DisplayController.INSTANCE.get(this).addChangeListener(this);
// Update theme
- WallpaperColorInfo.INSTANCE.get(this).addOnChangeListener(this);
+ if (Utilities.ATLEAST_P) {
+ getSystemService(WallpaperManager.class)
+ .addOnColorsChangedListener(this, MAIN_EXECUTOR.getHandler());
+ }
int themeRes = Themes.getActivityThemeRes(this);
if (themeRes != mThemeRes) {
mThemeRes = themeRes;
@@ -114,7 +120,7 @@
}
@Override
- public void onExtractedColorsChanged(WallpaperColorInfo wallpaperColorInfo) {
+ public void onColorsChanged(WallpaperColors wallpaperColors, int which) {
updateTheme();
}
@@ -278,7 +284,9 @@
@Override
protected void onDestroy() {
super.onDestroy();
- WallpaperColorInfo.INSTANCE.get(this).removeOnChangeListener(this);
+ if (Utilities.ATLEAST_P) {
+ getSystemService(WallpaperManager.class).removeOnColorsChangedListener(this);
+ }
DisplayController.INSTANCE.get(this).removeChangeListener(this);
}