mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 09:56:49 +00:00
Merge "Stash taskbar if user touch down above the gesture height." into tm-qpr-dev am: 92564539d2
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20391178 Change-Id: I7e55d23264446cdb747682acbf01468a1487535f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -26,7 +26,6 @@ import android.annotation.ColorInt;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.TaskTransitionSpec;
|
||||
import android.view.WindowManagerGlobal;
|
||||
|
||||
@@ -196,15 +195,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
return mTaskbarLauncherStateController.createAnimToLauncher(toState, callbacks, duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ev MotionEvent in screen coordinates.
|
||||
* @return Whether any Taskbar item could handle the given MotionEvent if given the chance.
|
||||
*/
|
||||
public boolean isEventOverAnyTaskbarItem(MotionEvent ev) {
|
||||
return mControllers.taskbarViewController.isEventOverAnyItem(ev)
|
||||
|| mControllers.navbarButtonsViewController.isEventOverAnyItem(ev);
|
||||
}
|
||||
|
||||
public boolean isDraggingItem() {
|
||||
return mControllers.taskbarDragController.isDragging();
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ public class TaskbarControllers {
|
||||
|
||||
public void onConfigurationChanged(@Config int configChanges) {
|
||||
navbarButtonsViewController.onConfigurationChanged(configChanges);
|
||||
taskbarDragLayerController.onConfigurationChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,10 +115,18 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (mControllerCallbacks != null) {
|
||||
mControllerCallbacks.tryStashBasedOnMotionEvent(ev);
|
||||
}
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (mControllerCallbacks != null && ev.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||
mControllerCallbacks.onActionOutsideEvent();
|
||||
if (mControllerCallbacks != null) {
|
||||
mControllerCallbacks.tryStashBasedOnMotionEvent(ev);
|
||||
}
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@ package com.android.launcher3.taskbar;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.util.DimensionUtils;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
@@ -38,6 +40,7 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
private final TaskbarActivityContext mActivity;
|
||||
private final TaskbarDragLayer mTaskbarDragLayer;
|
||||
private final int mFolderMargin;
|
||||
private float mGestureHeightYThreshold;
|
||||
|
||||
// Alpha properties for taskbar background.
|
||||
private final AnimatedFloat mBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
|
||||
@@ -64,6 +67,7 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
mTaskbarDragLayer = taskbarDragLayer;
|
||||
final Resources resources = mTaskbarDragLayer.getResources();
|
||||
mFolderMargin = resources.getDimensionPixelSize(R.dimen.taskbar_folder_margin);
|
||||
updateGestureHeight();
|
||||
}
|
||||
|
||||
public void init(TaskbarControllers controllers) {
|
||||
@@ -123,6 +127,19 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
return mBgOffset;
|
||||
}
|
||||
|
||||
private void updateGestureHeight() {
|
||||
int gestureHeight = ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE,
|
||||
mActivity.getResources());
|
||||
mGestureHeightYThreshold = mActivity.getDeviceProfile().heightPx - gestureHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make updates when configuration changes.
|
||||
*/
|
||||
public void onConfigurationChanged() {
|
||||
updateGestureHeight();
|
||||
}
|
||||
|
||||
private void updateBackgroundAlpha() {
|
||||
final float bgNavbar = mBgNavbar.value;
|
||||
final float bgTaskbar = mBgTaskbar.value * mKeyguardBgTaskbar.value
|
||||
@@ -164,6 +181,8 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
*/
|
||||
public class TaskbarDragLayerCallbacks {
|
||||
|
||||
private final int[] mTempOutLocation = new int[2];
|
||||
|
||||
/**
|
||||
* Called to update the touchable insets.
|
||||
* @see ViewTreeObserver.InternalInsetsInfo#setTouchableInsets(int)
|
||||
@@ -173,9 +192,9 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever TaskbarDragLayer receives an ACTION_OUTSIDE event.
|
||||
* Listens to TaskbarDragLayer touch events and responds accordingly.
|
||||
*/
|
||||
public void onActionOutsideEvent() {
|
||||
public void tryStashBasedOnMotionEvent(MotionEvent ev) {
|
||||
if (!DisplayController.isTransientTaskbar(mActivity)) {
|
||||
return;
|
||||
}
|
||||
@@ -183,7 +202,24 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
return;
|
||||
}
|
||||
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
|
||||
boolean stashTaskbar = false;
|
||||
|
||||
MotionEvent screenCoordinates = MotionEvent.obtain(ev);
|
||||
if (ev.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||
stashTaskbar = true;
|
||||
} else if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
mTaskbarDragLayer.getLocationOnScreen(mTempOutLocation);
|
||||
screenCoordinates.offsetLocation(mTempOutLocation[0], mTempOutLocation[1]);
|
||||
|
||||
if (!mControllers.taskbarViewController.isEventOverAnyItem(screenCoordinates)
|
||||
&& screenCoordinates.getY() < mGestureHeightYThreshold) {
|
||||
stashTaskbar = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (stashTaskbar) {
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user