Minor tweaks to MainActivity
This commit is contained in:
parent
20f99f2b5f
commit
615b81e295
10
.idea/libraries/library_1_5_2.xml
generated
Normal file
10
.idea/libraries/library_1_5_2.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="library-1.5.2">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.doomonafireball.betterpickers/library/1.5.2/classes.jar!/" />
|
||||||
|
<root url="file://$PROJECT_DIR$/HypoAlarm/build/exploded-aar/com.doomonafireball.betterpickers/library/1.5.2/res" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -75,6 +75,7 @@
|
|||||||
<orderEntry type="library" exported="" name="play-services-4.3.23" 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="library-2.4.0" level="project" />
|
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="library-1.5.2" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
@ -32,6 +32,9 @@ dependencies {
|
|||||||
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:1.5.2'
|
||||||
|
|
||||||
//compile project(':GlowPadBackport')
|
//compile project(':GlowPadBackport')
|
||||||
//compile project(':SeekArc')
|
//compile project(':SeekArc')
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package za.org.treehouse.hypoalarm;
|
package za.org.treehouse.hypoalarm;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@ -377,7 +376,7 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
} else {
|
} else {
|
||||||
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmPendingIntent);
|
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmPendingIntent);
|
||||||
}
|
}
|
||||||
Log.d("MainActivity", "Setting alarm for " + MainActivity.debugDate(cal));
|
Log.d("MainActivity", "Setting alarm for " + debugDate(cal));
|
||||||
|
|
||||||
// Set an alarm for the pre-alarm notification, an hour before the alarm
|
// Set an alarm for the pre-alarm notification, an hour before the alarm
|
||||||
Calendar preNotifyCal = (Calendar) cal.clone();
|
Calendar preNotifyCal = (Calendar) cal.clone();
|
||||||
@ -390,7 +389,7 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
} else {
|
} else {
|
||||||
alarmManager.set(AlarmManager.RTC_WAKEUP, preNotifyCal.getTimeInMillis(), preNotifyPendingIntent);
|
alarmManager.set(AlarmManager.RTC_WAKEUP, preNotifyCal.getTimeInMillis(), preNotifyPendingIntent);
|
||||||
}
|
}
|
||||||
Log.d("MainActivity", "Setting pre-alarm for " + MainActivity.debugDate(preNotifyCal));
|
Log.d("MainActivity", "Setting pre-alarm for " + debugDate(preNotifyCal));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -404,7 +403,7 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
Boolean alarmActive = sharedPref.getBoolean(context.getString(R.string.AlarmActivePref), defaultActive);
|
Boolean alarmActive = sharedPref.getBoolean(context.getString(R.string.AlarmActivePref), defaultActive);
|
||||||
int gracePeriod = sharedPref.getInt(context.getString(R.string.GracePeriodPref), MainActivity.defaultGracePeriod);
|
int gracePeriod = sharedPref.getInt(context.getString(R.string.GracePeriodPref), defaultGracePeriod);
|
||||||
|
|
||||||
cancelGraceAlarm(context);
|
cancelGraceAlarm(context);
|
||||||
|
|
||||||
@ -414,17 +413,16 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
graceCal.set(Calendar.SECOND, 0);
|
graceCal.set(Calendar.SECOND, 0);
|
||||||
graceCal.add(Calendar.MINUTE, gracePeriod);
|
graceCal.add(Calendar.MINUTE, gracePeriod);
|
||||||
Intent graceIntent = new Intent(context, GraceReceiver.class);
|
Intent graceIntent = new Intent(context, GraceReceiver.class);
|
||||||
PendingIntent gracePendingIntent = PendingIntent.getBroadcast(context, MainActivity.GRACE_REQUEST, graceIntent, 0);
|
PendingIntent gracePendingIntent = PendingIntent.getBroadcast(context, GRACE_REQUEST, graceIntent, 0);
|
||||||
if (Build.VERSION.SDK_INT >= 19) {
|
if (Build.VERSION.SDK_INT >= 19) {
|
||||||
alarmManager.setExact(AlarmManager.RTC_WAKEUP, graceCal.getTimeInMillis(), gracePendingIntent);
|
alarmManager.setExact(AlarmManager.RTC_WAKEUP, graceCal.getTimeInMillis(), gracePendingIntent);
|
||||||
} else {
|
} else {
|
||||||
alarmManager.set(AlarmManager.RTC_WAKEUP, graceCal.getTimeInMillis(), gracePendingIntent);
|
alarmManager.set(AlarmManager.RTC_WAKEUP, graceCal.getTimeInMillis(), gracePendingIntent);
|
||||||
}
|
}
|
||||||
Log.d("MainActivity", "Setting grace alarm for " + MainActivity.debugDate(graceCal));
|
Log.d("MainActivity", "Setting grace alarm for " + debugDate(graceCal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alarm time picker
|
|
||||||
public static class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
|
public static class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
|
||||||
SharedPreferences sharedPref;
|
SharedPreferences sharedPref;
|
||||||
|
|
||||||
@ -440,8 +438,7 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
int minute = cal.get(Calendar.MINUTE);
|
int minute = cal.get(Calendar.MINUTE);
|
||||||
|
|
||||||
// Create a new instance of TimePickerDialog and return it
|
// Create a new instance of TimePickerDialog and return it
|
||||||
return new TimePickerDialog(getActivity(), this, hour, minute,
|
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
|
||||||
DateFormat.is24HourFormat(getActivity()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||||
|
Loading…
Reference in New Issue
Block a user