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

Commit 67b4c4f2 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov Committed by Android Git Automerger
Browse files

am e4b231dd: Changed design of the alarm dialog

* commit 'e4b231dd':
  Changed design of the alarm dialog
parents 71a1f85e e4b231dd
Loading
Loading
Loading
Loading
+36 −15
Original line number Diff line number Diff line
@@ -21,21 +21,6 @@
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ListView
        android:id="@+id/alarms_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginLeft="16dip"
        android:layout_marginRight="16dip" />

    <View
        android:layout_width="match_parent"
        android:layout_height="1dip"
        android:layout_marginLeft="16dip"
        android:layout_marginRight="16dip"
        android:background="?android:attr/dividerHorizontal" />

    <LinearLayout
        android:id="@+id/add_alarm"
        android:clickable="true"
@@ -64,4 +49,40 @@

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dip"
        android:layout_marginLeft="16dip"
        android:layout_marginRight="16dip"
        android:background="?android:attr/dividerHorizontal" />

    <ListView
        android:id="@+id/alarms_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginLeft="16dip"
        android:layout_marginRight="16dip" />

    <View
        android:layout_width="match_parent"
        android:layout_height="1dip"
        android:layout_marginLeft="16dip"
        android:layout_marginRight="16dip"
        android:background="?android:attr/dividerHorizontal" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        style="?android:attr/buttonBarStyle">

        <Button android:id="@+id/done"
            style="?android:attr/buttonBarButtonStyle"
            android:focusable="true"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="@string/done"/>
    </LinearLayout>

</LinearLayout>
+8 −7
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@
        android:layout_height="match_parent"
        android:gravity="center_vertical"
        android:layout_weight="1"
        android:layout_gravity="center_vertical"
        android:orientation="vertical"
        android:paddingLeft="16dip"
        android:paddingRight="16dip">
@@ -62,21 +63,22 @@

            <com.android.deskclock.AndroidClockTextView 
                android:id="@+id/timeDisplay"
                android:includeFontPadding="false"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingRight="6dip"
                android:paddingBottom="3dip"
                android:textSize="28sp"
                android:textColor="?android:attr/textColorPrimary"/>
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="?android:attr/textColorPrimary"
                useClockTypeface="false"/>

            <com.android.deskclock.AndroidClockTextView 
                android:id="@+id/am_pm"
                android:layout_width="wrap_content"
                android:layout_width="0dip"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textStyle="bold"
                android:textColor="?android:attr/textColorPrimary"/>
                android:textColor="?android:attr/textColorPrimary"
                useClockTypeface="false"/>

            <TextView android:id="@+id/label"
                android:layout_width="wrap_content"
@@ -92,7 +94,6 @@
        </LinearLayout>

        <TextView android:id="@+id/daysOfWeek"
            android:includeFontPadding="false"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
