From cde7840fbe07e65aeca52aabd224cc36ed764657 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 15 Mar 2023 18:52:15 +0100 Subject: [PATCH] Added option to configure number of subject lines of widget --- CHANGELOG.md | 6 ++++ app/src/main/assets/CHANGELOG.md | 6 ++++ .../faircode/email/ActivityWidgetUnified.java | 13 ++++++- .../WidgetUnifiedRemoteViewsFactory.java | 4 +++ .../res/layout/activity_widget_unified.xml | 36 ++++++++++++++++++- app/src/main/res/values/strings.xml | 1 + metadata/en-US/changelogs/2054.txt | 6 ++++ 7 files changed, 70 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a8d66d512..6e613d4aeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ For support you can use [the contact form](https://contact.faircode.eu/?product= ### [Rahonavis](https://en.wikipedia.org/wiki/Rahonavis) +### Next version + +* Added option to configure number of widget subject lines +* Small improvements and minor bug fixes +* Updated [translations](https://crowdin.com/project/open-source-email) + ### 1.2054 - 2023-03-14 * Added rule action option to delete keywords diff --git a/app/src/main/assets/CHANGELOG.md b/app/src/main/assets/CHANGELOG.md index 4a8d66d512..6e613d4aeb 100644 --- a/app/src/main/assets/CHANGELOG.md +++ b/app/src/main/assets/CHANGELOG.md @@ -6,6 +6,12 @@ For support you can use [the contact form](https://contact.faircode.eu/?product= ### [Rahonavis](https://en.wikipedia.org/wiki/Rahonavis) +### Next version + +* Added option to configure number of widget subject lines +* Small improvements and minor bug fixes +* Updated [translations](https://crowdin.com/project/open-source-email) + ### 1.2054 - 2023-03-14 * Added rule action option to delete keywords diff --git a/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java b/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java index 18d0874a79..eb62adc855 100644 --- a/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java +++ b/app/src/main/java/eu/faircode/email/ActivityWidgetUnified.java @@ -47,6 +47,7 @@ import com.flask.colorpicker.ColorPickerView; import com.flask.colorpicker.builder.ColorPickerClickListener; import com.flask.colorpicker.builder.ColorPickerDialogBuilder; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -67,6 +68,8 @@ public class ActivityWidgetUnified extends ActivityBase { private CheckBox cbSeparatorLines; private Spinner spFontSize; private Spinner spPadding; + private Spinner spSubjectLines; + private TextView tvSubjectLinesHint; private CheckBox cbAvatars; private CheckBox cbRefresh; private CheckBox cbCompose; @@ -79,6 +82,8 @@ public class ActivityWidgetUnified extends ActivityBase { private ArrayAdapter adapterFontSize; private ArrayAdapter adapterPadding; + private NumberFormat NF = NumberFormat.getNumberInstance(); + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -105,9 +110,10 @@ public class ActivityWidgetUnified extends ActivityBase { boolean separators = prefs.getBoolean("widget." + appWidgetId + ".separators", true); int font = prefs.getInt("widget." + appWidgetId + ".font", 0); int padding = prefs.getInt("widget." + appWidgetId + ".padding", 0); + int subject_lines = prefs.getInt("widget." + appWidgetId + ".subject_lines", 1); + boolean avatars = prefs.getBoolean("widget." + appWidgetId + ".avatars", false); boolean refresh = prefs.getBoolean("widget." + appWidgetId + ".refresh", false); boolean compose = prefs.getBoolean("widget." + appWidgetId + ".compose", false); - boolean avatars = prefs.getBoolean("widget." + appWidgetId + ".avatars", false); daynight = daynight && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S); @@ -127,6 +133,8 @@ public class ActivityWidgetUnified extends ActivityBase { cbSeparatorLines = findViewById(R.id.cbSeparatorLines); spFontSize = findViewById(R.id.spFontSize); spPadding = findViewById(R.id.spPadding); + spSubjectLines = findViewById(R.id.spSubjectLines); + tvSubjectLinesHint = findViewById(R.id.tvSubjectLinesHint); cbAvatars = findViewById(R.id.cbAvatars); cbRefresh = findViewById(R.id.cbRefresh); cbCompose = findViewById(R.id.cbCompose); @@ -268,6 +276,7 @@ public class ActivityWidgetUnified extends ActivityBase { editor.putBoolean("widget." + appWidgetId + ".separators", cbSeparatorLines.isChecked()); editor.putInt("widget." + appWidgetId + ".font", tinyOut(font)); editor.putInt("widget." + appWidgetId + ".padding", tinyOut(padding)); + editor.putInt("widget." + appWidgetId + ".subject_lines", spSubjectLines.getSelectedItemPosition() + 1); editor.putBoolean("widget." + appWidgetId + ".avatars", cbAvatars.isChecked()); editor.putBoolean("widget." + appWidgetId + ".refresh", cbRefresh.isChecked()); editor.putBoolean("widget." + appWidgetId + ".compose", cbCompose.isChecked()); @@ -399,6 +408,8 @@ public class ActivityWidgetUnified extends ActivityBase { spFontSize.setSelection(tinyIn(font)); spPadding.setSelection(tinyIn(padding)); cbAvatars.setChecked(avatars); + spSubjectLines.setSelection(subject_lines - 1); + tvSubjectLinesHint.setText(getString(R.string.title_advanced_preview_lines_hint, NF.format(HtmlHelper.PREVIEW_SIZE))); cbRefresh.setChecked(refresh); cbCompose.setChecked(compose); diff --git a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java index a37d8cd99f..b96ab14598 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnifiedRemoteViewsFactory.java @@ -66,6 +66,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot private int font; private int padding; private boolean avatars; + private int subject_lines; private boolean prefer_contact; private boolean only_contact; private boolean distinguish_contacts; @@ -116,6 +117,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot font = prefs.getInt("widget." + appWidgetId + ".font", 0); padding = prefs.getInt("widget." + appWidgetId + ".padding", 0); avatars = prefs.getBoolean("widget." + appWidgetId + ".avatars", false); + subject_lines = prefs.getInt("widget." + appWidgetId + ".subject_lines", 1); prefer_contact = prefs.getBoolean("prefer_contact", false); only_contact = prefs.getBoolean("only_contact", false); @@ -279,6 +281,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot views.setInt(R.id.separator, "setBackgroundColor", colorSeparator); } + views.setInt(idSubject, "setMaxLines", subject_lines); + views.setViewVisibility(R.id.separator, separators ? View.VISIBLE : View.GONE); views.setViewVisibility(idAccount, account < 0 && !allColors ? View.VISIBLE : View.GONE); diff --git a/app/src/main/res/layout/activity_widget_unified.xml b/app/src/main/res/layout/activity_widget_unified.xml index 58c66bf0cc..8c690e89d0 100644 --- a/app/src/main/res/layout/activity_widget_unified.xml +++ b/app/src/main/res/layout/activity_widget_unified.xml @@ -169,6 +169,40 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvPadding" /> + + + + + + + app:layout_constraintTop_toBottomOf="@id/tvSubjectLinesHint" /> Show separator lines Semi transparent background Show unread count at the top + Maximum number of subject lines Show contact avatars Show refresh messages button Show compose new message button diff --git a/metadata/en-US/changelogs/2054.txt b/metadata/en-US/changelogs/2054.txt index b990558d54..7aba28ad1b 100644 --- a/metadata/en-US/changelogs/2054.txt +++ b/metadata/en-US/changelogs/2054.txt @@ -6,6 +6,12 @@ For support you can use the contact form. Rahonavis +Next version + +* Added option to configure number of widget subject lines +* Small improvements and minor bug fixes +* Updated translations + 1.2054 - 2023-03-14 * Added rule action option to delete keywords