From 3453080f7f86c26405d9ed0e0931be79defb351b Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 3 Feb 2022 09:09:39 +0100 Subject: [PATCH] Added option to change message column width --- CHANGELOG.md | 5 +++ app/src/main/assets/CHANGELOG.md | 5 +++ .../java/eu/faircode/email/ActivityView.java | 30 +++++++++++------ .../eu/faircode/email/FragmentOptions.java | 1 + .../email/FragmentOptionsDisplay.java | 33 ++++++++++++++++++- .../res/layout/fragment_options_display.xml | 25 +++++++++++++- app/src/main/res/values/strings.xml | 1 + metadata/en-US/changelogs/1830.txt | 5 +++ 8 files changed, 93 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 638fdc2384..a1607125bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ 🌎 [Google Translate](https://translate.google.com/translate?sl=en&u=https://github.com/M66B/FairEmail/blob/master/CHANGELOG.md) +### Next version + +* Added slider to change message column width +* Small improvements and minor bug fixes + ### [Epidexipteryx](https://en.wikipedia.org/wiki/Epidexipteryx) ### 1.1830 - 2022-02-02 diff --git a/app/src/main/assets/CHANGELOG.md b/app/src/main/assets/CHANGELOG.md index 638fdc2384..a1607125bd 100644 --- a/app/src/main/assets/CHANGELOG.md +++ b/app/src/main/assets/CHANGELOG.md @@ -2,6 +2,11 @@ 🌎 [Google Translate](https://translate.google.com/translate?sl=en&u=https://github.com/M66B/FairEmail/blob/master/CHANGELOG.md) +### Next version + +* Added slider to change message column width +* Small improvements and minor bug fixes + ### [Epidexipteryx](https://en.wikipedia.org/wiki/Epidexipteryx) ### 1.1830 - 2022-02-02 diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index c7ee947bd6..ac2c809f57 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -220,6 +220,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB Log.i("Orientation=" + config.orientation + " layout=" + layout + " portrait rows=" + portrait2 + " cols=" + portrait2c + " min=" + portrait_min_size + " landscape cols=" + landscape + " min=" + landscape); + boolean duo = Helper.isSurfaceDuo(); // 1=small, 2=normal, 3=large, 4=xlarge if (layout > 0) @@ -244,17 +245,26 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB content_separator = findViewById(R.id.content_separator); content_pane = findViewById(R.id.content_pane); - // Special: Surface Duo - boolean duo = Helper.isSurfaceDuo(); - if (duo && content_pane != null) { - View content_frame = findViewById(R.id.content_frame); - ViewGroup.LayoutParams lparam = content_frame.getLayoutParams(); - if (lparam instanceof LinearLayout.LayoutParams) { - ((LinearLayout.LayoutParams) lparam).weight = 1; // 50/50 - content_frame.setLayoutParams(lparam); + if (content_pane != null) { + // Special: Surface Duo + if (duo) { + View content_frame = findViewById(R.id.content_frame); + ViewGroup.LayoutParams lparam = content_frame.getLayoutParams(); + if (lparam instanceof LinearLayout.LayoutParams) { + ((LinearLayout.LayoutParams) lparam).weight = 1; // 50/50 + content_frame.setLayoutParams(lparam); + } + // https://docs.microsoft.com/en-us/dual-screen/android/duo-dimensions + content_separator.getLayoutParams().width = Helper.dp2pixels(this, 34); + } else { + int column_width = prefs.getInt("column_width", 67); + ViewGroup.LayoutParams lparam = content_pane.getLayoutParams(); + if (lparam instanceof LinearLayout.LayoutParams) { + ((LinearLayout.LayoutParams) lparam).weight = + (float) (100 - column_width) / column_width * 2; + content_pane.setLayoutParams(lparam); + } } - // https://docs.microsoft.com/en-us/dual-screen/android/duo-dimensions - content_separator.getLayoutParams().width = Helper.dp2pixels(this, 34); } owner = new TwoStateOwner(this, "drawer"); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index e69474d5b8..f9ec7cfb62 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -133,6 +133,7 @@ public class FragmentOptions extends FragmentBase { "send_pending", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_highlight", "portrait2", "portrait2c", "portrait_min_size", "landscape", "landscape_min_size", + "column_width", "nav_count", "nav_unseen_drafts", "navbar_colorize", "indentation", "group_category", "date", "date_fixed", "date_bold", "threading", "threading_unread", "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 234fece9e7..b71e6ecb0d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -75,6 +75,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swLandscape; private Spinner spLandscapeMinSize; private SwitchCompat swClosePane; + private TextView tvColumnWidth; + private SeekBar sbColumnWidth; private SwitchCompat swNavOptions; private SwitchCompat swNavMessageCount; private SwitchCompat swNavUnseenDrafts; @@ -168,7 +170,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private final static String[] RESET_OPTIONS = new String[]{ "theme", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_highlight", "group_category", "date", "date_fixed", "date_bold", - "portrait2", "portrait2c", "landscape", "close_pane", + "portrait2", "portrait2c", "landscape", "close_pane", "column_width", "nav_options", "nav_count", "nav_unseen_drafts", "navbar_colorize", "threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color", "highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide", @@ -213,6 +215,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swLandscape = view.findViewById(R.id.swLandscape); spLandscapeMinSize = view.findViewById(R.id.spLandscapeMinSize); swClosePane = view.findViewById(R.id.swClosePane); + tvColumnWidth = view.findViewById(R.id.tvColumnWidth); + sbColumnWidth = view.findViewById(R.id.sbColumnWidth); swNavOptions = view.findViewById(R.id.swNavOptions); swNavMessageCount = view.findViewById(R.id.swNavMessageCount); swNavUnseenDrafts = view.findViewById(R.id.swNavUnseenDrafts); @@ -458,6 +462,28 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); + sbColumnWidth.setEnabled(!Helper.isSurfaceDuo()); + sbColumnWidth.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (progress < 10) + progress = 10; + if (progress > 90) + progress = 90; + prefs.edit().putInt("column_width", progress).apply(); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + // Do nothing + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + // Do nothing + } + }); + swNavOptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -1169,6 +1195,11 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swLandscape.setChecked(prefs.getBoolean("landscape", true)); spLandscapeMinSize.setSelection(prefs.getInt("landscape_min_size", 0)); swClosePane.setChecked(prefs.getBoolean("close_pane", !Helper.isSurfaceDuo())); + + int column_width = prefs.getInt("column_width", 67); + tvColumnWidth.setText(getString(R.string.title_advanced_column_width, NF.format(column_width))); + sbColumnWidth.setProgress(column_width); + swNavOptions.setChecked(prefs.getBoolean("nav_options", true)); swNavMessageCount.setChecked(prefs.getBoolean("nav_count", false)); swNavUnseenDrafts.setChecked(prefs.getBoolean("nav_unseen_drafts", false)); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index cf9d4215f4..7d3172f29e 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -433,6 +433,29 @@ app:layout_constraintTop_toBottomOf="@id/tvLandscapeSplitMinHint" app:switchPadding="12dp" /> + + + + Use two columns Minimum screen size for splitting the screen Collapse row or column when closing a conversation + Message column width: %1$s %% Show navigation menu options Pin navigation menu Hide navigation menu options? diff --git a/metadata/en-US/changelogs/1830.txt b/metadata/en-US/changelogs/1830.txt index 638fdc2384..a1607125bd 100644 --- a/metadata/en-US/changelogs/1830.txt +++ b/metadata/en-US/changelogs/1830.txt @@ -2,6 +2,11 @@ 🌎 [Google Translate](https://translate.google.com/translate?sl=en&u=https://github.com/M66B/FairEmail/blob/master/CHANGELOG.md) +### Next version + +* Added slider to change message column width +* Small improvements and minor bug fixes + ### [Epidexipteryx](https://en.wikipedia.org/wiki/Epidexipteryx) ### 1.1830 - 2022-02-02