Only show unstash feedforward hint when long press will unstash

Test: Long press to unstash while in an app still works and shows feedforward; long pressing handle while in overview, all apps, or when IME is showing doesn't show anything.
Fixes: 218902248
Change-Id: I2c96570cab018c0e63c446793b84b210964bdb94
This commit is contained in:
Tony Wickham
2022-02-11 00:22:35 +00:00
parent 40570799b3
commit 31a4c539d0

View File

@@ -275,6 +275,9 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
// taskbar, we use an OnLongClickListener on TaskbarView instead.
return false;
}
if (!canCurrentlyManuallyUnstash()) {
return false;
}
if (updateAndAnimateIsManuallyStashedInApp(false)) {
mControllers.taskbarActivityContext.getDragLayer().performHapticFeedback(LONG_PRESS);
return true;
@@ -282,6 +285,16 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
return false;
}
/**
* Returns whether taskbar will unstash when long pressing it based on the current state. The
* only time this is true is if the user is in an app and the taskbar is only stashed because
* the user previously long pressed to manually stash (not due to other reasons like IME).
*/
private boolean canCurrentlyManuallyUnstash() {
return (mState & (FLAG_IN_APP | FLAGS_STASHED_IN_APP))
== (FLAG_IN_APP | FLAG_STASHED_IN_APP_MANUAL);
}
/**
* Updates whether we should stash the taskbar when in apps, and animates to the changed state.
* @return Whether we started an animation to either be newly stashed or unstashed.
@@ -423,6 +436,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
// Already unstashed, no need to hint in that direction.
return;
}
if (!canCurrentlyManuallyUnstash()) {
// If any other flags are causing us to be stashed, long press won't cause us to
// unstash, so don't hint that it will.
return;
}
mTaskbarStashedHandleHintScale.animateToValue(
animateForward ? UNSTASHED_TASKBAR_HANDLE_HINT_SCALE : 1)
.setDuration(TASKBAR_HINT_STASH_DURATION).start();