Loading quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +36 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ import android.view.ViewTreeObserver; import android.view.animation.Interpolator; import android.widget.HorizontalScrollView; import android.widget.TextView; import android.window.OnBackInvokedDispatcher; import android.window.WindowOnBackInvokedDispatcher; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; Loading Loading @@ -109,6 +111,8 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { @Nullable private AnimatorSet mOpenAnimation; private boolean mIsBackCallbackRegistered = false; @Nullable private KeyboardQuickSwitchViewController.ViewCallbacks mViewCallbacks; public KeyboardQuickSwitchView(@NonNull Context context) { Loading Loading @@ -158,6 +162,34 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { mIsRtl = Utilities.isRtl(resources); } private void registerOnBackInvokedCallback() { OnBackInvokedDispatcher dispatcher = findOnBackInvokedDispatcher(); if (isOnBackInvokedCallbackEnabled(dispatcher) && !mIsBackCallbackRegistered) { dispatcher.registerOnBackInvokedCallback( OnBackInvokedDispatcher.PRIORITY_OVERLAY, mViewCallbacks.onBackInvokedCallback); mIsBackCallbackRegistered = true; } } private void unregisterOnBackInvokedCallback() { OnBackInvokedDispatcher dispatcher = findOnBackInvokedDispatcher(); if (isOnBackInvokedCallbackEnabled(dispatcher) && mIsBackCallbackRegistered) { dispatcher.unregisterOnBackInvokedCallback( mViewCallbacks.onBackInvokedCallback); mIsBackCallbackRegistered = false; } } private boolean isOnBackInvokedCallbackEnabled(OnBackInvokedDispatcher dispatcher) { return dispatcher instanceof WindowOnBackInvokedDispatcher && ((WindowOnBackInvokedDispatcher) dispatcher).isOnBackInvokedCallbackEnabled() && mViewCallbacks != null; } private KeyboardQuickSwitchTaskView createAndAddTaskView( int index, boolean isFinalView, Loading Loading @@ -277,6 +309,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { registerOnBackInvokedCallback(); animateOpen(currentFocusIndexOverride); getViewTreeObserver().removeOnGlobalLayoutListener(this); Loading @@ -293,6 +326,9 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { } void resetViewCallbacks() { // Unregister the back invoked callback after the view is closed and before the // mViewCallbacks is reset. unregisterOnBackInvokedCallback(); mViewCallbacks = null; } Loading quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.animation.AnimationUtils; import android.window.OnBackInvokedCallback; import android.window.RemoteTransition; import androidx.annotation.NonNull; Loading Loading @@ -331,6 +332,7 @@ public class KeyboardQuickSwitchViewController { } class ViewCallbacks { public final OnBackInvokedCallback onBackInvokedCallback = () -> closeQuickSwitchView(true); boolean onKeyUp(int keyCode, KeyEvent event, boolean isRTL, boolean allowTraversal) { if (keyCode != KeyEvent.KEYCODE_TAB Loading Loading
quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +36 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ import android.view.ViewTreeObserver; import android.view.animation.Interpolator; import android.widget.HorizontalScrollView; import android.widget.TextView; import android.window.OnBackInvokedDispatcher; import android.window.WindowOnBackInvokedDispatcher; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; Loading Loading @@ -109,6 +111,8 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { @Nullable private AnimatorSet mOpenAnimation; private boolean mIsBackCallbackRegistered = false; @Nullable private KeyboardQuickSwitchViewController.ViewCallbacks mViewCallbacks; public KeyboardQuickSwitchView(@NonNull Context context) { Loading Loading @@ -158,6 +162,34 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { mIsRtl = Utilities.isRtl(resources); } private void registerOnBackInvokedCallback() { OnBackInvokedDispatcher dispatcher = findOnBackInvokedDispatcher(); if (isOnBackInvokedCallbackEnabled(dispatcher) && !mIsBackCallbackRegistered) { dispatcher.registerOnBackInvokedCallback( OnBackInvokedDispatcher.PRIORITY_OVERLAY, mViewCallbacks.onBackInvokedCallback); mIsBackCallbackRegistered = true; } } private void unregisterOnBackInvokedCallback() { OnBackInvokedDispatcher dispatcher = findOnBackInvokedDispatcher(); if (isOnBackInvokedCallbackEnabled(dispatcher) && mIsBackCallbackRegistered) { dispatcher.unregisterOnBackInvokedCallback( mViewCallbacks.onBackInvokedCallback); mIsBackCallbackRegistered = false; } } private boolean isOnBackInvokedCallbackEnabled(OnBackInvokedDispatcher dispatcher) { return dispatcher instanceof WindowOnBackInvokedDispatcher && ((WindowOnBackInvokedDispatcher) dispatcher).isOnBackInvokedCallbackEnabled() && mViewCallbacks != null; } private KeyboardQuickSwitchTaskView createAndAddTaskView( int index, boolean isFinalView, Loading Loading @@ -277,6 +309,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { registerOnBackInvokedCallback(); animateOpen(currentFocusIndexOverride); getViewTreeObserver().removeOnGlobalLayoutListener(this); Loading @@ -293,6 +326,9 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { } void resetViewCallbacks() { // Unregister the back invoked callback after the view is closed and before the // mViewCallbacks is reset. unregisterOnBackInvokedCallback(); mViewCallbacks = null; } Loading
quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.animation.AnimationUtils; import android.window.OnBackInvokedCallback; import android.window.RemoteTransition; import androidx.annotation.NonNull; Loading Loading @@ -331,6 +332,7 @@ public class KeyboardQuickSwitchViewController { } class ViewCallbacks { public final OnBackInvokedCallback onBackInvokedCallback = () -> closeQuickSwitchView(true); boolean onKeyUp(int keyCode, KeyEvent event, boolean isRTL, boolean allowTraversal) { if (keyCode != KeyEvent.KEYCODE_TAB Loading