diff --git a/.idea/dictionaries/tim.xml b/.idea/dictionaries/tim.xml
new file mode 100644
index 0000000..35af06f
--- /dev/null
+++ b/.idea/dictionaries/tim.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/appcompat_v7_19_1_0.xml b/.idea/libraries/appcompat_v7_19_1_0.xml
deleted file mode 100644
index 5408177..0000000
--- a/.idea/libraries/appcompat_v7_19_1_0.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/appcompat_v7_20_0_0.xml b/.idea/libraries/appcompat_v7_20_0_0.xml
new file mode 100644
index 0000000..7d24a24
--- /dev/null
+++ b/.idea/libraries/appcompat_v7_20_0_0.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/glowpadbackport_2_1_0.xml b/.idea/libraries/glowpadbackport_2_1_0.xml
index 6e77482..ec78e4f 100644
--- a/.idea/libraries/glowpadbackport_2_1_0.xml
+++ b/.idea/libraries/glowpadbackport_2_1_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_4_3_23.xml b/.idea/libraries/play_services_4_3_23.xml
deleted file mode 100644
index 11775e0..0000000
--- a/.idea/libraries/play_services_4_3_23.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/play_services_5_0_77.xml b/.idea/libraries/play_services_5_0_77.xml
new file mode 100644
index 0000000..bc03b74
--- /dev/null
+++ b/.idea/libraries/play_services_5_0_77.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/support_annotations_20_0_0.xml b/.idea/libraries/support_annotations_20_0_0.xml
new file mode 100644
index 0000000..9e4620b
--- /dev/null
+++ b/.idea/libraries/support_annotations_20_0_0.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/support_v4_19_1_0.xml b/.idea/libraries/support_v4_19_1_0.xml
deleted file mode 100644
index 3f6ff2d..0000000
--- a/.idea/libraries/support_v4_19_1_0.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/support_v4_20_0_0.xml b/.idea/libraries/support_v4_20_0_0.xml
new file mode 100644
index 0000000..d2b25df
--- /dev/null
+++ b/.idea/libraries/support_v4_20_0_0.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GlowPadBackport/GlowPadBackport.iml b/GlowPadBackport/GlowPadBackport.iml
index b6f321c..283470d 100644
--- a/GlowPadBackport/GlowPadBackport.iml
+++ b/GlowPadBackport/GlowPadBackport.iml
@@ -6,8 +6,13 @@
+
+
+
+
+
-
+
@@ -15,7 +20,7 @@
-
+
diff --git a/HypoAlarm/HypoAlarm-HypoAlarm.iml b/HypoAlarm/HypoAlarm-HypoAlarm.iml
index 978d53d..3b58f0b 100644
--- a/HypoAlarm/HypoAlarm-HypoAlarm.iml
+++ b/HypoAlarm/HypoAlarm-HypoAlarm.iml
@@ -22,19 +22,19 @@
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -58,22 +58,30 @@
-
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
+
+
+
+
diff --git a/HypoAlarm/build.gradle b/HypoAlarm/build.gradle
index 8370ce7..89cdb11 100644
--- a/HypoAlarm/build.gradle
+++ b/HypoAlarm/build.gradle
@@ -1,14 +1,13 @@
apply plugin: 'android'
android {
- compileSdkVersion 19
- buildToolsVersion '19.0.1'
-
+ compileSdkVersion 20
+ buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 10
- targetSdkVersion 19
+ targetSdkVersion 20
versionCode 1
- versionName "1.0"
+ versionName '1.0'
}
buildTypes {
release {
@@ -16,26 +15,22 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
-}
-repositories {
- flatDir {
- dirs 'libs'
+ productFlavors {
}
}
+repositories {
+ flatDir { dirs 'libs' }
+}
dependencies {
- compile 'com.android.support:support-v4:19.1.0'
- compile 'com.android.support:appcompat-v7:19.1.0'
-
+ compile 'com.android.support:appcompat-v7:20.+'
+ compile 'com.android.support:support-v4:20.+'
compile 'com.google.android.gms:play-services:+'
//compile 'com.google.android.gms:play-services:4.2.42'
-
compile 'net.frakbot.glowpadbackport:glowpadbackport:+'
//compile 'net.frakbot.glowpadbackport:glowpadbackport:2.1.0'
-
//compile 'com.doomonafireball.betterpickers:library:+'
//compile 'com.doomonafireball.betterpickers:library:1.5.2'
//compile 'com.doomonafireball.betterpickers:library:1.5.3-SNAPSHOT'
-
//compile 'com.github.flavienlaurent.datetimepicker:library:+'
//compile 'com.github.flavienlaurent.datetimepicker:library:0.0.1'
}
diff --git a/HypoAlarm/src/main/AndroidManifest.xml b/HypoAlarm/src/main/AndroidManifest.xml
index ac511e5..3e303b7 100644
--- a/HypoAlarm/src/main/AndroidManifest.xml
+++ b/HypoAlarm/src/main/AndroidManifest.xml
@@ -51,7 +51,7 @@
-
+
diff --git a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmChangeReceiver.java b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmChangeReceiver.java
index 9aab468..7f37f67 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmChangeReceiver.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmChangeReceiver.java
@@ -13,9 +13,10 @@ public class AlarmChangeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
+ // Don't set this to happen on TIME_SET, or it'll restart the alarm every time the network (or NTP) sets the time.
+ // intent.getAction().equals("android.intent.action.TIME_SET")
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED") ||
- intent.getAction().equals("android.intent.action.TIMEZONE_CHANGED") ||
- intent.getAction().equals("android.intent.action.TIME_SET")) {
+ intent.getAction().equals("android.intent.action.TIMEZONE_CHANGED")) {
String alarmTimeStr = sharedPref.getString(context.getString(R.string.AlarmTimePref), MainActivity.defaultTimeStr);
Calendar cal = MainActivity.TimeStringToCalendar(alarmTimeStr);
Log.d("AlarmChangeReceiver", intent.getAction() + ": resetting alarm for " + MainActivity.debugDate(cal));
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 e1bf047..7ae11c0 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/AlarmNotify.java
@@ -76,6 +76,7 @@ public class AlarmNotify extends Service {
@Override
public void run() {
notificationRunning = true;
+ // Make progress out of 1000 and not just 100, for greater resolution
int max = 1000;
// Count in milliseconds for greater progress resolution
int milliSecondsLeft = (int) ((AlarmService.graceEndTime - System.currentTimeMillis()));
@@ -87,7 +88,10 @@ public class AlarmNotify extends Service {
if (!notificationRunning) {
return;
}
+ // Recalculate milliSecondsLeft so that progress gets updated correctly.
+ milliSecondsLeft = (int) ((AlarmService.graceEndTime - System.currentTimeMillis()));
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);
@@ -95,11 +99,10 @@ public class AlarmNotify extends Service {
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
+ // Recalculate the progress
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);
+ Log.d("AlarmNotify", "progress is " + progress + "; max is " + max);
// Sleep until we need to update again
try {
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 64416e4..1036f2c 100644
--- a/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java
+++ b/HypoAlarm/src/main/java/za/org/treehouse/hypoalarm/MainActivity.java
@@ -74,11 +74,9 @@ public class MainActivity extends ActionBarActivity {
public static final int RINGTONE_REQUEST = 7;
public static final String TIMEPICKER_TAG = "alarmTimePicker";
public static final String defaultTimeStr = "09:00";
- public static final int defaultGracePeriod = 60;
+ public static final int defaultGracePeriod = 2;
public static final Boolean defaultActive = true;
- public static final Boolean HYPOALARM_DEBUG = false;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -119,12 +117,6 @@ public class MainActivity extends ActionBarActivity {
*/
// Set alarm time
String alarmTimeStr = verifyTimeString(sharedPref.getString(getString(R.string.AlarmTimePref), defaultTimeStr));
- // When debugging, set the alarm for one minute's time
- if (HYPOALARM_DEBUG) {
- Calendar c = Calendar.getInstance();
- c.add(Calendar.MINUTE, 1);
- alarmTimeStr = CalendarToTimeString(c);
- }
final Button alarmTimeButton = (Button) getActivity().findViewById(R.id.alarm_time);
alarmTimeButton.setText(alarmTimeStr);
alarmTimeButton.setOnClickListener(new View.OnClickListener() {
diff --git a/HypoAlarm/src/main/res/values/strings.xml b/HypoAlarm/src/main/res/values/strings.xml
index 37fabc2..bd67f20 100644
--- a/HypoAlarm/src/main/res/values/strings.xml
+++ b/HypoAlarm/src/main/res/values/strings.xml
@@ -10,6 +10,7 @@
Upcoming alarm
+ - 2 minutes
- 10 minutes
- 15 minutes
- 30 minutes