Added 1 week duration

pull/164/head
M66B 5 years ago
parent 9ef30a653e
commit 5f90d1b171

@ -61,6 +61,7 @@ public class FragmentDialogDuration extends FragmentDialogBase {
final TextView tvDuration = dview.findViewById(R.id.tvDuration);
final Button btn1hour = dview.findViewById(R.id.btn1hour);
final Button btn1day = dview.findViewById(R.id.btn1day);
final Button btn1week = dview.findViewById(R.id.btn1week);
final TimePicker timePicker = dview.findViewById(R.id.timePicker);
final DatePicker datePicker = dview.findViewById(R.id.datePicker);
@ -114,13 +115,18 @@ public class FragmentDialogDuration extends FragmentDialogBase {
})
.create();
btn1hour.setOnClickListener(new View.OnClickListener() {
View.OnClickListener buttonListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
long now = new Date().getTime();
long duration = 3600 * 1000L;
if (view.getId() != R.id.btn1hour)
duration *= 24;
if (view.getId() == R.id.btn1week)
duration *= 7;
Bundle args = getArguments();
args.putLong("duration", duration);
@ -128,23 +134,11 @@ public class FragmentDialogDuration extends FragmentDialogBase {
sendResult(RESULT_OK);
}
});
btn1day.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
long now = new Date().getTime();
long duration = 24 * 3600 * 1000L;
};
Bundle args = getArguments();
args.putLong("duration", duration);
args.putLong("time", now + duration);
sendResult(RESULT_OK);
}
});
btn1hour.setOnClickListener(buttonListener);
btn1day.setOnClickListener(buttonListener);
btn1week.setOnClickListener(buttonListener);
timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
@Override

@ -43,10 +43,23 @@
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_1day"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn1week"
app:layout_constraintStart_toEndOf="@id/btn1hour"
app:layout_constraintTop_toBottomOf="@id/tvDuration" />
<Button
android:id="@+id/btn1week"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_1week"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/btn1day"
app:layout_constraintTop_toBottomOf="@id/tvDuration" />
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"

@ -905,6 +905,7 @@
<string name="title_via">Via: %1$s</string>
<string name="title_1hour">1 hour</string>
<string name="title_1day">1 day</string>
<string name="title_1week">1 week</string>
<string name="title_now">Now</string>
<string name="title_after">After %1$s</string>
<string name="title_reset">Reset</string>

Loading…
Cancel
Save