Added account color dot option

pull/215/head
M66B 5 months ago
parent d086623dd7
commit d486080152

@ -46,6 +46,7 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.text.LineBreaker;
import android.net.Uri;
import android.os.Build;
@ -271,7 +272,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean threading_unread;
private boolean indentation;
private boolean avatars;
private boolean color_stripe;
private int account_color;
private boolean check_authentication;
private boolean native_dkim;
private boolean check_tls;
@ -364,6 +365,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private View view;
private View header;
private ImageView ivBadge;
private View vwColor;
private ImageButton ibExpander;
private ImageView ibFlagged;
@ -737,6 +739,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
view = itemView.findViewById(R.id.clItem);
header = itemView.findViewById(R.id.inHeader);
ivBadge = itemView.findViewById(R.id.ivBadge);
vwColor = itemView.findViewById(R.id.vwColor);
ibExpander = itemView.findViewById(R.id.ibExpander);
ibFlagged = itemView.findViewById(R.id.ibFlagged);
@ -772,7 +775,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvError.setAutoLinkMask(Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS);
ibError = itemView.findViewById(R.id.ibError);
if (vwColor != null)
if (account_color == 1 && vwColor != null)
vwColor.getLayoutParams().width = colorStripeWidth;
if (tvFrom != null) {
@ -1380,11 +1383,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
int colorBackground =
(message.accountColor == null || !ActivityBilling.isPro(context)
? colorSeparator : message.accountColor);
if (!Objects.equals(vwColor.getTag() == null, colorBackground)) {
if (account_color == 2)
((GradientDrawable) ivBadge.getDrawable().mutate()).setColor(colorBackground);
ivBadge.setVisibility(account_color == 2 ? View.VISIBLE : View.GONE);
if (account_color == 1 &&
!Objects.equals(vwColor.getTag() == null, colorBackground)) {
vwColor.setTag(colorBackground);
vwColor.setBackgroundColor(colorBackground);
}
vwColor.setVisibility(color_stripe ? View.VISIBLE : View.GONE);
vwColor.setVisibility(account_color == 1 ? View.VISIBLE : View.GONE);
// Expander
if (!Objects.equals(ibExpander.getTag(), expanded)) {
@ -7964,6 +7973,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean expanded = properties.getValue("expanded", message.id);
ivBadge.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
vwColor.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
if (ibExpander.getVisibility() == View.VISIBLE)
@ -8274,7 +8284,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.indentation = prefs.getBoolean("indentation", false);
this.avatars = (contacts && avatars) || (bimi || gravatars || libravatars || favicons || generated);
this.color_stripe = prefs.getBoolean("color_stripe", true);
this.account_color = prefs.getInt("account_color", 1);
this.check_authentication = prefs.getBoolean("check_authentication", true);
this.native_dkim = prefs.getBoolean("native_dkim", false);
this.check_tls = prefs.getBoolean("check_tls", true);

@ -1054,6 +1054,15 @@ public class ApplicationEx extends Application
ContactInfo.clearCache(context); // SVG scale
}
if (version < 2218) {
if (prefs.contains("color_stripe")) {
boolean color_stripe = prefs.getBoolean("color_stripe", true);
editor
.putInt("account_color", color_stripe ? 1 : 0)
.remove("color_stripe");
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)
editor.remove("background_service");

@ -149,7 +149,7 @@ public class FragmentOptions extends FragmentBase {
"hide_toolbar", "edge_to_edge", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed",
"indentation", "date", "date_week", "date_fixed", "date_bold", "date_time", "threading", "threading_unread",
"show_filtered",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
"highlight_unread", "highlight_color", "account_color", "color_stripe_wide",
"avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "generated_icons", "identicons",
"circular", "saturation", "brightness", "threshold",
"authentication", "authentication_indicator",

@ -111,7 +111,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swHighlightUnread;
private ViewButtonColor btnHighlightColor;
private SwitchCompat swColorStripe;
private Spinner spAccountColor;
private SwitchCompat swColorStripeWide;
private SwitchCompat swAvatars;
private ImageButton ibBimi;
@ -220,7 +220,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"portrait2", "portrait2c", "landscape", "close_pane", "column_width",
"hide_toolbar", "edge_to_edge", "nav_options", "nav_categories", "nav_last_sync", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "show_unexposed",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_swap", "actionbar_color",
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
"highlight_unread", "highlight_color", "account_color", "color_stripe_wide",
"avatars", "bimi", "bimi_vmc", "gravatars", "libravatars", "favicons", "favicons_partial", "favicons_manifest", "ddg_icons", "favicons_dmarc", "generated_icons", "identicons",
"circular", "saturation", "brightness", "threshold",
"email_format", "prefer_contact", "only_contact", "distinguish_contacts", "show_recipients", "reverse_addresses",
@ -294,7 +294,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swHighlightUnread = view.findViewById(R.id.swHighlightUnread);
btnHighlightColor = view.findViewById(R.id.btnHighlightColor);
swColorStripe = view.findViewById(R.id.swColorStripe);
spAccountColor = view.findViewById(R.id.spAccountColor);
swColorStripeWide = view.findViewById(R.id.swColorStripeWide);
swAvatars = view.findViewById(R.id.swAvatars);
swBimi = view.findViewById(R.id.swBimi);
@ -801,11 +801,17 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swColorStripe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
spAccountColor.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("color_stripe", checked).apply();
//swColorStripeWide.setEnabled(checked);
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
prefs.edit().putInt("account_color", position).apply();
swColorStripeWide.setEnabled(position == 1);
WidgetUnified.updateData(getContext());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("account_color").apply();
WidgetUnified.updateData(getContext());
}
});
@ -1640,9 +1646,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
btnHighlightColor.setColor(prefs.getInt("highlight_color",
Helper.resolveColor(getContext(), R.attr.colorUnreadHighlight)));
swColorStripe.setChecked(prefs.getBoolean("color_stripe", true));
spAccountColor.setSelection(prefs.getInt("account_color", 1));
swColorStripeWide.setChecked(prefs.getBoolean("color_stripe_wide", false));
//swColorStripeWide.setEnabled(swColorStripe.isChecked());
swColorStripeWide.setEnabled(spAccountColor.getSelectedItemPosition() == 1);
swAvatars.setChecked(prefs.getBoolean("avatars", true));
swBimi.setChecked(prefs.getBoolean("bimi", false));
swBimiVmc.setChecked(prefs.getBoolean("bimi_vmc", false));

@ -105,7 +105,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
threading = prefs.getBoolean("threading", true);
subject_top = prefs.getBoolean("subject_top", false);
subject_italic = prefs.getBoolean("subject_italic", true);
color_stripe = prefs.getBoolean("color_stripe", true);
color_stripe = (prefs.getInt("account_color", 1) > 0);
account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);

