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

Commit be4d68e7 authored by Adam Powell's avatar Adam Powell
Browse files

Updated styles and metrics.

* Added preliminary ButtonGroup support for buttons that display as a unit.
* Fixed a bug with MenuBuilder that caused old-style icon menus to fail.
* Added support for explicitly setting line height in text.

Change-Id: I1ba65f09dd9e1bc833d247ebe72052a21e3f99f0
parent 2493c164
Loading
Loading
Loading
Loading
+181 −79
Original line number Diff line number Diff line
@@ -2114,7 +2114,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843567"
 value="16843566"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2136,7 +2136,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843576"
 value="16843575"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2147,7 +2147,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843575"
 value="16843574"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2158,18 +2158,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843577"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="actionButtonPadding"
 type="int"
 transient="false"
 volatile="false"
 value="16843547"
 value="16843576"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2202,7 +2191,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843584"
 value="16843582"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2213,7 +2202,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843549"
 value="16843548"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2224,7 +2213,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843580"
 value="16843578"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2235,7 +2224,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843550"
 value="16843549"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2246,7 +2235,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843578"
 value="16843577"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2257,7 +2246,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843585"
 value="16843583"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2268,7 +2257,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843586"
 value="16843584"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2367,7 +2356,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843598"
 value="16843596"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2488,7 +2477,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843574"
 value="16843573"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2829,7 +2818,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843593"
 value="16843591"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2840,7 +2829,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843592"
 value="16843590"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2869,6 +2858,17 @@
 visibility="public"
>
</field>
<field name="buttonGroupStyle"
 type="int"
 transient="false"
 volatile="false"
 value="16843599"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="buttonStyle"
 type="int"
 transient="false"
@@ -3643,7 +3643,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843597"
 value="16843595"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -3760,6 +3760,17 @@
 visibility="public"
>
</field>
<field name="dividerVertical"
 type="int"
 transient="false"
 volatile="false"
 value="16843598"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="drawSelectorOnTop"
 type="int"
 transient="false"
@@ -4501,7 +4512,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843557"
 value="16843556"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4512,7 +4523,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843561"
 value="16843560"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4523,7 +4534,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843562"
 value="16843561"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4534,7 +4545,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843563"
 value="16843562"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4545,7 +4556,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843564"
 value="16843563"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4556,7 +4567,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843559"
 value="16843558"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4567,7 +4578,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843560"
 value="16843559"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4578,7 +4589,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843565"
 value="16843564"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4589,7 +4600,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843566"
 value="16843565"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5073,7 +5084,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843583"
 value="16843581"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5194,7 +5205,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843570"
 value="16843569"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5205,7 +5216,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843568"
 value="16843567"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5216,7 +5227,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843569"
 value="16843568"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5575,17 +5586,6 @@
 visibility="public"
>
</field>
<field name="itemPadding"
 type="int"
 transient="false"
 volatile="false"
 value="16843579"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="itemTextAppearance"
 type="int"
 transient="false"
@@ -6855,7 +6855,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843572"
 value="16843571"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -6899,7 +6899,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843594"
 value="16843592"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -6910,7 +6910,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843588"
 value="16843586"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -6998,7 +6998,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843596"
 value="16843594"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -7482,7 +7482,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843556"
 value="16843555"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -7812,7 +7812,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843589"
 value="16843587"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -7911,7 +7911,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843548"
 value="16843547"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -8076,7 +8076,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843555"
 value="16843554"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9121,7 +9121,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843573"
 value="16843572"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9143,7 +9143,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843571"
 value="16843570"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9242,7 +9242,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843587"
 value="16843585"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9473,7 +9473,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843582"
 value="16843580"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9858,7 +9858,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843590"
 value="16843588"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9935,7 +9935,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843591"
 value="16843589"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9979,7 +9979,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843595"
 value="16843593"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -10173,6 +10173,17 @@
 visibility="public"
>
</field>
<field name="textLineHeight"
 type="int"
 transient="false"
 volatile="false"
 value="16843597"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="textOff"
 type="int"
 transient="false"
@@ -10397,7 +10408,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843581"
 value="16843579"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -10672,7 +10683,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843552"
 value="16843551"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -10683,7 +10694,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843553"
 value="16843552"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -10694,7 +10705,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843554"
 value="16843553"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -11024,7 +11035,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843558"
 value="16843557"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -11035,7 +11046,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843551"
 value="16843550"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -16937,7 +16948,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16973984"
 value="16973987"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -16948,7 +16959,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16973985"
 value="16973988"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -17087,6 +17098,39 @@
 visibility="public"
>
</field>
<field name="Theme_Holo_Dialog"
 type="int"
 transient="false"
 volatile="false"
 value="16973981"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="Theme_Holo_Light"
 type="int"
 transient="false"
 volatile="false"
 value="16973980"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="Theme_Holo_Light_Dialog"
 type="int"
 transient="false"
 volatile="false"
 value="16973982"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="Theme_Holo_NoActionBar"
 type="int"
 transient="false"
@@ -17388,7 +17432,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16973983"
 value="16973986"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -17399,7 +17443,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16973982"
 value="16973985"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -17553,7 +17597,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16973986"
 value="16973989"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -17619,7 +17663,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16973980"
 value="16973983"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -17674,7 +17718,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16973981"
 value="16973984"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -228700,6 +228744,51 @@
