Loading quickstep/src/com/android/launcher3/statehandlers/DepthController.java +16 −4 Original line number Diff line number Diff line Loading @@ -108,6 +108,13 @@ public class DepthController implements StateHandler<LauncherState>, } }; private final Runnable mOpaquenessListener = new Runnable() { @Override public void run() { dispatchTransactionSurface(mDepth); } }; private final Launcher mLauncher; /** * Blur radius when completely zoomed out, in pixels. Loading Loading @@ -158,21 +165,26 @@ public class DepthController implements StateHandler<LauncherState>, if (windowToken != null) { mWallpaperManager.setWallpaperZoomOut(windowToken, mDepth); } CrossWindowBlurListeners.getInstance().addListener(mLauncher.getMainExecutor(), mCrossWindowBlurListener); onAttached(); } @Override public void onViewDetachedFromWindow(View view) { CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener); mLauncher.getScrimView().removeOpaquenessListener(mOpaquenessListener); } }; mLauncher.getRootView().addOnAttachStateChangeListener(mOnAttachListener); if (mLauncher.getRootView().isAttachedToWindow()) { CrossWindowBlurListeners.getInstance().addListener(mLauncher.getMainExecutor(), mCrossWindowBlurListener); onAttached(); } } } private void onAttached() { CrossWindowBlurListeners.getInstance().addListener(mLauncher.getMainExecutor(), mCrossWindowBlurListener); mLauncher.getScrimView().addOpaquenessListener(mOpaquenessListener); } /** Loading src/com/android/launcher3/views/ScrimView.java +35 −1 Original line number Diff line number Diff line Loading @@ -25,23 +25,27 @@ import android.graphics.drawable.ColorDrawable; import android.util.AttributeSet; import android.view.View; import androidx.annotation.NonNull; import androidx.core.graphics.ColorUtils; import com.android.launcher3.BaseActivity; import com.android.launcher3.Insettable; import com.android.launcher3.util.SystemUiController; import java.util.ArrayList; /** * Simple scrim which draws a flat color */ public class ScrimView extends View implements Insettable { private static final float STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD = 0.9f; private final ArrayList<Runnable> mOpaquenessListeners = new ArrayList<>(1); private SystemUiController mSystemUiController; private ScrimDrawingController mDrawingController; private int mBackgroundColor; private boolean mIsVisible = true; private boolean mLastDispatchedOpaqueness; public ScrimView(Context context, AttributeSet attrs) { super(context, attrs); Loading @@ -60,6 +64,7 @@ public class ScrimView extends View implements Insettable { @Override protected boolean onSetAlpha(int alpha) { updateSysUiColors(); dispatchVisibilityListenersIfNeeded(); return super.onSetAlpha(alpha); } Loading @@ -67,6 +72,7 @@ public class ScrimView extends View implements Insettable { public void setBackgroundColor(int color) { mBackgroundColor = color; updateSysUiColors(); dispatchVisibilityListenersIfNeeded(); super.setBackgroundColor(color); } Loading @@ -74,6 +80,7 @@ public class ScrimView extends View implements Insettable { public void onVisibilityAggregated(boolean isVisible) { super.onVisibilityAggregated(isVisible); mIsVisible = isVisible; dispatchVisibilityListenersIfNeeded(); } public boolean isFullyOpaque() { Loading Loading @@ -108,6 +115,17 @@ public class ScrimView extends View implements Insettable { } } private void dispatchVisibilityListenersIfNeeded() { boolean fullyOpaque = isFullyOpaque(); if (mLastDispatchedOpaqueness == fullyOpaque) { return; } mLastDispatchedOpaqueness = fullyOpaque; for (int i = 0; i < mOpaquenessListeners.size(); i++) { mOpaquenessListeners.get(i).run(); } } private SystemUiController getSystemUiController() { if (mSystemUiController == null) { mSystemUiController = BaseActivity.fromContext(getContext()).getSystemUiController(); Loading Loading @@ -135,6 +153,22 @@ public class ScrimView extends View implements Insettable { } } /** * Registers a listener to be notified of whether the scrim is occluding other UI elements. * @see #isFullyOpaque() */ public void addOpaquenessListener(@NonNull Runnable listener) { mOpaquenessListeners.add(listener); } /** * Removes previously registered listener. * @see #addOpaquenessListener(Runnable) */ public void removeOpaquenessListener(@NonNull Runnable listener) { mOpaquenessListeners.remove(listener); } /** * A Utility interface allowing for other surfaces to draw on ScrimView */ Loading Loading
quickstep/src/com/android/launcher3/statehandlers/DepthController.java +16 −4 Original line number Diff line number Diff line Loading @@ -108,6 +108,13 @@ public class DepthController implements StateHandler<LauncherState>, } }; private final Runnable mOpaquenessListener = new Runnable() { @Override public void run() { dispatchTransactionSurface(mDepth); } }; private final Launcher mLauncher; /** * Blur radius when completely zoomed out, in pixels. Loading Loading @@ -158,21 +165,26 @@ public class DepthController implements StateHandler<LauncherState>, if (windowToken != null) { mWallpaperManager.setWallpaperZoomOut(windowToken, mDepth); } CrossWindowBlurListeners.getInstance().addListener(mLauncher.getMainExecutor(), mCrossWindowBlurListener); onAttached(); } @Override public void onViewDetachedFromWindow(View view) { CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener); mLauncher.getScrimView().removeOpaquenessListener(mOpaquenessListener); } }; mLauncher.getRootView().addOnAttachStateChangeListener(mOnAttachListener); if (mLauncher.getRootView().isAttachedToWindow()) { CrossWindowBlurListeners.getInstance().addListener(mLauncher.getMainExecutor(), mCrossWindowBlurListener); onAttached(); } } } private void onAttached() { CrossWindowBlurListeners.getInstance().addListener(mLauncher.getMainExecutor(), mCrossWindowBlurListener); mLauncher.getScrimView().addOpaquenessListener(mOpaquenessListener); } /** Loading
src/com/android/launcher3/views/ScrimView.java +35 −1 Original line number Diff line number Diff line Loading @@ -25,23 +25,27 @@ import android.graphics.drawable.ColorDrawable; import android.util.AttributeSet; import android.view.View; import androidx.annotation.NonNull; import androidx.core.graphics.ColorUtils; import com.android.launcher3.BaseActivity; import com.android.launcher3.Insettable; import com.android.launcher3.util.SystemUiController; import java.util.ArrayList; /** * Simple scrim which draws a flat color */ public class ScrimView extends View implements Insettable { private static final float STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD = 0.9f; private final ArrayList<Runnable> mOpaquenessListeners = new ArrayList<>(1); private SystemUiController mSystemUiController; private ScrimDrawingController mDrawingController; private int mBackgroundColor; private boolean mIsVisible = true; private boolean mLastDispatchedOpaqueness; public ScrimView(Context context, AttributeSet attrs) { super(context, attrs); Loading @@ -60,6 +64,7 @@ public class ScrimView extends View implements Insettable { @Override protected boolean onSetAlpha(int alpha) { updateSysUiColors(); dispatchVisibilityListenersIfNeeded(); return super.onSetAlpha(alpha); } Loading @@ -67,6 +72,7 @@ public class ScrimView extends View implements Insettable { public void setBackgroundColor(int color) { mBackgroundColor = color; updateSysUiColors(); dispatchVisibilityListenersIfNeeded(); super.setBackgroundColor(color); } Loading @@ -74,6 +80,7 @@ public class ScrimView extends View implements Insettable { public void onVisibilityAggregated(boolean isVisible) { super.onVisibilityAggregated(isVisible); mIsVisible = isVisible; dispatchVisibilityListenersIfNeeded(); } public boolean isFullyOpaque() { Loading Loading @@ -108,6 +115,17 @@ public class ScrimView extends View implements Insettable { } } private void dispatchVisibilityListenersIfNeeded() { boolean fullyOpaque = isFullyOpaque(); if (mLastDispatchedOpaqueness == fullyOpaque) { return; } mLastDispatchedOpaqueness = fullyOpaque; for (int i = 0; i < mOpaquenessListeners.size(); i++) { mOpaquenessListeners.get(i).run(); } } private SystemUiController getSystemUiController() { if (mSystemUiController == null) { mSystemUiController = BaseActivity.fromContext(getContext()).getSystemUiController(); Loading Loading @@ -135,6 +153,22 @@ public class ScrimView extends View implements Insettable { } } /** * Registers a listener to be notified of whether the scrim is occluding other UI elements. * @see #isFullyOpaque() */ public void addOpaquenessListener(@NonNull Runnable listener) { mOpaquenessListeners.add(listener); } /** * Removes previously registered listener. * @see #addOpaquenessListener(Runnable) */ public void removeOpaquenessListener(@NonNull Runnable listener) { mOpaquenessListeners.remove(listener); } /** * A Utility interface allowing for other surfaces to draw on ScrimView */ Loading