Merge "Sync up Home Handle and Assistant Handle fade" into qt-r1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
680f7af7b3
@@ -74,6 +74,7 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
|
||||
|
||||
private boolean mHandlesShowing = false;
|
||||
private long mHandlesLastHiddenAt;
|
||||
private long mShowAndGoEndsAt;
|
||||
/**
|
||||
* This should always be initialized as {@link AssistHandleBehavior#OFF} to ensure proper
|
||||
* behavior lifecycle.
|
||||
@@ -144,7 +145,9 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
|
||||
|
||||
private void showAndGoInternal() {
|
||||
maybeShowHandles(/* ignoreThreshold = */ false);
|
||||
mHandler.postDelayed(mHideHandles, getShowAndGoDuration());
|
||||
long showAndGoDuration = getShowAndGoDuration();
|
||||
mShowAndGoEndsAt = SystemClock.elapsedRealtime() + showAndGoDuration;
|
||||
mHandler.postDelayed(mHideHandles, showAndGoDuration);
|
||||
}
|
||||
|
||||
@Override // AssistHandleCallbacks
|
||||
@@ -162,6 +165,10 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
|
||||
mHandler.post(() -> maybeShowHandles(/* ignoreThreshold = */ true));
|
||||
}
|
||||
|
||||
public long getShowAndGoRemainingTimeMs() {
|
||||
return Long.max(mShowAndGoEndsAt - SystemClock.elapsedRealtime(), 0);
|
||||
}
|
||||
|
||||
boolean areHandlesShowing() {
|
||||
return mHandlesShowing;
|
||||
}
|
||||
@@ -271,6 +278,7 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
|
||||
private void clearPendingCommands() {
|
||||
mHandler.removeCallbacks(mHideHandles);
|
||||
mHandler.removeCallbacks(mShowAndGo);
|
||||
mShowAndGoEndsAt = 0;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -440,6 +440,10 @@ public class AssistManager implements ConfigurationChangedReceiver {
|
||||
mAssistUtils.onLockscreenShown();
|
||||
}
|
||||
|
||||
public long getAssistHandleShowAndGoRemainingDurationMs() {
|
||||
return mHandleController.getShowAndGoRemainingTimeMs();
|
||||
}
|
||||
|
||||
/** Returns the logging flags for the given Assistant invocation type. */
|
||||
public int toLoggingSubType(int invocationType) {
|
||||
return toLoggingSubType(invocationType, mPhoneStateMonitor.getPhoneState());
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static com.android.systemui.Interpolators.ALPHA_IN;
|
||||
import static com.android.systemui.Interpolators.ALPHA_OUT;
|
||||
import static com.android.systemui.Interpolators.LINEAR;
|
||||
|
||||
import android.animation.Animator;
|
||||
@@ -24,6 +22,8 @@ import android.animation.ValueAnimator;
|
||||
import android.view.View;
|
||||
import android.view.View.AccessibilityDelegate;
|
||||
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.assist.AssistManager;
|
||||
import com.android.systemui.statusbar.policy.KeyButtonDrawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -33,12 +33,13 @@ import java.util.ArrayList;
|
||||
* multiples of the same nav bar icon appearing.
|
||||
*/
|
||||
public class ButtonDispatcher {
|
||||
private final static int FADE_DURATION_IN = 150;
|
||||
private final static int FADE_DURATION_OUT = 1000;
|
||||
private static final int FADE_DURATION_IN = 150;
|
||||
private static final int FADE_DURATION_OUT = 250;
|
||||
|
||||
private final ArrayList<View> mViews = new ArrayList<>();
|
||||
|
||||
private final int mId;
|
||||
private final AssistManager mAssistManager;
|
||||
|
||||
private View.OnClickListener mClickListener;
|
||||
private View.OnTouchListener mTouchListener;
|
||||
@@ -56,7 +57,10 @@ public class ButtonDispatcher {
|
||||
private AccessibilityDelegate mAccessibilityDelegate;
|
||||
|
||||
private final ValueAnimator.AnimatorUpdateListener mAlphaListener = animation ->
|
||||
setAlpha((float) animation.getAnimatedValue());
|
||||
setAlpha(
|
||||
(float) animation.getAnimatedValue(),
|
||||
false /* animate */,
|
||||
false /* cancelAnimator */);
|
||||
|
||||
private final AnimatorListenerAdapter mFadeListener = new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -68,6 +72,7 @@ public class ButtonDispatcher {
|
||||
|
||||
public ButtonDispatcher(int id) {
|
||||
mId = id;
|
||||
mAssistManager = Dependency.get(AssistManager.class);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
@@ -168,16 +173,30 @@ public class ButtonDispatcher {
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha, boolean animate) {
|
||||
setAlpha(alpha, animate, (getAlpha() < alpha) ? FADE_DURATION_IN : FADE_DURATION_OUT);
|
||||
setAlpha(alpha, animate, true /* cancelAnimator */);
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha, boolean animate, long duration) {
|
||||
setAlpha(alpha, animate, duration, true /* cancelAnimator */);
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha, boolean animate, boolean cancelAnimator) {
|
||||
setAlpha(
|
||||
alpha,
|
||||
animate,
|
||||
(getAlpha() < alpha) ? FADE_DURATION_IN : FADE_DURATION_OUT,
|
||||
cancelAnimator);
|
||||
}
|
||||
|
||||
public void setAlpha(float alpha, boolean animate, long duration, boolean cancelAnimator) {
|
||||
if (mFadeAnimator != null && (cancelAnimator || animate)) {
|
||||
mFadeAnimator.cancel();
|
||||
}
|
||||
if (animate) {
|
||||
if (mFadeAnimator != null) {
|
||||
mFadeAnimator.cancel();
|
||||
}
|
||||
setVisibility(View.VISIBLE);
|
||||
mFadeAnimator = ValueAnimator.ofFloat(getAlpha(), alpha);
|
||||
mFadeAnimator.setStartDelay(
|
||||
mAssistManager.getAssistHandleShowAndGoRemainingDurationMs());
|
||||
mFadeAnimator.setDuration(duration);
|
||||
mFadeAnimator.setInterpolator(LINEAR);
|
||||
mFadeAnimator.addListener(mFadeListener);
|
||||
|
||||
Reference in New Issue
Block a user