mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 09:56:49 +00:00
Stash taskbar if user touch down above the gesture height.
Bug: 252905206
Test: open taskbar, tap in gesture area, confirm no stash
open taskbar, tap on taskbar item, confirm no stash
open taskbar, tap to the side above gesture area, confirm stash
Change-Id: Ide030840440b5f0541d0ccfb055b8a8a7e851657
This commit is contained in:
@@ -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;
|
||||
@@ -37,6 +39,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);
|
||||
@@ -63,6 +66,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) {
|
||||
@@ -122,6 +126,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
|
||||
@@ -158,6 +175,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)
|
||||
@@ -167,9 +186,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;
|
||||
}
|
||||
@@ -177,7 +196,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