- Remove the TIME_SET receiver, as this could reset the alarm whenever the network decides to reset the phone time.
- Recalculate the grace period notification progress, based on current time rather than once per update. This was causing the notification to persist when the phone went to sleep, past the time that the grace period had actually expired. - Upgrade to latest libraries.
This commit is contained in:
parent
7810231e19
commit
093de96c68
3
.idea/dictionaries/tim.xml
generated
Normal file
3
.idea/dictionaries/tim.xml
generated
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="tim" />
|
||||||
|
</component>
|
10
.idea/libraries/appcompat_v7_19_1_0.xml
generated
10
.idea/libraries/appcompat_v7_19_1_0.xml
generated
@ -1,10 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="appcompat-v7-19.1.0">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.android.support/appcompat-v7/19.1.0/classes.jar!/" />
|
|
||||||
<root url="file://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.android.support/appcompat-v7/19.1.0/res" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
10
.idea/libraries/appcompat_v7_20_0_0.xml
generated
Normal file
10
.idea/libraries/appcompat_v7_20_0_0.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="appcompat-v7-20.0.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="file://$PROJECT_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/20.0.0/res" />
|
||||||
|
<root url="jar://$PROJECT_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/20.0.0/classes.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
4
.idea/libraries/glowpadbackport_2_1_0.xml
generated
4
.idea/libraries/glowpadbackport_2_1_0.xml
generated
@ -1,8 +1,8 @@
|
|||||||
<component name="libraryTable">
|
<component name="libraryTable">
|
||||||
<library name="glowpadbackport-2.1.0">
|
<library name="glowpadbackport-2.1.0">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/net.frakbot.glowpadbackport/glowpadbackport/2.1.0/res" />
|
<root url="file://$PROJECT_DIR$/build/intermediates/exploded-aar/net.frakbot.glowpadbackport/glowpadbackport/2.1.0/res" />
|
||||||
<root url="jar://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/net.frakbot.glowpadbackport/glowpadbackport/2.1.0/classes.jar!/" />
|
<root url="jar://$PROJECT_DIR$/build/intermediates/exploded-aar/net.frakbot.glowpadbackport/glowpadbackport/2.1.0/classes.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
|
10
.idea/libraries/play_services_4_3_23.xml
generated
10
.idea/libraries/play_services_4_3_23.xml
generated
@ -1,10 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="play-services-4.3.23">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.google.android.gms/play-services/4.3.23/res" />
|
|
||||||
<root url="jar://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.google.android.gms/play-services/4.3.23/classes.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
10
.idea/libraries/play_services_5_0_77.xml
generated
Normal file
10
.idea/libraries/play_services_5_0_77.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="play-services-5.0.77">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services/5.0.77/classes.jar!/" />
|
||||||
|
<root url="file://$PROJECT_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services/5.0.77/res" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -1,11 +1,11 @@
|
|||||||
<component name="libraryTable">
|
<component name="libraryTable">
|
||||||
<library name="support-v4-19.1.0">
|
<library name="support-annotations-20.0.0">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0.jar!/" />
|
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-annotations/20.0.0/support-annotations-20.0.0.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-v4/19.1.0/support-v4-19.1.0-sources.jar!/" />
|
<root url="jar://$APPLICATION_HOME_DIR$/sdk/extras/android/m2repository/com/android/support/support-annotations/20.0.0/support-annotations-20.0.0-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
10
.idea/libraries/support_v4_20_0_0.xml
generated
Normal file
10
.idea/libraries/support_v4_20_0_0.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="support-v4-20.0.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/classes.jar!/" />
|
||||||
|
<root url="file://$PROJECT_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/res" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -6,8 +6,13 @@
|
|||||||
<option name="GRADLE_PROJECT_PATH" value=":GlowPadBackport" />
|
<option name="GRADLE_PROJECT_PATH" value=":GlowPadBackport" />
|
||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
|
<facet type="java-gradle" name="Java-Gradle">
|
||||||
|
<configuration>
|
||||||
|
<option name="BUILD_FOLDER_PATH" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
</component>
|
</component>
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<output url="file://$MODULE_DIR$/build/classes/main" />
|
<output url="file://$MODULE_DIR$/build/classes/main" />
|
||||||
<output-test url="file://$MODULE_DIR$/build/classes/test" />
|
<output-test url="file://$MODULE_DIR$/build/classes/test" />
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
@ -15,7 +20,7 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
@ -22,19 +22,19 @@
|
|||||||
</facet>
|
</facet>
|
||||||
</component>
|
</component>
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
<output url="file://$MODULE_DIR$/build/classes/debug" />
|
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/test/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/test/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/test/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/test/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/test/debug" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||||
@ -58,22 +58,30 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/apk" />
|
<excludeFolder url="file://$MODULE_DIR$/build/apk" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/assets" />
|
<excludeFolder url="file://$MODULE_DIR$/build/assets" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/bundles" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/classes" />
|
<excludeFolder url="file://$MODULE_DIR$/build/classes" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" />
|
<excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/dex" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/exploded-aar" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/incremental" />
|
<excludeFolder url="file://$MODULE_DIR$/build/incremental" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/lint-results-release-fatal_files" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/manifests" />
|
<excludeFolder url="file://$MODULE_DIR$/build/manifests" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/ndk" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/pre-dexed" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/res" />
|
<excludeFolder url="file://$MODULE_DIR$/build/res" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/rs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/source" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/symbols" />
|
<excludeFolder url="file://$MODULE_DIR$/build/symbols" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" />
|
<orderEntry type="library" exported="" name="appcompat-v7-20.0.0" level="project" />
|
||||||
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
<orderEntry type="library" exported="" name="play-services-5.0.77" level="project" />
|
||||||
<orderEntry type="library" exported="" name="play-services-4.3.23" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="glowpadbackport-2.1.0" level="project" />
|
<orderEntry type="library" exported="" name="glowpadbackport-2.1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="support-annotations-20.0.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="support-v4-20.0.0" level="project" />
|
||||||
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
|
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
apply plugin: 'android'
|
apply plugin: 'android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 19
|
compileSdkVersion 20
|
||||||
buildToolsVersion '19.0.1'
|
buildToolsVersion '20.0.0'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 10
|
minSdkVersion 10
|
||||||
targetSdkVersion 19
|
targetSdkVersion 20
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName '1.0'
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@ -16,26 +15,22 @@ android {
|
|||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
productFlavors {
|
||||||
repositories {
|
|
||||||
flatDir {
|
|
||||||
dirs 'libs'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
repositories {
|
||||||
|
flatDir { dirs 'libs' }
|
||||||
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:support-v4:19.1.0'
|
compile 'com.android.support:appcompat-v7:20.+'
|
||||||
compile 'com.android.support:appcompat-v7:19.1.0'
|
compile 'com.android.support:support-v4:20.+'
|
||||||
|
|
||||||
compile 'com.google.android.gms:play-services:+'
|
compile 'com.google.android.gms:play-services:+'
|
||||||
//compile 'com.google.android.gms:play-services:4.2.42'
|
//compile 'com.google.android.gms:play-services:4.2.42'
|
||||||
|
|
||||||
compile 'net.frakbot.glowpadbackport:glowpadbackport:+'
|
compile 'net.frakbot.glowpadbackport:glowpadbackport:+'
|
||||||
//compile 'net.frakbot.glowpadbackport:glowpadbackport:2.1.0'
|
//compile 'net.frakbot.glowpadbackport:glowpadbackport:2.1.0'
|
||||||
|
|
||||||
//compile 'com.doomonafireball.betterpickers:library:+'
|
//compile 'com.doomonafireball.betterpickers:library:+'
|
||||||
//compile 'com.doomonafireball.betterpickers:library:1.5.2'
|
//compile 'com.doomonafireball.betterpickers:library:1.5.2'
|
||||||
//compile 'com.doomonafireball.betterpickers:library:1.5.3-SNAPSHOT'
|
//compile 'com.doomonafireball.betterpickers:library:1.5.3-SNAPSHOT'
|
||||||
|
|
||||||
//compile 'com.github.flavienlaurent.datetimepicker:library:+'
|
//compile 'com.github.flavienlaurent.datetimepicker:library:+'
|
||||||
//compile 'com.github.flavienlaurent.datetimepicker:library:0.0.1'
|
//compile 'com.github.flavienlaurent.datetimepicker:library:0.0.1'
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
||||||
<action android:name="android.intent.action.TIME_SET" />
|
<!--action android:name="android.intent.action.TIME_SET" /-->
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
@ -13,9 +13,10 @@ public class AlarmChangeReceiver extends BroadcastReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
|
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") ||
|
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED") ||
|
||||||
intent.getAction().equals("android.intent.action.TIMEZONE_CHANGED") ||
|
intent.getAction().equals("android.intent.action.TIMEZONE_CHANGED")) {
|
||||||
intent.getAction().equals("android.intent.action.TIME_SET")) {
|
|
||||||
String alarmTimeStr = sharedPref.getString(context.getString(R.string.AlarmTimePref), MainActivity.defaultTimeStr);
|
String alarmTimeStr = sharedPref.getString(context.getString(R.string.AlarmTimePref), MainActivity.defaultTimeStr);
|
||||||
Calendar cal = MainActivity.TimeStringToCalendar(alarmTimeStr);
|
Calendar cal = MainActivity.TimeStringToCalendar(alarmTimeStr);
|
||||||
Log.d("AlarmChangeReceiver", intent.getAction() + ": resetting alarm for " + MainActivity.debugDate(cal));
|
Log.d("AlarmChangeReceiver", intent.getAction() + ": resetting alarm for " + MainActivity.debugDate(cal));
|
||||||
|
@ -76,6 +76,7 @@ public class AlarmNotify extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
notificationRunning = true;
|
notificationRunning = true;
|
||||||
|
// Make progress out of 1000 and not just 100, for greater resolution
|
||||||
int max = 1000;
|
int max = 1000;
|
||||||
// Count in milliseconds for greater progress resolution
|
// Count in milliseconds for greater progress resolution
|
||||||
int milliSecondsLeft = (int) ((AlarmService.graceEndTime - System.currentTimeMillis()));
|
int milliSecondsLeft = (int) ((AlarmService.graceEndTime - System.currentTimeMillis()));
|
||||||
@ -87,7 +88,10 @@ public class AlarmNotify extends Service {
|
|||||||
if (!notificationRunning) {
|
if (!notificationRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Recalculate milliSecondsLeft so that progress gets updated correctly.
|
||||||
|
milliSecondsLeft = (int) ((AlarmService.graceEndTime - System.currentTimeMillis()));
|
||||||
int minutesLeft = (milliSecondsLeft / 1000) / 60;
|
int minutesLeft = (milliSecondsLeft / 1000) / 60;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
notification.setContentText(String.format(getString(R.string.notificationText), MainActivity.MinutesToGracePeriodStr(minutesLeft)));
|
notification.setContentText(String.format(getString(R.string.notificationText), MainActivity.MinutesToGracePeriodStr(minutesLeft)));
|
||||||
notification.setProgress(max, progress, false);
|
notification.setProgress(max, progress, false);
|
||||||
@ -95,11 +99,10 @@ public class AlarmNotify extends Service {
|
|||||||
nm.notify(notifyID, notification.build());
|
nm.notify(notifyID, notification.build());
|
||||||
}
|
}
|
||||||
// Prepare secondsLeft and progress for the next loop
|
// Prepare secondsLeft and progress for the next loop
|
||||||
milliSecondsLeft = milliSecondsLeft - UPDATE_INTERVAL;
|
// Recalculate the progress
|
||||||
// Multiply each int by 1000 for greater progress resolution
|
|
||||||
progress = ((gracePeriodMilliSeconds - milliSecondsLeft) * max) / gracePeriodMilliSeconds;
|
progress = ((gracePeriodMilliSeconds - milliSecondsLeft) * max) / gracePeriodMilliSeconds;
|
||||||
//Log.d("AlarmNotify", "milliSecondsLeft is " + milliSecondsLeft + " and progress is " + progress + " (gracePeriodMilliSeconds is " + 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
|
// Sleep until we need to update again
|
||||||
try {
|
try {
|
||||||
|
@ -74,11 +74,9 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
public static final int RINGTONE_REQUEST = 7;
|
public static final int RINGTONE_REQUEST = 7;
|
||||||
public static final String TIMEPICKER_TAG = "alarmTimePicker";
|
public static final String TIMEPICKER_TAG = "alarmTimePicker";
|
||||||
public static final String defaultTimeStr = "09:00";
|
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 defaultActive = true;
|
||||||
|
|
||||||
public static final Boolean HYPOALARM_DEBUG = false;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -119,12 +117,6 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
*/
|
*/
|
||||||
// Set alarm time
|
// Set alarm time
|
||||||
String alarmTimeStr = verifyTimeString(sharedPref.getString(getString(R.string.AlarmTimePref), defaultTimeStr));
|
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);
|
final Button alarmTimeButton = (Button) getActivity().findViewById(R.id.alarm_time);
|
||||||
alarmTimeButton.setText(alarmTimeStr);
|
alarmTimeButton.setText(alarmTimeStr);
|
||||||
alarmTimeButton.setOnClickListener(new View.OnClickListener() {
|
alarmTimeButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<string name="pre_alarm_notification">Upcoming alarm</string>
|
<string name="pre_alarm_notification">Upcoming alarm</string>
|
||||||
|
|
||||||
<string-array name="grace_period_array">
|
<string-array name="grace_period_array">
|
||||||
|
<item>2 minutes</item>
|
||||||
<item>10 minutes</item>
|
<item>10 minutes</item>
|
||||||
<item>15 minutes</item>
|
<item>15 minutes</item>
|
||||||
<item>30 minutes</item>
|
<item>30 minutes</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user