diff --git a/src/main/java/trikita/talalarmo/alarm/AlarmActivity.java b/src/main/java/trikita/talalarmo/alarm/AlarmActivity.java
index 820775a..4248016 100644
--- a/src/main/java/trikita/talalarmo/alarm/AlarmActivity.java
+++ b/src/main/java/trikita/talalarmo/alarm/AlarmActivity.java
@@ -1,24 +1,34 @@
package trikita.talalarmo.alarm;
+import android.animation.Animator;
+import android.animation.ArgbEvaluator;
+import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
+import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
import trikita.anvil.RenderableView;
+import trikita.anvil.Anvil;
import static trikita.anvil.DSL.*;
import trikita.jedux.Action;
import trikita.talalarmo.Actions;
import trikita.talalarmo.App;
+import trikita.talalarmo.R;
import trikita.talalarmo.ui.Theme;
public class AlarmActivity extends Activity {
private PowerManager.WakeLock mWakeLock;
+ private ValueAnimator mAnimator;
+ private int bgColor;
+ private int txt;
+ private boolean canceled;
@Override
protected void onCreate(Bundle b) {
@@ -37,15 +47,60 @@ protected void onCreate(Bundle b) {
window.setStatusBarColor(Theme.get(App.getState().settings().theme()).primaryDarkColor);
}
+ txt = R.string.alarm_off;
+ int colorFrom = Theme.get(App.getState().settings().theme()).backgroundColor;
+ int colorTo = Theme.get(App.getState().settings().theme()).accentColor;
+ bgColor = colorFrom;
+ mAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
+ mAnimator.setDuration(2000); // millis
+ mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animator) {
+ bgColor = (int) animator.getAnimatedValue();
+ Anvil.render();
+ }
+ });
+ mAnimator.addListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animator) {
+ canceled = false;
+ }
+ @Override
+ public void onAnimationCancel(Animator animator) {
+ canceled = true;
+ txt = R.string.hold_dismiss_prompt;
+ bgColor = colorFrom;
+ Anvil.render();
+ }
+ @Override
+ public void onAnimationEnd(Animator animator) {
+ if (!canceled) {
+ stopAlarm();
+ }
+ }
+ @Override
+ public void onAnimationRepeat(Animator animator) {}
+ });
+
setContentView(new RenderableView(this) {
public void view() {
Theme.materialIcon(() -> {
size(FILL, FILL);
- text("\ue857"); // "alarm off"
+ text(txt); // "alarm off"
textColor(Theme.get(App.getState().settings().theme()).accentColor);
textSize(dip(128));
- backgroundColor(Theme.get(App.getState().settings().theme()).backgroundColor);
- onClick(v -> stopAlarm());
+ backgroundColor(bgColor);
+ onTouch((v, e) -> {
+ if(e.getAction() == MotionEvent.ACTION_DOWN){
+ mAnimator.start();
+ return true;
+ }
+ if(e.getAction() == MotionEvent.ACTION_UP){
+ mAnimator.cancel();
+ return true;
+ }
+ return false;
+ });
});
}
});
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 789ddf4..cf0e6c0 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -9,6 +9,8 @@
Vibrate
Fade-in sound
Tap here\nto set alarm
+ HOLD
+ "\ue857"
1 hour
%s hours