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

Commit 5c511472 authored by Tsung-Mao Fang's avatar Tsung-Mao Fang Committed by Android (Google) Code Review
Browse files

Merge "Rename back button to navigate up button" into tm-dev

parents 87d60042 cf700d9e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -71,8 +71,8 @@ public class FeatureFlagUtils {
     * Hide back key in the Settings two pane design.
     * @hide
     */
    public static final String SETTINGS_HIDE_SECONDARY_PAGE_BACK_BUTTON_IN_TWO_PANE =
            "settings_hide_secondary_page_back_button_in_two_pane";
    public static final String SETTINGS_HIDE_SECOND_LAYER_PAGE_NAVIGATE_UP_BUTTON_IN_TWO_PANE =
            "settings_hide_second_layer_page_navigate_up_button_in_two_pane";

    private static final Map<String, String> DEFAULT_FLAGS;

@@ -99,7 +99,7 @@ public class FeatureFlagUtils {
        DEFAULT_FLAGS.put(SETTINGS_APP_LANGUAGE_SELECTION, "true");
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS, "true");
        DEFAULT_FLAGS.put(SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME, "false");
        DEFAULT_FLAGS.put(SETTINGS_HIDE_SECONDARY_PAGE_BACK_BUTTON_IN_TWO_PANE, "true");
        DEFAULT_FLAGS.put(SETTINGS_HIDE_SECOND_LAYER_PAGE_NAVIGATE_UP_BUTTON_IN_TWO_PANE, "true");
    }

    private static final Set<String> PERSISTENT_FLAGS;
@@ -109,7 +109,7 @@ public class FeatureFlagUtils {
        PERSISTENT_FLAGS.add(SETTINGS_SUPPORT_LARGE_SCREEN);
        PERSISTENT_FLAGS.add(SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS);
        PERSISTENT_FLAGS.add(SETTINGS_APP_ALLOW_DARK_THEME_ACTIVATION_AT_BEDTIME);
        PERSISTENT_FLAGS.add(SETTINGS_HIDE_SECONDARY_PAGE_BACK_BUTTON_IN_TWO_PANE);
        PERSISTENT_FLAGS.add(SETTINGS_HIDE_SECOND_LAYER_PAGE_NAVIGATE_UP_BUTTON_IN_TWO_PANE);
    }

    /**
+15 −8
Original line number Diff line number Diff line
@@ -51,27 +51,34 @@ public class ActivityEmbeddingUtils {
    }

    /**
     * Whether current activity is embedded in the Settings app or not.
     * Whether the current activity is embedded in the Settings app or not.
     *
     * @param activity Activity that needs the check
     */
    public static boolean isActivityEmbedded(Activity activity) {
        return SplitController.getInstance().isActivityEmbedded(activity);
    }

    /**
     * Whether current activity is suggested to show back button or not.
     * Whether the current activity should hide the navigate up button.
     *
     * @param activity             Activity that needs the check
     * @param isSecondLayerPage indicates if the activity(page) is shown in the 2nd layer of
     *                             Settings app
     */
    public static boolean shouldHideBackButton(Activity activity, boolean isSecondaryLayerPage) {
    public static boolean shouldHideNavigateUpButton(Activity activity, boolean isSecondLayerPage) {
        if (!BuildCompat.isAtLeastT()) {
            return false;
        }
        if (!isSecondaryLayerPage) {
        if (!isSecondLayerPage) {
            return false;
        }
        final String shouldHideBackButton = Settings.Global.getString(activity.getContentResolver(),
                "settings_hide_secondary_page_back_button_in_two_pane");
        final String shouldHideNavigateUpButton =
                Settings.Global.getString(activity.getContentResolver(),
                        "settings_hide_second_layer_page_navigate_up_button_in_two_pane");

        if (TextUtils.isEmpty(shouldHideBackButton)
                || TextUtils.equals("true", shouldHideBackButton)) {
        if (TextUtils.isEmpty(shouldHideNavigateUpButton)
                || Boolean.parseBoolean(shouldHideNavigateUpButton)) {
            return isActivityEmbedded(activity);
        }
        return false;