Added option to disable indentation

This commit is contained in:
M66B
2019-10-12 19:40:30 +02:00
parent a71f18b020
commit c2dcb86dfb
5 changed files with 29 additions and 4 deletions

View File

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

View File

@@ -48,6 +48,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swCards;
private SwitchCompat swDate;
private SwitchCompat swThreading;
private SwitchCompat swIndentation;
private SwitchCompat swHighlightUnread;
private SwitchCompat swAvatars;
private SwitchCompat swGeneratedIcons;
@@ -75,7 +76,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swActionbar;
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "cards", "date", "threading", "highlight_unread",
"theme", "startup", "cards", "date", "threading", "indentation", "highlight_unread",
"avatars", "generated_icons", "identicons", "circular", "name_email", "distinguish_contacts", "authentication",
"subject_top", "subject_italic", "subject_ellipsize",
"flags", "flags_background", "preview", "preview_italic", "addresses", "attachments_alt",
@@ -98,6 +99,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swCards = view.findViewById(R.id.swCards);
swDate = view.findViewById(R.id.swDate);
swThreading = view.findViewById(R.id.swThreading);
swIndentation = view.findViewById(R.id.swIndentation);
swHighlightUnread = view.findViewById(R.id.swHighlightUnread);
swAvatars = view.findViewById(R.id.swAvatars);
swGeneratedIcons = view.findViewById(R.id.swGeneratedIcons);
@@ -171,6 +173,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swIndentation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("indentation", checked).apply();
}
});
swHighlightUnread.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -410,6 +419,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swCards.setChecked(prefs.getBoolean("cards", true));
swDate.setChecked(prefs.getBoolean("date", true));
swThreading.setChecked(prefs.getBoolean("threading", true));
swIndentation.setChecked(prefs.getBoolean("indentation", true));
swHighlightUnread.setChecked(prefs.getBoolean("highlight_unread", false));
swAvatars.setChecked(prefs.getBoolean("avatars", true));
swGeneratedIcons.setChecked(prefs.getBoolean("generated_icons", true));

View File

@@ -34,6 +34,7 @@ public class ViewCardOptional extends CardView {
private boolean cards;
private boolean compact;
private boolean threading;
private boolean indentation;
private int margin;
private int ident;
private Integer color = null;
@@ -58,6 +59,7 @@ public class ViewCardOptional extends CardView {
cards = prefs.getBoolean("cards", true);
compact = prefs.getBoolean("compact", false);
threading = prefs.getBoolean("threading", true);
indentation = prefs.getBoolean("indentation", true);
margin = Helper.dp2pixels(context, compact ? 3 : 6);
ident = Helper.dp2pixels(context, 12 + (compact ? 3 : 6));
@@ -94,7 +96,7 @@ public class ViewCardOptional extends CardView {
}
public void setOutgoing(boolean outgoing) {
if (cards && threading) {
if (cards && threading && indentation) {
ViewGroup.MarginLayoutParams lparam = (ViewGroup.MarginLayoutParams) getLayoutParams();
lparam.setMarginStart(outgoing ? margin : ident);
lparam.setMarginEnd(outgoing ? ident : margin);