Bring back account categories for unified inbox

pull/207/head
M66B 3 years ago
parent efbcda3f50
commit a3c9b1738a

@ -102,6 +102,7 @@ public interface DaoMessage {
" AND (NOT :filter_deleted OR NOT message.ui_deleted)" +
" AND (:filter_language IS NULL OR SUM(message.language = :filter_language) > 0)" +
" ORDER BY -IFNULL(message.importance, 1)" +
", CASE WHEN :group_category THEN account.category ELSE '' END COLLATE NOCASE" +
", CASE" +
" WHEN 'unread' = :sort THEN SUM(1 - message.ui_seen) = 0" +
" WHEN 'starred' = :sort THEN COUNT(message.id) - SUM(1 - message.ui_flagged) = 0" +
@ -116,7 +117,7 @@ public interface DaoMessage {
", CASE WHEN :ascending THEN message.received ELSE -message.received END")
DataSource.Factory<Integer, TupleMessageEx> pagedUnified(
String type,
boolean threading,
boolean threading, boolean group_category,
String sort, boolean ascending,
boolean filter_seen, boolean filter_unflagged, boolean filter_unknown, boolean filter_snoozed, boolean filter_deleted, String filter_language,
boolean found,

@ -313,6 +313,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private boolean cards;
private boolean dividers;
private boolean category;
private boolean date;
private boolean date_fixed;
private boolean date_bold;
@ -448,6 +449,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
swipenav = prefs.getBoolean("swipenav", true);
cards = prefs.getBoolean("cards", true);
dividers = prefs.getBoolean("dividers", true);
category = prefs.getBoolean("group_category", false);
date = prefs.getBoolean("date", true);
date_fixed = (!date && prefs.getBoolean("date_fixed", false));
date_bold = prefs.getBoolean("date_bold", false);
@ -843,9 +845,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (message == null)
return null;
boolean ch = (category &&
viewType == AdapterMessage.ViewType.UNIFIED &&
(pos == 0
? message.accountCategory != null
: !Objects.equals(prev.accountCategory, message.accountCategory)));
boolean dh = (date && !date_fixed && SORT_DATE_HEADER.contains(adapter.getSort()));
if (!dh)
if (!ch && !dh)
return null;
if (pos > 0) {
@ -861,15 +868,21 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
dh = false;
}
if (!dh)
if (!ch && !dh)
return null;
View header = inflater.inflate(R.layout.item_group, parent, false);
TextView tvCategory = header.findViewById(R.id.tvCategory);
TextView tvDate = header.findViewById(R.id.tvDate);
tvCategory.setVisibility(View.GONE);
tvCategory.setVisibility(ch ? View.VISIBLE : View.GONE);
tvDate.setVisibility(dh ? View.VISIBLE : View.GONE);
if (ch) {
tvCategory.setText(message.accountCategory);
if (date_bold)
tvCategory.setTypeface(Typeface.DEFAULT_BOLD);
}
if (dh) {
int zoom = adapter.getZoom();
if (zoom > 0)

@ -150,7 +150,7 @@ public class FragmentOptions extends FragmentBase {
"contrast", "display_font", "monospaced_pre",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_separators",
"collapse_quotes", "image_placeholders", "inline_images",
"seekbar", "actionbar", "actionbar_color",
"seekbar", "actionbar", "actionbar_color", "group_category",
"autoscroll", "swipenav", "reversed", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose",
"swipe_reply",
"language_detection",

@ -96,6 +96,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swSeekbar;
private SwitchCompat swActionbar;
private SwitchCompat swActionbarColor;
private SwitchCompat swCategory;
private SwitchCompat swHighlightUnread;
private ViewButtonColor btnHighlightColor;
@ -189,7 +190,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"date", "date_fixed", "date_bold",
"portrait2", "portrait2c", "landscape", "close_pane", "column_width",
"nav_options", "nav_categories", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color", "group_category",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
"avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "generated_icons", "identicons",
"circular", "saturation", "brightness", "threshold",
@ -250,6 +251,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swSeekbar = view.findViewById(R.id.swSeekbar);
swActionbar = view.findViewById(R.id.swActionbar);
swActionbarColor = view.findViewById(R.id.swActionbarColor);
swCategory = view.findViewById(R.id.swCategory);
swHighlightUnread = view.findViewById(R.id.swHighlightUnread);
btnHighlightColor = view.findViewById(R.id.btnHighlightColor);
@ -622,6 +624,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swCategory.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("group_category", checked).apply();
}
});
swHighlightUnread.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1334,6 +1343,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
swActionbarColor.setChecked(prefs.getBoolean("actionbar_color", false));
swActionbarColor.setEnabled(swActionbar.isChecked());
swCategory.setChecked(prefs.getBoolean("group_category", false));
swHighlightUnread.setChecked(prefs.getBoolean("highlight_unread", true));

@ -123,6 +123,7 @@ public class ViewModelMessages extends ViewModel {
db.message().pagedUnified(
args.type,
args.threading,
args.group_category,
args.sort, args.ascending,
args.filter_seen,
args.filter_unflagged,
@ -182,7 +183,7 @@ public class ViewModelMessages extends ViewModel {
builder = new LivePagedListBuilder<>(
db.message().pagedUnified(
null,
args.threading,
args.threading, false,
"time", false,
false, false, false, false, false,
null,
@ -486,6 +487,7 @@ public class ViewModelMessages extends ViewModel {
private boolean server;
private boolean threading;
private boolean group_category;
private String sort;
private boolean ascending;
private boolean filter_seen;
@ -517,6 +519,7 @@ public class ViewModelMessages extends ViewModel {
boolean outbox = EntityFolder.OUTBOX.equals(type);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.group_category = prefs.getBoolean("group_category", false);
this.sort = prefs.getString(FragmentMessages.getSort(context, viewType, type), "time");
this.ascending = prefs.getBoolean(FragmentMessages.getSortOrder(context, viewType, type), outbox);
this.filter_seen = prefs.getBoolean(FragmentMessages.getFilter(context, "seen", viewType, type), false);
@ -545,6 +548,7 @@ public class ViewModelMessages extends ViewModel {
this.server == other.server &&
this.threading == other.threading &&
this.group_category == other.group_category &&
Objects.equals(this.sort, other.sort) &&
this.ascending == other.ascending &&
this.filter_seen == other.filter_seen &&
@ -566,6 +570,7 @@ public class ViewModelMessages extends ViewModel {
" thread=" + thread + ":" + id +
" criteria=" + criteria + ":" + server + "" +
" threading=" + threading +
" category=" + group_category +
" sort=" + sort + ":" + ascending +
" filter seen=" + filter_seen +
" unflagged=" + filter_unflagged +

@ -651,6 +651,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swActionbar"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCategory"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_category_header"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swActionbarColor"
app:switchPadding="12dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>

@ -470,7 +470,6 @@
<string name="title_advanced_cards_shadow">Use shadow for unread messages when using card style</string>
<string name="title_advanced_cards_shadow_highlight">Use highlight color instead of accent color</string>
<string name="title_advanced_tabular_dividers">Use divider lines when using tabular style</string>
<string name="title_advanced_category_header">Group by account category</string>
<string name="title_advanced_date_header">Group by date</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>
@ -542,6 +541,7 @@
<string name="title_advanced_seekbar">Show relative conversation position with a dot</string>
<string name="title_advanced_actionbar">Show conversation action bar</string>
<string name="title_advanced_actionbar_color">Use account color as background color for conversation action bar</string>
<string name="title_advanced_category_header">Group by account category</string>
<string name="title_advanced_navbar_colorize">Colorize the Android navigation bar</string>
<string name="title_advanced_bundled_fonts">Use bundled fonts</string>
<string name="title_advanced_parse_classes">Parse style sheets</string>

Loading…
Cancel
Save