Skip to content

Commit

Permalink
Merge pull request #4 from ewired/master
Browse files Browse the repository at this point in the history
Added 10 second snooze duration for when slider is set to zero
  • Loading branch information
nproth committed Apr 11, 2019
2 parents 4ed20c8 + 26e3625 commit 47e31e5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/src/main/java/de/nproth/pin/NoteActivity.java
Expand Up @@ -46,6 +46,7 @@ public class NoteActivity extends AppCompatActivity implements ServiceConnection

private int[] mDurations;
private int[] mSteps;
private int[] mZeroSnoozeDurations;

private PinboardService.PinboardBinder mPinboard;

Expand Down Expand Up @@ -73,6 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {

mDurations = getResources().getIntArray(R.array.snooze_durations);
mSteps = getResources().getIntArray(R.array.snooze_duration_steps);
mZeroSnoozeDurations = getResources().getIntArray(R.array.zero_snooze_durations);

prepareEditPin();

Expand Down Expand Up @@ -143,15 +145,18 @@ public void onUserChangeBegin(int val) {}

@Override
public void onUserChange(int val) {
int cur = val * 1000;
// if zero, assume zero_snooze_duration
int cur = val == 0 ? getResources().getInteger(R.integer.zero_snooze_duration) : val * 1000;
Timespan span = new Timespan(NoteActivity.this, cur);
String txt = getResources().getString(R.string.ftext_button_snooze_duration, (int) span.inHours(), span.restMins());
if (span.millis < 60000) txt = ((int) span.inSecs()) + getResources().getString(R.string.symbol_time_seconds);
SnoozeDurationButton.setText(txt);
}

@Override
public void onUserChangeEnd(int val) {
mPinboard.setSnoozeDuration(val * 1000);
// if zero, assume zero_snooze_duration
mPinboard.setSnoozeDuration(val == 0 ? getResources().getInteger(R.integer.zero_snooze_duration) : val * 1000);
}
});

Expand Down Expand Up @@ -198,9 +203,15 @@ private void loadSnoozeDuration() {
SnoozeDurationSlider.setStepValue(mSteps[index] / 1000);
SnoozeDurationSlider.setValue((int) (dur / 1000));//in seconds
//setValue / getValue takes care of normalizing, aligning to steps, ...
Timespan span = new Timespan(this, SnoozeDurationSlider.getValue() * 1000);

Log.d("NoteActivity", "Loaded slider value " + SnoozeDurationSlider.getValue());
// If zero, assume zero_snooze_duration
long spanMillis = SnoozeDurationSlider.getValue() == 0 ? getResources().getInteger(R.integer.zero_snooze_duration) : SnoozeDurationSlider.getValue() * 1000;
Timespan span = new Timespan(this, spanMillis);

Log.d("NoteActivity", "Loaded milliseconds " + span.millis);
String txt = getResources().getString(R.string.ftext_button_snooze_duration, (int) span.inHours(), span.restMins());
if (span.millis < 60000) txt = ((int) span.inSecs()) + getResources().getString(R.string.symbol_time_seconds);
SnoozeDurationButton.setText(txt);
mPinboard.update();
}
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/values/values.xml
@@ -1,6 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- in milliseconds -->
<integer name="zero_snooze_duration">10000</integer>

<!-- Not currently in use -->
<integer-array name="zero_snooze_durations">
<!--<item>1000</item>--><!-- 10sec: 1sec -->
<!--<item>5000</item>--><!-- 1min: 5sec -->
<item>10000</item><!-- 0:30h: 10sec -->
<item>30000</item><!-- 1:00h: 30sec -->
<!--<item>10000</item><!- 1:30h: 10sec -->
<!--<item>10000</item><!- 2:00h: 10sec -->
<!--<item>10000</item><!- 3:00h: 10sec -->
<item>10000</item><!-- 6:00h: 10sec -->
<!--<item>10000</item><!- 12:00h: 10sec -->
<item>10000</item><!-- 24:00h: 10sec -->
</integer-array>

<integer-array name="snooze_durations">
<!--<item>10000</item>--><!-- 10sec -->
<!--<item>60000</item>--><!-- 1min -->
Expand Down

0 comments on commit 47e31e5

Please sign in to comment.