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

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

Update themes; dialogs, metrics

Add divider attributes to LinearLayout, plus styles for borderless
buttons. Update text field assets.

Change-Id: I673acab1692cc028a0327e8c154069253a4d52e8
parent dcafdb2e
Loading
Loading
Loading
Loading
+136 −13
Original line number Diff line number Diff line
@@ -2539,6 +2539,17 @@
 visibility="public"
>
</field>
<field name="borderlessButtonStyle"
 type="int"
 transient="false"
 volatile="false"
 value="16843580"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="bottom"
 type="int"
 transient="false"
@@ -3562,6 +3573,28 @@
 visibility="public"
>
</field>
<field name="dividerHorizontal"
 type="int"
 transient="false"
 volatile="false"
 value="16843581"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="dividerPadding"
 type="int"
 transient="false"
 volatile="false"
 value="16843579"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="dividerVertical"
 type="int"
 transient="false"
@@ -8391,6 +8424,17 @@
 visibility="public"
>
</field>
<field name="showDividers"
 type="int"
 transient="false"
 volatile="false"
 value="16843578"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="showSilent"
 type="int"
 transient="false"
@@ -15520,6 +15564,17 @@
 visibility="public"
>
</field>
<field name="Widget_Holo_Button_Borderless"
 type="int"
 transient="false"
 volatile="false"
 value="16974047"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="Widget_Holo_Button_Inset"
 type="int"
 transient="false"
@@ -236929,6 +236984,17 @@
 visibility="public"
>
</method>
<method name="getShowDividers"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getWeightSum"
 return="float"
 abstract="false"
@@ -237009,6 +237075,19 @@
<parameter name="i" type="int">
</parameter>
</method>
<method name="setDividerDrawable"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="divider" type="android.graphics.drawable.Drawable">
</parameter>
</method>
<method name="setGravity"
 return="void"
 abstract="false"
@@ -237061,6 +237140,19 @@
<parameter name="orientation" type="int">
</parameter>
</method>
<method name="setShowDividers"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="showDividers" type="int">
</parameter>
</method>
<method name="setVerticalGravity"
 return="void"
 abstract="false"
@@ -237098,6 +237190,50 @@
 visibility="public"
>
</field>
<field name="SHOW_DIVIDER_BEGINNING"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SHOW_DIVIDER_END"
 type="int"
 transient="false"
 volatile="false"
 value="4"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SHOW_DIVIDER_MIDDLE"
 type="int"
 transient="false"
 volatile="false"
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SHOW_DIVIDER_NONE"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="VERTICAL"
 type="int"
 transient="false"
