Minor tweaks to MainActivity

This commit is contained in:
Timothy Allen 2014-04-17 16:24:52 +02:00
parent 20f99f2b5f
commit 615b81e295
4 changed files with 20 additions and 9 deletions

10
.idea/libraries/library_1_5_2.xml generated Normal file
View 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>

View File

@ -75,6 +75,7 @@
<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="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="library-1.5.2" level="project" />
</component>
</module>

View File

@ -32,6 +32,9 @@ dependencies {
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 project(':GlowPadBackport')
//compile project(':SeekArc')

View File

@ -1,6 +1,5 @@
package za.org.treehouse.hypoalarm;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
@ -377,7 +376,7 @@ public class MainActivity extends ActionBarActivity {
} else {
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
Calendar preNotifyCal = (Calendar) cal.clone();
@ -390,7 +389,7 @@ public class MainActivity extends ActionBarActivity {
} else {
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);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
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);
@ -414,17 +413,16 @@ public class MainActivity extends ActionBarActivity {
graceCal.set(Calendar.SECOND, 0);
graceCal.add(Calendar.MINUTE, gracePeriod);
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) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, graceCal.getTimeInMillis(), gracePendingIntent);
} else {
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 {
SharedPreferences sharedPref;
@ -440,8 +438,7 @@ public class MainActivity extends ActionBarActivity {
int minute = cal.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute,
DateFormat.is24HourFormat(getActivity()));
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {