mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 19:28:10 +00:00
=> The entire DragLayer is translated during the -1 transition which creates a janky looking edge at the top of the screen => By bumping the scrim up a level, we avoid this => Separated WorkspaceAndHotseatScrim into two separate scrims, since only part of the scrim needed to be bumped up to a level. Further, it was an overloaded class. => We had previously been implicitly relying on the fact that the scrim was rendered in the Workspace parent; we need to make sure to propagate workspace inavlidations to the container of the scrim. While things would still work without this change, it's more correct to leave it, as we no longer assume a hierarchy for functinoality. Bug: 178215332 Test: manual verification. See video in bug. Change-Id: I0a76ddf35ceea8c9635367f69380ef24f42e9479
139 lines
4.4 KiB
Java
139 lines
4.4 KiB
Java
package com.android.launcher3;
|
|
|
|
import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.content.Context;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Rect;
|
|
import android.os.Build;
|
|
import android.util.AttributeSet;
|
|
import android.view.ViewDebug;
|
|
import android.view.WindowInsets;
|
|
|
|
import com.android.launcher3.graphics.SysUiScrim;
|
|
import com.android.launcher3.statemanager.StatefulActivity;
|
|
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
public class LauncherRootView extends InsettableFrameLayout {
|
|
|
|
private final Rect mTempRect = new Rect();
|
|
|
|
private final StatefulActivity mActivity;
|
|
|
|
@ViewDebug.ExportedProperty(category = "launcher")
|
|
private static final List<Rect> SYSTEM_GESTURE_EXCLUSION_RECT =
|
|
Collections.singletonList(new Rect());
|
|
|
|
private WindowStateListener mWindowStateListener;
|
|
@ViewDebug.ExportedProperty(category = "launcher")
|
|
private boolean mDisallowBackGesture;
|
|
@ViewDebug.ExportedProperty(category = "launcher")
|
|
private boolean mForceHideBackArrow;
|
|
|
|
private SysUiScrim mSysUiScrim;
|
|
|
|
public LauncherRootView(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
mActivity = StatefulActivity.fromContext(context);
|
|
}
|
|
|
|
private void handleSystemWindowInsets(Rect insets) {
|
|
// Update device profile before notifying th children.
|
|
mActivity.getDeviceProfile().updateInsets(insets);
|
|
boolean resetState = !insets.equals(mInsets);
|
|
setInsets(insets);
|
|
|
|
if (resetState) {
|
|
mActivity.getStateManager().reapplyState(true /* cancelCurrentAnimation */);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
|
mTempRect.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
|
|
insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
|
|
handleSystemWindowInsets(mTempRect);
|
|
return insets;
|
|
}
|
|
|
|
@Override
|
|
public void setInsets(Rect insets) {
|
|
// If the insets haven't changed, this is a no-op. Avoid unnecessary layout caused by
|
|
// modifying child layout params.
|
|
if (!insets.equals(mInsets)) {
|
|
super.setInsets(insets);
|
|
}
|
|
}
|
|
|
|
public void dispatchInsets() {
|
|
mActivity.getDeviceProfile().updateInsets(mInsets);
|
|
super.setInsets(mInsets);
|
|
}
|
|
|
|
public void setWindowStateListener(WindowStateListener listener) {
|
|
mWindowStateListener = listener;
|
|
}
|
|
|
|
@Override
|
|
public void onWindowFocusChanged(boolean hasWindowFocus) {
|
|
super.onWindowFocusChanged(hasWindowFocus);
|
|
if (mWindowStateListener != null) {
|
|
mWindowStateListener.onWindowFocusChanged(hasWindowFocus);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onWindowVisibilityChanged(int visibility) {
|
|
super.onWindowVisibilityChanged(visibility);
|
|
if (mWindowStateListener != null) {
|
|
mWindowStateListener.onWindowVisibilityChanged(visibility);
|
|
}
|
|
}
|
|
|
|
public void setSysUiScrim(SysUiScrim scrim) {
|
|
mSysUiScrim = scrim;
|
|
}
|
|
|
|
@Override
|
|
protected void dispatchDraw(Canvas canvas) {
|
|
if (mSysUiScrim != null) {
|
|
mSysUiScrim.draw(canvas);
|
|
}
|
|
super.dispatchDraw(canvas);
|
|
}
|
|
|
|
@Override
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
super.onLayout(changed, l, t, r, b);
|
|
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(l, t, r, b);
|
|
setDisallowBackGesture(mDisallowBackGesture);
|
|
}
|
|
|
|
@TargetApi(Build.VERSION_CODES.Q)
|
|
public void setForceHideBackArrow(boolean forceHideBackArrow) {
|
|
this.mForceHideBackArrow = forceHideBackArrow;
|
|
setDisallowBackGesture(mDisallowBackGesture);
|
|
}
|
|
|
|
@TargetApi(Build.VERSION_CODES.Q)
|
|
public void setDisallowBackGesture(boolean disallowBackGesture) {
|
|
if (!Utilities.ATLEAST_Q || SEPARATE_RECENTS_ACTIVITY.get()) {
|
|
return;
|
|
}
|
|
mDisallowBackGesture = disallowBackGesture;
|
|
setSystemGestureExclusionRects((mForceHideBackArrow || mDisallowBackGesture)
|
|
? SYSTEM_GESTURE_EXCLUSION_RECT
|
|
: Collections.emptyList());
|
|
}
|
|
|
|
public interface WindowStateListener {
|
|
|
|
void onWindowFocusChanged(boolean hasFocus);
|
|
|
|
void onWindowVisibilityChanged(int visibility);
|
|
}
|
|
}
|