Merge "Simplifying scrim drawable initialization." into ub-launcher3-master
This commit is contained in:
commit
b1513bd811
|
@ -121,7 +121,6 @@ public class WorkspaceAndHotseatScrim implements
|
||||||
|
|
||||||
private Workspace mWorkspace;
|
private Workspace mWorkspace;
|
||||||
|
|
||||||
private final boolean mHasSysUiScrim;
|
|
||||||
private boolean mDrawTopScrim, mDrawBottomScrim;
|
private boolean mDrawTopScrim, mDrawBottomScrim;
|
||||||
|
|
||||||
private final RectF mFinalMaskRect = new RectF();
|
private final RectF mFinalMaskRect = new RectF();
|
||||||
|
@ -149,15 +148,9 @@ public class WorkspaceAndHotseatScrim implements
|
||||||
|
|
||||||
mMaskHeight = Utilities.pxFromDp(ALPHA_MASK_BITMAP_DP,
|
mMaskHeight = Utilities.pxFromDp(ALPHA_MASK_BITMAP_DP,
|
||||||
view.getResources().getDisplayMetrics());
|
view.getResources().getDisplayMetrics());
|
||||||
|
|
||||||
mHasSysUiScrim = !mWallpaperColorInfo.supportsDarkText();
|
|
||||||
if (mHasSysUiScrim) {
|
|
||||||
mTopScrim = Themes.getAttrDrawable(view.getContext(), R.attr.workspaceStatusBarScrim);
|
mTopScrim = Themes.getAttrDrawable(view.getContext(), R.attr.workspaceStatusBarScrim);
|
||||||
mBottomMask = createDitheredAlphaMask();
|
mBottomMask = mTopScrim == null ? null : createDitheredAlphaMask();
|
||||||
} else {
|
mHideSysUiScrim = mTopScrim == null;
|
||||||
mTopScrim = null;
|
|
||||||
mBottomMask = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
view.addOnAttachStateChangeListener(this);
|
view.addOnAttachStateChangeListener(this);
|
||||||
onExtractedColorsChanged(mWallpaperColorInfo);
|
onExtractedColorsChanged(mWallpaperColorInfo);
|
||||||
|
@ -185,7 +178,7 @@ public class WorkspaceAndHotseatScrim implements
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mHideSysUiScrim && mHasSysUiScrim) {
|
if (!mHideSysUiScrim) {
|
||||||
if (mSysUiProgress <= 0) {
|
if (mSysUiProgress <= 0) {
|
||||||
mAnimateScrimOnNextDraw = false;
|
mAnimateScrimOnNextDraw = false;
|
||||||
return;
|
return;
|
||||||
|
@ -213,8 +206,9 @@ public class WorkspaceAndHotseatScrim implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInsetsChanged(Rect insets) {
|
public void onInsetsChanged(Rect insets) {
|
||||||
mDrawTopScrim = insets.top > 0;
|
mDrawTopScrim = mTopScrim != null && insets.top > 0;
|
||||||
mDrawBottomScrim = !mLauncher.getDeviceProfile().isVerticalBarLayout();
|
mDrawBottomScrim = mBottomMask != null &&
|
||||||
|
!mLauncher.getDeviceProfile().isVerticalBarLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScrimProgress(float progress) {
|
private void setScrimProgress(float progress) {
|
||||||
|
@ -230,7 +224,7 @@ public class WorkspaceAndHotseatScrim implements
|
||||||
mWallpaperColorInfo.addOnChangeListener(this);
|
mWallpaperColorInfo.addOnChangeListener(this);
|
||||||
onExtractedColorsChanged(mWallpaperColorInfo);
|
onExtractedColorsChanged(mWallpaperColorInfo);
|
||||||
|
|
||||||
if (mHasSysUiScrim) {
|
if (mTopScrim != null) {
|
||||||
IntentFilter filter = new IntentFilter(ACTION_SCREEN_OFF);
|
IntentFilter filter = new IntentFilter(ACTION_SCREEN_OFF);
|
||||||
filter.addAction(ACTION_USER_PRESENT); // When the device wakes up + keyguard is gone
|
filter.addAction(ACTION_USER_PRESENT); // When the device wakes up + keyguard is gone
|
||||||
mRoot.getContext().registerReceiver(mReceiver, filter);
|
mRoot.getContext().registerReceiver(mReceiver, filter);
|
||||||
|
@ -240,7 +234,7 @@ public class WorkspaceAndHotseatScrim implements
|
||||||
@Override
|
@Override
|
||||||
public void onViewDetachedFromWindow(View view) {
|
public void onViewDetachedFromWindow(View view) {
|
||||||
mWallpaperColorInfo.removeOnChangeListener(this);
|
mWallpaperColorInfo.removeOnChangeListener(this);
|
||||||
if (mHasSysUiScrim) {
|
if (mTopScrim != null) {
|
||||||
mRoot.getContext().unregisterReceiver(mReceiver);
|
mRoot.getContext().unregisterReceiver(mReceiver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,14 +253,14 @@ public class WorkspaceAndHotseatScrim implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSize(int w, int h) {
|
public void setSize(int w, int h) {
|
||||||
if (mHasSysUiScrim) {
|
if (mTopScrim != null) {
|
||||||
mTopScrim.setBounds(0, 0, w, h);
|
mTopScrim.setBounds(0, 0, w, h);
|
||||||
mFinalMaskRect.set(0, h - mMaskHeight, w, h);
|
mFinalMaskRect.set(0, h - mMaskHeight, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideSysUiScrim(boolean hideSysUiScrim) {
|
public void hideSysUiScrim(boolean hideSysUiScrim) {
|
||||||
mHideSysUiScrim = hideSysUiScrim;
|
mHideSysUiScrim = hideSysUiScrim || (mTopScrim == null);
|
||||||
if (!hideSysUiScrim) {
|
if (!hideSysUiScrim) {
|
||||||
mAnimateScrimOnNextDraw = true;
|
mAnimateScrimOnNextDraw = true;
|
||||||
}
|
}
|
||||||
|
@ -281,19 +275,19 @@ public class WorkspaceAndHotseatScrim implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reapplySysUiAlpha() {
|
private void reapplySysUiAlpha() {
|
||||||
if (mHasSysUiScrim) {
|
|
||||||
reapplySysUiAlphaNoInvalidate();
|
reapplySysUiAlphaNoInvalidate();
|
||||||
if (!mHideSysUiScrim) {
|
if (!mHideSysUiScrim) {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void reapplySysUiAlphaNoInvalidate() {
|
private void reapplySysUiAlphaNoInvalidate() {
|
||||||
float factor = mSysUiProgress * mSysUiAnimMultiplier;
|
float factor = mSysUiProgress * mSysUiAnimMultiplier;
|
||||||
mBottomMaskPaint.setAlpha(Math.round(MAX_HOTSEAT_SCRIM_ALPHA * factor));
|
mBottomMaskPaint.setAlpha(Math.round(MAX_HOTSEAT_SCRIM_ALPHA * factor));
|
||||||
|
if (mTopScrim != null) {
|
||||||
mTopScrim.setAlpha(Math.round(255 * factor));
|
mTopScrim.setAlpha(Math.round(255 * factor));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
mRoot.invalidate();
|
mRoot.invalidate();
|
||||||
|
|
Loading…
Reference in New Issue