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

Commit b8c30bbf authored by Matthew Ng's avatar Matthew Ng
Browse files

Added an option to hide the home button

Test: manual
Bug: 112934365
Change-Id: I35dd870054389f54118956123d51145b6a2c42b4
parent 252e8d04
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -281,6 +281,11 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
            }
        }

        @Override
        public void onHomeButtonVisibilityChanged(boolean visible) {
            getHomeButton().setVisibility(visible ? VISIBLE : GONE);
        }

        @Override
        public void onColorAdaptChanged(boolean enabled) {
            if (enabled) {
@@ -672,6 +677,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        // TODO(b/113914868): investigation log for disappearing home button
        Log.i(TAG, "updateNavButtonIcons (b/113914868): home disabled=" + disableHome
                + " mDisabledFlags=" + mDisabledFlags);
        disableHome |= mPrototypeController.hideHomeButton();

        // Always disable recents when alternate car mode UI is active and for secondary displays.
        boolean disableRecent = isRecentsButtonDisabled();
@@ -945,6 +951,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

            // TODO(b/112934365): remove after prototype finished, only needed to escape from pin
            getBackButton().setVisibility(VISIBLE);
            getHomeButton().setVisibility(VISIBLE);
        } else {
            mScreenPinningNotify.showPinningExitToast();
        }
+26 −18
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import java.lang.annotation.RetentionPolicy;
 */
public class NavigationPrototypeController extends ContentObserver {
    private static final String HIDE_BACK_BUTTON_SETTING = "quickstepcontroller_hideback";
    private static final String HIDE_HOME_BUTTON_SETTING = "quickstepcontroller_hidehome";

    static final String NAVBAR_EXPERIMENTS_DISABLED = "navbarexperiments_disabled";
    private final String GESTURE_MATCH_SETTING = "quickstepcontroller_gesture_match_map";
@@ -73,6 +74,7 @@ public class NavigationPrototypeController extends ContentObserver {
     */
    public void register() {
        registerObserver(HIDE_BACK_BUTTON_SETTING);
        registerObserver(HIDE_HOME_BUTTON_SETTING);
        registerObserver(GESTURE_MATCH_SETTING);
        registerObserver(NAV_COLOR_ADAPT_ENABLE_SETTING);
    }
@@ -88,7 +90,6 @@ public class NavigationPrototypeController extends ContentObserver {
    public void onChange(boolean selfChange, Uri uri) {
        super.onChange(selfChange, uri);
        if (!selfChange && mListener != null) {
            try {
            final String path = uri.getPath();
            if (path.endsWith(GESTURE_MATCH_SETTING)) {
                // Get the settings gesture map corresponding to each action
@@ -97,14 +98,13 @@ public class NavigationPrototypeController extends ContentObserver {
                mListener.onGestureRemap(mActionMap);
            } else if (path.endsWith(HIDE_BACK_BUTTON_SETTING)) {
                mListener.onBackButtonVisibilityChanged(
                            !getGlobalBool(HIDE_BACK_BUTTON_SETTING));
                        !getGlobalBool(HIDE_BACK_BUTTON_SETTING, false));
            } else if (path.endsWith(HIDE_HOME_BUTTON_SETTING)) {
                mListener.onHomeButtonVisibilityChanged(!hideHomeButton());
            } else if (path.endsWith(NAV_COLOR_ADAPT_ENABLE_SETTING)) {
                mListener.onColorAdaptChanged(
                        NavBarTintController.isEnabled(mContext));
            }
            } catch (SettingNotFoundException e) {
                e.printStackTrace();
            }
        }
    }

@@ -116,6 +116,13 @@ public class NavigationPrototypeController extends ContentObserver {
        return mActionMap;
    }

    /**
     * @return if home button should be invisible
     */
    boolean hideHomeButton() {
        return getGlobalBool(HIDE_HOME_BUTTON_SETTING, false /* default */);
    }

    /**
     * Since Settings.Global cannot pass arrays, use a string to represent each character as a
     * gesture map to actions corresponding to {@see GestureAction}. The number is represented as:
@@ -131,8 +138,8 @@ public class NavigationPrototypeController extends ContentObserver {
        }
    }

    private boolean getGlobalBool(String name) throws SettingNotFoundException {
        return Settings.Global.getInt(mContext.getContentResolver(), name) == 1;
    private boolean getGlobalBool(String name, boolean defaultVal) {
        return Settings.Global.getInt(mContext.getContentResolver(), name, defaultVal ? 1 : 0) == 1;
    }

    private void registerObserver(String name) {
@@ -143,6 +150,7 @@ public class NavigationPrototypeController extends ContentObserver {
    public interface OnPrototypeChangedListener {
        void onGestureRemap(@GestureAction int[] actions);
        void onBackButtonVisibilityChanged(boolean visible);
        void onHomeButtonVisibilityChanged(boolean visible);
        void onColorAdaptChanged(boolean enabled);
    }
}