summaryrefslogtreecommitdiff
path: root/src/com/android/deskclock/timer/TimerCircleView.java
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2022-02-23 18:26:53 +0100
committerMichael W <baddaemon87@gmail.com>2022-04-18 10:02:59 +0200
commit23d7064d1abf2feb41d3d1a1812038a26e836181 (patch)
treefbaa16cf9a6a2cdb6948c111185b6073d12287e9 /src/com/android/deskclock/timer/TimerCircleView.java
parenta997c68c843843e79bf79fed3eee7728ebf1e643 (diff)
DeskClock: Material Me? No YOU!
* Since Android 12 introduced a new style, try to mimic it for this app * Due to AndroidX and the support libraries still being old, we have to, like Settings does with SettingsLib, create our own styles in the desired looks * Also adjust the color scheme to reflect Material You * We deviated from AOSP already quite a bit, so we don't need to really care about the change's footprint * Clean up behind us by removing (now unused) resources and includes in files that were modified anyways (and adjust order while on it) * Copy CollapsibleToolbarBaseActivity and required resources from SettingsLib - that way we can mimic the style easily without having to move this app to system_ext or using privileged_api * Since we always use dark layout, modify slightly so it works for us * Remove things we don't need so we don't have to copy too many files from SettingsLib Change-Id: I4c81e03c71f468a9e468426a8233ad96059cb05d
Diffstat (limited to 'src/com/android/deskclock/timer/TimerCircleView.java')
-rw-r--r--src/com/android/deskclock/timer/TimerCircleView.java20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/com/android/deskclock/timer/TimerCircleView.java b/src/com/android/deskclock/timer/TimerCircleView.java
index f605f9186..ce181ddb9 100644
--- a/src/com/android/deskclock/timer/TimerCircleView.java
+++ b/src/com/android/deskclock/timer/TimerCircleView.java
@@ -38,9 +38,6 @@ public final class TimerCircleView extends View {
/** The size of the dot indicating the progress through the timer. */
private final float mDotRadius;
- /** An amount to subtract from the true radius to account for drawing thicknesses. */
- private final float mRadiusOffset;
-
/** The color indicating the remaining portion of the timer. */
private final int mRemainderColor;
@@ -65,20 +62,17 @@ public final class TimerCircleView extends View {
super(context, attrs);
final Resources resources = context.getResources();
- final float dotDiameter = resources.getDimension(R.dimen.circletimer_dot_size);
-
- mDotRadius = dotDiameter / 2f;
mStrokeSize = resources.getDimension(R.dimen.circletimer_circle_size);
- mRadiusOffset = Utils.calculateRadiusOffset(mStrokeSize, dotDiameter, 0);
+ mDotRadius = mStrokeSize / 2;
- mRemainderColor = Color.WHITE;
- mCompletedColor = ThemeUtils.resolveColor(context, R.attr.colorAccent);
+ mRemainderColor = ThemeUtils.resolveColor(context, R.attr.colorAccent);
+ mCompletedColor = resources.getColor(R.color.secondary_color, context.getTheme());
mPaint.setAntiAlias(true);
mPaint.setStyle(Paint.Style.STROKE);
mFill.setAntiAlias(true);
- mFill.setColor(mCompletedColor);
+ mFill.setColor(mRemainderColor);
mFill.setStyle(Paint.Style.FILL);
}
@@ -98,7 +92,7 @@ public final class TimerCircleView extends View {
// Compute the size and location of the circle to be drawn.
final int xCenter = getWidth() / 2;
final int yCenter = getHeight() / 2;
- final float radius = Math.min(xCenter, yCenter) - mRadiusOffset;
+ final float radius = Math.min(xCenter, yCenter) - mStrokeSize;
// Reset old painting state.
mPaint.setColor(mRemainderColor);
@@ -115,7 +109,7 @@ public final class TimerCircleView extends View {
} else if (mTimer.isExpired()) {
mPaint.setColor(mCompletedColor);
- // Draw a complete white circle; no red arc required.
+ // Draw a complete circle; no arc required.
canvas.drawCircle(xCenter, yCenter, radius, mPaint);
// Red percent is 1 since the timer has expired.
@@ -137,7 +131,7 @@ public final class TimerCircleView extends View {
canvas.drawArc(mArcRect, 270, -redPercent * 360 , false, mPaint);
}
- // Draw a red dot to indicate current progress through the timer.
+ // Draw a dot to indicate current progress through the timer.
final float dotAngleDegrees = 270 - redPercent * 360;
final double dotAngleRadians = Math.toRadians(dotAngleDegrees);
final float dotX = xCenter + (float) (radius * Math.cos(dotAngleRadians));