Improved durations

pull/212/head
M66B 2 years ago
parent eb5bf0d3ad
commit 66565c73d3

@ -44,6 +44,7 @@ import androidx.appcompat.widget.PopupMenu;
import androidx.preference.PreferenceManager;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@ -179,6 +180,11 @@ public class FragmentDialogDuration extends FragmentDialogBase {
cal.set(Calendar.HOUR_OF_DAY, 18);
long evening = cal.getTimeInMillis();
String at18pm = dtf.format(cal.getTimeInMillis());
cal.add(Calendar.DATE, 1);
int tomorrow = cal.get(Calendar.DAY_OF_WEEK);
cal.add(Calendar.DATE, 1);
int after_tomorrow = cal.get(Calendar.DAY_OF_WEEK);
String[] daynames = new DateFormatSymbols().getWeekdays();
popupMenu.getMenu().findItem(R.id.menu_this_afternoon)
.setTitle(getString(R.string.title_today_at, at12pm))
@ -186,18 +192,23 @@ public class FragmentDialogDuration extends FragmentDialogBase {
popupMenu.getMenu().findItem(R.id.menu_this_evening)
.setTitle(getString(R.string.title_today_at, at18pm))
.setVisible(now < evening);
popupMenu.getMenu().findItem(R.id.menu_tomorrow_morning)
.setTitle(getString(R.string.title_tomorrow_at, at8am));
popupMenu.getMenu().findItem(R.id.menu_tomorrow_afternoon)
.setTitle(getString(R.string.title_tomorrow_at, at12pm));
popupMenu.getMenu().findItem(R.id.menu_after_tomorrow_morning)
.setTitle(getString(R.string.title_after_tomorrow_at, at8am));
.setTitle(getString(R.string.title_day_at_time, daynames[after_tomorrow], at8am));
popupMenu.getMenu().findItem(R.id.menu_after_tomorrow_afternoon)
.setTitle(getString(R.string.title_after_tomorrow_at, at12pm));
.setTitle(getString(R.string.title_day_at_time, daynames[after_tomorrow], at12pm));
popupMenu.getMenu().findItem(R.id.menu_saturday_norming)
.setTitle(getString(R.string.title_saturday_at, at8am));
.setTitle(getString(R.string.title_day_at_time, daynames[Calendar.SATURDAY], at8am))
.setVisible(tomorrow != Calendar.SATURDAY && after_tomorrow != Calendar.SATURDAY);
popupMenu.getMenu().findItem(R.id.menu_monday_norming)
.setTitle(getString(R.string.title_monday_at, at8am));
.setTitle(getString(R.string.title_day_at_time, daynames[Calendar.MONDAY], at8am))
.setVisible(tomorrow != Calendar.MONDAY && after_tomorrow != Calendar.MONDAY);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override

@ -14,16 +14,16 @@
android:title="@string/title_tomorrow_at" />
<item
android:id="@+id/menu_after_tomorrow_morning"
android:title="@string/title_after_tomorrow_at" />
android:title="@string/title_day_at_time" />
<item
android:id="@+id/menu_after_tomorrow_afternoon"
android:title="@string/title_after_tomorrow_at" />
android:title="@string/title_day_at_time" />
<item
android:id="@+id/menu_saturday_norming"
android:title="@string/title_saturday_at" />
android:title="@string/title_day_at_time" />
<item
android:id="@+id/menu_monday_norming"
android:title="@string/title_monday_at" />
android:title="@string/title_day_at_time" />
<item
android:id="@+id/menu_next_week"
android:title="@string/title_next_week" />

@ -2114,9 +2114,7 @@
<string name="title_more_overflow">More &#8230;</string>
<string name="title_today_at">Today at %1$s</string>
<string name="title_tomorrow_at">Tomorrow at %1$s</string>
<string name="title_after_tomorrow_at">After tomorrow at %1$s</string>
<string name="title_saturday_at">Saturday at %1$s</string>
<string name="title_monday_at">Monday at %1$s</string>
<string name="title_day_at_time">%1$s at %2$s</string>
<string name="title_next_week">This time next week</string>
<string name="title_now">Now</string>
<string name="title_after">After %1$s</string>

Loading…
Cancel
Save