@ -869,28 +869,38 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swHighlightUnread" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swColorStripe"
<TextView
android:id="@+id/tvAccountColor"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_color_stripe"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_account_color"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnHighlightColor"
app:switchPadding="12dp" />
app:layout_constraintTop_toBottomOf="@id/btnHighlightColor" />
<eu.faircode.email.SpinnerEx
android:id="@+id/spAccountColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:entries="@array/accountColorNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAccountColor" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swColorStripeWide"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginStart="24dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_color_stripe_wide"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swColorStripe"
app:layout_constraintTop_toBottomOf="@id/spAccountColor"
app:switchPadding="12dp" />
<View

@ -4,13 +4,21 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="@+id/parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/badge" />
<eu.faircode.email.ViewStripe
android:id="@+id/vwColor"
android:layout_width="6dp"
android:layout_height="0dp"
android:background="?attr/colorAccent"
app:layout_constraintBottom_toBottomOf="@+id/paddingBottom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivBadge"
app:layout_constraintTop_toTopOf="parent" />
<View

@ -3,13 +3,21 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="@+id/parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/badge" />
<eu.faircode.email.ViewStripe
android:id="@+id/vwColor"
android:layout_width="6dp"
android:layout_height="0dp"
android:background="?attr/colorAccent"
app:layout_constraintBottom_toBottomOf="@+id/paddingBottom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivBadge"
app:layout_constraintTop_toTopOf="parent" />
<View

@ -609,7 +609,7 @@
<string name="title_advanced_threading_unread">Show number of unread messages in conversations</string>
<string name="title_advanced_indentation">Left/right indent received/sent messages in conversations</string>
<string name="title_advanced_highlight_unread">Highlight unread messages</string>
<string name="title_advanced_color_stripe">Show color stripe</string>
<string name="title_advanced_account_color">Show a color stripe or color dot</string>
<string name="title_advanced_color_stripe_wide">Use wide color stripe</string>
<string name="title_advanced_avatars">Show contact photos</string>
<string name="title_advanced_bimi">Show Brand Indicators for Message Identification (BIMI)</string>
@ -2887,6 +2887,12 @@
<item>Extra large</item>
</string-array>
<string-array name="accountColorNames">
<item>None</item>
<item>Stripe</item>
<item>Dot</item>
</string-array>
<string-array name="answerValues" translatable="false">
<item>reply</item>
<item>reply_all</item>

Loading…
Cancel
Save