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

Commit 9920e0f1 authored by Filip Gruszczynski's avatar Filip Gruszczynski Committed by Android (Google) Code Review
Browse files

Merge "Swtich from max_action_buttons resource to a method."

parents de8d9332 6c54e728
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -177,8 +177,7 @@ public class ActionMenuPresenter extends BaseMenuPresenter

    public void onConfigurationChanged(Configuration newConfig) {
        if (!mMaxItemsSet) {
            mMaxItems = mContext.getResources().getInteger(
                    com.android.internal.R.integer.max_action_buttons);
            mMaxItems = ActionBarPolicy.get(mContext).getMaxActionButtons();
        }
        if (mMenu != null) {
            mMenu.onItemsChanged(true);
+22 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.view;
import com.android.internal.R;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Build;
@@ -38,10 +39,29 @@ public class ActionBarPolicy {
        mContext = context;
    }

    /**
     * Returns the maximum number of action buttons that should be permitted within an action
     * bar/action mode. This will be used to determine how many showAsAction="ifRoom" items can fit.
     * "always" items can override this.
     */
    public int getMaxActionButtons() {
        return mContext.getResources().getInteger(R.integer.max_action_buttons);
        final Configuration config = mContext.getResources().getConfiguration();
        final int width = config.screenWidthDp;
        final int height = config.screenHeightDp;
        final int smallest = config.smallestScreenWidthDp;
        if (smallest > 600 || (width > 960 && height > 720) || (width > 720 && height > 960)) {
            // For values-w600dp, values-sw600dp and values-xlarge.
            return 5;
        } else if (width >= 500 || (width > 640 && height > 480) || (width > 480 && height > 640)) {
            // For values-w500dp and values-large.
            return 4;
        } else if (width >= 360) {
            // For values-w360dp.
            return 3;
        } else {
            return 2;
        }
    }

    public boolean showsOverflowMenuButton() {
        return true;
    }
+1 −5
Original line number Diff line number Diff line
@@ -22,10 +22,6 @@
    <dimen name="thumbnail_width">360dp</dimen>
    <!-- The height that is used when creating thumbnails of applications. -->
    <dimen name="thumbnail_height">360dp</dimen>
    <!-- The maximum number of action buttons that should be permitted within
         an action bar/action mode. This will be used to determine how many
         showAsAction="ifRoom" items can fit. "always" items can override this. -->
    <integer name="max_action_buttons">5</integer>
    <!-- Default height of an action bar. -->
    <dimen name="action_bar_default_height">56dip</dimen>
    <!-- Vertical padding around action bar icons. -->
+0 −24
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
    <!-- The maximum number of action buttons that should be permitted within
         an action bar/action mode. This will be used to determine how many
         showAsAction="ifRoom" items can fit. "always" items can override this. -->
    <integer name="max_action_buttons">3</integer>
</resources>
+0 −24
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
    <!-- The maximum number of action buttons that should be permitted within
         an action bar/action mode. This will be used to determine how many
         showAsAction="ifRoom" items can fit. "always" items can override this. -->
    <integer name="max_action_buttons">4</integer>
</resources>
Loading