- 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">
|
||||
<library name="glowpadbackport-2.1.0">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/HypoAlarm/build/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="file://$PROJECT_DIR$/build/intermediates/exploded-aar/net.frakbot.glowpadbackport/glowpadbackport/2.1.0/res" />
|
||||
<root url="jar://$PROJECT_DIR$/build/intermediates/exploded-aar/net.frakbot.glowpadbackport/glowpadbackport/2.1.0/classes.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<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">
|
||||
<library name="support-v4-19.1.0">
|
||||
<library name="support-annotations-20.0.0">
|
||||
<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>
|
||||
<JAVADOC />
|
||||
<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>
|
||||
</library>
|
||||
</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" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="java-gradle" name="Java-Gradle">
|
||||
<configuration>
|
||||
<option name="BUILD_FOLDER_PATH" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<output url="file://$MODULE_DIR$/build/classes/main" />
|
||||
<output-test url="file://$MODULE_DIR$/build/classes/test" />
|
||||
<exclude-output />
|
||||
@ -15,7 +20,7 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
@ -22,19 +22,19 @@
|
||||
</facet>
|
||||
</component>
|
||||
<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 />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/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/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/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/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/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/source/r/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/generated/source/buildConfig/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/generated/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/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/generated/source/buildConfig/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/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/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
@ -58,22 +58,30 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/apk" />
|
||||
<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/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/intermediates" />
|
||||
<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/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/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/source" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</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="library" exported="" name="appcompat-v7-19.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-4.3.23" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-20.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="play-services-5.0.77" 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" />
|
||||
</component>
|
||||
</module>
|
||||
|
@ -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'
|
||||
}
|
||||
}
|
||||
productFlavors {
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
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'
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<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>
|
||||
</receiver>
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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 {
|
||||
|
@ -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() {
|
||||
|
@ -10,6 +10,7 @@
|
||||
<string name="pre_alarm_notification">Upcoming alarm</string>
|
||||
|
||||
<string-array name="grace_period_array">
|
||||
<item>2 minutes</item>
|
||||
<item>10 minutes</item>
|
||||
<item>15 minutes</item>
|
||||
<item>30 minutes</item>
|
||||
|
Loading…
Reference in New Issue
Block a user