Merge "Better support transient and persistent taskbar in taskbar's overlays." into tm-qpr-dev
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
android:id="@+id/edu_start_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginBottom="92dp"
|
||||
android:layout_marginBottom="18dp"
|
||||
android:layout_marginTop="32dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
@@ -877,6 +877,16 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(false);
|
||||
}
|
||||
|
||||
/** Called when we want to hide the overlay window when user performs swipe up gesture. */
|
||||
public void onSwipeToHideOverlay() {
|
||||
mControllers.taskbarOverlayController.hideWindow();
|
||||
}
|
||||
|
||||
/** Returns {@code true} if taskbar is stashed. */
|
||||
public boolean isTaskbarStashed() {
|
||||
return mControllers.taskbarStashController.isStashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to start the taskbar translation spring to its settled translation (0).
|
||||
*/
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package com.android.launcher3.taskbar;
|
||||
|
||||
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_APP_EDU;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
|
||||
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
|
||||
@@ -62,20 +62,21 @@ public class TaskbarEduController implements TaskbarControllers.LoggableTaskbarC
|
||||
: R.layout.taskbar_edu_pages_persistent,
|
||||
mPagedView,
|
||||
true);
|
||||
|
||||
// Provide enough room for taskbar.
|
||||
View startButton = mTaskbarEduView.findViewById(R.id.edu_start_button);
|
||||
ViewGroup.MarginLayoutParams layoutParams =
|
||||
(ViewGroup.MarginLayoutParams) startButton.getLayoutParams();
|
||||
DeviceProfile dp = overlayContext.getDeviceProfile();
|
||||
layoutParams.bottomMargin += DisplayController.isTransientTaskbar(overlayContext)
|
||||
? dp.taskbarSize + dp.transientTaskbarMargin
|
||||
: dp.taskbarSize;
|
||||
|
||||
mTaskbarEduView.init(new TaskbarEduCallbacks());
|
||||
|
||||
mControllers.navbarButtonsViewController.setSlideInViewVisible(true);
|
||||
TaskbarStashController stashController = mControllers.taskbarStashController;
|
||||
stashController.updateStateForFlag(FLAG_STASHED_IN_APP_EDU, true);
|
||||
stashController.applyState(overlayController.getOpenDuration());
|
||||
|
||||
mTaskbarEduView.setOnCloseBeginListener(() -> {
|
||||
mControllers.navbarButtonsViewController.setSlideInViewVisible(false);
|
||||
// Post in case view is closing due to gesture navigation. If a gesture is in progress,
|
||||
// wait to unstash until after the gesture is finished.
|
||||
MAIN_EXECUTOR.post(() -> stashController.resetFlagIfNoGestureInProgress(
|
||||
FLAG_STASHED_IN_APP_EDU));
|
||||
});
|
||||
mTaskbarEduView.setOnCloseBeginListener(
|
||||
() -> mControllers.navbarButtonsViewController.setSlideInViewVisible(false));
|
||||
mTaskbarEduView.addOnCloseListener(() -> mTaskbarEduView = null);
|
||||
mTaskbarEduView.show();
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
public static final int FLAG_IN_SETUP = 1 << 8; // In the Setup Wizard
|
||||
public static final int FLAG_STASHED_SMALL_SCREEN = 1 << 9; // phone screen gesture nav, stashed
|
||||
public static final int FLAG_STASHED_IN_APP_AUTO = 1 << 10; // Autohide (transient taskbar).
|
||||
public static final int FLAG_STASHED_IN_APP_EDU = 1 << 11; // EDU is visible.
|
||||
|
||||
// If any of these flags are enabled, isInApp should return true.
|
||||
private static final int FLAGS_IN_APP = FLAG_IN_APP | FLAG_IN_SETUP;
|
||||
@@ -91,7 +90,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
private static final int FLAGS_STASHED_IN_APP = FLAG_STASHED_IN_APP_MANUAL
|
||||
| FLAG_STASHED_IN_SYSUI_STATE | FLAG_STASHED_IN_APP_EMPTY | FLAG_STASHED_IN_APP_SETUP
|
||||
| FLAG_STASHED_IN_APP_IME | FLAG_STASHED_IN_TASKBAR_ALL_APPS
|
||||
| FLAG_STASHED_SMALL_SCREEN | FLAG_STASHED_IN_APP_AUTO | FLAG_STASHED_IN_APP_EDU;
|
||||
| FLAG_STASHED_SMALL_SCREEN | FLAG_STASHED_IN_APP_AUTO;
|
||||
|
||||
private static final int FLAGS_STASHED_IN_APP_IGNORING_IME =
|
||||
FLAGS_STASHED_IN_APP & ~FLAG_STASHED_IN_APP_IME;
|
||||
@@ -101,8 +100,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
// Currently any flag that causes us to stash in an app is included, except for IME or All Apps
|
||||
// since those cover the underlying app anyway and thus the app shouldn't change insets.
|
||||
private static final int FLAGS_REPORT_STASHED_INSETS_TO_APP = FLAGS_STASHED_IN_APP
|
||||
& ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_TASKBAR_ALL_APPS
|
||||
& ~FLAG_STASHED_IN_APP_EDU;
|
||||
& ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_TASKBAR_ALL_APPS;
|
||||
|
||||
/**
|
||||
* How long to stash/unstash when manually invoked via long press.
|
||||
@@ -728,7 +726,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
// Only update the following flags when system gesture is not in progress.
|
||||
boolean shouldStashForIme = shouldStashForIme();
|
||||
updateStateForFlag(FLAG_STASHED_IN_TASKBAR_ALL_APPS, false);
|
||||
updateStateForFlag(FLAG_STASHED_IN_APP_EDU, false);
|
||||
if (hasAnyFlag(FLAG_STASHED_IN_APP_IME) != shouldStashForIme) {
|
||||
updateStateForFlag(FLAG_STASHED_IN_APP_IME, shouldStashForIme);
|
||||
applyState(TASKBAR_STASH_DURATION_FOR_IME, getTaskbarStashStartDelayForIme());
|
||||
|
||||
@@ -25,6 +25,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.TaskView;
|
||||
|
||||
@@ -84,7 +85,9 @@ public class TaskbarUIController {
|
||||
* Manually closes the overlay window.
|
||||
*/
|
||||
public void hideOverlayWindow() {
|
||||
mControllers.taskbarOverlayController.hideWindow();
|
||||
if (!DisplayController.isTransientTaskbar(mControllers.taskbarActivityContext)) {
|
||||
mControllers.taskbarOverlayController.hideWindow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+14
-5
@@ -16,6 +16,7 @@
|
||||
package com.android.launcher3.taskbar.allapps;
|
||||
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_APP_AUTO;
|
||||
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_TASKBAR_ALL_APPS;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
|
||||
@@ -28,6 +29,7 @@ import com.android.launcher3.taskbar.TaskbarControllers;
|
||||
import com.android.launcher3.taskbar.TaskbarStashController;
|
||||
import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
|
||||
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
|
||||
/**
|
||||
* Handles the {@link TaskbarAllAppsContainerView} behavior and synchronizes its transitions with
|
||||
@@ -88,18 +90,25 @@ final class TaskbarAllAppsViewController {
|
||||
}
|
||||
|
||||
private void setUpTaskbarStashing() {
|
||||
mTaskbarStashController.updateStateForFlag(FLAG_STASHED_IN_TASKBAR_ALL_APPS, true);
|
||||
mTaskbarStashController.updateStateForFlag(
|
||||
DisplayController.isTransientTaskbar(mContext)
|
||||
? FLAG_STASHED_IN_APP_AUTO
|
||||
: FLAG_STASHED_IN_TASKBAR_ALL_APPS,
|
||||
true);
|
||||
mTaskbarStashController.applyState(
|
||||
ALL_APPS.getTransitionDuration(mContext, true /* isToState */));
|
||||
|
||||
mNavbarButtonsViewController.setSlideInViewVisible(true);
|
||||
mSlideInView.setOnCloseBeginListener(() -> {
|
||||
mNavbarButtonsViewController.setSlideInViewVisible(false);
|
||||
AbstractFloatingView.closeOpenContainer(
|
||||
mContext, AbstractFloatingView.TYPE_ACTION_POPUP);
|
||||
// Post in case view is closing due to gesture navigation. If a gesture is in progress,
|
||||
// wait to unstash until after the gesture is finished.
|
||||
MAIN_EXECUTOR.post(() -> mTaskbarStashController.resetFlagIfNoGestureInProgress(
|
||||
FLAG_STASHED_IN_TASKBAR_ALL_APPS));
|
||||
if (!DisplayController.isTransientTaskbar(mContext)) {
|
||||
// Post in case view is closing due to gesture navigation. If a gesture is in
|
||||
// progress, wait to unstash until after the gesture is finished.
|
||||
MAIN_EXECUTOR.post(() -> mTaskbarStashController.resetFlagIfNoGestureInProgress(
|
||||
FLAG_STASHED_IN_TASKBAR_ALL_APPS));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,11 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
private final float mUnstashArea;
|
||||
private final float mScreenWidth;
|
||||
|
||||
private final int mTaskbarThresholdY;
|
||||
private boolean mHasPassedTaskbarThreshold;
|
||||
private final int mTaskbarNavThresholdY;
|
||||
private final int mTaskbarAppWindowThresholdY;
|
||||
private final boolean mTaskbarAlreadyOpen;
|
||||
private boolean mHasPassedTaskbarNavThreshold;
|
||||
private boolean mHasPassedTaskbarAppWindowThreshold;
|
||||
|
||||
private final PointF mDownPos = new PointF();
|
||||
private final PointF mLastPos = new PointF();
|
||||
@@ -73,11 +76,18 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
Resources res = context.getResources();
|
||||
mUnstashArea = res.getDimensionPixelSize(R.dimen.taskbar_unstash_input_area);
|
||||
int taskbarThreshold = res.getDimensionPixelSize(ENABLE_TASKBAR_REVISED_THRESHOLDS.get()
|
||||
int taskbarNavThreshold = res.getDimensionPixelSize(ENABLE_TASKBAR_REVISED_THRESHOLDS.get()
|
||||
? R.dimen.taskbar_nav_threshold_v2
|
||||
: R.dimen.taskbar_nav_threshold);
|
||||
int taskbarAppWindowThreshold = res.getDimensionPixelSize(
|
||||
ENABLE_TASKBAR_REVISED_THRESHOLDS.get()
|
||||
? R.dimen.taskbar_app_window_threshold_v2
|
||||
: R.dimen.taskbar_app_window_threshold);
|
||||
int screenHeight = taskbarActivityContext.getDeviceProfile().heightPx;
|
||||
mTaskbarThresholdY = screenHeight - taskbarThreshold;
|
||||
mTaskbarNavThresholdY = screenHeight - taskbarNavThreshold;
|
||||
mTaskbarAppWindowThresholdY = screenHeight - taskbarAppWindowThreshold;
|
||||
mTaskbarAlreadyOpen = mTaskbarActivityContext != null
|
||||
&& !mTaskbarActivityContext.isTaskbarStashed();
|
||||
|
||||
mIsTransientTaskbar = DisplayController.isTransientTaskbar(context);
|
||||
|
||||
@@ -113,7 +123,8 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
mDownPos.set(ev.getX(), ev.getY());
|
||||
mLastPos.set(mDownPos);
|
||||
|
||||
mHasPassedTaskbarThreshold = false;
|
||||
mHasPassedTaskbarNavThreshold = false;
|
||||
mHasPassedTaskbarAppWindowThreshold = false;
|
||||
mTaskbarActivityContext.setAutohideSuspendFlag(
|
||||
FLAG_AUTOHIDE_SUSPEND_TOUCHING, true);
|
||||
if (isInArea(x)) {
|
||||
@@ -156,18 +167,23 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
if (mIsTransientTaskbar) {
|
||||
float dY = mLastPos.y - mDownPos.y;
|
||||
boolean passedTaskbarThreshold = dY < 0
|
||||
&& mLastPos.y < mTaskbarThresholdY;
|
||||
|
||||
if (!mHasPassedTaskbarThreshold
|
||||
&& passedTaskbarThreshold) {
|
||||
mHasPassedTaskbarThreshold = true;
|
||||
boolean passedTaskbarNavThreshold = dY < 0
|
||||
&& mLastPos.y < mTaskbarNavThresholdY;
|
||||
boolean passedTaskbarAppWindowThreshold = dY < 0
|
||||
&& mLastPos.y < mTaskbarAppWindowThresholdY;
|
||||
|
||||
if (!mHasPassedTaskbarNavThreshold && passedTaskbarNavThreshold) {
|
||||
mHasPassedTaskbarNavThreshold = true;
|
||||
mTaskbarActivityContext.onSwipeToUnstashTaskbar();
|
||||
}
|
||||
if (mTaskbarAlreadyOpen || (!mHasPassedTaskbarAppWindowThreshold
|
||||
&& passedTaskbarAppWindowThreshold)) {
|
||||
mHasPassedTaskbarAppWindowThreshold = true;
|
||||
mTaskbarActivityContext.onSwipeToHideOverlay();
|
||||
}
|
||||
|
||||
if (dY < 0) {
|
||||
dY = -OverScroll.dampedScroll(-dY, mTaskbarThresholdY);
|
||||
dY = -OverScroll.dampedScroll(-dY, mTaskbarNavThresholdY);
|
||||
if (mTransitionCallback != null) {
|
||||
mTransitionCallback.onActionMove(dY);
|
||||
}
|
||||
@@ -185,7 +201,8 @@ public class TaskbarStashInputConsumer extends DelegateInputConsumer {
|
||||
if (mTransitionCallback != null) {
|
||||
mTransitionCallback.onActionEnd();
|
||||
}
|
||||
mHasPassedTaskbarThreshold = false;
|
||||
mHasPassedTaskbarNavThreshold = false;
|
||||
mHasPassedTaskbarAppWindowThreshold = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user