Loading res/values/dimens.xml +1 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ <dimen name="alarm_timeline_layout_padding_top">50dp</dimen> <dimen name="alarm_timeline_title_margin_bottom">10dp</dimen> <dimen name="alarm_timeline_title_text_size">24dp</dimen> <dimen name="circletimer_diamond_size">12dip</dimen> <dimen name="circletimer_dot_size">12dip</dimen> <dimen name="circletimer_circle_size">4dip</dimen> <dimen name="circletimer_marker_size">16dip</dimen> Loading src/com/android/deskclock/CircleButtonsLayout.java +3 −4 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ public class CircleButtonsLayout extends FrameLayout { private FrameLayout mLabel; private TextView mLabelText; @SuppressWarnings("unused") public CircleButtonsLayout(Context context) { this(context, null); mContext = context; Loading @@ -52,13 +53,11 @@ public class CircleButtonsLayout extends FrameLayout { mLeftButtonPadding = mContext.getResources().getDimension(leftButtonPaddingDimenId); mRightButtonPadding = mContext.getResources().getDimension(rightButtonPaddingDimenId); float diamondStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_diamond_size); float dotStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_dot_size); float markerStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_marker_size); mStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_circle_size); mDiamOffset = Utils.calculateRadiusOffset(mStrokeSize, diamondStrokeSize, markerStrokeSize) * 2; mDiamOffset = Utils.calculateRadiusOffset(mStrokeSize, dotStrokeSize, markerStrokeSize) * 2; } @Override Loading src/com/android/deskclock/CircleTimerView.java +26 −35 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package com.android.deskclock; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Paint; Loading @@ -13,7 +12,10 @@ import android.view.View; import com.android.deskclock.stopwatch.Stopwatches; /** * TODO: Insert description here. (generated by isaackatz) * Class to draw a circle for timers and stopwatches. * These two usages require two different animation modes: * Timer counts down. In this mode the animation is counter-clockwise and stops at 0. * Stopwatch counts up. In this mode the animation is clockwise and will run until stopped. */ public class CircleTimerView extends View { Loading @@ -27,24 +29,19 @@ public class CircleTimerView extends View { private long mAccumulatedTime = 0; private boolean mPaused = false; private boolean mAnimate = false; private static float mCircleXCenterLeftPadding = 0; private static float mStrokeSize = 4; private static float mDiamondStrokeSize = 12; private static float mDotRadius = 6; private static float mMarkerStrokeSize = 2; private final Paint mPaint = new Paint(); private final Paint mFill = new Paint(); private final RectF mArcRect = new RectF(); private float mRectHalfWidth = 6f; private Resources mResources; private float mRadiusOffset; // amount to remove from radius to account for markers on circle private float mScreenDensity; // Class has 2 modes: // Timer mode - counting down. in this mode the animation is counter-clockwise and stops at 0 // Stop watch mode - counting up - in this mode the animation is clockwise and will keep the // animation until stopped. private boolean mTimerMode = false; // default is stop watch view // Stopwatch mode is the default. private boolean mTimerMode = false; @SuppressWarnings("unused") public CircleTimerView(Context context) { this(context, null); } Loading Loading @@ -115,23 +112,21 @@ public class CircleTimerView extends View { private void init(Context c) { mResources = c.getResources(); mCircleXCenterLeftPadding = (mResources.getDimension(R.dimen.timer_circle_width) - mResources.getDimension(R.dimen.timer_circle_diameter)) / 2; mStrokeSize = mResources.getDimension(R.dimen.circletimer_circle_size); mDiamondStrokeSize = mResources.getDimension(R.dimen.circletimer_diamond_size); mMarkerStrokeSize = mResources.getDimension(R.dimen.circletimer_marker_size); Resources resources = c.getResources(); mStrokeSize = resources.getDimension(R.dimen.circletimer_circle_size); float dotDiameter = resources.getDimension(R.dimen.circletimer_dot_size); mMarkerStrokeSize = resources.getDimension(R.dimen.circletimer_marker_size); mRadiusOffset = Utils.calculateRadiusOffset( mStrokeSize, mDiamondStrokeSize, mMarkerStrokeSize); mStrokeSize, dotDiameter, mMarkerStrokeSize); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mWhiteColor = mResources.getColor(R.color.clock_white); mRedColor = mResources.getColor(R.color.clock_red); mScreenDensity = mResources.getDisplayMetrics().density; mWhiteColor = resources.getColor(R.color.clock_white); mRedColor = resources.getColor(R.color.clock_red); mScreenDensity = resources.getDisplayMetrics().density; mFill.setAntiAlias(true); mFill.setStyle(Paint.Style.FILL); mFill.setColor(mRedColor); mRectHalfWidth = mDiamondStrokeSize / 2f; mDotRadius = dotDiameter / 2f; } public void setTimerMode(boolean mode) { Loading @@ -151,7 +146,7 @@ public class CircleTimerView extends View { mPaint.setColor(mWhiteColor); canvas.drawCircle (xCenter, yCenter, radius, mPaint); if (mTimerMode) { drawRedDiamond(canvas, 0f, xCenter, yCenter, radius); drawRedDot(canvas, 0f, xCenter, yCenter, radius); } } else { if (mAnimate) { Loading Loading @@ -195,30 +190,26 @@ public class CircleTimerView extends View { canvas.drawArc (mArcRect, 270 + angle, mScreenDensity * (float) (360 / (radius * Math.PI)) , false, mPaint); } drawRedDiamond(canvas, redPercent, xCenter, yCenter, radius); drawRedDot(canvas, redPercent, xCenter, yCenter, radius); } if (mAnimate) { invalidate(); } } protected void drawRedDiamond( protected void drawRedDot( Canvas canvas, float degrees, int xCenter, int yCenter, float radius) { mPaint.setColor(mRedColor); float diamondPercent; float dotPercent; if (mTimerMode) { diamondPercent = 270 - degrees * 360; dotPercent = 270 - degrees * 360; } else { diamondPercent = 270 + degrees * 360; dotPercent = 270 + degrees * 360; } canvas.save(); final double diamondRadians = Math.toRadians(diamondPercent); canvas.translate(xCenter + (float) (radius * Math.cos(diamondRadians)), yCenter + (float) (radius * Math.sin(diamondRadians))); canvas.rotate(diamondPercent + 45f); canvas.drawRect(-mRectHalfWidth, -mRectHalfWidth, mRectHalfWidth, mRectHalfWidth, mFill); canvas.restore(); final double dotRadians = Math.toRadians(dotPercent); canvas.drawCircle(xCenter + (float) (radius * Math.cos(dotRadians)), yCenter + (float) (radius * Math.sin(dotRadians)), mDotRadius, mFill); } public static final String PREF_CTV_PAUSED = "_ctv_paused"; Loading src/com/android/deskclock/Utils.java +5 −17 Original line number Diff line number Diff line Loading @@ -38,11 +38,9 @@ import android.os.Handler; import android.os.SystemClock; import android.preference.PreferenceManager; import android.provider.Settings; import android.text.Spannable; import android.text.TextUtils; import android.text.format.DateFormat; import android.text.format.DateUtils; import android.text.style.ForegroundColorSpan; import android.view.MenuItem; import android.view.View; import android.view.animation.AccelerateInterpolator; Loading @@ -61,8 +59,6 @@ import java.util.TimeZone; public class Utils { private final static String TAG = Utils.class.getName(); private final static String PARAM_LANGUAGE_CODE = "hl"; /** Loading @@ -85,13 +81,6 @@ public class Utils { public static final String CLOCK_TYPE_DIGITAL = "digital"; public static final String CLOCK_TYPE_ANALOG = "analog"; /** * time format constants */ public final static String HOURS_24 = "kk"; public final static String HOURS = "h"; public final static String MINUTES = ":mm"; /** * Returns whether the SDK is the KeyLimePie release or later. */ Loading Loading @@ -125,7 +114,7 @@ public class Utils { /** * Adds two query parameters into the Uri, namely the language code and the version code * of the app's package as gotten via the context. * of the application's package as gotten via the context. * @return the uri with added query parameters */ private static Uri uriWithAddedParameters(Context context, Uri baseUri) { Loading Loading @@ -167,8 +156,8 @@ public class Utils { * of the extra painted objects. */ public static float calculateRadiusOffset( float strokeSize, float diamondStrokeSize, float markerStrokeSize) { return Math.max(strokeSize, Math.max(diamondStrokeSize, markerStrokeSize)); float strokeSize, float dotStrokeSize, float markerStrokeSize) { return Math.max(strokeSize, Math.max(dotStrokeSize, markerStrokeSize)); } /** Loading @@ -178,9 +167,9 @@ public class Utils { public static float calculateRadiusOffset(Resources resources) { if (resources != null) { float strokeSize = resources.getDimension(R.dimen.circletimer_circle_size); float diamondStrokeSize = resources.getDimension(R.dimen.circletimer_diamond_size); float dotStrokeSize = resources.getDimension(R.dimen.circletimer_dot_size); float markerStrokeSize = resources.getDimension(R.dimen.circletimer_marker_size); return calculateRadiusOffset(strokeSize, diamondStrokeSize, markerStrokeSize); return calculateRadiusOffset(strokeSize, dotStrokeSize, markerStrokeSize); } else { return 0f; } Loading Loading @@ -268,7 +257,6 @@ public class Utils { final float xrange = mContentView.getWidth() - mSaverView.getWidth(); final float yrange = mContentView.getHeight() - mSaverView.getHeight(); Log.v("xrange: "+xrange+" yrange: "+yrange); if (xrange == 0 && yrange == 0) { delay = 500; // back in a split second Loading Loading
res/values/dimens.xml +1 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ <dimen name="alarm_timeline_layout_padding_top">50dp</dimen> <dimen name="alarm_timeline_title_margin_bottom">10dp</dimen> <dimen name="alarm_timeline_title_text_size">24dp</dimen> <dimen name="circletimer_diamond_size">12dip</dimen> <dimen name="circletimer_dot_size">12dip</dimen> <dimen name="circletimer_circle_size">4dip</dimen> <dimen name="circletimer_marker_size">16dip</dimen> Loading
src/com/android/deskclock/CircleButtonsLayout.java +3 −4 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ public class CircleButtonsLayout extends FrameLayout { private FrameLayout mLabel; private TextView mLabelText; @SuppressWarnings("unused") public CircleButtonsLayout(Context context) { this(context, null); mContext = context; Loading @@ -52,13 +53,11 @@ public class CircleButtonsLayout extends FrameLayout { mLeftButtonPadding = mContext.getResources().getDimension(leftButtonPaddingDimenId); mRightButtonPadding = mContext.getResources().getDimension(rightButtonPaddingDimenId); float diamondStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_diamond_size); float dotStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_dot_size); float markerStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_marker_size); mStrokeSize = mContext.getResources().getDimension(R.dimen.circletimer_circle_size); mDiamOffset = Utils.calculateRadiusOffset(mStrokeSize, diamondStrokeSize, markerStrokeSize) * 2; mDiamOffset = Utils.calculateRadiusOffset(mStrokeSize, dotStrokeSize, markerStrokeSize) * 2; } @Override Loading
src/com/android/deskclock/CircleTimerView.java +26 −35 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package com.android.deskclock; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Paint; Loading @@ -13,7 +12,10 @@ import android.view.View; import com.android.deskclock.stopwatch.Stopwatches; /** * TODO: Insert description here. (generated by isaackatz) * Class to draw a circle for timers and stopwatches. * These two usages require two different animation modes: * Timer counts down. In this mode the animation is counter-clockwise and stops at 0. * Stopwatch counts up. In this mode the animation is clockwise and will run until stopped. */ public class CircleTimerView extends View { Loading @@ -27,24 +29,19 @@ public class CircleTimerView extends View { private long mAccumulatedTime = 0; private boolean mPaused = false; private boolean mAnimate = false; private static float mCircleXCenterLeftPadding = 0; private static float mStrokeSize = 4; private static float mDiamondStrokeSize = 12; private static float mDotRadius = 6; private static float mMarkerStrokeSize = 2; private final Paint mPaint = new Paint(); private final Paint mFill = new Paint(); private final RectF mArcRect = new RectF(); private float mRectHalfWidth = 6f; private Resources mResources; private float mRadiusOffset; // amount to remove from radius to account for markers on circle private float mScreenDensity; // Class has 2 modes: // Timer mode - counting down. in this mode the animation is counter-clockwise and stops at 0 // Stop watch mode - counting up - in this mode the animation is clockwise and will keep the // animation until stopped. private boolean mTimerMode = false; // default is stop watch view // Stopwatch mode is the default. private boolean mTimerMode = false; @SuppressWarnings("unused") public CircleTimerView(Context context) { this(context, null); } Loading Loading @@ -115,23 +112,21 @@ public class CircleTimerView extends View { private void init(Context c) { mResources = c.getResources(); mCircleXCenterLeftPadding = (mResources.getDimension(R.dimen.timer_circle_width) - mResources.getDimension(R.dimen.timer_circle_diameter)) / 2; mStrokeSize = mResources.getDimension(R.dimen.circletimer_circle_size); mDiamondStrokeSize = mResources.getDimension(R.dimen.circletimer_diamond_size); mMarkerStrokeSize = mResources.getDimension(R.dimen.circletimer_marker_size); Resources resources = c.getResources(); mStrokeSize = resources.getDimension(R.dimen.circletimer_circle_size); float dotDiameter = resources.getDimension(R.dimen.circletimer_dot_size); mMarkerStrokeSize = resources.getDimension(R.dimen.circletimer_marker_size); mRadiusOffset = Utils.calculateRadiusOffset( mStrokeSize, mDiamondStrokeSize, mMarkerStrokeSize); mStrokeSize, dotDiameter, mMarkerStrokeSize); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mWhiteColor = mResources.getColor(R.color.clock_white); mRedColor = mResources.getColor(R.color.clock_red); mScreenDensity = mResources.getDisplayMetrics().density; mWhiteColor = resources.getColor(R.color.clock_white); mRedColor = resources.getColor(R.color.clock_red); mScreenDensity = resources.getDisplayMetrics().density; mFill.setAntiAlias(true); mFill.setStyle(Paint.Style.FILL); mFill.setColor(mRedColor); mRectHalfWidth = mDiamondStrokeSize / 2f; mDotRadius = dotDiameter / 2f; } public void setTimerMode(boolean mode) { Loading @@ -151,7 +146,7 @@ public class CircleTimerView extends View { mPaint.setColor(mWhiteColor); canvas.drawCircle (xCenter, yCenter, radius, mPaint); if (mTimerMode) { drawRedDiamond(canvas, 0f, xCenter, yCenter, radius); drawRedDot(canvas, 0f, xCenter, yCenter, radius); } } else { if (mAnimate) { Loading Loading @@ -195,30 +190,26 @@ public class CircleTimerView extends View { canvas.drawArc (mArcRect, 270 + angle, mScreenDensity * (float) (360 / (radius * Math.PI)) , false, mPaint); } drawRedDiamond(canvas, redPercent, xCenter, yCenter, radius); drawRedDot(canvas, redPercent, xCenter, yCenter, radius); } if (mAnimate) { invalidate(); } } protected void drawRedDiamond( protected void drawRedDot( Canvas canvas, float degrees, int xCenter, int yCenter, float radius) { mPaint.setColor(mRedColor); float diamondPercent; float dotPercent; if (mTimerMode) { diamondPercent = 270 - degrees * 360; dotPercent = 270 - degrees * 360; } else { diamondPercent = 270 + degrees * 360; dotPercent = 270 + degrees * 360; } canvas.save(); final double diamondRadians = Math.toRadians(diamondPercent); canvas.translate(xCenter + (float) (radius * Math.cos(diamondRadians)), yCenter + (float) (radius * Math.sin(diamondRadians))); canvas.rotate(diamondPercent + 45f); canvas.drawRect(-mRectHalfWidth, -mRectHalfWidth, mRectHalfWidth, mRectHalfWidth, mFill); canvas.restore(); final double dotRadians = Math.toRadians(dotPercent); canvas.drawCircle(xCenter + (float) (radius * Math.cos(dotRadians)), yCenter + (float) (radius * Math.sin(dotRadians)), mDotRadius, mFill); } public static final String PREF_CTV_PAUSED = "_ctv_paused"; Loading
src/com/android/deskclock/Utils.java +5 −17 Original line number Diff line number Diff line Loading @@ -38,11 +38,9 @@ import android.os.Handler; import android.os.SystemClock; import android.preference.PreferenceManager; import android.provider.Settings; import android.text.Spannable; import android.text.TextUtils; import android.text.format.DateFormat; import android.text.format.DateUtils; import android.text.style.ForegroundColorSpan; import android.view.MenuItem; import android.view.View; import android.view.animation.AccelerateInterpolator; Loading @@ -61,8 +59,6 @@ import java.util.TimeZone; public class Utils { private final static String TAG = Utils.class.getName(); private final static String PARAM_LANGUAGE_CODE = "hl"; /** Loading @@ -85,13 +81,6 @@ public class Utils { public static final String CLOCK_TYPE_DIGITAL = "digital"; public static final String CLOCK_TYPE_ANALOG = "analog"; /** * time format constants */ public final static String HOURS_24 = "kk"; public final static String HOURS = "h"; public final static String MINUTES = ":mm"; /** * Returns whether the SDK is the KeyLimePie release or later. */ Loading Loading @@ -125,7 +114,7 @@ public class Utils { /** * Adds two query parameters into the Uri, namely the language code and the version code * of the app's package as gotten via the context. * of the application's package as gotten via the context. * @return the uri with added query parameters */ private static Uri uriWithAddedParameters(Context context, Uri baseUri) { Loading Loading @@ -167,8 +156,8 @@ public class Utils { * of the extra painted objects. */ public static float calculateRadiusOffset( float strokeSize, float diamondStrokeSize, float markerStrokeSize) { return Math.max(strokeSize, Math.max(diamondStrokeSize, markerStrokeSize)); float strokeSize, float dotStrokeSize, float markerStrokeSize) { return Math.max(strokeSize, Math.max(dotStrokeSize, markerStrokeSize)); } /** Loading @@ -178,9 +167,9 @@ public class Utils { public static float calculateRadiusOffset(Resources resources) { if (resources != null) { float strokeSize = resources.getDimension(R.dimen.circletimer_circle_size); float diamondStrokeSize = resources.getDimension(R.dimen.circletimer_diamond_size); float dotStrokeSize = resources.getDimension(R.dimen.circletimer_dot_size); float markerStrokeSize = resources.getDimension(R.dimen.circletimer_marker_size); return calculateRadiusOffset(strokeSize, diamondStrokeSize, markerStrokeSize); return calculateRadiusOffset(strokeSize, dotStrokeSize, markerStrokeSize); } else { return 0f; } Loading Loading @@ -268,7 +257,6 @@ public class Utils { final float xrange = mContentView.getWidth() - mSaverView.getWidth(); final float yrange = mContentView.getHeight() - mSaverView.getHeight(); Log.v("xrange: "+xrange+" yrange: "+yrange); if (xrange == 0 && yrange == 0) { delay = 500; // back in a split second Loading