Added option to disable auto expanding

pull/147/head
M66B 7 years ago
parent d0d030641b
commit afa16f2f9a

@ -116,6 +116,7 @@ public class FragmentMessages extends FragmentBase {
private boolean threading;
private boolean pull;
private boolean actionbar;
private boolean autoexpand;
private boolean autoclose;
private boolean autonext;
private boolean addresses;
@ -133,7 +134,7 @@ public class FragmentMessages extends FragmentBase {
private Long next = null;
private Long closeNext = null;
private int autoCloseCount = 0;
private boolean autoExpand = true;
private boolean autoExpanded = true;
private Map<String, List<Long>> values = new HashMap<>();
private LongSparseArray<Spanned> bodies = new LongSparseArray<>();
private LongSparseArray<TupleAccountSwipes> accountSwipes = new LongSparseArray<>();
@ -189,6 +190,7 @@ public class FragmentMessages extends FragmentBase {
threading = prefs.getBoolean("threading", true);
actionbar = prefs.getBoolean("actionbar", true);
autoexpand = prefs.getBoolean("autoexpand", true);
autoclose = prefs.getBoolean("autoclose", true);
autonext = prefs.getBoolean("autonext", false);
addresses = prefs.getBoolean("addresses", true);
@ -1347,7 +1349,7 @@ public class FragmentMessages extends FragmentBase {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("autoExpand", autoExpand);
outState.putBoolean("autoExpanded", autoExpanded);
outState.putInt("autoCloseCount", autoCloseCount);
outState.putStringArray("values", values.keySet().toArray(new String[0]));
@ -1363,7 +1365,7 @@ public class FragmentMessages extends FragmentBase {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) {
autoExpand = savedInstanceState.getBoolean("autoExpand");
autoExpanded = savedInstanceState.getBoolean("autoExpanded");
autoCloseCount = savedInstanceState.getInt("autoCloseCount");
String[] names = savedInstanceState.getStringArray("values");
@ -1931,8 +1933,8 @@ public class FragmentMessages extends FragmentBase {
}
}
if (autoExpand) {
autoExpand = false;
if (autoExpanded) {
autoExpanded = false;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
long download = prefs.getInt("download", 32768);
@ -1972,21 +1974,22 @@ public class FragmentMessages extends FragmentBase {
// - single, non archived/trashed/sent message
// - one unread, non archived/trashed/sent message in conversation
// - sole message
TupleMessageEx expand = null;
if (count == 1)
expand = single;
else if (unseen == 1)
expand = see;
else if (messages.size() == 1)
expand = messages.get(0);
if (expand != null &&
(expand.content || !metered || (expand.size != null && expand.size < download))) {
if (!values.containsKey("expanded"))
values.put("expanded", new ArrayList<Long>());
values.get("expanded").add(expand.id);
handleExpand(expand.id);
if (autoexpand) {
TupleMessageEx expand = null;
if (count == 1)
expand = single;
else if (unseen == 1)
expand = see;
else if (messages.size() == 1)
expand = messages.get(0);
if (expand != null &&
(expand.content || !metered || (expand.size != null && expand.size < download))) {
if (!values.containsKey("expanded"))
values.put("expanded", new ArrayList<Long>());
values.get("expanded").add(expand.id);
handleExpand(expand.id);
}
}
} else {
if (autoCloseCount > 0 && (autoclose || autonext)) {

@ -70,9 +70,10 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private SwitchCompat swPreview;
private SwitchCompat swAddresses;
private SwitchCompat swImages;
private SwitchCompat swActionbar;
private SwitchCompat swPull;
private SwitchCompat swActionbar;
private SwitchCompat swAutoExpand;
private SwitchCompat swAutoClose;
private SwitchCompat swAutoNext;
private SwitchCompat swAutoRead;
@ -90,20 +91,20 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private Group grpNotification;
static String[] OPTIONS_RESTART = new String[]{
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages",
"pull", "actionbar", "autoclose", "autonext", "debug"
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages", "actionbar",
"pull", "autoexpand", "autoclose", "autonext",
"debug"
};
private final static String[] ADVANCED_OPTIONS = new String[]{
"enabled", "updates",
"metered", "download",
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses",
"pull", "actionbar", "autoclose", "autonext",
"autoread", "collapse", "automove", "sender", "autoresize", "autosend",
"light", "sound", "debug",
"first", "why", "last_update_check",
"app_support", "message_swipe", "message_select",
"folder_actions", "folder_sync",
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages", "actionbar",
"pull", "autoexpand", "autoclose", "autonext", "autoread", "collapse", "automove", "sender", "autoresize", "autosend",
"light", "sound",
"debug",
"first", "why", "last_update_check", "app_support", "message_swipe", "message_select", "folder_actions", "folder_sync",
"edit_ref_confirmed", "autosend", "automove", "show_html_confirmed", "show_images_confirmed"
};
@Override
@ -130,9 +131,10 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swPreview = view.findViewById(R.id.swPreview);
swAddresses = view.findViewById(R.id.swAddresses);
swImages = view.findViewById(R.id.swImages);
swActionbar = view.findViewById(R.id.swActionbar);
swPull = view.findViewById(R.id.swPull);
swActionbar = view.findViewById(R.id.swActionbar);
swAutoExpand = view.findViewById(R.id.swAutoExpand);
swAutoClose = view.findViewById(R.id.swAutoClose);
swAutoNext = view.findViewById(R.id.swAutoNext);
swAutoRead = view.findViewById(R.id.swAutoRead);
@ -273,6 +275,14 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
}
});
swActionbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("actionbar", checked).apply();
}
});
swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -280,10 +290,10 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
}
});
swActionbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
swAutoExpand.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("actionbar", checked).apply();
prefs.edit().putBoolean("autoexpand", checked).apply();
}
});
@ -455,9 +465,10 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swPreview.setChecked(prefs.getBoolean("preview", false));
swAddresses.setChecked(prefs.getBoolean("addresses", true));
swImages.setChecked(prefs.getBoolean("autoimages", false));
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
swPull.setChecked(prefs.getBoolean("pull", true));
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true));
swAutoClose.setChecked(prefs.getBoolean("autoclose", true));
swAutoNext.setChecked(prefs.getBoolean("autonext", false));
swAutoNext.setEnabled(!swAutoClose.isChecked());

