Added optional background color instead of flag color

pull/162/head
M66B 6 years ago
parent ff2a4201c2
commit 0e8860ae1e

@ -96,6 +96,7 @@ import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.FileProvider;
import androidx.core.graphics.ColorUtils;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
@ -194,6 +195,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private String subject_ellipsize;
private boolean flags;
private boolean flags_background;
private boolean preview;
private boolean preview_italic;
private boolean attachments_alt;
@ -240,7 +242,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
View.OnLongClickListener,
View.OnTouchListener,
BottomNavigationView.OnNavigationItemSelectedListener {
private View card;
private ViewCardOptional card;
private View view;
private View vwColor;
@ -951,11 +953,26 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void bindFlagged(TupleMessageEx message) {
boolean pro = ActivityBilling.isPro(context);
if (!pro)
message.color = null;
int flagged = (message.count - message.unflagged);
ibFlagged.setImageResource(flagged > 0 ? R.drawable.baseline_star_24 : R.drawable.baseline_star_border_24);
ibFlagged.setImageTintList(ColorStateList.valueOf(flagged > 0
? message.color == null || !ActivityBilling.isPro(context)
? colorAccent : message.color : textColorSecondary));
if (flags_background) {
if (message.color == null)
card.setCardBackgroundColor(Color.TRANSPARENT);
else
card.setCardBackgroundColor(ColorUtils.setAlphaComponent(message.color, 127));
} else {
card.setCardBackgroundColor(Color.TRANSPARENT);
if (message.color == null)
ibFlagged.setImageTintList(ColorStateList.valueOf(flagged > 0 ? colorAccent : textColorSecondary));
else
ibFlagged.setImageTintList(ColorStateList.valueOf(message.color));
}
ibFlagged.setEnabled(message.uid != null);
if (flags)
@ -3195,6 +3212,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.subject_italic = prefs.getBoolean("subject_italic", true);
this.subject_ellipsize = prefs.getString("subject_ellipsize", "middle");
this.flags = prefs.getBoolean("flags", true);
this.flags_background = prefs.getBoolean("flags_background", false);
this.preview = prefs.getBoolean("preview", false);
this.preview_italic = prefs.getBoolean("preview_italic", true);
this.attachments_alt = prefs.getBoolean("attachments_alt", false);

@ -40,7 +40,8 @@ public class FragmentOptions extends FragmentBase {
static String[] OPTIONS_RESTART = new String[]{
"subscriptions",
"startup", "cards", "date", "threading", "highlight_unread", "avatars", "generated_icons", "identicons", "circular",
"name_email", "authentication", "subject_top", "subject_italic", "subject_ellipsize", "flags", "preview", "preview_italic",
"name_email", "authentication", "subject_top", "subject_italic", "subject_ellipsize",
"flags", "flags_background", "preview", "preview_italic",
"addresses", "attachments_alt",
"contrast", "monospaced", "text_color",
"inline_images", "collapse_quotes", "autocontent", "seekbar", "actionbar",

@ -59,6 +59,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swSubjectItalic;
private Spinner spSubjectEllipsize;
private SwitchCompat swFlags;
private SwitchCompat swFlagsBackground;
private SwitchCompat swPreview;
private SwitchCompat swPreviewItalic;
private SwitchCompat swAddresses;
@ -77,7 +78,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"theme", "startup", "cards", "date", "threading", "highlight_unread",
"avatars", "generated_icons", "identicons", "circular", "name_email",
"authentication", "subject_top", "subject_italic", "subject_ellipsize",
"flags", "preview", "preview_italic", "addresses", "attachments_alt",
"flags", "flags_background", "preview", "preview_italic", "addresses", "attachments_alt",
"contrast", "monospaced", "text_color",
"inline_images", "collapse_quotes", "autocontent", "seekbar", "actionbar",
};
@ -108,6 +109,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swSubjectItalic = view.findViewById(R.id.swSubjectItalic);
spSubjectEllipsize = view.findViewById(R.id.spSubjectEllipsize);
swFlags = view.findViewById(R.id.swFlags);
swFlagsBackground = view.findViewById(R.id.swFlagsBackground);
swPreview = view.findViewById(R.id.swPreview);
swPreviewItalic = view.findViewById(R.id.swPreviewItalic);
swAddresses = view.findViewById(R.id.swAddresses);
@ -257,6 +259,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swFlagsBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("flags_background", checked).apply();
}
});
swPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -419,6 +428,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
swFlags.setChecked(prefs.getBoolean("flags", true));
swFlagsBackground.setChecked(prefs.getBoolean("flags_background", false));
swPreview.setChecked(prefs.getBoolean("preview", false));
swPreviewItalic.setChecked(prefs.getBoolean("preview_italic", true));
swPreviewItalic.setEnabled(swPreview.isChecked());

@ -50,9 +50,9 @@ public class ViewCardOptional extends CardView {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean cards = prefs.getBoolean("cards", true);
boolean compact = prefs.getBoolean("compact", false);
if (cards) {
int dp6 = Helper.dp2pixels(getContext(), 6);
int color = Helper.resolveColor(getContext(), R.attr.colorCardBackground);
FrameLayout.LayoutParams lparam = (FrameLayout.LayoutParams) getLayoutParams();
lparam.setMargins(dp6, compact ? 0 : dp6, dp6, dp6);
@ -60,13 +60,21 @@ public class ViewCardOptional extends CardView {
setRadius(dp6);
setElevation(compact ? dp6 / 2f : dp6);
setCardBackgroundColor(color);
getChildAt(0).setPadding(dp6, dp6, dp6, dp6);
} else {
setRadius(0);
setElevation(0);
setCardBackgroundColor(Color.TRANSPARENT);
}
}
@Override
public void setCardBackgroundColor(int color) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean cards = prefs.getBoolean("cards", true);
if (cards && color == Color.TRANSPARENT)
color = Helper.resolveColor(getContext(), R.attr.colorCardBackground);
super.setCardBackgroundColor(color);
}
}

@ -267,6 +267,17 @@
app:layout_constraintTop_toBottomOf="@id/spSubjectEllipsize"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swFlagsBackground"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_flags_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swFlags"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPreview"
android:layout_width="0dp"
@ -275,7 +286,7 @@
android:text="@string/title_advanced_preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swFlags"
app:layout_constraintTop_toBottomOf="@id/swFlagsBackground"
app:switchPadding="12dp" />
<TextView

@ -251,6 +251,7 @@
<string name="title_advanced_subject_italic">Show subject in italics</string>
<string name="title_advanced_subject_elipsed">When needed, shorten the subject</string>
<string name="title_advanced_flags">Show stars</string>
<string name="title_advanced_flags_background">Show colored background instead of colored stars</string>
<string name="title_advanced_preview">Show message preview</string>
<string name="title_advanced_preview_italic">Show message preview in italics</string>
<string name="title_advanced_addresses">Show address details by default</string>

Loading…
Cancel
Save