+9 −0
Original line number Diff line number Diff line
@@ -232,6 +232,15 @@ public class AlarmClock extends Activity implements OnItemClickListener {
                    }
            });
        }

        View doneButton = findViewById(R.id.done);
        if (doneButton != null) {
            doneButton.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    finish();
                }
            });
        }
    }

    private void addNewAlarm() {
+22 −15
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.deskclock;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.FontMetrics;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.util.AttributeSet;
@@ -36,6 +37,7 @@ public class AndroidClockTextView extends View {

    private static final String ATTR_FONT_HIGHLIGHTS_ENABLED = "fontHighlightsEnabled";
    private static final String ATTR_SHORT_FORM = "shortForm";
    private static final String ATTR_USE_CLOCK_TYPEFACE = "useClockTypeface";

    private static Typeface sTypeface;
    private static Typeface sHighlightTypeface;
@@ -55,9 +57,9 @@ public class AndroidClockTextView extends View {
    private Rect mTempRect = new Rect();
    private int mX = -1;
    private int mY = -1;
    private float mFontDescent;
    private boolean mHighlightsEnabled;
    private boolean mShortForm;
    private boolean mUseClockTypeface;

    public AndroidClockTextView(Context context) {
        super(context);
@@ -71,6 +73,10 @@ public class AndroidClockTextView extends View {
        mHighlightsEnabled =
            attrs.getAttributeBooleanValue(null, ATTR_FONT_HIGHLIGHTS_ENABLED, true);
        mShortForm =attrs.getAttributeBooleanValue(null, ATTR_SHORT_FORM, false);
        mUseClockTypeface =attrs.getAttributeBooleanValue(null, ATTR_USE_CLOCK_TYPEFACE, true);
        if (!mUseClockTypeface) {
            mHighlightsEnabled = false;
        }

        mTextSize = mProperties.getTextSize();
        mColor = mProperties.getTextColors().getDefaultColor();
@@ -81,12 +87,13 @@ public class AndroidClockTextView extends View {
        }

        mTextPaint = new Paint();
        mTextPaint.setTypeface(sTypeface);
        mTextPaint.setTypeface(mUseClockTypeface ? sTypeface : mProperties.getTypeface());
        mTextPaint.setColor(mColor);
        mTextPaint.setTextAlign(Paint.Align.LEFT);
        mTextPaint.setAntiAlias(true);
        mTextPaint.setTextSize(mTextSize);
        mTextPaint.setAlpha(mTextAlpha);
        mTextPaint.setFakeBoldText(!mUseClockTypeface);

        mHighlightPaint = new Paint();
        mHighlightPaint.setTypeface(sHighlightTypeface);
@@ -96,7 +103,6 @@ public class AndroidClockTextView extends View {
        mHighlightPaint.setTextSize(mTextSize);
        mHighlightPaint.setAlpha(mHighlightsEnabled ? mHighlightAlpha : mTextAlpha);

        mFontDescent = mTextPaint.getFontMetrics().descent;
    }

    public void setTextColor(int color) {
@@ -108,9 +114,13 @@ public class AndroidClockTextView extends View {
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int measuredWidth, measuredHeight;
        FontMetrics fontMetrics = mTextPaint.getFontMetrics();

        mTextPaint.getTextBounds(mText, 0, mText.length(), mTextBounds);
        if (mUseClockTypeface) {
            mHighlightPaint.getTextBounds(mText, 0, mText.length(), mTempRect);
            mTextBounds.union(mTempRect);
        }

        int mode = MeasureSpec.getMode(widthMeasureSpec);
        if (mode == MeasureSpec.EXACTLY) {
@@ -122,20 +132,15 @@ public class AndroidClockTextView extends View {
        if (mode == MeasureSpec.EXACTLY) {
            measuredHeight = MeasureSpec.getSize(heightMeasureSpec);
        } else {
            // Text bounds are measured from the bottom-left corner, so mTextBounds.top
            // Text bounds are measured from the bottom-left corner, so fontMetrics.top
            // is a negative number
            measuredHeight = -mTextBounds.top + getPaddingTop() + getPaddingBottom();
            measuredHeight = (int) (-fontMetrics.top + fontMetrics.bottom +
                    getPaddingTop() + getPaddingBottom());
        }
        setMeasuredDimension(measuredWidth, measuredHeight);

        mX = getPaddingLeft();
        mY = (int) (measuredHeight - getPaddingBottom() - mFontDescent);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        mX = getPaddingLeft();
        mY = (int) (getHeight() - getPaddingBottom() - mFontDescent);
        mY = (int) (measuredHeight - getPaddingBottom() - fontMetrics.descent);
    }

    public void setText(CharSequence time) {
@@ -161,7 +166,9 @@ public class AndroidClockTextView extends View {
    protected void onDraw(Canvas canvas) {
        if (mText != null) {
            canvas.drawText(mText, mX, mY, mTextPaint);
            if (mUseClockTypeface) {
                canvas.drawText(mText, mX, mY, mHighlightPaint);
            }
        }
    }
}