@ -361,6 +361,31 @@
app:layout_constraintTop_toBottomOf="@id/vSeparatorBehavior"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoExpand"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_autoexpand"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPull"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvAutoExpandHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_autoexpand_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/swAutoExpand" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoClose"
android:layout_width="match_parent"
@ -370,11 +395,11 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_autoclose"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPull"
app:layout_constraintTop_toBottomOf="@id/tvAutoExpandHint"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvAutocloseHint"
android:id="@+id/tvAutoCloseHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
@ -395,7 +420,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_autonext"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAutocloseHint"
app:layout_constraintTop_toBottomOf="@id/tvAutoCloseHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -158,6 +158,7 @@
<string name="title_advanced_sound">Select notification sound</string>
<string name="title_advanced_pull_refresh">Pull down to refresh</string>
<string name="title_advanced_autoexpand">Automatically expand messages</string>
<string name="title_advanced_autoclose">Automatically close conversations</string>
<string name="title_advanced_autonext">Automatically go to next conversation on close conversation</string>
<string name="title_advanced_autoread">Automatically mark messages read on moving messages</string>
@ -177,7 +178,8 @@
<string name="title_advanced_unified_hint">Show unified inbox folders or unified inbox messages</string>
<string name="title_advanced_threading_hint">Group messages related to each other</string>
<string name="title_advanced_preview_hint">Only available when message text was downloaded</string>
<string name="title_advanced_autoclose_hint">Automatically close conversation threads when all messages are archived, sent or trashed</string>
<string name="title_advanced_autoexpand_hint">Automatically open message when there is just one message or just one unread message in a conversation</string>
<string name="title_advanced_autoclose_hint">Automatically close conversations when all messages are archived, sent or trashed</string>
<string name="title_advanced_sender_hint">Most providers do not allow modified sender addresses</string>
<string name="title_select">Select &#8230;</string>

Loading…
Cancel
Save