diff --git a/HypoAlarm/src/main/AndroidManifest.xml b/HypoAlarm/src/main/AndroidManifest.xml index b406700..906e3b8 100644 --- a/HypoAlarm/src/main/AndroidManifest.xml +++ b/HypoAlarm/src/main/AndroidManifest.xml @@ -43,6 +43,8 @@ + + diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java index 8b151f3..2233fa8 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java @@ -1,13 +1,9 @@ package za.org.treehouse.hypoalarm; import android.app.Activity; -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; -import android.os.Handler; import android.util.Log; import android.view.View; import android.view.Window; @@ -16,6 +12,8 @@ import android.widget.Button; import com.triggertrap.seekarc.SeekArc; +import net.sebastianopoggi.ui.GlowPadBackport.GlowPadView; + // TODO See GlowPad. public class AlarmAlertActivity extends Activity { @@ -31,7 +29,7 @@ public class AlarmAlertActivity extends Activity { alertActivity = this; requestWindowFeature(Window.FEATURE_NO_TITLE); - Window window = getWindow(); + final Window window = getWindow(); // Set to use the full screen window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD @@ -40,11 +38,12 @@ public class AlarmAlertActivity extends Activity { | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | WindowManager.LayoutParams.FLAG_FULLSCREEN ); - if (Build.VERSION.SDK_INT >= 16) { + + if (Build.VERSION.SDK_INT >= 14) { window.getDecorView(). - setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_FULLSCREEN); + setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); } + setContentView(R.layout.alarm_alert); notifyIntent = new Intent(getApplicationContext(), AlarmNotify.class); @@ -56,8 +55,9 @@ public class AlarmAlertActivity extends Activity { @Override public void onStart() { super.onStart(); - /* - Button cancelButton = (Button) findViewById(R.id.cancel_dialog_button); + + /* CANCEL BUTTON + final Button cancelButton = (Button) findViewById(R.id.cancel_dialog_button); cancelButton.setOnClickListener (new View.OnClickListener() { @Override public void onClick(View view) { @@ -65,7 +65,8 @@ public class AlarmAlertActivity extends Activity { } }); */ - SeekArc cancelArc = (SeekArc) findViewById(R.id.cancel_dialog_seekArc); + /* CANCEL SEEKARC + final SeekArc cancelArc = (SeekArc) findViewById(R.id.cancel_dialog_seekArc); cancelArc.setOnSeekArcChangeListener(new SeekArc.OnSeekArcChangeListener() { volatile Boolean seekFinished = false; @Override @@ -82,7 +83,35 @@ public class AlarmAlertActivity extends Activity { public void onStopTrackingTouch(SeekArc seekArc) { } }); + */ + final GlowPadView cancelGlowPad = (GlowPadView) findViewById(R.id.cancel_glowpad); + cancelGlowPad.setOnTriggerListener(new GlowPadView.OnTriggerListener() { + @Override + public void onGrabbed(View v, int handle) { + // Do nothing + } + @Override + public void onReleased(View v, int handle) { + // Do nothing + } + + @Override + public void onTrigger(View v, int target) { + // if (target == "") + AlarmReceiver.dismissAlarm(alertActivity); + } + + @Override + public void onGrabbedStateChange(View v, int handle) { + // Do nothing + } + + @Override + public void onFinishFinalAnimation() { + // Do nothing + } + }); } /** diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java index b1232dc..659d918 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java @@ -55,8 +55,6 @@ public class AlarmNotify extends Service { .setAutoCancel(false) .setPriority(Notification.PRIORITY_HIGH); - -// TODO if alarm alert is snoozing and we cancel, cancel the snooze. // Set up dismiss action Intent cancellerIntent = new Intent(getBaseContext(), CancelGraceReceiver.class); PendingIntent cancellerPendingIntent = PendingIntent.getBroadcast(getBaseContext(), MainActivity.CANCEL_GRACE_REQUEST, cancellerIntent, PendingIntent.FLAG_CANCEL_CURRENT); @@ -86,10 +84,6 @@ public class AlarmNotify extends Service { public void run() { notificationRunning = true; int max = 1000; - /* TODO check that graceEndTime is always set. - if (AlarmReceiver.graceEndTime == 0) { - AlarmReceiver.graceEndTime = System.currentTimeMillis() + (gracePeriod * 60 * 1000); - }*/ // Count in milliseconds for greater progress resolution int milliSecondsLeft = (int) ((AlarmReceiver.graceEndTime - System.currentTimeMillis())); int gracePeriodMilliSeconds = gracePeriod * 60 * 1000; diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmReceiver.java index 97acdac..d3cf51d 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmReceiver.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmReceiver.java @@ -23,8 +23,8 @@ import java.util.Calendar; */ public class AlarmReceiver extends BroadcastReceiver { - private static final int SNOOZE_TIME = 1000*20; //1000*60*5; // Snooze for 5 minutes if need be - private static final int ALERT_LIFE = 1000*10; //1000*60*2; // 2 minutes + private static final int SNOOZE_TIME = 1000*20; //TODO 1000*60*5; // Snooze for 5 minutes if need be + private static final int ALERT_LIFE = 1000*60; //TODO 1000*60*2; // 2 minutes private static SharedPreferences sharedPref; private static AlarmManager alarmManager, graceManager; private static PendingIntent alarmPendingIntent, gracePendingIntent; diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/BootReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/BootReceiver.java index 0e983f2..67fbd14 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/BootReceiver.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/BootReceiver.java @@ -6,6 +6,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.preference.PreferenceManager; import android.util.Log; @@ -14,7 +15,7 @@ import java.util.Calendar; public class BootReceiver extends BroadcastReceiver { private static SharedPreferences sharedPref; private static AlarmManager alarmManager; - private static PendingIntent alarmIntent; + private static PendingIntent alarmPendingIntent; @Override public void onReceive(Context context, Intent intent) { @@ -22,13 +23,17 @@ public class BootReceiver extends BroadcastReceiver { if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { // Reset for tomorrow; as of API 19, setRepeating() is inexact, so we use setExact() String alarmTimeStr = sharedPref.getString(context.getString(R.string.AlarmTimePref), null); - if (alarmTimeStr != null) { + Boolean alarmActive = sharedPref.getBoolean(context.getString(R.string.AlarmActivePref), true); + if (alarmTimeStr != null && alarmActive) { // If it's later than alarmTimeStr, Calendar automatically advances the day. Calendar cal = MainActivity.TimeStringToCalendar(alarmTimeStr); alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); - // TODO use set() for older APIs - alarmManager.setExact(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmIntent); + alarmPendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); + if (Build.VERSION.SDK_INT >= 19) { + alarmManager.setExact(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmPendingIntent); + } else { + alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmPendingIntent); + } Log.d("BootReceiver", "Setting alarm for "+MainActivity.debugDate(cal)); } } diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/GraceReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/GraceReceiver.java index 4eaf358..76696b8 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/GraceReceiver.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/GraceReceiver.java @@ -17,6 +17,8 @@ public class GraceReceiver extends BroadcastReceiver { sharedPref = PreferenceManager.getDefaultSharedPreferences(context); Boolean alarmActive = sharedPref.getBoolean(context.getString(R.string.AlarmActivePref), true); + // TODO get location of phone and send in the message + if (alarmActive) { String phoneNumber = sharedPref.getString(context.getString(R.string.PhoneNumberPref), null); String message = sharedPref.getString(context.getString(R.string.MessagePref), null); diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java index 3bdeb58..2c25cea 100644 --- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java +++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java @@ -69,6 +69,8 @@ public class MainActivity extends ActionBarActivity { private static EditText phoneNumberButton; private static EditText messageButton; + public static Boolean HYPOALARM_DEBUG=true; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -143,10 +145,11 @@ public class MainActivity extends ActionBarActivity { String alarmTimeStr = verifyTimeString(sharedPref.getString(getString(R.string.AlarmTimePref), defaultTimeStr)); alarmTimeButton = (Button) getActivity().findViewById(R.id.alarm_time); - // TODO remove this testing stuff - Calendar c = Calendar.getInstance(); - c.add(Calendar.MINUTE, 1); - alarmTimeStr = CalendarToTimeString(c); + if (HYPOALARM_DEBUG) { + Calendar c = Calendar.getInstance(); + c.add(Calendar.MINUTE, 1); + alarmTimeStr = CalendarToTimeString(c); + } alarmTimeButton.setText(alarmTimeStr); alarmTimeButton.setOnClickListener(new View.OnClickListener() { @@ -157,11 +160,11 @@ public class MainActivity extends ActionBarActivity { } }); - // TODO remove these simulated clicks - DialogFragment alarmFragment = new TimePickerFragment(); - alarmFragment.show(getActivity().getSupportFragmentManager(), "alarmTimePicker"); - alarmFragment.dismiss(); - + if (HYPOALARM_DEBUG) { + DialogFragment alarmFragment = new TimePickerFragment(); + alarmFragment.show(getActivity().getSupportFragmentManager(), "alarmTimePicker"); + alarmFragment.dismiss(); + } // Set grace period int defaultGrace = 60; diff --git a/HypoAlarm/src/main/res/drawable-hdpi/ic_alarm_activated.png b/HypoAlarm/src/main/res/drawable-hdpi/ic_alarm_activated.png new file mode 100644 index 0000000..642d78a Binary files /dev/null and b/HypoAlarm/src/main/res/drawable-hdpi/ic_alarm_activated.png differ diff --git a/HypoAlarm/src/main/res/drawable-hdpi/ic_alarm_normal.png b/HypoAlarm/src/main/res/drawable-hdpi/ic_alarm_normal.png new file mode 100644 index 0000000..225a7b5 Binary files /dev/null and b/HypoAlarm/src/main/res/drawable-hdpi/ic_alarm_normal.png differ diff --git a/HypoAlarm/src/main/res/drawable-hdpi/ic_lockscreen_glowdot.png b/HypoAlarm/src/main/res/drawable-hdpi/ic_glowdot.png similarity index 100% rename from HypoAlarm/src/main/res/drawable-hdpi/ic_lockscreen_glowdot.png rename to HypoAlarm/src/main/res/drawable-hdpi/ic_glowdot.png diff --git a/HypoAlarm/src/main/res/drawable-hdpi/ic_lockscreen_handle_pressed.png b/HypoAlarm/src/main/res/drawable-hdpi/ic_handle_pressed.png similarity index 100% rename from HypoAlarm/src/main/res/drawable-hdpi/ic_lockscreen_handle_pressed.png rename to HypoAlarm/src/main/res/drawable-hdpi/ic_handle_pressed.png diff --git a/HypoAlarm/src/main/res/drawable-hdpi/ic_launcher.png b/HypoAlarm/src/main/res/drawable-hdpi/ic_launcher.png index 1d371ad..e6cb05d 100644 Binary files a/HypoAlarm/src/main/res/drawable-hdpi/ic_launcher.png and b/HypoAlarm/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/HypoAlarm/src/main/res/drawable-hdpi/ic_launcher_grey.png b/HypoAlarm/src/main/res/drawable-hdpi/ic_launcher_grey.png index d8cfd2c..73165cc 100644 Binary files a/HypoAlarm/src/main/res/drawable-hdpi/ic_launcher_grey.png and b/HypoAlarm/src/main/res/drawable-hdpi/ic_launcher_grey.png differ diff --git a/HypoAlarm/src/main/res/drawable-mdpi/ic_alarm_activated.png b/HypoAlarm/src/main/res/drawable-mdpi/ic_alarm_activated.png new file mode 100644 index 0000000..280da1a Binary files /dev/null and b/HypoAlarm/src/main/res/drawable-mdpi/ic_alarm_activated.png differ diff --git a/HypoAlarm/src/main/res/drawable-mdpi/ic_alarm_normal.png b/HypoAlarm/src/main/res/drawable-mdpi/ic_alarm_normal.png new file mode 100644 index 0000000..41d6162 Binary files /dev/null and b/HypoAlarm/src/main/res/drawable-mdpi/ic_alarm_normal.png differ diff --git a/HypoAlarm/src/main/res/drawable-mdpi/ic_lockscreen_glowdot.png b/HypoAlarm/src/main/res/drawable-mdpi/ic_glowdot.png similarity index 100% rename from HypoAlarm/src/main/res/drawable-mdpi/ic_lockscreen_glowdot.png rename to HypoAlarm/src/main/res/drawable-mdpi/ic_glowdot.png diff --git a/HypoAlarm/src/main/res/drawable-mdpi/ic_lockscreen_handle_pressed.png b/HypoAlarm/src/main/res/drawable-mdpi/ic_handle_pressed.png similarity index 100% rename from HypoAlarm/src/main/res/drawable-mdpi/ic_lockscreen_handle_pressed.png rename to HypoAlarm/src/main/res/drawable-mdpi/ic_handle_pressed.png diff --git a/HypoAlarm/src/main/res/drawable-mdpi/ic_launcher.png b/HypoAlarm/src/main/res/drawable-mdpi/ic_launcher.png index 178ed19..975b85b 100644 Binary files a/HypoAlarm/src/main/res/drawable-mdpi/ic_launcher.png and b/HypoAlarm/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/HypoAlarm/src/main/res/drawable-mdpi/ic_launcher_grey.png b/HypoAlarm/src/main/res/drawable-mdpi/ic_launcher_grey.png index e211fba..8ef4655 100644 Binary files a/HypoAlarm/src/main/res/drawable-mdpi/ic_launcher_grey.png and b/HypoAlarm/src/main/res/drawable-mdpi/ic_launcher_grey.png differ diff --git a/HypoAlarm/src/main/res/drawable-xhdpi/ic_alarm_activated.png b/HypoAlarm/src/main/res/drawable-xhdpi/ic_alarm_activated.png new file mode 100644 index 0000000..df2797c Binary files /dev/null and b/HypoAlarm/src/main/res/drawable-xhdpi/ic_alarm_activated.png differ diff --git a/HypoAlarm/src/main/res/drawable-xhdpi/ic_alarm_normal.png b/HypoAlarm/src/main/res/drawable-xhdpi/ic_alarm_normal.png new file mode 100644 index 0000000..2792749 Binary files /dev/null and b/HypoAlarm/src/main/res/drawable-xhdpi/ic_alarm_normal.png differ diff --git a/HypoAlarm/src/main/res/drawable-xhdpi/ic_lockscreen_glowdot.png b/HypoAlarm/src/main/res/drawable-xhdpi/ic_glowdot.png similarity index 100% rename from HypoAlarm/src/main/res/drawable-xhdpi/ic_lockscreen_glowdot.png rename to HypoAlarm/src/main/res/drawable-xhdpi/ic_glowdot.png diff --git a/HypoAlarm/src/main/res/drawable-xhdpi/ic_lockscreen_handle_pressed.png b/HypoAlarm/src/main/res/drawable-xhdpi/ic_handle_pressed.png similarity index 100% rename from HypoAlarm/src/main/res/drawable-xhdpi/ic_lockscreen_handle_pressed.png rename to HypoAlarm/src/main/res/drawable-xhdpi/ic_handle_pressed.png diff --git a/HypoAlarm/src/main/res/drawable-xhdpi/ic_launcher.png b/HypoAlarm/src/main/res/drawable-xhdpi/ic_launcher.png index fb1f16f..bfd7e20 100644 Binary files a/HypoAlarm/src/main/res/drawable-xhdpi/ic_launcher.png and b/HypoAlarm/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/HypoAlarm/src/main/res/drawable-xhdpi/ic_launcher_grey.png b/HypoAlarm/src/main/res/drawable-xhdpi/ic_launcher_grey.png index 803f36a..11fa706 100644 Binary files a/HypoAlarm/src/main/res/drawable-xhdpi/ic_launcher_grey.png and b/HypoAlarm/src/main/res/drawable-xhdpi/ic_launcher_grey.png differ diff --git a/HypoAlarm/src/main/res/drawable-xxhdpi/ic_alarm_activated.png b/HypoAlarm/src/main/res/drawable-xxhdpi/ic_alarm_activated.png new file mode 100644 index 0000000..ce2f480 Binary files /dev/null and b/HypoAlarm/src/main/res/drawable-xxhdpi/ic_alarm_activated.png differ diff --git a/HypoAlarm/src/main/res/drawable-xxhdpi/ic_alarm_normal.png b/HypoAlarm/src/main/res/drawable-xxhdpi/ic_alarm_normal.png new file mode 100644 index 0000000..347f35f Binary files /dev/null and b/HypoAlarm/src/main/res/drawable-xxhdpi/ic_alarm_normal.png differ diff --git a/HypoAlarm/src/main/res/drawable-xxhdpi/ic_launcher.png b/HypoAlarm/src/main/res/drawable-xxhdpi/ic_launcher.png index 592272f..e04a5f2 100644 Binary files a/HypoAlarm/src/main/res/drawable-xxhdpi/ic_launcher.png and b/HypoAlarm/src/main/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/HypoAlarm/src/main/res/drawable-xxhdpi/ic_launcher_grey.png b/HypoAlarm/src/main/res/drawable-xxhdpi/ic_launcher_grey.png index 12a2c1b..add77dc 100644 Binary files a/HypoAlarm/src/main/res/drawable-xxhdpi/ic_launcher_grey.png and b/HypoAlarm/src/main/res/drawable-xxhdpi/ic_launcher_grey.png differ diff --git a/HypoAlarm/src/main/res/drawable/ic_alarm.xml b/HypoAlarm/src/main/res/drawable/ic_alarm.xml new file mode 100644 index 0000000..da4a64e --- /dev/null +++ b/HypoAlarm/src/main/res/drawable/ic_alarm.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/HypoAlarm/src/main/res/drawable/ic_alarm_activated_layer.xml b/HypoAlarm/src/main/res/drawable/ic_alarm_activated_layer.xml new file mode 100644 index 0000000..5a02271 --- /dev/null +++ b/HypoAlarm/src/main/res/drawable/ic_alarm_activated_layer.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + diff --git a/HypoAlarm/src/main/res/drawable/ic_alarm_normal_layer.xml b/HypoAlarm/src/main/res/drawable/ic_alarm_normal_layer.xml new file mode 100644 index 0000000..4b12d9f --- /dev/null +++ b/HypoAlarm/src/main/res/drawable/ic_alarm_normal_layer.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/HypoAlarm/src/main/res/drawable/ic_outerring.xml b/HypoAlarm/src/main/res/drawable/ic_outerring.xml new file mode 100644 index 0000000..fd4ef09 --- /dev/null +++ b/HypoAlarm/src/main/res/drawable/ic_outerring.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/HypoAlarm/src/main/res/layout/alarm_alert.xml b/HypoAlarm/src/main/res/layout/alarm_alert.xml index 133f197..2d9b517 100644 --- a/HypoAlarm/src/main/res/layout/alarm_alert.xml +++ b/HypoAlarm/src/main/res/layout/alarm_alert.xml @@ -1,95 +1,100 @@ - + + + - + -