diff --git a/GlowPadBackport/GlowPadBackport.iml b/GlowPadBackport/GlowPadBackport.iml
index c9680be..b6f321c 100644
--- a/GlowPadBackport/GlowPadBackport.iml
+++ b/GlowPadBackport/GlowPadBackport.iml
@@ -11,7 +11,10 @@
-
+
+
+
+
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 9d1ce67..4a9d4fb 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmAlertActivity.java
@@ -9,7 +9,6 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
-//import com.triggertrap.seekarc.SeekArc;
import net.frakbot.glowpadbackport.GlowPadView;
import java.util.Random;
@@ -53,25 +52,6 @@ public class AlarmAlertActivity extends Activity {
public void onStart() {
super.onStart();
- /* CANCEL SEEKARC
- final SeekArc cancelArc = (SeekArc) findViewById(R.id.cancel_dialog_seekArc);
- cancelArc.setOnSeekArcChangeListener(new SeekArc.OnSeekArcChangeListener() {
- volatile Boolean seekFinished = false;
- @Override
- public void onProgressChanged(SeekArc seekArc, int progress, boolean fromUser) {
- if (progress > 98 && !seekFinished && fromUser) {
- AlarmService.dismissAlarm(alertActivity);
- seekFinished = true;
- }
- }
- @Override
- public void onStartTrackingTouch(SeekArc seekArc) {
- }
- @Override
- public void onStopTrackingTouch(SeekArc seekArc) {
- }
- });
- */
final GlowPadView cancelGlowPad = (GlowPadView) findViewById(R.id.cancel_glowpad);
cancelGlowPad.setOnTriggerListener(new GlowPadView.OnTriggerListener() {
@Override
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 5c06540..d74f34e 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java
@@ -12,6 +12,7 @@ import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
+import android.support.v4.app.NotificationCompat;
import android.util.Log;
public class AlarmNotify extends Service {
@@ -45,71 +46,70 @@ public class AlarmNotify extends Service {
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_grey);
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- if (Build.VERSION.SDK_INT >= 11) {
- final Notification.Builder notification = new Notification.Builder(this)
- .setContentTitle(getString(R.string.app_name))
- .setContentText(String.format(getString(R.string.notificationText), MainActivity.MinutesToGracePeriodStr(gracePeriod)))
- .setSmallIcon(R.drawable.alarm_notification)
- .setLargeIcon(bm)
- .setOnlyAlertOnce(true)
- .setAutoCancel(false)
- .setPriority(Notification.PRIORITY_HIGH);
+ final NotificationCompat.Builder notification = new NotificationCompat.Builder(this)
+ .setContentTitle(getString(R.string.app_name))
+ .setContentText(String.format(getString(R.string.notificationText), MainActivity.MinutesToGracePeriodStr(gracePeriod)))
+ .setSmallIcon(R.drawable.alarm_notification)
+ .setLargeIcon(bm)
+ .setOnlyAlertOnce(true)
+ .setAutoCancel(false)
+ .setPriority(Notification.PRIORITY_HIGH);
- // 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);
+ // 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);
- // Cancel the grace period if the user clears the notification
- notification.setDeleteIntent(cancellerPendingIntent);
- // Allow the user to cancel by clicking a "Cancel" button
- notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.notificationCancellation), cancellerPendingIntent);
- // Allow the user to cancel by selecting the ContentText or ContentTitle
- notification.setContentIntent(cancellerPendingIntent);
+ // Cancel the grace period if the user clears the notification
+ notification.setDeleteIntent(cancellerPendingIntent);
+ // Allow the user to cancel by clicking a "Cancel" button
+ notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.notificationCancellation), cancellerPendingIntent);
+ // Allow the user to cancel by selecting the ContentText or ContentTitle
+ notification.setContentIntent(cancellerPendingIntent);
- nm.cancel(notifyID);
- nm.notify(notifyID, notification.build());
+ nm.cancel(notifyID);
+ nm.notify(notifyID, notification.build());
- new Thread(new Runnable() {
- @Override
- public void run() {
- notificationRunning = true;
- int max = 1000;
- // Count in milliseconds for greater progress resolution
- int milliSecondsLeft = (int) ((AlarmService.graceEndTime - System.currentTimeMillis()));
- int gracePeriodMilliSeconds = gracePeriod * 60 * 1000;
- int progress = ((gracePeriodMilliSeconds - milliSecondsLeft) * max) / gracePeriodMilliSeconds;
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ notificationRunning = true;
+ int max = 1000;
+ // Count in milliseconds for greater progress resolution
+ int milliSecondsLeft = (int) ((AlarmService.graceEndTime - System.currentTimeMillis()));
+ int gracePeriodMilliSeconds = gracePeriod * 60 * 1000;
+ int progress = ((gracePeriodMilliSeconds - milliSecondsLeft) * max) / gracePeriodMilliSeconds;
- while (progress < max) {
- // Stop the thread if the notification is cancelled elsewhere
- if (!notificationRunning) {
- return;
- }
- int minutesLeft = (milliSecondsLeft / 1000) / 60;
- if (Build.VERSION.SDK_INT >= 11) {
- notification.setContentText(String.format(getString(R.string.notificationText), MainActivity.MinutesToGracePeriodStr(minutesLeft)));
- notification.setProgress(max, progress, false);
- // Update the notification
- nm.notify(notifyID, notification.build());
- }
- // Prepare secondsLeft and progress for the next loop
- milliSecondsLeft = milliSecondsLeft - UPDATE_INTERVAL;
- // Multiply each int by 1000 for greater progress resolution
- progress = ((gracePeriodMilliSeconds - milliSecondsLeft) * max) / gracePeriodMilliSeconds;
- //Log.d("AlarmNotify", "milliSecondsLeft is " + milliSecondsLeft + " and progress is " + progress + " (gracePeriodMilliSeconds is " + gracePeriodMilliSeconds + ")");
- //Log.d("AlarmNotify", "progress is " + progress + "; max is " + max);
-
- // Sleep until we need to update again
- try {
- Thread.sleep(UPDATE_INTERVAL);
- } catch (InterruptedException e) {
- Log.d("AlarmNotify", "sleep failure: " + e.toString());
- }
+ while (progress < max) {
+ // Stop the thread if the notification is cancelled elsewhere
+ if (!notificationRunning) {
+ return;
+ }
+ int minutesLeft = (milliSecondsLeft / 1000) / 60;
+ if (Build.VERSION.SDK_INT >= 11) {
+ notification.setContentText(String.format(getString(R.string.notificationText), MainActivity.MinutesToGracePeriodStr(minutesLeft)));
+ notification.setProgress(max, progress, false);
+ // Update the notification
+ nm.notify(notifyID, notification.build());
+ }
+ // Prepare secondsLeft and progress for the next loop
+ milliSecondsLeft = milliSecondsLeft - UPDATE_INTERVAL;
+ // Multiply each int by 1000 for greater progress resolution
+ progress = ((gracePeriodMilliSeconds - milliSecondsLeft) * max) / gracePeriodMilliSeconds;
+ //Log.d("AlarmNotify", "milliSecondsLeft is " + milliSecondsLeft + " and progress is " + progress + " (gracePeriodMilliSeconds is " + gracePeriodMilliSeconds + ")");
+ //Log.d("AlarmNotify", "progress is " + progress + "; max is " + max);
+
+ // Sleep until we need to update again
+ try {
+ Thread.sleep(UPDATE_INTERVAL);
+ } catch (InterruptedException e) {
+ Log.d("AlarmNotify", "sleep failure: " + e.toString());
}
- stopSelf(); // stop notification service
}
- }).start();
- }
- return super.onStartCommand(intent, flags, startId);
+ stopSelf(); // stop notification service
+ }
+ }).start();
+
+ return super.onStartCommand(intent, flags, startId);
}
}
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java
index 9f9ec0a..7205a07 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmService.java
@@ -16,8 +16,8 @@ import android.util.Log;
import java.util.Calendar;
public class AlarmService extends Service {
- private static final int SNOOZE_TIME = 1000*60;//60*5; // Snooze for 5 minutes if need be
- private static final int ALERT_LIFE = 1000*10;//60*2; // 2 minutes
+ private static final int SNOOZE_TIME = 1000*60*5; // Snooze for 5 minutes if need be
+ private static final int ALERT_LIFE = 1000*60*1; // 2 minutes
private static AlarmManager alarmManager;
private static Intent alarmServiceIntent, alertActivityIntent, notifyIntent;
public static Boolean alarmStarted = false;
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 43094fb..54d83f5 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/GraceReceiver.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/GraceReceiver.java
@@ -77,7 +77,6 @@ public class GraceReceiver extends BroadcastReceiver {
}
private void sendText(Context context) {
SmsManager sms = SmsManager.getDefault();
- // TODO uncomment sendTextMessage
if (!MainActivity.HYPOALARM_DEBUG) {
sms.sendTextMessage(phoneNumber, null, message, null, 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 e79112c..78a62a5 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java
@@ -32,12 +32,14 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
+import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TimePicker;
import android.widget.Toast;
+import android.widget.ToggleButton;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -69,7 +71,7 @@ public class MainActivity extends ActionBarActivity {
private static Button alarmTimeButton;
private static EditText messageButton;
- public static Boolean HYPOALARM_DEBUG = true;
+ public static Boolean HYPOALARM_DEBUG = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -92,7 +94,6 @@ public class MainActivity extends ActionBarActivity {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
-
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
@@ -104,7 +105,7 @@ public class MainActivity extends ActionBarActivity {
// Allow alarm to activate
Boolean alarmActive = sharedPref.getBoolean(getString(R.string.AlarmActivePref), true);
- Switch alarmActiveSwitch = (Switch) getActivity().findViewById(R.id.alarm_active_switch);
+ CompoundButton alarmActiveSwitch = (CompoundButton) getActivity().findViewById(R.id.alarm_active_switch);
alarmActiveSwitch.setChecked(alarmActive);
alarmActiveSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@@ -145,6 +146,7 @@ public class MainActivity extends ActionBarActivity {
}
});
+
// Set alarm time
String defaultTimeStr = "09:00";
String alarmTimeStr = verifyTimeString(sharedPref.getString(getString(R.string.AlarmTimePref), defaultTimeStr));
@@ -512,18 +514,13 @@ public class MainActivity extends ActionBarActivity {
}
public static String formattedTime(Context context, Calendar cal) {
- String pattern;
- if (Build.VERSION.SDK_INT >= 18) {
- String skeleton = DateFormat.is24HourFormat(context) ? "EHm" : "Ehma";
- pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
+ SimpleDateFormat print;
+ if (DateFormat.is24HourFormat(context)) {
+ print = new SimpleDateFormat("E HH:mm");
} else {
- pattern = "EHm";
+ print = new SimpleDateFormat("E hh:mm a");
}
- return (String) DateFormat.format(pattern, cal);
- }
- public static String debugDate(Calendar cal) {
- SimpleDateFormat print = new SimpleDateFormat("dd-MM-yyyy HH:mm:ssZ");
- return print.format(cal.getTime());
+ return (String) print.format(cal.getTime());
}
public static int GracePeriodToMinutes(String gracePeriod) {
@@ -569,6 +566,11 @@ public class MainActivity extends ActionBarActivity {
return remMinutes + minStr;
}
+ public static String debugDate(Calendar cal) {
+ SimpleDateFormat print = new SimpleDateFormat("dd-MM-yyyy HH:mm:ssZ");
+ return print.format(cal.getTime());
+ }
+
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmNotify.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmNotify.java
index 076438b..8a8152e 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmNotify.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/PreAlarmNotify.java
@@ -12,6 +12,7 @@ import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
+import android.support.v4.app.NotificationCompat;
import android.text.format.DateFormat;
import android.util.Log;
@@ -47,30 +48,29 @@ public class PreAlarmNotify extends Service {
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_grey);
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- if (Build.VERSION.SDK_INT >= 11) {
- final Notification.Builder notification = new Notification.Builder(this)
- .setContentTitle(getString(R.string.preNotificationTitle))
- .setContentText(alarmTimeStr)
- .setSmallIcon(R.drawable.alarm_notification)
- .setLargeIcon(bm)
- .setOnlyAlertOnce(true)
- .setAutoCancel(false)
- .setPriority(Notification.PRIORITY_HIGH);
+ final NotificationCompat.Builder notification = new NotificationCompat.Builder(this)
+ .setContentTitle(getString(R.string.preNotificationTitle))
+ .setContentText(alarmTimeStr)
+ .setSmallIcon(R.drawable.alarm_notification)
+ .setLargeIcon(bm)
+ .setOnlyAlertOnce(true)
+ .setAutoCancel(false)
+ .setPriority(Notification.PRIORITY_HIGH);
- // Set up dismiss action
- Intent cancelAlarmIntent = new Intent(getBaseContext(), CancelAlarmReceiver.class);
- PendingIntent cancelAlarmPendingIntent = PendingIntent.getBroadcast(getBaseContext(), MainActivity.CANCEL_ALARM_REQUEST, cancelAlarmIntent, PendingIntent.FLAG_CANCEL_CURRENT);
+ // Set up dismiss action
+ Intent cancelAlarmIntent = new Intent(getBaseContext(), CancelAlarmReceiver.class);
+ PendingIntent cancelAlarmPendingIntent = PendingIntent.getBroadcast(getBaseContext(), MainActivity.CANCEL_ALARM_REQUEST, cancelAlarmIntent, PendingIntent.FLAG_CANCEL_CURRENT);
- // Cancel the grace period if the user clears the notification
- notification.setDeleteIntent(cancelAlarmPendingIntent);
- // Allow the user to cancel by clicking a "Cancel" button
- notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.preNotificationCancellation), cancelAlarmPendingIntent);
- // Allow the user to cancel by selecting the ContentText or ContentTitle
- notification.setContentIntent(cancelAlarmPendingIntent);
+ // Cancel the grace period if the user clears the notification
+ notification.setDeleteIntent(cancelAlarmPendingIntent);
+ // Allow the user to cancel by clicking a "Cancel" button
+ notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.preNotificationCancellation), cancelAlarmPendingIntent);
+ // Allow the user to cancel by selecting the ContentText or ContentTitle
+ notification.setContentIntent(cancelAlarmPendingIntent);
+
+ nm.cancel(this.preNotifyID);
+ nm.notify(this.preNotifyID, notification.build());
- nm.cancel(this.preNotifyID);
- nm.notify(this.preNotifyID, notification.build());
- }
return super.onStartCommand(intent, flags, startId);
}
}
diff --git a/HypoAlarm/src/main/res/layout-v14/activeswitch.xml b/HypoAlarm/src/main/res/layout-v14/activeswitch.xml
new file mode 100644
index 0000000..2fc1e8c
--- /dev/null
+++ b/HypoAlarm/src/main/res/layout-v14/activeswitch.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/HypoAlarm/src/main/res/layout/activeswitch.xml b/HypoAlarm/src/main/res/layout/activeswitch.xml
new file mode 100644
index 0000000..2324226
--- /dev/null
+++ b/HypoAlarm/src/main/res/layout/activeswitch.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/HypoAlarm/src/main/res/layout/alarm_alert.xml b/HypoAlarm/src/main/res/layout/alarm_alert.xml
index f65ea67..b197695 100644
--- a/HypoAlarm/src/main/res/layout/alarm_alert.xml
+++ b/HypoAlarm/src/main/res/layout/alarm_alert.xml
@@ -6,68 +6,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AlarmNotificationActivity">
-
-
-
+ android:layout_marginTop="@dimen/alarm_widget_vertical_margin" />
-
-
+ android:fillViewport="true" >
-
+ android:layout_height="fill_parent"
+ android:stretchColumns="0"
+ android:shrinkColumns="1"
+ android:dividerPadding="10dp"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin">
-
-
+
-
+
+
-
+
-
-
+
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HypoAlarm/src/main/res/values-small/dimens.xml b/HypoAlarm/src/main/res/values-small/dimens.xml
new file mode 100644
index 0000000..af94e7f
--- /dev/null
+++ b/HypoAlarm/src/main/res/values-small/dimens.xml
@@ -0,0 +1,33 @@
+
+
+
+ 8dp
+ 8dp
+
+
+
+ 110dip
+
+
+ 50dip
+
+
+ 20dip
+
+
+ 10dip
+
+
+ 220dp
+
+
+ 72dp
+
+
+ 11dp
+
+ 20dp
+
\ No newline at end of file
diff --git a/HypoAlarm/src/main/res/values/dimens.xml b/HypoAlarm/src/main/res/values/dimens.xml
index 8f0e32c..48f9c21 100644
--- a/HypoAlarm/src/main/res/values/dimens.xml
+++ b/HypoAlarm/src/main/res/values/dimens.xml
@@ -4,7 +4,6 @@
16dp
16dp
-
135dip
@@ -29,4 +28,6 @@
So, (94 - 38)/2 ==> 28dp -->
11dp
+ 60dp
+
\ No newline at end of file
diff --git a/HypoAlarm/src/main/res/values/styles.xml b/HypoAlarm/src/main/res/values/styles.xml
index 09be2f9..898d102 100644
--- a/HypoAlarm/src/main/res/values/styles.xml
+++ b/HypoAlarm/src/main/res/values/styles.xml
@@ -1,17 +1,6 @@
-
-
-