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

Commit eefc9089 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Add API to report the presence of a permanent menu key on the device."

parents 748d9f2f 8c470625
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22263,6 +22263,7 @@ package android.view {
    method public static deprecated int getTouchSlop();
    method public static deprecated int getWindowTouchSlop();
    method public static long getZoomControlsTimeout();
    method public boolean hasPermanentMenuKey();
  }
  public class ViewDebug {
+36 −3
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.view;
import android.app.AppGlobals;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.RemoteException;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.SparseArray;
@@ -219,6 +221,9 @@ public class ViewConfiguration {
    private final int mOverscrollDistance;
    private final int mOverflingDistance;

    private boolean sHasPermanentMenuKey;
    private boolean sHasPermanentMenuKeySet;

    private static final SparseArray<ViewConfiguration> sConfigurations =
            new SparseArray<ViewConfiguration>(2);

@@ -254,11 +259,12 @@ public class ViewConfiguration {
     * @see android.util.DisplayMetrics
     */
    private ViewConfiguration(Context context) {
        final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        final Resources res = context.getResources();
        final DisplayMetrics metrics = res.getDisplayMetrics();
        final Configuration config = res.getConfiguration();
        final float density = metrics.density;
        final float sizeAndDensity;
        if (context.getResources().getConfiguration().isLayoutSizeAtLeast(
                Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
        if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
            sizeAndDensity = density * 1.5f;
        } else {
            sizeAndDensity = density;
@@ -280,6 +286,17 @@ public class ViewConfiguration {

        mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
        mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);

        if (!sHasPermanentMenuKeySet) {
            IWindowManager wm = Display.getWindowManager();
            try {
                sHasPermanentMenuKey = wm.canStatusBarHide() && !res.getBoolean(
                        com.android.internal.R.bool.config_showNavigationBar);
                sHasPermanentMenuKeySet = true;
            } catch (RemoteException ex) {
                sHasPermanentMenuKey = false;
            }
        }
    }

    /**
@@ -640,4 +657,20 @@ public class ViewConfiguration {
    public static float getScrollFriction() {
        return SCROLL_FRICTION;
    }

    /**
     * Report if the device has a permanent menu key available to the user.
     *
     * <p>As of Android 3.0, devices may not have a permanent menu key available.
     * Apps should use the action bar to present menu options to users.
     * However, there are some apps where the action bar is inappropriate
     * or undesirable. This method may be used to detect if a menu key is present.
     * If not, applications should provide another on-screen affordance to access
     * functionality.
     *
     * @return true if a permanent menu key is present, false otherwise.
     */
    public boolean hasPermanentMenuKey() {
        return sHasPermanentMenuKey;
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.view.MenuItem;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.ImageButton;

@@ -69,9 +70,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter {
        final Resources res = context.getResources();

        if (!mReserveOverflowSet) {
            // TODO Use the no-buttons specifier instead here
            mReserveOverflow = res.getConfiguration()
                    .isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE);
            mReserveOverflow = !ViewConfiguration.get(context).hasPermanentMenuKey();
        }

        if (!mWidthLimitSet) {
+4 −0
Original line number Diff line number Diff line
@@ -658,4 +658,8 @@
         This is intended to allow packaging drivers or tools for installation on a PC. -->
    <string translatable="false" name="config_isoImagePath"></string>

    <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
         autodetected from the Configuration. -->
    <bool name="config_showNavigationBar">false</bool>

</resources>
+0 −4
Original line number Diff line number Diff line
@@ -36,10 +36,6 @@
    <!-- Whether or not we show the number in the bar. -->
    <bool name="config_statusBarShowNumber">true</bool>

    <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
         autodetected from the Configuration. -->
    <bool name="config_showNavigationBar">false</bool>

    <!-- How many icons may be shown at once in the system bar. Includes any
         slots that may be reused for things like IME control. -->
    <integer name="config_maxNotificationIcons">5</integer>
Loading