Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added snooze duration and clarified settings

Allowed the user to set a snooze duration instead of defaulting to 9
minutes.
Added labels to the alarm setting screen to clarify that the donation
amount is in cents and the grace period and snooze duration are in
minutes.
  • Loading branch information...
commit b064f5ed408e3387eaae1aee78be647c77e12794 1 parent 1ac0947
@jzongker jzongker authored
View
5 src/main/java/com/pledgeapps/buyingtime/AlarmActivity.java
@@ -29,6 +29,7 @@
EditText graceMinutesText;
EditText centsPerMinuteText;
+ EditText snoozeDurationText;
Button alarmTimeButton;
Button daysButton;
Button saveButton;
@@ -77,6 +78,8 @@ protected void onCreate(Bundle savedInstanceState) {
activeToggle = (ToggleButton) findViewById(R.id.activeToggle);
graceMinutesText = (EditText) findViewById(R.id.graceMinutesText);
centsPerMinuteText = (EditText) findViewById(R.id.centsPerMinuteText);
+ snoozeDurationText = (EditText) findViewById(R.id.snoozeDurationText);
+
alarmTimeButton = (Button) findViewById(R.id.alarmTimeButton);
daysButton = (Button) findViewById(R.id.daysButton);
saveButton = (Button) findViewById(R.id.saveButton);
@@ -105,6 +108,7 @@ private void populateFields()
activeToggle.setChecked(alarm.active);
centsPerMinuteText.setText(Integer.toString(alarm.centsPerMinute));
graceMinutesText.setText(Integer.toString(alarm.graceMinutes));
+ snoozeDurationText.setText(Integer.toString(alarm.snoozeDuration));
alarmTimeButton.setText(alarm.getDisplayTime());
daysButton.setText(alarm.getDisplayDays());
@@ -137,6 +141,7 @@ private void save()
alarm.graceMinutes = Integer.parseInt(graceMinutesText.getText().toString());
alarm.centsPerMinute = Integer.parseInt(centsPerMinuteText.getText().toString());
+ alarm.snoozeDuration = Integer.parseInt(snoozeDurationText.getText().toString());
alarm.active = activeToggle.isChecked();
alarm.daysOfWeek = selectedDays;
if (alarmIndex==-1) Alarms.getCurrent().add(alarm);
View
8 src/main/java/com/pledgeapps/buyingtime/AlertActivity.java
@@ -179,13 +179,13 @@ private void snooze()
{
silenceAlarm();
- //Date nextAlarmTime = new Date();
- alarm.nextNotificationTime.setTime( alarm.nextNotificationTime.getTime() + 9 * 60 * 1000 ); //9 minutes
+ int snoozeMinutes = alarm.snoozeDuration;
+ if (snoozeMinutes<1) snoozeMinutes=9; //Just in case an invalid number gets entered
+
+ alarm.nextNotificationTime.setTime( alarm.nextNotificationTime.getTime() + snoozeMinutes * 60 * 1000 );
AlarmHelper.getCurrent().setAlarm(getApplicationContext(), alarm);
snoozeButton.setText("Snoozing...");
snoozeButton.setEnabled(false);
-
- //finish();
}
private void dismiss()
View
14 src/main/java/com/pledgeapps/buyingtime/data/Alarm.java
@@ -7,12 +7,13 @@
import java.util.List;
public class Alarm {
- public int hour;
- public int minute;
- public boolean active;
- public int[] daysOfWeek;
- public int graceMinutes;
- public int centsPerMinute;
+ public int hour = 6;
+ public int minute = 0;
+ public boolean active = true;
+ public int[] daysOfWeek = new int[0];
+ public int graceMinutes = 9;
+ public int centsPerMinute = 11;
+ public int snoozeDuration = 9;
public String guid;
public Date nextAlarmTime; //This is the date/time the alarm is set for. (does not update when snoozed)
@@ -27,6 +28,7 @@ public static Alarm createNewAlarm()
a.active = true;
a.daysOfWeek = new int[]{1,2,3,4,5};
a.graceMinutes = 9;
+ a.snoozeDuration = 9;
a.centsPerMinute = 11;
a.guid = java.util.UUID.randomUUID().toString();
return a;
View
20 src/main/res/layout/activity_alarm.xml
@@ -20,13 +20,25 @@
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dp" >
<TextView android:layout_width="0px" android:layout_height="wrap_content" android:gravity="left" android:text="Pledge Per Minute:" android:layout_weight="40" />
- <EditText android:id="@+id/centsPerMinuteText" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="60" android:inputType="number" />
+ <LinearLayout android:layout_width="0px" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight="60" >
+ <EditText android:id="@+id/centsPerMinuteText" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="60" android:inputType="number" />
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="cents" />
+ </LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dp" >
- <TextView android:layout_width="0px" android:layout_height="wrap_content" android:gravity="left" android:text="Grace Minutes:" android:layout_weight="40" />
- <EditText android:id="@+id/graceMinutesText" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="60" android:inputType="number" />
+ <TextView android:layout_width="0px" android:layout_height="wrap_content" android:gravity="left" android:text="Grace Period:" android:layout_weight="40" />
+ <LinearLayout android:layout_width="0px" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight="60" >
+ <EditText android:id="@+id/graceMinutesText" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="60" android:inputType="number" />
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="minutes" />
+ </LinearLayout>
+ </LinearLayout>
+ <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dp" >
+ <TextView android:layout_width="0px" android:layout_height="wrap_content" android:gravity="left" android:text="Snooze Duration:" android:layout_weight="40" />
+ <LinearLayout android:layout_width="0px" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight="60" >
+ <EditText android:id="@+id/snoozeDurationText" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="60" android:inputType="number" />
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="minutes" />
+ </LinearLayout>
</LinearLayout>
-
</LinearLayout>
</ScrollView>
Please sign in to comment.
Something went wrong with that request. Please try again.