Added option for two columns in portrait mode

This commit is contained in:
M66B 2021-08-10 08:55:34 +02:00
parent 0dcbe6430d
commit 73e824c3ec
5 changed files with 48 additions and 8 deletions

View File

@ -177,16 +177,18 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Configuration config = getResources().getConfiguration();
final boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
final boolean portrait2 = prefs.getBoolean("portrait2", false);
final boolean portrait2c = prefs.getBoolean("portrait2c", false);
final boolean portrait3 = prefs.getBoolean("portrait3", false);
final boolean landscape = prefs.getBoolean("landscape", true);
final boolean landscape3 = prefs.getBoolean("landscape3", true);
Log.i("Orientation=" + config.orientation +
" normal=" + normal +
" portrait=" + portrait2 + "/" + portrait3 +
" landscape=" + landscape + "/" + landscape3);
Log.i("Orientation=" + config.orientation + " normal=" + normal +
" portrait 2=" + portrait2 + " 2c=" + portrait2c + " nav=" + portrait3 +
" landscape 2=" + landscape + " nav=" + landscape3);
int viewId;
if (config.orientation == ORIENTATION_PORTRAIT || !normal || !landscape)
if (config.orientation == ORIENTATION_PORTRAIT && portrait2c)
viewId = R.layout.activity_view_landscape_split;
else if (config.orientation == ORIENTATION_PORTRAIT || !(normal && landscape))
viewId = (portrait2 ? R.layout.activity_view_portrait_split : R.layout.activity_view_portrait);
else
viewId = R.layout.activity_view_landscape_split;

View File

@ -108,7 +108,7 @@ public class FragmentOptions extends FragmentBase {
"subscriptions",
"check_authentication", "check_reply_domain", "check_mx", "check_blocklist",
"send_pending",
"portrait2", "portrait3", "landscape", "landscape3", "nav_count", "startup",
"portrait2", "portrait2c", "portrait3", "landscape", "landscape3", "nav_count", "startup",
"cards", "beige", "tabular_card_bg", "shadow_unread",
"indentation", "date", "date_bold", "threading", "threading_unread",
"highlight_unread", "highlight_color", "color_stripe",

View File

@ -68,6 +68,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swDateBold;
private SwitchCompat swNavBarColorize;
private SwitchCompat swPortrait2;
private SwitchCompat swPortrait2c;
private SwitchCompat swPortrait3;
private SwitchCompat swLandscape;
private SwitchCompat swLandscape3;
@ -156,7 +157,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",
"date", "date_bold", "navbar_colorize",
"portrait2", "portrait3", "landscape", "landscape3", "nav_count",
"portrait2", "portrait2c", "portrait3", "landscape", "landscape3", "nav_count",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color",
"highlight_unread", "highlight_color", "color_stripe",
"avatars", "bimi", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
@ -192,6 +193,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDateBold = view.findViewById(R.id.swDateBold);
swNavBarColorize = view.findViewById(R.id.swNavBarColorize);
swPortrait2 = view.findViewById(R.id.swPortrait2);
swPortrait2c = view.findViewById(R.id.swPortrait2c);
swPortrait3 = view.findViewById(R.id.swPortrait3);
swLandscape = view.findViewById(R.id.swLandscape);
swLandscape3 = view.findViewById(R.id.swLandscape3);
@ -359,6 +361,17 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("portrait2", checked).apply();
if (checked)
prefs.edit().putBoolean("portrait2c", false).apply();
}
});
swPortrait2c.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("portrait2c", checked).apply();
if (checked)
prefs.edit().putBoolean("portrait2", false).apply();
}
});
@ -1033,6 +1046,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDateBold.setEnabled(swDate.isChecked());
swNavBarColorize.setChecked(prefs.getBoolean("navbar_colorize", false));
swPortrait2.setChecked(prefs.getBoolean("portrait2", false));
swPortrait2c.setChecked(prefs.getBoolean("portrait2c", false) && !swPortrait2.isChecked());
swPortrait3.setChecked(prefs.getBoolean("portrait3", false));
swPortrait3.setEnabled(normal);
swLandscape.setChecked(prefs.getBoolean("landscape", true));

View File

@ -254,6 +254,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPortrait2" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPortrait2c"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_portrait2c"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPortrait2Hint"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvPortrait2cHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_split_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPortrait2c" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPortrait3"
android:layout_width="0dp"
@ -262,7 +285,7 @@
android:text="@string/title_advanced_portrait3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPortrait2Hint"
app:layout_constraintTop_toBottomOf="@id/tvPortrait2cHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -396,6 +396,7 @@
<string name="title_advanced_caption_debug" translatable="false">Debug</string>
<string name="title_advanced_portrait2">Use two rows in portrait mode</string>
<string name="title_advanced_portrait2c">Use two columns in portrait mode</string>
<string name="title_advanced_portrait3">Show navigation menu in portrait mode by default</string>
<string name="title_advanced_landscape">Use two columns in landscape mode</string>
<string name="title_advanced_landscape3">Show navigation menu in landscape mode by default</string>