Added option to always show date and time

This commit is contained in:
M66B 2023-05-19 15:02:13 +02:00
parent 2b95587e00
commit 4fa0377b3e
5 changed files with 32 additions and 4 deletions

View File

@ -261,6 +261,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean date;
private boolean date_week;
private boolean date_fixed;
private boolean date_time;
private boolean cards;
private boolean shadow_unread;
private boolean shadow_border;
@ -336,6 +337,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private NumberFormat NF = NumberFormat.getNumberInstance();
private DateFormat TF;
private DateFormat DTF;
private DateFormat DTFS;
private static final ExecutorService executorDiffer =
Helper.getBackgroundExecutor(0, "differ");
@ -1419,7 +1421,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
message.totalSize != null && ("size".equals(sort) || "attachments".equals(sort))
? View.VISIBLE : View.GONE);
SpannableStringBuilder time;
if (date_week)
if (date_time)
time = new SpannableStringBuilderEx(DTFS.format(message.received));
else if (date_week)
time = new SpannableStringBuilderEx(Helper.getRelativeDateSpanString(context, message.received));
else
time = new SpannableStringBuilderEx(
@ -7573,6 +7577,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.TF = Helper.getTimeInstance(context, SimpleDateFormat.SHORT);
this.DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.LONG, SimpleDateFormat.LONG);
this.DTFS = Helper.getDateTimeInstance(context, SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
ConnectionHelper.NetworkState state = ConnectionHelper.getNetworkState(context);
this.suitable = state.isSuitable();
@ -7618,6 +7623,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.date = prefs.getBoolean("date", true);
this.date_week = prefs.getBoolean("date_week", false);
this.date_fixed = (!date && prefs.getBoolean("date_fixed", false));
this.date_time = prefs.getBoolean("date_time", false);
this.cards = prefs.getBoolean("cards", true);
this.shadow_unread = prefs.getBoolean("shadow_unread", false);
this.shadow_border = prefs.getBoolean("shadow_border", true);

View File

@ -136,7 +136,7 @@ public class FragmentOptions extends FragmentBase {
"portrait2", "portrait2c", "portrait_min_size", "landscape", "landscape_min_size",
"column_width",
"hide_toolbar", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
"indentation", "date", "date_week", "date_fixed", "date_bold", "threading", "threading_unread",
"indentation", "date", "date_week", "date_fixed", "date_bold", "date_time", "threading", "threading_unread",
"show_filtered",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
"avatars", "bimi", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",

View File

@ -71,6 +71,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swDateWeek;
private SwitchCompat swDateFixed;
private SwitchCompat swDateBold;
private SwitchCompat swDateTime;
private SwitchCompat swCategory;
private SwitchCompat swCards;
private SwitchCompat swBeige;
@ -198,7 +199,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup",
"date", "date_week", "date_fixed", "date_bold", "group_category",
"date", "date_week", "date_fixed", "date_bold", "date_time", "group_category",
"cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers",
"portrait2", "portrait2c", "landscape", "close_pane", "open_pane", "column_width",
"hide_toolbar", "nav_options", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
@ -239,6 +240,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDateWeek = view.findViewById(R.id.swDateWeek);
swDateFixed = view.findViewById(R.id.swDateFixed);
swDateBold = view.findViewById(R.id.swDateBold);
swDateTime = view.findViewById(R.id.swDateTime);
swCategory = view.findViewById(R.id.swCategory);
swCards = view.findViewById(R.id.swCards);
swBeige = view.findViewById(R.id.swBeige);
@ -445,6 +447,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swDateTime.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("date_time", checked).apply();
}
});
swCategory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1425,6 +1434,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDateFixed.setEnabled(!swDate.isChecked());
swDateBold.setChecked(prefs.getBoolean("date_bold", false));
swDateBold.setEnabled(swDate.isChecked() || swDateFixed.isChecked());
swDateTime.setChecked(prefs.getBoolean("date_time", false));
swCategory.setChecked(prefs.getBoolean("group_category", false));
swCards.setChecked(prefs.getBoolean("cards", true));
swBeige.setChecked(prefs.getBoolean("beige", true));

View File

@ -194,6 +194,17 @@
app:layout_constraintTop_toBottomOf="@id/swDateFixed"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDateTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_date_time"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDateBold"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCategory"
android:layout_width="0dp"
@ -202,7 +213,7 @@
android:text="@string/title_advanced_category_header"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDateBold"
app:layout_constraintTop_toBottomOf="@id/swDateTime"
app:switchPadding="12dp" />
<TextView

View File

@ -550,6 +550,7 @@
<string name="title_advanced_date_week">Group by week instead of day</string>
<string name="title_advanced_date_fixed">Show fixed date header at the top</string>
<string name="title_advanced_date_bold">Show date in bold</string>
<string name="title_advanced_date_time">Always show both a date and a time</string>
<string name="title_advanced_threading">Conversation threading</string>
<string name="title_advanced_threading_unread">Show number of unread messages in conversations</string>
<string name="title_advanced_indentation">Left/right indent received/sent messages in conversations</string>