Merge "Updating window manager estimation logic:" into tm-dev am: d586e1948b
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/17070486 Change-Id: I02864003cf66b733a420afec69756edade427cc4
This commit is contained in:
@@ -26,7 +26,6 @@ import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
|
||||
import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.NO_BUTTON;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
@@ -38,7 +37,6 @@ import android.app.ActivityOptions;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.graphics.Insets;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.devicestate.DeviceStateManager;
|
||||
import android.os.Bundle;
|
||||
@@ -46,7 +44,6 @@ import android.os.CancellationSignal;
|
||||
import android.os.IBinder;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.window.SplashScreen;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -614,17 +611,4 @@ public abstract class BaseQuickstepLauncher extends Launcher {
|
||||
mDepthController.dump(prefix, writer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWindowInsets(WindowInsets.Builder updatedInsetsBuilder,
|
||||
WindowInsets oldInsets) {
|
||||
// Override the tappable insets to be 0 on the bottom for gesture nav (otherwise taskbar
|
||||
// would count towards it). This is used for the bottom protection in All Apps for example.
|
||||
if (DisplayController.getNavigationMode(this) == NO_BUTTON) {
|
||||
Insets oldTappableInsets = oldInsets.getInsets(WindowInsets.Type.tappableElement());
|
||||
Insets newTappableInsets = Insets.of(oldTappableInsets.left, oldTappableInsets.top,
|
||||
oldTappableInsets.right, 0);
|
||||
updatedInsetsBuilder.setInsets(WindowInsets.Type.tappableElement(), newTappableInsets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.app.Person;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
@@ -36,20 +35,6 @@ public class ApiWrapper {
|
||||
return persons == null ? Utilities.EMPTY_PERSON_ARRAY : persons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the display is an internal displays
|
||||
*/
|
||||
public static boolean isInternalDisplay(Display display) {
|
||||
return display.getType() == Display.TYPE_INTERNAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique ID representing the display
|
||||
*/
|
||||
public static String getUniqueId(Display display) {
|
||||
return display.getUniqueId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum space that should be left empty at the end of hotseat
|
||||
*/
|
||||
|
||||
@@ -35,11 +35,11 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.ResourceUtils;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.window.CachedDisplayInfo;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Maintains state for supporting nav bars and tracking their gestures in multiple orientations.
|
||||
@@ -51,55 +51,17 @@ import java.util.Objects;
|
||||
*/
|
||||
class OrientationTouchTransformer {
|
||||
|
||||
private static class CurrentDisplay {
|
||||
public Point size;
|
||||
public int rotation;
|
||||
|
||||
CurrentDisplay() {
|
||||
this.size = new Point(0, 0);
|
||||
this.rotation = 0;
|
||||
}
|
||||
|
||||
CurrentDisplay(Point size, int rotation) {
|
||||
this.size = size;
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CurrentDisplay:"
|
||||
+ " rotation: " + rotation
|
||||
+ " size: " + size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CurrentDisplay display = (CurrentDisplay) o;
|
||||
if (rotation != display.rotation) return false;
|
||||
|
||||
return Objects.equals(size, display.size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(size, rotation);
|
||||
}
|
||||
};
|
||||
|
||||
private static final String TAG = "OrientationTouchTransformer";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private static final int QUICKSTEP_ROTATION_UNINITIALIZED = -1;
|
||||
|
||||
private final Map<CurrentDisplay, OrientationRectF> mSwipeTouchRegions =
|
||||
new HashMap<CurrentDisplay, OrientationRectF>();
|
||||
private final Map<CachedDisplayInfo, OrientationRectF> mSwipeTouchRegions =
|
||||
new HashMap<CachedDisplayInfo, OrientationRectF>();
|
||||
private final RectF mAssistantLeftRegion = new RectF();
|
||||
private final RectF mAssistantRightRegion = new RectF();
|
||||
private final RectF mOneHandedModeRegion = new RectF();
|
||||
private CurrentDisplay mCurrentDisplay = new CurrentDisplay();
|
||||
private CachedDisplayInfo mCachedDisplayInfo = new CachedDisplayInfo();
|
||||
private int mNavBarGesturalHeight;
|
||||
private final int mNavBarLargerGesturalHeight;
|
||||
private boolean mEnableMultipleRegions;
|
||||
@@ -184,22 +146,22 @@ class OrientationTouchTransformer {
|
||||
* @see #enableMultipleRegions(boolean, Info)
|
||||
*/
|
||||
void createOrAddTouchRegion(Info info) {
|
||||
mCurrentDisplay = new CurrentDisplay(info.currentSize, info.rotation);
|
||||
mCachedDisplayInfo = new CachedDisplayInfo(info.currentSize, info.rotation);
|
||||
|
||||
if (mQuickStepStartingRotation > QUICKSTEP_ROTATION_UNINITIALIZED
|
||||
&& mCurrentDisplay.rotation == mQuickStepStartingRotation) {
|
||||
&& mCachedDisplayInfo.rotation == mQuickStepStartingRotation) {
|
||||
// User already was swiping and the current screen is same rotation as the starting one
|
||||
// Remove active nav bars in other rotations except for the one we started out in
|
||||
resetSwipeRegions(info);
|
||||
return;
|
||||
}
|
||||
OrientationRectF region = mSwipeTouchRegions.get(mCurrentDisplay);
|
||||
OrientationRectF region = mSwipeTouchRegions.get(mCachedDisplayInfo);
|
||||
if (region != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEnableMultipleRegions) {
|
||||
mSwipeTouchRegions.put(mCurrentDisplay, createRegionForDisplay(info));
|
||||
mSwipeTouchRegions.put(mCachedDisplayInfo, createRegionForDisplay(info));
|
||||
} else {
|
||||
resetSwipeRegions(info);
|
||||
}
|
||||
@@ -245,31 +207,31 @@ class OrientationTouchTransformer {
|
||||
*/
|
||||
private void resetSwipeRegions(Info region) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "clearing all regions except rotation: " + mCurrentDisplay.rotation);
|
||||
Log.d(TAG, "clearing all regions except rotation: " + mCachedDisplayInfo.rotation);
|
||||
}
|
||||
|
||||
mCurrentDisplay = new CurrentDisplay(region.currentSize, region.rotation);
|
||||
OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplay);
|
||||
mCachedDisplayInfo = new CachedDisplayInfo(region.currentSize, region.rotation);
|
||||
OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCachedDisplayInfo);
|
||||
if (regionToKeep == null) {
|
||||
regionToKeep = createRegionForDisplay(region);
|
||||
}
|
||||
mSwipeTouchRegions.clear();
|
||||
mSwipeTouchRegions.put(mCurrentDisplay, regionToKeep);
|
||||
mSwipeTouchRegions.put(mCachedDisplayInfo, regionToKeep);
|
||||
updateAssistantRegions(regionToKeep);
|
||||
}
|
||||
|
||||
private void resetSwipeRegions() {
|
||||
OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplay);
|
||||
OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCachedDisplayInfo);
|
||||
mSwipeTouchRegions.clear();
|
||||
if (regionToKeep != null) {
|
||||
mSwipeTouchRegions.put(mCurrentDisplay, regionToKeep);
|
||||
mSwipeTouchRegions.put(mCachedDisplayInfo, regionToKeep);
|
||||
updateAssistantRegions(regionToKeep);
|
||||
}
|
||||
}
|
||||
|
||||
private OrientationRectF createRegionForDisplay(Info display) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "creating rotation region for: " + mCurrentDisplay.rotation
|
||||
Log.d(TAG, "creating rotation region for: " + mCachedDisplayInfo.rotation
|
||||
+ " with mode: " + mMode + " displayRotation: " + display.rotation);
|
||||
}
|
||||
|
||||
@@ -368,7 +330,7 @@ class OrientationTouchTransformer {
|
||||
true);
|
||||
}
|
||||
} else {
|
||||
mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation,
|
||||
mLastRectTouched.applyTransformFromRotation(event, mCachedDisplayInfo.rotation,
|
||||
true);
|
||||
}
|
||||
break;
|
||||
@@ -387,7 +349,7 @@ class OrientationTouchTransformer {
|
||||
true);
|
||||
}
|
||||
} else {
|
||||
mLastRectTouched.applyTransformFromRotation(event, mCurrentDisplay.rotation,
|
||||
mLastRectTouched.applyTransformFromRotation(event, mCachedDisplayInfo.rotation,
|
||||
true);
|
||||
}
|
||||
mLastRectTouched = null;
|
||||
@@ -403,11 +365,12 @@ class OrientationTouchTransformer {
|
||||
if (rect == null) {
|
||||
continue;
|
||||
}
|
||||
if (rect.applyTransformFromRotation(event, mCurrentDisplay.rotation, false)) {
|
||||
if (rect.applyTransformFromRotation(
|
||||
event, mCachedDisplayInfo.rotation, false)) {
|
||||
mLastRectTouched = rect;
|
||||
mActiveTouchRotation = rect.getRotation();
|
||||
if (mEnableMultipleRegions
|
||||
&& mCurrentDisplay.rotation == mActiveTouchRotation) {
|
||||
&& mCachedDisplayInfo.rotation == mActiveTouchRotation) {
|
||||
// TODO(b/154580671) might make this block unnecessary
|
||||
// Start a touch session for the default nav region for the display
|
||||
mQuickStepStartingRotation = mLastRectTouched.getRotation();
|
||||
@@ -430,7 +393,7 @@ class OrientationTouchTransformer {
|
||||
pw.println(" lastTouchedRegion=" + mLastRectTouched);
|
||||
pw.println(" multipleRegionsEnabled=" + mEnableMultipleRegions);
|
||||
StringBuilder regions = new StringBuilder(" currentTouchableRotations=");
|
||||
for (CurrentDisplay key: mSwipeTouchRegions.keySet()) {
|
||||
for (CachedDisplayInfo key: mSwipeTouchRegions.keySet()) {
|
||||
OrientationRectF rectF = mSwipeTouchRegions.get(key);
|
||||
regions.append(rectF).append(" ");
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ public class RecentsOrientedState implements
|
||||
width = Math.min(currentSize.x, currentSize.y);
|
||||
height = Math.max(currentSize.x, currentSize.y);
|
||||
}
|
||||
return idp.getBestMatch(width, height);
|
||||
return idp.getBestMatch(width, height, mRecentsActivityRotation);
|
||||
}
|
||||
|
||||
private static String nameAndAddress(Object obj) {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.quickstep.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.launcher3.util.window.WindowManagerProxy;
|
||||
|
||||
/**
|
||||
* Extension of {@link WindowManagerProxy} with some assumption for the default system Launcher
|
||||
*/
|
||||
public class SystemWindowManagerProxy extends WindowManagerProxy {
|
||||
|
||||
public SystemWindowManagerProxy(Context context) {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayId(Display display) {
|
||||
return display.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInternalDisplay(Display display) {
|
||||
return display.getType() == Display.TYPE_INTERNAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotation(Context context) {
|
||||
return context.getResources().getConfiguration().windowConfiguration.getRotation();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user