Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 690d897c authored by Tracy Zhou's avatar Tracy Zhou
Browse files

[Reland] Fix touch focus not updated correctly after launching overview with live tile.

- Set touch mode to false at the first dpad left or right key event, since the framework doesn't do so in the live tile case
- Clear focus at any motion event

Similar to ag/19938037

Fixes: 277625965
Test: Meta+Tab to launch overview from app, or swipe from app, then use DPAD_LEFT and DPAD_RIGHT to go through overview. Make sure the selected task is highlighted. Also make sure swipe up to overview and go home doesn't highlight any icons on the home screen
Change-Id: I7afa46af7eb1cd826d2dc893583685936721868a
parent cd868804
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public class OverviewInputConsumer<S extends BaseState<S>, T extends StatefulAct

    private final boolean mStartingInActivityBounds;
    private boolean mTargetHandledTouch;
    private boolean mHasSetTouchModeForFirstDPadEvent;

    public OverviewInputConsumer(GestureState gestureState, T activity,
            @Nullable InputMonitorCompat inputMonitor, boolean startingInActivityBounds) {
@@ -95,6 +96,9 @@ public class OverviewInputConsumer<S extends BaseState<S>, T extends StatefulAct
                mInputMonitor.pilferPointers();
            }
        }
        if (mHasSetTouchModeForFirstDPadEvent) {
            mActivity.getRootView().clearFocus();
        }
    }

    @Override
@@ -112,6 +116,19 @@ public class OverviewInputConsumer<S extends BaseState<S>, T extends StatefulAct
                mgr.dispatchVolumeKeyEventAsSystemService(ev,
                        AudioManager.USE_DEFAULT_STREAM_TYPE);
                break;
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                if (!mHasSetTouchModeForFirstDPadEvent) {
                    // When Overview is launched via meta+tab or swipe up from an app, the touch
                    // mode somehow is not changed to false by the Android framework. The subsequent
                    // key events (e.g. DPAD_LEFT, DPAD_RIGHT) can only be dispatched to focused
                    // views, while focus can only be requested in
                    // {@link View#requestFocusNoSearch(int, Rect)} when touch mode is false. To
                    // note, here we launch overview with live tile.
                    mHasSetTouchModeForFirstDPadEvent = true;
                    mActivity.getRootView().getViewRootImpl().touchModeChanged(false);
                }
                break;
            default:
                break;
        }