Added option to disable two column mode

This commit is contained in:
M66B 2019-10-19 13:51:16 +02:00
parent 0a01551fa3
commit 47bf65194c
7 changed files with 43 additions and 4 deletions

View File

@ -78,6 +78,8 @@ import java.util.List;
import javax.net.ssl.HttpsURLConnection;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
public class ActivityView extends ActivityBilling implements FragmentManager.OnBackStackChangedListener {
private String startup;
@ -133,7 +135,15 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
startup = prefs.getString("startup", "unified");
view = LayoutInflater.from(this).inflate(R.layout.activity_view, null);
Configuration config = getResources().getConfiguration();
boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
boolean landscape = prefs.getBoolean("landscape", true);
Log.i("Orientation=" + config.orientation + " normal=" + normal + " landscape=" + landscape);
view = LayoutInflater.from(this).inflate(
config.orientation == ORIENTATION_PORTRAIT || !normal || !landscape
? R.layout.activity_view_portrait
: R.layout.activity_view_landscape, null);
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

View File

@ -39,7 +39,7 @@ public class FragmentOptions extends FragmentBase {
static String[] OPTIONS_RESTART = new String[]{
"subscriptions",
"startup", "cards", "date", "threading", "indentation", "highlight_unread",
"landscape", "startup", "cards", "date", "threading", "indentation", "highlight_unread",
"avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"name_email", "distinguish_contacts", "authentication",
"subject_top", "subject_italic", "subject_ellipsize",

View File

@ -22,6 +22,7 @@ package eu.faircode.email;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -48,6 +49,7 @@ import androidx.preference.PreferenceManager;
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private Button btnTheme;
private SwitchCompat swLandscape;
private Spinner spStartup;
private SwitchCompat swCards;
private SwitchCompat swDate;
@ -86,7 +88,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swActionbar;
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "cards", "date", "threading", "indentation", "highlight_unread",
"theme", "landscape", "startup", "cards", "date", "threading", "indentation", "highlight_unread",
"avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
"name_email", "distinguish_contacts", "authentication",
"subject_top", "subject_italic", "subject_ellipsize",
@ -106,6 +108,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
// Get controls
btnTheme = view.findViewById(R.id.btnTheme);
swLandscape = view.findViewById(R.id.swLandscape);
spStartup = view.findViewById(R.id.spStartup);
swCards = view.findViewById(R.id.swCards);
swDate = view.findViewById(R.id.swDate);
@ -155,6 +158,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swLandscape.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("landscape", checked).apply();
}
});
spStartup.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -486,6 +496,12 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private void setOptions() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean normal = getResources().getConfiguration()
.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
swLandscape.setChecked(prefs.getBoolean("landscape", true));
swLandscape.setEnabled(normal);
String startup = prefs.getString("startup", "unified");
String[] startupValues = getResources().getStringArray(R.array.startupValues);
for (int pos = 0; pos < startupValues.length; pos++)

View File

@ -35,6 +35,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLayoutHint" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLandscape"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_landscape"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnTheme"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvStartup"
android:layout_width="0dp"
@ -45,7 +57,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnTheme" />
app:layout_constraintTop_toBottomOf="@id/swLandscape" />
<Spinner
android:id="@+id/spStartup"

View File

@ -241,6 +241,7 @@
<string name="title_advanced_rlah">Roam like at home</string>
<string name="title_advanced_manage_connectivity">Manage connectivity</string>
<string name="title_advanced_landscape">Use two columns in landscape mode</string>
<string name="title_advanced_startup">Show on start screen</string>
<string name="title_advanced_cards">Show cards</string>
<string name="title_advanced_date_header">Group by date</string>