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

Commit d8b7d2ce authored by James Cook's avatar James Cook
Browse files

Fix TabHost stealing focus on hardware keyboard keypress

Don't try to change focus at all on exit from touch mode. The old
behavior might have been useful for very old apps with a TabHost as
their primary UI, but that's not a modern app structure.

Bug: 21417491
Change-Id: I3db2ab42c90b6c82f23216244a8183c4290eb7d7
parent ce48c1c1
Loading
Loading
Loading
Loading
+1 −24
Original line number Diff line number Diff line
@@ -188,32 +188,9 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
        mLocalActivityManager = activityGroup;
    }


    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        final ViewTreeObserver treeObserver = getViewTreeObserver();
        treeObserver.addOnTouchModeChangeListener(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        final ViewTreeObserver treeObserver = getViewTreeObserver();
        treeObserver.removeOnTouchModeChangeListener(this);
    }

    /**
     * {@inheritDoc}
     */
    public void onTouchModeChanged(boolean isInTouchMode) {
        if (!isInTouchMode) {
            // leaving touch mode.. if nothing has focus, let's give it to
            // the indicator of the current tab
            if (mCurrentView != null && (!mCurrentView.hasFocus() || mCurrentView.isFocused())) {
                mTabWidget.getChildTabViewAt(mCurrentTab).requestFocus();
            }
        }
        // No longer used, but kept to maintain API compatibility.
    }

    /**