Removing dependency on wallpaper colors and using theme resources

Bug: 184676715
Test: Manual
Change-Id: Ie9a9a784c4a8a8cd484bfd8ea463deedcd4deed6
This commit is contained in:
Sunny Goyal committed 2021-04-27 16:29:08 -07:00
1 parent f4bd91f0ab
commit 4ed0fb5074
29 files changed
+82 -1737

No files matched your search

@@ -23,11 +23,8 @@ import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.util.DisplayController.getSingleFrameMs;
import android.annotation.TargetApi;
import android.app.WallpaperInfo;
import android.app.WallpaperManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -42,15 +39,11 @@ import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.SimpleBroadcastReceiver;
import com.android.launcher3.util.TouchController;
import java.io.PrintWriter;
@@ -117,9 +110,6 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
protected final T mActivity;
private final MultiValueAlpha mMultiValueAlpha;
private final WallpaperManager mWallpaperManager;
private final SimpleBroadcastReceiver mWallpaperChangeReceiver =
new SimpleBroadcastReceiver(this::onWallpaperChanged);
private final String[] mWallpapersWithoutSysuiScrims;
// All the touch controllers for the view
protected TouchController[] mControllers;
@@ -130,15 +120,11 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
private TouchCompleteListener mTouchCompleteListener;
protected boolean mAllowSysuiScrims = true;
public BaseDragLayer(Context context, AttributeSet attrs, int alphaChannelCount) {
super(context, attrs);
mActivity = (T) ActivityContext.lookupContext(context);
mMultiValueAlpha = new MultiValueAlpha(this, alphaChannelCount);
mWallpaperManager = context.getSystemService(WallpaperManager.class);
mWallpapersWithoutSysuiScrims = getResources().getStringArray(
R.array.live_wallpapers_remove_sysui_scrims);
}
/**
@@ -562,46 +548,4 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
}
return super.dispatchApplyWindowInsets(insets);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mWallpaperChangeReceiver.register(mActivity, Intent.ACTION_WALLPAPER_CHANGED);
onWallpaperChanged(null);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mActivity.unregisterReceiver(mWallpaperChangeReceiver);
}
private void onWallpaperChanged(Intent unusedBroadcastIntent) {
WallpaperInfo newWallpaperInfo = mWallpaperManager.getWallpaperInfo();
boolean oldAllowSysuiScrims = mAllowSysuiScrims;
mAllowSysuiScrims = computeAllowSysuiScrims(newWallpaperInfo);
if (mAllowSysuiScrims != oldAllowSysuiScrims) {
// Reapply insets so scrim can be removed or re-added if necessary.
setInsets(mInsets);
}
}
/**
* Determines whether we can scrim the status bar and nav bar for the given wallpaper by
* checking against a list of live wallpapers that we don't show the scrims on.
*/
private boolean computeAllowSysuiScrims(@Nullable WallpaperInfo newWallpaperInfo) {
if (newWallpaperInfo == null) {
// Static wallpapers need scrim unless determined otherwise by wallpaperColors.
return true;
}
ComponentName newWallpaper = newWallpaperInfo.getComponent();
for (String wallpaperWithoutScrim : mWallpapersWithoutSysuiScrims) {
if (newWallpaper.equals(ComponentName.unflattenFromString(wallpaperWithoutScrim))) {
// New wallpaper does not need a scrim.
return false;
}
}
return true;
}
}