Added option to show number of messages / top action bar

This commit is contained in:
M66B
2022-07-06 08:30:01 +02:00
parent 32f517fb2f
commit bf583f11c7
7 changed files with 58 additions and 3 deletions

View File

@@ -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)

View File

@@ -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;

View File

@@ -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",

View File

@@ -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));