mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 15:56:49 +00:00
Merge "Using WindowContext for listening to configuration changes" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6dcd0272f1
@@ -19,7 +19,7 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
|
||||
import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON;
|
||||
import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.util.DisplayController.DisplayHolder.CHANGE_SIZE;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_SIZE;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS;
|
||||
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
|
||||
|
||||
@@ -267,7 +267,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
|
||||
}
|
||||
|
||||
private float dpiFromPx(float pixels) {
|
||||
return Utilities.dpiFromPx(pixels, mLauncher.getResources().getDisplayMetrics());
|
||||
return Utilities.dpiFromPx(pixels, mLauncher.getResources().getDisplayMetrics().densityDpi);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,8 +17,8 @@ package com.android.quickstep;
|
||||
|
||||
import static android.content.Intent.ACTION_USER_UNLOCKED;
|
||||
|
||||
import static com.android.launcher3.util.DisplayController.DisplayHolder.CHANGE_ALL;
|
||||
import static com.android.launcher3.util.DisplayController.DisplayHolder.CHANGE_FRAME_DELAY;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_ALL;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_FRAME_DELAY;
|
||||
import static com.android.launcher3.util.SettingsCache.ONE_HANDED_ENABLED;
|
||||
import static com.android.launcher3.util.SettingsCache.ONE_HANDED_SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
||||
@@ -62,7 +62,6 @@ import androidx.annotation.BinderThread;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.DisplayHolder;
|
||||
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
@@ -91,7 +90,7 @@ public class RecentsAnimationDeviceState implements
|
||||
|
||||
private final Context mContext;
|
||||
private final SysUINavigationMode mSysUiNavMode;
|
||||
private final DisplayHolder mDisplayHolder;
|
||||
private final DisplayController mDisplayController;
|
||||
private final int mDisplayId;
|
||||
private final RotationTouchHelper mRotationTouchHelper;
|
||||
|
||||
@@ -128,17 +127,13 @@ public class RecentsAnimationDeviceState implements
|
||||
private boolean mIsUserSetupComplete;
|
||||
|
||||
public RecentsAnimationDeviceState(Context context) {
|
||||
this(context, DisplayController.getDefaultDisplay(context));
|
||||
}
|
||||
|
||||
public RecentsAnimationDeviceState(Context context, DisplayHolder displayHolder) {
|
||||
mContext = context;
|
||||
mDisplayHolder = displayHolder;
|
||||
mDisplayController = DisplayController.INSTANCE.get(context);
|
||||
mSysUiNavMode = SysUINavigationMode.INSTANCE.get(context);
|
||||
mDisplayId = mDisplayHolder.getInfo().id;
|
||||
mDisplayId = mDisplayController.getInfo().id;
|
||||
mIsOneHandedModeSupported = SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false);
|
||||
runOnDestroy(() -> mDisplayHolder.removeChangeListener(this));
|
||||
mRotationTouchHelper = new RotationTouchHelper(context, mDisplayHolder);
|
||||
runOnDestroy(() -> mDisplayController.removeChangeListener(this));
|
||||
mRotationTouchHelper = new RotationTouchHelper(context, mDisplayController);
|
||||
runOnDestroy(mRotationTouchHelper::destroy);
|
||||
|
||||
// Register for user unlocked if necessary
|
||||
@@ -244,9 +239,9 @@ public class RecentsAnimationDeviceState implements
|
||||
|
||||
@Override
|
||||
public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) {
|
||||
mDisplayHolder.removeChangeListener(this);
|
||||
mDisplayHolder.addChangeListener(this);
|
||||
onDisplayInfoChanged(mDisplayHolder.getInfo(), CHANGE_ALL);
|
||||
mDisplayController.removeChangeListener(this);
|
||||
mDisplayController.addChangeListener(this);
|
||||
onDisplayInfoChanged(mDisplayController.getInfo(), CHANGE_ALL);
|
||||
|
||||
if (newMode == NO_BUTTON) {
|
||||
mExclusionListener.register();
|
||||
@@ -254,7 +249,7 @@ public class RecentsAnimationDeviceState implements
|
||||
mExclusionListener.unregister();
|
||||
}
|
||||
|
||||
mNavBarPosition = new NavBarPosition(newMode, mDisplayHolder.getInfo());
|
||||
mNavBarPosition = new NavBarPosition(newMode, mDisplayController.getInfo());
|
||||
mMode = newMode;
|
||||
}
|
||||
|
||||
@@ -556,11 +551,11 @@ public class RecentsAnimationDeviceState implements
|
||||
}
|
||||
|
||||
if (mIsOneHandedModeEnabled || mIsSwipeToNotificationEnabled) {
|
||||
final Info displayInfo = mDisplayHolder.getInfo();
|
||||
final Info displayInfo = mDisplayController.getInfo();
|
||||
return (mRotationTouchHelper.touchInOneHandedModeRegion(ev)
|
||||
&& displayInfo.rotation != Surface.ROTATION_90
|
||||
&& displayInfo.rotation != Surface.ROTATION_270
|
||||
&& displayInfo.metrics.densityDpi < DisplayMetrics.DENSITY_600);
|
||||
&& displayInfo.densityDpi < DisplayMetrics.DENSITY_600);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ package com.android.quickstep;
|
||||
|
||||
import static android.view.Surface.ROTATION_0;
|
||||
|
||||
import static com.android.launcher3.util.DisplayController.DisplayHolder.CHANGE_ALL;
|
||||
import static com.android.launcher3.util.DisplayController.DisplayHolder.CHANGE_FRAME_DELAY;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_ALL;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_FRAME_DELAY;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS;
|
||||
|
||||
@@ -28,7 +28,7 @@ import android.view.MotionEvent;
|
||||
import android.view.OrientationEventListener;
|
||||
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.DisplayController.DisplayHolder;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.quickstep.util.RecentsOrientedState;
|
||||
@@ -44,7 +44,7 @@ public class RotationTouchHelper implements
|
||||
DisplayInfoChangeListener {
|
||||
|
||||
private final OrientationTouchTransformer mOrientationTouchTransformer;
|
||||
private final DisplayHolder mDisplayHolder;
|
||||
private final DisplayController mDisplayController;
|
||||
private final SysUINavigationMode mSysUiNavMode;
|
||||
private final int mDisplayId;
|
||||
private int mDisplayRotation;
|
||||
@@ -121,12 +121,12 @@ public class RotationTouchHelper implements
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public RotationTouchHelper(Context context, DisplayHolder displayHolder) {
|
||||
public RotationTouchHelper(Context context, DisplayController displayController) {
|
||||
mContext = context;
|
||||
mDisplayHolder = displayHolder;
|
||||
mDisplayController = displayController;
|
||||
Resources resources = mContext.getResources();
|
||||
mSysUiNavMode = SysUINavigationMode.INSTANCE.get(context);
|
||||
mDisplayId = mDisplayHolder.getInfo().id;
|
||||
mDisplayId = mDisplayController.getInfo().id;
|
||||
|
||||
mOrientationTouchTransformer = new OrientationTouchTransformer(resources, mMode,
|
||||
() -> QuickStepContract.getWindowCornerRadius(resources));
|
||||
@@ -201,7 +201,7 @@ public class RotationTouchHelper implements
|
||||
return;
|
||||
}
|
||||
|
||||
mOrientationTouchTransformer.createOrAddTouchRegion(mDisplayHolder.getInfo());
|
||||
mOrientationTouchTransformer.createOrAddTouchRegion(mDisplayController.getInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,11 +223,11 @@ public class RotationTouchHelper implements
|
||||
|
||||
@Override
|
||||
public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) {
|
||||
mDisplayHolder.removeChangeListener(this);
|
||||
mDisplayHolder.addChangeListener(this);
|
||||
onDisplayInfoChanged(mDisplayHolder.getInfo(), CHANGE_ALL);
|
||||
mDisplayController.removeChangeListener(this);
|
||||
mDisplayController.addChangeListener(this);
|
||||
onDisplayInfoChanged(mDisplayController.getInfo(), CHANGE_ALL);
|
||||
|
||||
mOrientationTouchTransformer.setNavigationMode(newMode, mDisplayHolder.getInfo(),
|
||||
mOrientationTouchTransformer.setNavigationMode(newMode, mDisplayController.getInfo(),
|
||||
mContext.getResources());
|
||||
if (!mMode.hasGestures && newMode.hasGestures) {
|
||||
setupOrientationSwipeHandler();
|
||||
@@ -276,8 +276,8 @@ public class RotationTouchHelper implements
|
||||
* Sets the gestural height.
|
||||
*/
|
||||
void setGesturalHeight(int newGesturalHeight) {
|
||||
mOrientationTouchTransformer.setGesturalHeight(newGesturalHeight, mDisplayHolder.getInfo(),
|
||||
mContext.getResources());
|
||||
mOrientationTouchTransformer.setGesturalHeight(
|
||||
newGesturalHeight, mDisplayController.getInfo(), mContext.getResources());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,7 +293,7 @@ public class RotationTouchHelper implements
|
||||
}
|
||||
|
||||
private void enableMultipleRegions(boolean enable) {
|
||||
mOrientationTouchTransformer.enableMultipleRegions(enable, mDisplayHolder.getInfo());
|
||||
mOrientationTouchTransformer.enableMultipleRegions(enable, mDisplayController.getInfo());
|
||||
notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getQuickStepStartingRotation());
|
||||
if (enable && !mInOverview && !TestProtocol.sDisableSensorRotation) {
|
||||
// Clear any previous state from sensor manager
|
||||
@@ -356,7 +356,7 @@ public class RotationTouchHelper implements
|
||||
* notifies system UI of the primary rotation the user is interacting with
|
||||
*/
|
||||
private void toggleSecondaryNavBarsForRotation() {
|
||||
mOrientationTouchTransformer.setSingleActiveRegion(mDisplayHolder.getInfo());
|
||||
mOrientationTouchTransformer.setSingleActiveRegion(mDisplayController.getInfo());
|
||||
notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ public final class TaskViewUtils {
|
||||
|
||||
// RecentsView never updates the display rotation until swipe-up so the value may
|
||||
// be stale. Use the display value instead.
|
||||
int displayRotation = DisplayController.getDefaultDisplay(context).getInfo().rotation;
|
||||
int displayRotation = DisplayController.INSTANCE.get(context).getInfo().rotation;
|
||||
tsv.getOrientationState().update(displayRotation, displayRotation);
|
||||
|
||||
tsv.setPreview(targets.apps[targets.apps.length - 1]);
|
||||
@@ -437,7 +437,7 @@ public final class TaskViewUtils {
|
||||
|
||||
// RecentsView never updates the display rotation until swipe-up so the value may
|
||||
// be stale. Use the display value instead.
|
||||
int displayRotation = DisplayController.getDefaultDisplay(recentsView.getContext())
|
||||
int displayRotation = DisplayController.INSTANCE.get(recentsView.getContext())
|
||||
.getInfo().rotation;
|
||||
tvs.getOrientationState().update(displayRotation, displayRotation);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FallbackNavBarTouchController implements TouchController,
|
||||
SysUINavigationMode.Mode sysUINavigationMode = SysUINavigationMode.getMode(mActivity);
|
||||
if (sysUINavigationMode == SysUINavigationMode.Mode.NO_BUTTON) {
|
||||
NavBarPosition navBarPosition = new NavBarPosition(sysUINavigationMode,
|
||||
DisplayController.getDefaultDisplay(mActivity).getInfo());
|
||||
DisplayController.INSTANCE.get(mActivity).getInfo());
|
||||
mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(mActivity,
|
||||
true /* disableHorizontalSwipe */, navBarPosition,
|
||||
null /* onInterceptTouch */, this);
|
||||
|
||||
@@ -116,7 +116,7 @@ public class DeviceLockedInputConsumer implements InputConsumer,
|
||||
R.dimen.device_locked_y_offset);
|
||||
|
||||
// Do not use DeviceProfile as the user data might be locked
|
||||
mDisplaySize = DisplayController.getDefaultDisplay(context).getInfo().realSize;
|
||||
mDisplaySize = DisplayController.INSTANCE.get(context).getInfo().realSize;
|
||||
|
||||
// Init states
|
||||
mStateCallback = new MultiStateCallback(STATE_NAMES);
|
||||
|
||||
@@ -44,12 +44,10 @@ import com.android.systemui.shared.system.InputMonitorCompat;
|
||||
*/
|
||||
public class OneHandedModeInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
private static final String TAG = "OneHandedModeInputConsumer";
|
||||
private static final int ANGLE_MAX = 150;
|
||||
private static final int ANGLE_MIN = 30;
|
||||
|
||||
private final Context mContext;
|
||||
private final DisplayController.DisplayHolder mDisplayHolder;
|
||||
private final Point mDisplaySize;
|
||||
private final RecentsAnimationDeviceState mDeviceState;
|
||||
|
||||
@@ -68,12 +66,11 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
|
||||
InputConsumer delegate, InputMonitorCompat inputMonitor) {
|
||||
super(delegate, inputMonitor);
|
||||
mContext = context;
|
||||
mDisplayHolder = DisplayController.getDefaultDisplay(mContext);
|
||||
mDeviceState = deviceState;
|
||||
mDragDistThreshold = context.getResources().getDimensionPixelSize(
|
||||
R.dimen.gestures_onehanded_drag_threshold);
|
||||
mSquaredSlop = Utilities.squaredTouchSlop(context);
|
||||
mDisplaySize = mDisplayHolder.getInfo().realSize;
|
||||
mDisplaySize = DisplayController.INSTANCE.get(mContext).getInfo().realSize;
|
||||
mNavBarSize = ResourceUtils.getNavbarSize(NAVBAR_BOTTOM_GESTURE_SIZE,
|
||||
mContext.getResources());
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class SplitScreenBounds {
|
||||
|
||||
WindowBounds bounds = new WindowBounds(wm.getBounds(),
|
||||
new Rect(insets.left, insets.top, insets.right, insets.bottom));
|
||||
int rotation = DisplayController.getDefaultDisplay(context).getInfo().rotation;
|
||||
int rotation = DisplayController.INSTANCE.get(context).getInfo().rotation;
|
||||
int halfDividerSize = context.getResources()
|
||||
.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user