From 1b0c5032d1b773d93fed3b1b14587163b86ca521 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Wed, 23 May 2018 12:54:27 -0700 Subject: [PATCH] Fixing keyboard navigation when Overview list is empty Bug: 80155387 Change-Id: Ife86fe4b718ef01291a04b21020155110d75fa7b Testing: Manual --- .../android/launcher3/uioverrides/AllAppsState.java | 7 ------- .../launcher3/uioverrides/OverviewState.java | 5 ----- .../com/android/quickstep/views/RecentsView.java | 12 ++---------- .../quickstep/views/RecentsViewContainer.java | 13 ++++++++++--- src/com/android/launcher3/LauncherState.java | 6 +----- src/com/android/launcher3/LauncherStateManager.java | 13 +++++-------- .../android/launcher3/states/SpringLoadedState.java | 6 ------ .../android/launcher3/uioverrides/AllAppsState.java | 7 ------- 8 files changed, 18 insertions(+), 51 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java index d86ba6aa6c..1eaa8bc92c 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java @@ -18,8 +18,6 @@ package com.android.launcher3.uioverrides; import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS; import static com.android.launcher3.anim.Interpolators.DEACCEL_2; -import android.view.View; - import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; @@ -61,11 +59,6 @@ public class AllAppsState extends LauncherState { return 0f; } - @Override - public View getFinalFocus(Launcher launcher) { - return launcher.getAppsView(); - } - @Override public float[] getWorkspaceScaleAndTranslation(Launcher launcher) { float[] scaleAndTranslation = LauncherState.OVERVIEW.getWorkspaceScaleAndTranslation( diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java index 0116a8e0e7..9169ffbc1e 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java @@ -83,11 +83,6 @@ public class OverviewState extends LauncherState { DiscoveryBounce.showForOverviewIfNeeded(launcher); } - @Override - public View getFinalFocus(Launcher launcher) { - return launcher.getOverviewPanel(); - } - public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) { return new PageAlphaProvider(DEACCEL_2) { @Override diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 4f169fb472..4d6b89cff1 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -271,6 +271,7 @@ public abstract class RecentsView extends PagedView impl .getDimensionPixelSize(R.dimen.recents_empty_message_text_padding); setWillNotDraw(false); updateEmptyMessage(); + setFocusable(false); } public boolean isRtl() { @@ -931,16 +932,6 @@ public abstract class RecentsView extends PagedView impl return true; } - @Override - public void onVisibilityAggregated(boolean isVisible) { - super.onVisibilityAggregated(isVisible); - if (isVisible && !isFocused()) { - // Having focus, even in touch mode, keeps us from losing [Alt+]Tab by preventing - // switching to keyboard mode. - requestFocus(); - } - } - private void runDismissAnimation(PendingAnimation pendingAnim) { AnimatorPlaybackController controller = AnimatorPlaybackController.wrap( pendingAnim.anim, DISMISS_TASK_DURATION); @@ -1285,6 +1276,7 @@ public abstract class RecentsView extends PagedView impl private void onChildViewsChanged() { final int childCount = getChildCount(); mClearAllButton.setVisibility(childCount == 0 ? INVISIBLE : VISIBLE); + setFocusable(childCount != 0); } public void revealClearAllButton() { diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java index 3391214dee..31c8b64480 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java +++ b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java @@ -113,8 +113,15 @@ public class RecentsViewContainer extends InsettableFrameLayout { @Override public void addFocusables(ArrayList views, int direction, int focusableMode) { - // Carousel is first in tab order. - views.add(mRecentsView); - views.add(mClearAllButton); + if (mRecentsView.getChildCount() > 0) { + // Carousel is first in tab order. + views.add(mRecentsView); + views.add(mClearAllButton); + } + } + + public boolean requestFocus(int direction, Rect previouslyFocusedRect) { + return mRecentsView.requestFocus(direction, previouslyFocusedRect) || + super.requestFocus(direction, previouslyFocusedRect); } } \ No newline at end of file diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 76681f280f..5b010dc2d4 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -18,11 +18,11 @@ package com.android.launcher3; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; + import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.states.RotationHelper.REQUEST_NONE; import android.graphics.Rect; -import android.view.View; import android.view.animation.Interpolator; import com.android.launcher3.states.SpringLoadedState; @@ -196,10 +196,6 @@ public class LauncherState { public void onStateDisabled(Launcher launcher) { } - public View getFinalFocus(Launcher launcher) { - return launcher.getWorkspace(); - } - public int getVisibleElements(Launcher launcher) { if (launcher.getDeviceProfile().isVerticalBarLayout()) { return HOTSEAT_ICONS | VERTICAL_SWIPE_INDICATOR; diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java index 3fcdee934c..f938e2412a 100644 --- a/src/com/android/launcher3/LauncherStateManager.java +++ b/src/com/android/launcher3/LauncherStateManager.java @@ -17,6 +17,7 @@ package com.android.launcher3; import static android.view.View.VISIBLE; + import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; @@ -35,7 +36,6 @@ import android.animation.AnimatorSet; import android.os.Handler; import android.os.Looper; import android.support.annotation.IntDef; -import android.view.View; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; @@ -251,7 +251,7 @@ public class LauncherStateManager { prepareForAtomicAnimation(mState, state, builder); AnimatorSet animation = createAnimationToNewWorkspaceInternal( state, builder, onCompleteRunnable); - Runnable runnable = new StartAnimRunnable(animation, state.getFinalFocus(mLauncher)); + Runnable runnable = new StartAnimRunnable(animation); if (delay > 0) { mUiHandler.postDelayed(runnable, delay); } else { @@ -397,6 +397,8 @@ public class LauncherStateManager { } UiFactory.onLauncherStateOrResumeChanged(mLauncher); + + mLauncher.getDragLayer().requestFocus(); } public void onWindowFocusChanged() { @@ -480,11 +482,9 @@ public class LauncherStateManager { private class StartAnimRunnable implements Runnable { private final AnimatorSet mAnim; - private final View mViewToFocus; - public StartAnimRunnable(AnimatorSet anim, View viewToFocus) { + public StartAnimRunnable(AnimatorSet anim) { mAnim = anim; - mViewToFocus = viewToFocus; } @Override @@ -492,9 +492,6 @@ public class LauncherStateManager { if (mConfig.mCurrentAnimation != mAnim) { return; } - if (mViewToFocus != null) { - mViewToFocus.requestFocus(); - } mAnim.start(); } } diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java index aa7d0d5a3d..35f7f8831a 100644 --- a/src/com/android/launcher3/states/SpringLoadedState.java +++ b/src/com/android/launcher3/states/SpringLoadedState.java @@ -19,7 +19,6 @@ import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_M import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK; import android.graphics.Rect; -import android.view.View; import com.android.launcher3.DeviceProfile; import com.android.launcher3.InstallShortcutReceiver; @@ -98,9 +97,4 @@ public class SpringLoadedState extends LauncherState { InstallShortcutReceiver.disableAndFlushInstallQueue( InstallShortcutReceiver.FLAG_DRAG_AND_DROP, launcher); } - - @Override - public View getFinalFocus(Launcher launcher) { - return null; - } } diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java index 4a2f544e8d..f7bb254565 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java @@ -19,8 +19,6 @@ import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS; import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_SEEN; import static com.android.launcher3.anim.Interpolators.DEACCEL_2; -import android.view.View; - import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; @@ -67,11 +65,6 @@ public class AllAppsState extends LauncherState { return ALL_APPS_HEADER | ALL_APPS_CONTENT; } - @Override - public View getFinalFocus(Launcher launcher) { - return launcher.getAppsView(); - } - @Override public float[] getWorkspaceScaleAndTranslation(Launcher launcher) { return new float[] { 1f, 0,