mirror of https://github.com/M66B/FairEmail.git
Added snooze quick buttons
This commit is contained in:
parent
a7df80ac0f
commit
e64fa77fd5
|
@ -25,6 +25,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
@ -56,6 +57,8 @@ public class FragmentDialogDuration extends FragmentDialogEx {
|
|||
|
||||
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_duration, null);
|
||||
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 TimePicker timePicker = dview.findViewById(R.id.timePicker);
|
||||
final DatePicker datePicker = dview.findViewById(R.id.datePicker);
|
||||
|
||||
|
@ -77,6 +80,59 @@ public class FragmentDialogDuration extends FragmentDialogEx {
|
|||
timePicker.setMinute(cal.get(Calendar.MINUTE));
|
||||
}
|
||||
|
||||
Dialog dialog = new AlertDialog.Builder(getContext())
|
||||
.setTitle(title)
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
long now = new Date().getTime();
|
||||
long duration = (cal.getTimeInMillis() - now);
|
||||
if (duration < 0)
|
||||
duration = 0;
|
||||
Log.i("Set duration=" + duration + " time=" + new Date(cal.getTimeInMillis()));
|
||||
|
||||
Bundle args = getArguments();
|
||||
args.putLong("duration", duration);
|
||||
args.putLong("time", cal.getTimeInMillis());
|
||||
|
||||
sendResult(RESULT_OK);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
|
||||
btn1hour.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();
|
||||
|
||||
long now = new Date().getTime();
|
||||
long duration = 3600 * 1000L;
|
||||
|
||||
Bundle args = getArguments();
|
||||
args.putLong("duration", duration);
|
||||
args.putLong("time", now + duration);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
|
||||
@Override
|
||||
public void onTimeChanged(TimePicker view, int hour, int minute) {
|
||||
|
@ -105,25 +161,6 @@ public class FragmentDialogDuration extends FragmentDialogEx {
|
|||
}
|
||||
);
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setTitle(title)
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
long now = new Date().getTime();
|
||||
long duration = (cal.getTimeInMillis() - now);
|
||||
if (duration < 0)
|
||||
duration = 0;
|
||||
Log.i("Set duration=" + duration + " time=" + new Date(cal.getTimeInMillis()));
|
||||
|
||||
Bundle args = getArguments();
|
||||
args.putLong("duration", duration);
|
||||
args.putLong("time", cal.getTimeInMillis());
|
||||
|
||||
sendResult(RESULT_OK);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,32 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn1hour"
|
||||
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_1hour"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn1day"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDuration" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn1day"
|
||||
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_1day"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/btn1hour"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDuration" />
|
||||
|
||||
<TimePicker
|
||||
android:id="@+id/timePicker"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -28,7 +54,7 @@
|
|||
android:timePickerMode="spinner"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvDuration" />
|
||||
app:layout_constraintTop_toBottomOf="@id/btn1hour" />
|
||||
|
||||
<DatePicker
|
||||
android:id="@+id/datePicker"
|
||||
|
|
|
@ -794,6 +794,8 @@
|
|||
<string name="title_no_body">No message text found</string>
|
||||
<string name="title_no_charset">Unsupported encoding: %1$s</string>
|
||||
<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_icalendar_accept">Accept</string>
|
||||
<string name="title_icalendar_decline">Decline</string>
|
||||
|
|
Loading…
Reference in New Issue