Added option to show number of messages / top action bar

pull/209/head
M66B 3 years ago
parent 32f517fb2f
commit bf583f11c7

@ -29,6 +29,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Rect;
@ -61,6 +62,7 @@ import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import java.io.File;
import java.io.FileInputStream;
@ -72,6 +74,7 @@ import java.util.List;
import java.util.Map;
public class FragmentBase extends Fragment {
private CharSequence count = null;
private CharSequence title = null;
private CharSequence subtitle = " ";
private boolean finish = false;
@ -97,6 +100,11 @@ public class FragmentBase extends Fragment {
return null;
}
protected void setCount(String count) {
this.count = count;
updateSubtitle();
}
protected void setTitle(int resid) {
setTitle(getString(resid));
}
@ -410,9 +418,18 @@ public class FragmentBase extends Fragment {
actionbar.setTitle(title == null ? getString(R.string.app_name) : title);
actionbar.setSubtitle(subtitle);
} else {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
boolean list_count = prefs.getBoolean("list_count", false);
View custom = actionbar.getCustomView();
TextView tvCount = custom.findViewById(R.id.count);
TextView tvTitle = custom.findViewById(R.id.title);
TextView tvSubtitle = custom.findViewById(R.id.subtitle);
if (tvCount != null) {
tvCount.setText(count);
tvCount.setVisibility(!list_count || TextUtils.isEmpty(count)
? View.GONE : View.VISIBLE);
}
if (tvTitle != null)
tvTitle.setText(title == null ? getString(R.string.app_name) : title);
if (tvSubtitle != null)

@ -6193,6 +6193,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (messages == null)
return;
if (viewType != AdapterMessage.ViewType.SEARCH)
setCount(messages.size() == 0 ? null : NF.format(messages.size()));
if (viewType == AdapterMessage.ViewType.THREAD) {
if (handleThreadActions(messages, null, null))
return;

@ -145,6 +145,7 @@ public class FragmentOptions extends FragmentBase {
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
"message_zoom", "overview_mode", "override_width", "addresses", "button_extra", "attachments_alt", "thumbnails",
"contrast", "hyphenation", "display_font", "monospaced_pre",
"list_count", "bundled_fonts", "parse_classes",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_separators",
"collapse_quotes", "image_placeholders", "inline_images",
"seekbar", "actionbar", "actionbar_color", "group_category",

@ -171,6 +171,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swAttachmentsAlt;
private SwitchCompat swThumbnails;
private SwitchCompat swListCount;
private SwitchCompat swBundledFonts;
private SwitchCompat swParseClasses;
private SwitchCompat swBackgroundColor;
@ -207,7 +208,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"text_separators",
"collapse_quotes", "image_placeholders", "inline_images", "button_extra",
"unzip", "attachments_alt", "thumbnails",
"bundled_fonts", "parse_classes",
"list_count", "bundled_fonts", "parse_classes",
"background_color", "text_color", "text_size", "text_font", "text_align",
"authentication", "authentication_indicator"
};
@ -327,6 +328,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt);
swThumbnails = view.findViewById(R.id.swThumbnails);
swListCount = view.findViewById(R.id.swListCount);
swBundledFonts = view.findViewById(R.id.swBundledFonts);
swParseClasses = view.findViewById(R.id.swParseClasses);
swBackgroundColor = view.findViewById(R.id.swBackgroundColor);
@ -1199,6 +1201,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swListCount.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("list_count", checked).apply();
}
});
swBundledFonts.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1493,6 +1502,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
swThumbnails.setChecked(prefs.getBoolean("thumbnails", true));
swListCount.setChecked(prefs.getBoolean("list_count", false));
swBundledFonts.setChecked(prefs.getBoolean("bundled_fonts", true));
swParseClasses.setChecked(prefs.getBoolean("parse_classes", true));
swBackgroundColor.setChecked(prefs.getBoolean("background_color", false));

@ -12,10 +12,22 @@
android:singleLine="true"
android:text="Title"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/count"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:paddingEnd="6dp"
android:singleLine="true"
android:text="123"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/subtitle"
android:layout_width="0dp"

@ -1882,6 +1882,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swListCount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_list_count"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAdvanced"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swBundledFonts"
android:layout_width="0dp"
@ -1891,7 +1902,7 @@
android:text="@string/title_advanced_bundled_fonts"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAdvanced"
app:layout_constraintTop_toBottomOf="@id/swListCount"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -567,6 +567,7 @@
<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_list_count">Show the number of messages or conversations in the top action bar</string>
<string name="title_advanced_bundled_fonts">Use bundled fonts</string>
<string name="title_advanced_parse_classes">Parse style sheets</string>
<string name="title_advanced_authentication">Show authentication warnings</string>

Loading…
Cancel
Save