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

Commit 15b13a79 authored by Adam Powell's avatar Adam Powell
Browse files

Add a config override for ViewConfiguration#hasPermanentMenuKey

Allow device overlays to override the behavior of the
hasPermanentMenuKey method at build time. This is useful for devices
that do not behave as the usual autodetection mechanism expects.

Device overlays should set config_overrideHasPermanentMenuKey to 1 if
the device DOES have a permanent menu key or 2 if the device DOES NOT
have a permanent menu key.

Bug 11698700

Change-Id: I467b68528cf681b08adcaebc2402d8bdd84f6b5c
parent 1327e59f
Loading
Loading
Loading
Loading
+33 −6
Original line number Diff line number Diff line
@@ -212,6 +212,14 @@ public class ViewConfiguration {
     */
    private static final int OVERFLING_DISTANCE = 6;

    /**
     * Configuration values for overriding {@link #hasPermanentMenuKey()} behavior.
     * These constants must match the definition in res/values/config.xml.
     */
    private static final int HAS_PERMANENT_MENU_KEY_AUTODETECT = 0;
    private static final int HAS_PERMANENT_MENU_KEY_TRUE = 1;
    private static final int HAS_PERMANENT_MENU_KEY_FALSE = 2;

    private final int mEdgeSlop;
    private final int mFadingEdgeLength;
    private final int mMinimumFlingVelocity;
@@ -296,6 +304,12 @@ public class ViewConfiguration {
        mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);

        if (!sHasPermanentMenuKeySet) {
            final int configVal = res.getInteger(
                    com.android.internal.R.integer.config_overrideHasPermanentMenuKey);

            switch (configVal) {
                default:
                case HAS_PERMANENT_MENU_KEY_AUTODETECT: {
                    IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
                    try {
                        sHasPermanentMenuKey = !wm.hasNavigationBar();
@@ -304,6 +318,19 @@ public class ViewConfiguration {
                        sHasPermanentMenuKey = false;
                    }
                }
                break;

                case HAS_PERMANENT_MENU_KEY_TRUE:
                    sHasPermanentMenuKey = true;
                    sHasPermanentMenuKeySet = true;
                    break;

                case HAS_PERMANENT_MENU_KEY_FALSE:
                    sHasPermanentMenuKey = false;
                    sHasPermanentMenuKeySet = true;
                    break;
            }
        }

        mFadingMarqueeEnabled = res.getBoolean(
                com.android.internal.R.bool.config_ui_enableFadingMarquee);
+8 −0
Original line number Diff line number Diff line
@@ -1304,4 +1304,12 @@
        <item>333</item>
        <item>353</item>
    </string-array>

    <!-- Override the default detection behavior for the framework method
         android.view.ViewConfiguration#hasPermanentMenuKey().
         Valid settings are:
         0 - No change. Use the default autodetection behavior.
         1 - The device DOES have a permanent menu key; ignore autodetection.
         2 - The device DOES NOT have a permanent menu key; ignore autodetection. -->
    <integer name="config_overrideHasPermanentMenuKey">0</integer>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -318,6 +318,7 @@
  <java-symbol type="integer" name="config_mobile_mtu" />
  <java-symbol type="integer" name="config_volte_replacement_rat"/>
  <java-symbol type="integer" name="config_valid_wappush_index" />
  <java-symbol type="integer" name="config_overrideHasPermanentMenuKey" />

  <java-symbol type="color" name="tab_indicator_text_v4" />