@@ -245227,19 +245363,6 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="drawable" type="android.graphics.drawable.Drawable">
</parameter>
</method>
<method name="setDividerDrawable"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="resId" type="int">
</parameter>
</method>
+237 −3
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import com.android.internal.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
@@ -56,6 +58,23 @@ public class LinearLayout extends ViewGroup {
    public static final int HORIZONTAL = 0;
    public static final int VERTICAL = 1;

    /**
     * Don't show any dividers.
     */
    public static final int SHOW_DIVIDER_NONE = 0;
    /**
     * Show a divider at the beginning of the group.
     */
    public static final int SHOW_DIVIDER_BEGINNING = 1;
    /**
     * Show dividers between each item in the group.
     */
    public static final int SHOW_DIVIDER_MIDDLE = 2;
    /**
     * Show a divider at the end of the group.
     */
    public static final int SHOW_DIVIDER_END = 4;

    /**
     * Whether the children of this layout are baseline aligned.  Only applicable
     * if {@link #mOrientation} is horizontal.
@@ -119,6 +138,12 @@ public class LinearLayout extends ViewGroup {
    private static final int INDEX_BOTTOM = 2;
    private static final int INDEX_FILL = 3;

    private Drawable mDivider;
    private int mDividerWidth;
    private int mDividerHeight;
    private int mShowDividers;
    private int mDividerPadding;

    public LinearLayout(Context context) {
        super(context);
    }
@@ -155,9 +180,157 @@ public class LinearLayout extends ViewGroup {

        mUseLargestChild = a.getBoolean(R.styleable.LinearLayout_measureWithLargestChild, false);

        setDividerDrawable(a.getDrawable(R.styleable.LinearLayout_divider));
        mShowDividers = a.getInt(R.styleable.LinearLayout_showDividers, SHOW_DIVIDER_NONE);
        mDividerPadding = a.getDimensionPixelSize(R.styleable.LinearLayout_dividerPadding, 0);

        a.recycle();
    }

    /**
     * Set how dividers should be shown between items in this layout
     *
     * @param showDividers One or more of {@link #SHOW_DIVIDER_BEGINNING},
     *                     {@link #SHOW_DIVIDER_MIDDLE}, or {@link #SHOW_DIVIDER_END},
     *                     or {@link #SHOW_DIVIDER_NONE} to show no dividers.
     */
    public void setShowDividers(int showDividers) {
        if (showDividers != mShowDividers) {
            requestLayout();
        }
        mShowDividers = showDividers;
    }

    /**
     * @return A flag set indicating how dividers should be shown around items.
     * @see #setShowDividers(int)
     */
    public int getShowDividers() {
        return mShowDividers;
    }

    /**
     * Set a drawable to be used as a divider between items.
     * @param divider Drawable that will divide each item.
     * @see #setShowDividers(int)
     */
    public void setDividerDrawable(Drawable divider) {
        if (divider == mDivider) {
            return;
        }
        mDivider = divider;
        if (divider != null) {
            mDividerWidth = divider.getIntrinsicWidth();
            mDividerHeight = divider.getIntrinsicHeight();
        } else {
            mDividerWidth = 0;
            mDividerHeight = 0;
        }
        setWillNotDraw(divider == null);
        requestLayout();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        if (mDivider == null) {
            return;
        }

        if (mOrientation == VERTICAL) {
            drawDividersVertical(canvas);
        } else {
            drawDividersHorizontal(canvas);
        }
    }

    void drawDividersVertical(Canvas canvas) {
        final boolean showDividerBeginning =
            (mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING;
        final boolean showDividerMiddle =
                (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE;
        final boolean showDividerEnd =
                (mShowDividers & SHOW_DIVIDER_END) == SHOW_DIVIDER_END;

        final int count = getVirtualChildCount();
        int top = getPaddingTop();
        boolean firstVisible = true;
        for (int i = 0; i < count; i++) {
            final View child = getVirtualChildAt(i);

            if (child == null) {
                top += measureNullChild(i);
            } else if (child.getVisibility() != GONE) {
                if (firstVisible) {
                    firstVisible = false;
                    if (showDividerBeginning) {
                        drawHorizontalDivider(canvas, top);
                        top += mDividerHeight;
                    }
                } else if (showDividerMiddle) {
                    drawHorizontalDivider(canvas, top);
                    top += mDividerHeight;
                }

                LayoutParams lp = (LayoutParams) child.getLayoutParams();
                top += lp.topMargin + child.getHeight() + lp.bottomMargin;
            }
        }

        if (showDividerEnd) {
            drawHorizontalDivider(canvas, top);
        }
    }

    void drawDividersHorizontal(Canvas canvas) {
        final boolean showDividerBeginning =
            (mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING;
        final boolean showDividerMiddle =
                (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE;
        final boolean showDividerEnd =
                (mShowDividers & SHOW_DIVIDER_END) == SHOW_DIVIDER_END;

        final int count = getVirtualChildCount();
        int left = getPaddingLeft();
        boolean firstVisible = true;
        for (int i = 0; i < count; i++) {
            final View child = getVirtualChildAt(i);

            if (child == null) {
                left += measureNullChild(i);
            } else if (child.getVisibility() != GONE) {
                if (firstVisible) {
                    firstVisible = false;
                    if (showDividerBeginning) {
                        drawVerticalDivider(canvas, left);
                        left += mDividerWidth;
                    }
                } else if (showDividerMiddle) {
                    drawVerticalDivider(canvas, left);
                    left += mDividerWidth;
                }

                LayoutParams lp = (LayoutParams) child.getLayoutParams();
                left += lp.leftMargin + child.getWidth() + lp.rightMargin;
            }
        }

        if (showDividerEnd) {
            drawVerticalDivider(canvas, left);
        }
    }

    void drawHorizontalDivider(Canvas canvas, int top) {
        mDivider.setBounds(getPaddingLeft() + mDividerPadding, top,
                getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight);
        mDivider.draw(canvas);
    }

    void drawVerticalDivider(Canvas canvas, int left) {
        mDivider.setBounds(left, getPaddingTop() + mDividerPadding,
                left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding);
        mDivider.draw(canvas);
    }

    /**
     * <p>Indicates whether widgets contained within this layout are aligned
     * on their baseline or not.</p>
@@ -380,7 +553,14 @@ public class LinearLayout extends ViewGroup {

        int largestChildHeight = Integer.MIN_VALUE;

        // A divider at the end will change how much space views can consume.
        final boolean showDividerBeginning =
                (mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING;
        final boolean showDividerMiddle =
            (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE;

        // See how tall everyone is. Also remember max width.
        boolean firstVisible = true;
        for (int i = 0; i < count; ++i) {
            final View child = getVirtualChildAt(i);

@@ -394,6 +574,15 @@ public class LinearLayout extends ViewGroup {
               continue;
            }

            if (firstVisible) {
                firstVisible = false;
                if (showDividerBeginning) {
                    mTotalLength += mDividerHeight;
                }
            } else if (showDividerMiddle) {
                mTotalLength += mDividerHeight;
            }

            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) child.getLayoutParams();

            totalWeight += lp.weight;
@@ -486,6 +675,10 @@ public class LinearLayout extends ViewGroup {
            i += getChildrenSkipCount(child, i);
        }

        if (mTotalLength > 0 && (mShowDividers & SHOW_DIVIDER_END) == SHOW_DIVIDER_END) {
            mTotalLength += mDividerHeight;
        }

        if (useLargestChild && heightMode == MeasureSpec.AT_MOST) {
            mTotalLength = 0;

@@ -679,7 +872,14 @@ public class LinearLayout extends ViewGroup {

        int largestChildWidth = Integer.MIN_VALUE;

        // A divider at the end will change how much space views can consume.
        final boolean showDividerBeginning =
                (mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING;
        final boolean showDividerMiddle =
            (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE;

        // See how wide everyone is. Also remember max height.
        boolean firstVisible = true;
        for (int i = 0; i < count; ++i) {
            final View child = getVirtualChildAt(i);

@@ -693,6 +893,15 @@ public class LinearLayout extends ViewGroup {
                continue;
            }

            if (firstVisible) {
                firstVisible = false;
                if (showDividerBeginning) {
                    mTotalLength += mDividerWidth;
                }
            } else if (showDividerMiddle) {
                mTotalLength += mDividerWidth;
            }

            final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)
                    child.getLayoutParams();

@@ -803,6 +1012,10 @@ public class LinearLayout extends ViewGroup {
            i += getChildrenSkipCount(child, i);
        }

        if (mTotalLength > 0 && (mShowDividers & SHOW_DIVIDER_END) == SHOW_DIVIDER_END) {
            mTotalLength += mDividerWidth;
        }

        // Check mMaxAscent[INDEX_TOP] first because it maps to Gravity.TOP,
        // the most common case
        if (maxAscent[INDEX_TOP] != -1 ||
@@ -1128,6 +1341,13 @@ public class LinearLayout extends ViewGroup {
           
        }

        final boolean showDividerMiddle =
                (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE;

        if ((mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING) {
            childTop += mDividerHeight;
        }

        for (int i = 0; i < count; i++) {
            final View child = getVirtualChildAt(i);
            if (child == null) {
@@ -1162,12 +1382,15 @@ public class LinearLayout extends ViewGroup {
                        break;
                }
                
                
                childTop += lp.topMargin;
                setChildFrame(child, childLeft, childTop + getLocationOffset(child),
                        childWidth, childHeight);
                childTop += childHeight + lp.bottomMargin + getNextLocationOffset(child);

                if (showDividerMiddle) {
                    childTop += mDividerHeight;
                }

                i += getChildrenSkipCount(child, i);
            }
        }
@@ -1218,6 +1441,13 @@ public class LinearLayout extends ViewGroup {
            }
        }

        final boolean showDividerMiddle =
                (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE;

        if ((mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING) {
            childLeft += mDividerWidth;
        }

        for (int i = 0; i < count; i++) {
            final View child = getVirtualChildAt(i);

@@ -1282,6 +1512,10 @@ public class LinearLayout extends ViewGroup {
                childLeft += childWidth + lp.rightMargin +
                        getNextLocationOffset(child);

                if (showDividerMiddle) {
                    childLeft += mDividerWidth;
                }

                i += getChildrenSkipCount(child, i);
            }
        }
+32 −5
Original line number Diff line number Diff line
@@ -118,6 +118,12 @@ public class AlertController {
    
    private int mCheckedItem = -1;

    private int mAlertDialogLayout;
    private int mListLayout;
    private int mMultiChoiceItemLayout;
    private int mSingleChoiceItemLayout;
    private int mListItemLayout;

    private Handler mHandler;

    View.OnClickListener mButtonHandler = new View.OnClickListener() {
@@ -178,6 +184,27 @@ public class AlertController {
        mDialogInterface = di;
        mWindow = window;
        mHandler = new ButtonHandler(di);

        TypedArray a = context.obtainStyledAttributes(null,
                com.android.internal.R.styleable.AlertDialog,
                com.android.internal.R.attr.alertDialogStyle, 0);

        mAlertDialogLayout = a.getResourceId(com.android.internal.R.styleable.AlertDialog_layout,
                com.android.internal.R.layout.alert_dialog);
        mListLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_listLayout,
                com.android.internal.R.layout.select_dialog);
        mMultiChoiceItemLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_multiChoiceItemLayout,
                com.android.internal.R.layout.select_dialog_multichoice);
        mSingleChoiceItemLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_singleChoiceItemLayout,
                com.android.internal.R.layout.select_dialog_singlechoice);
        mListItemLayout = a.getResourceId(
                com.android.internal.R.styleable.AlertDialog_listItemLayout,
                com.android.internal.R.layout.select_dialog_item);

        a.recycle();
    }
    
    static boolean canTextInput(View v) {
@@ -210,7 +237,7 @@ public class AlertController {
            mWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                    WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        }
        mWindow.setContentView(com.android.internal.R.layout.alert_dialog);
        mWindow.setContentView(mAlertDialogLayout);
        setupView();
    }
    
@@ -810,13 +837,13 @@ public class AlertController {
        
        private void createListView(final AlertController dialog) {
            final RecycleListView listView = (RecycleListView)
                    mInflater.inflate(R.layout.select_dialog, null);
                    mInflater.inflate(dialog.mListLayout, null);
            ListAdapter adapter;
            
            if (mIsMultiChoice) {
                if (mCursor == null) {
                    adapter = new ArrayAdapter<CharSequence>(
                            mContext, R.layout.select_dialog_multichoice, R.id.text1, mItems) {
                            mContext, dialog.mMultiChoiceItemLayout, R.id.text1, mItems) {
                        @Override
                        public View getView(int position, View convertView, ViewGroup parent) {
                            View view = super.getView(position, convertView, parent);
@@ -850,7 +877,7 @@ public class AlertController {
    
                        @Override
                        public View newView(Context context, Cursor cursor, ViewGroup parent) {
                            return mInflater.inflate(R.layout.select_dialog_multichoice,
                            return mInflater.inflate(dialog.mMultiChoiceItemLayout,
                                    parent, false);
                        }
                        
@@ -858,7 +885,7 @@ public class AlertController {
                }
            } else {
                int layout = mIsSingleChoice 
                        ? R.layout.select_dialog_singlechoice : R.layout.select_dialog_item;
                        ? dialog.mSingleChoiceItemLayout : dialog.mListItemLayout;
                if (mCursor == null) {
                    adapter = (mAdapter != null) ? mAdapter
                            : new ArrayAdapter<CharSequence>(mContext, layout, R.id.text1, mItems);
+281 B
Loading image diff...
+279 B
Loading image diff...
Loading