</parameter>
</constructor>
</class>
<class name="ButtonGroup"
 extends="android.widget.LinearLayout"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="ButtonGroup"
 type="android.widget.ButtonGroup"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
</constructor>
<constructor name="ButtonGroup"
 type="android.widget.ButtonGroup"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
</constructor>
<constructor name="ButtonGroup"
 type="android.widget.ButtonGroup"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<parameter name="defStyleRes" type="int">
</parameter>
</constructor>
</class>
<class name="CheckBox"
 extends="android.widget.CompoundButton"
 abstract="false"
@@ -242958,6 +243047,19 @@
<parameter name="input" type="android.text.method.KeyListener">
</parameter>
</method>
<method name="setLineHeight"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="lineHeight" type="int">
</parameter>
</method>
<method name="setLineSpacing"
 return="void"
 abstract="false"
+72 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 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.
 */

package android.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

public class ButtonGroup extends LinearLayout {
    private Drawable mDivider;
    private Drawable mButtonBackground;

    public ButtonGroup(Context context) {
        this(context, null);
    }
    
    public ButtonGroup(Context context, AttributeSet attrs) {
        this(context, attrs, com.android.internal.R.attr.buttonGroupStyle);
    }
    
    public ButtonGroup(Context context, AttributeSet attrs, int defStyleRes) {
        super(context, attrs, defStyleRes);
        
        TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.ButtonGroup);
        
        mDivider = a.getDrawable(com.android.internal.R.styleable.ButtonGroup_divider);
        mButtonBackground = a.getDrawable(
                com.android.internal.R.styleable.ButtonGroup_buttonBackground);
        a.recycle();
    }
    
    @Override
    public void addView(View child, int index, ViewGroup.LayoutParams params) {
        if (getChildCount() > 0) {
            super.addView(makeDividerView(), index, makeDividerLayoutParams());
            if (index >= 0) {
                index++;
            }
        }
        child.setBackgroundDrawable(mButtonBackground);
        super.addView(child, index, params);
    }
    
    private ImageView makeDividerView() {
        ImageView result = new ImageView(mContext);
        result.setImageDrawable(mDivider);
        result.setScaleType(ImageView.ScaleType.FIT_XY);
        return result;
    }

    private LayoutParams makeDividerLayoutParams() {
        return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -589,7 +589,7 @@ public class Spinner extends AbsSpinner implements OnClickListener {
            
            setAnchorView(Spinner.this);
            setModal(true);
            setPromptPosition(POSITION_PROMPT_BELOW);
            setPromptPosition(POSITION_PROMPT_ABOVE);
            setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView parent, View v, int position, long id) {
                    Spinner.this.setSelection(position);
+27 −0
Original line number Diff line number Diff line
@@ -734,6 +734,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            case com.android.internal.R.styleable.TextView_textSelectHandle:
                mTextSelectHandleRes = a.getResourceId(attr, 0);
                break;
                
            case com.android.internal.R.styleable.TextView_textLineHeight:
                int lineHeight = a.getDimensionPixelSize(attr, 0);
                if (lineHeight != 0) {
                    setLineHeight(lineHeight);
                }
            }
        }
        a.recycle();
@@ -1063,6 +1069,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * or last-line padding.
     */
    public int getLineHeight() {
        if (mLineHeight != 0) {
            return mLineHeight;
        }
        return FastMath.round(mTextPaint.getFontMetricsInt(null) * mSpacingMult
                          + mSpacingAdd);
    }
@@ -1655,9 +1664,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                                       TextAppearance_textStyle, -1);

        setTypefaceByIndex(typefaceIndex, styleIndex);
        
        int lineHeight = appearance.getDimensionPixelSize(
                com.android.internal.R.styleable.TextAppearance_textLineHeight, 0);
        if (lineHeight != 0) {
            setLineHeight(lineHeight);
        }

        appearance.recycle();
    }

    /**
     * Set the height of a line of text in pixels. This value will override line height
     * values stored in the font modified by lineSpacingExtra and lineSpacingMultiplier.
     *
     * @param lineHeight Desired height of a single line of text in pixels
     */
    public void setLineHeight(int lineHeight) {
        mLineHeight = lineHeight;
    }

    /**
     * @return the size (in pixels) of the default text size in this TextView.
     */
@@ -8449,6 +8475,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

    private float                   mSpacingMult = 1;
    private float                   mSpacingAdd = 0;
    private int                     mLineHeight = 0;

    private static final int        LINES = 1;
    private static final int        EMS = LINES;
+5 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public class ActionMenuItemView extends FrameLayout
    }

    public ActionMenuItemView(Context context, AttributeSet attrs) {
        this(context, attrs, com.android.internal.R.attr.actionButtonStyle);
        super(context, attrs);
    }

    public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) {
@@ -114,6 +114,10 @@ public class ActionMenuItemView extends FrameLayout
        }
    }
    
    public boolean hasText() {
        return mTextButton.getVisibility() != GONE;
    }

    public void setShortcut(boolean showShortcut, char shortcutKey) {
        // Action buttons don't show text for shortcut keys.
    }
Loading