Skip to content

Commit f63b964

Browse files
authored
Merge pull request #8636 from cketti/remove-show-advanced-crypto-info
Remove unused advanced crypto status mode
2 parents 4c46433 + 1960cef commit f63b964

File tree

7 files changed

+34
-280
lines changed

7 files changed

+34
-280
lines changed

legacy/ui/legacy/src/main/java/com/fsck/k9/activity/AlternateRecipientAdapter.java

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import java.util.List;
55

66
import android.content.Context;
7-
import android.content.res.Resources;
8-
import android.graphics.PorterDuff.Mode;
97
import android.graphics.Typeface;
10-
import android.graphics.drawable.Drawable;
118
import android.text.TextUtils;
129
import android.view.LayoutInflater;
1310
import android.view.View;
@@ -16,14 +13,11 @@
1613
import android.widget.BaseAdapter;
1714
import android.widget.ImageView;
1815

19-
import androidx.annotation.AttrRes;
20-
import androidx.annotation.DrawableRes;
2116
import androidx.appcompat.widget.TooltipCompat;
2217
import com.fsck.k9.activity.compose.RecipientAdapter;
2318
import com.fsck.k9.ui.ContactBadge;
2419
import com.fsck.k9.ui.R;
2520
import com.fsck.k9.view.RecipientSelectView.Recipient;
26-
import com.fsck.k9.view.ThemeUtils;
2721
import com.google.android.material.textview.MaterialTextView;
2822

2923

@@ -37,7 +31,6 @@ public class AlternateRecipientAdapter extends BaseAdapter {
3731
private final AlternateRecipientListener listener;
3832
private List<Recipient> recipients;
3933
private Recipient currentRecipient;
40-
private boolean showAdvancedInfo;
4134

4235

4336
public AlternateRecipientAdapter(Context context, AlternateRecipientListener listener) {
@@ -171,69 +164,20 @@ public void onClick(View v) {
171164
}
172165

173166
private void configureCryptoStatusView(RecipientTokenHolder holder, Recipient recipient) {
174-
if (showAdvancedInfo) {
175-
configureCryptoStatusViewAdvanced(holder, recipient);
176-
} else {
177-
bindCryptoSimple(holder, recipient);
178-
}
179-
}
180-
181-
private void configureCryptoStatusViewAdvanced(RecipientTokenHolder holder, Recipient recipient) {
182-
switch (recipient.getCryptoStatus()) {
183-
case AVAILABLE_TRUSTED: {
184-
setCryptoStatusView(holder, R.drawable.status_lock_dots_3, R.attr.openpgp_green);
185-
break;
186-
}
187-
case AVAILABLE_UNTRUSTED: {
188-
setCryptoStatusView(holder, R.drawable.status_lock_dots_2, R.attr.openpgp_orange);
189-
break;
190-
}
191-
case UNAVAILABLE: {
192-
setCryptoStatusView(holder, R.drawable.status_lock_disabled_dots_1, R.attr.openpgp_red);
193-
break;
194-
}
195-
case UNDEFINED: {
196-
holder.itemCryptoStatus.setVisibility(View.GONE);
197-
break;
198-
}
199-
}
200-
}
201-
202-
private void setCryptoStatusView(RecipientTokenHolder holder, @DrawableRes int cryptoStatusRes,
203-
@AttrRes int cryptoStatusColorAttr) {
204-
Resources resources = context.getResources();
205-
206-
Drawable drawable = resources.getDrawable(cryptoStatusRes);
207-
// noinspection ConstantConditions, we know the resource exists!
208-
drawable.mutate();
209-
210-
int cryptoStatusColor = ThemeUtils.getStyledColor(context, cryptoStatusColorAttr);
211-
drawable.setColorFilter(cryptoStatusColor, Mode.SRC_ATOP);
212-
213-
holder.itemCryptoStatusIcon.setImageDrawable(drawable);
214-
holder.itemCryptoStatus.setVisibility(View.VISIBLE);
215-
}
216-
217-
private void bindCryptoSimple(RecipientTokenHolder holder, Recipient recipient) {
218-
holder.itemCryptoStatus.setVisibility(View.GONE);
219167
switch (recipient.getCryptoStatus()) {
220168
case AVAILABLE_TRUSTED:
221169
case AVAILABLE_UNTRUSTED: {
222-
holder.itemCryptoStatusSimple.setVisibility(View.VISIBLE);
170+
holder.itemCryptoStatus.setVisibility(View.VISIBLE);
223171
break;
224172
}
225173
case UNAVAILABLE:
226174
case UNDEFINED: {
227-
holder.itemCryptoStatusSimple.setVisibility(View.GONE);
175+
holder.itemCryptoStatus.setVisibility(View.GONE);
228176
break;
229177
}
230178
}
231179
}
232180

233-
public void setShowAdvancedInfo(boolean showAdvancedInfo) {
234-
this.showAdvancedInfo = showAdvancedInfo;
235-
}
236-
237181
private static class RecipientTokenHolder {
238182
public final View layoutHeader, layoutItem;
239183
public final MaterialTextView headerName;
@@ -243,9 +187,7 @@ private static class RecipientTokenHolder {
243187
public final View copyEmailAddress;
244188
public final MaterialTextView itemAddress;
245189
public final MaterialTextView itemAddressLabel;
246-
public final View itemCryptoStatus;
247-
public final ImageView itemCryptoStatusIcon;
248-
public final ImageView itemCryptoStatusSimple;
190+
public final ImageView itemCryptoStatus;
249191

250192

251193
public RecipientTokenHolder(View view) {
@@ -261,10 +203,8 @@ public RecipientTokenHolder(View view) {
261203
TooltipCompat.setTooltipText(copyEmailAddress, copyEmailAddress.getContext().getString(R.string.copy_action));
262204
itemAddress = view.findViewById(R.id.alternate_address);
263205
itemAddressLabel = view.findViewById(R.id.alternate_address_label);
264-
itemCryptoStatus = view.findViewById(R.id.alternate_crypto_status);
265-
itemCryptoStatusIcon = view.findViewById(R.id.alternate_crypto_status_icon);
266206

267-
itemCryptoStatusSimple = view.findViewById(R.id.alternate_crypto_status_simple);
207+
itemCryptoStatus = view.findViewById(R.id.alternate_crypto_status);
268208
}
269209

270210
public void setShowAsHeader(boolean isHeader) {

legacy/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientAdapter.java

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.regex.Pattern;
77

88
import android.content.Context;
9-
import android.graphics.drawable.Drawable;
109
import android.text.Spannable;
1110
import android.text.style.ForegroundColorSpan;
1211
import android.view.LayoutInflater;
@@ -17,21 +16,17 @@
1716
import android.widget.Filterable;
1817
import android.widget.ImageView;
1918

20-
import androidx.core.content.ContextCompat;
21-
import androidx.core.graphics.drawable.DrawableCompat;
2219
import com.fsck.k9.activity.misc.ContactPicture;
2320
import com.fsck.k9.ui.R;
2421
import com.fsck.k9.view.RecipientSelectView.Recipient;
2522
import com.fsck.k9.view.RecipientSelectView.RecipientCryptoStatus;
26-
import com.fsck.k9.view.ThemeUtils;
2723
import com.google.android.material.textview.MaterialTextView;
2824

2925

3026
public class RecipientAdapter extends BaseAdapter implements Filterable {
3127
private final Context context;
3228
private List<Recipient> recipients;
3329
private String highlight;
34-
private boolean showAdvancedInfo;
3530

3631

3732
public RecipientAdapter(Context context) {
@@ -94,59 +89,19 @@ private void bindView(View view, Recipient recipient) {
9489

9590
setContactPhotoOrPlaceholder(context, holder.photo, recipient);
9691

97-
if (showAdvancedInfo) {
98-
bindCryptoAdvanced(recipient, holder);
99-
} else {
100-
bindCryptoSimple(recipient, holder);
101-
}
102-
}
103-
104-
private void bindCryptoAdvanced(Recipient recipient, RecipientTokenHolder holder) {
105-
holder.cryptoStatusSimple.setVisibility(View.GONE);
106-
107-
Integer cryptoStatusRes = null, cryptoStatusColor = null;
108-
RecipientCryptoStatus cryptoStatus = recipient.getCryptoStatus();
109-
switch (cryptoStatus) {
110-
case AVAILABLE_TRUSTED: {
111-
cryptoStatusRes = R.drawable.status_lock_dots_3;
112-
cryptoStatusColor = ThemeUtils.getStyledColor(context, R.attr.openpgp_green);
113-
break;
114-
}
115-
case AVAILABLE_UNTRUSTED: {
116-
cryptoStatusRes = R.drawable.status_lock_dots_2;
117-
cryptoStatusColor = ThemeUtils.getStyledColor(context, R.attr.openpgp_orange);
118-
break;
119-
}
120-
case UNAVAILABLE: {
121-
cryptoStatusRes = R.drawable.status_lock_disabled_dots_1;
122-
cryptoStatusColor = ThemeUtils.getStyledColor(context, R.attr.openpgp_red);
123-
break;
124-
}
125-
}
126-
127-
if (cryptoStatusRes != null) {
128-
Drawable drawable = ContextCompat.getDrawable(context, cryptoStatusRes);
129-
DrawableCompat.wrap(drawable);
130-
DrawableCompat.setTint(drawable.mutate(), cryptoStatusColor);
131-
holder.cryptoStatusIcon.setImageDrawable(drawable);
132-
holder.cryptoStatus.setVisibility(View.VISIBLE);
133-
} else {
134-
holder.cryptoStatus.setVisibility(View.GONE);
135-
}
92+
bindCryptoStatus(recipient, holder);
13693
}
13794

138-
private void bindCryptoSimple(Recipient recipient, RecipientTokenHolder holder) {
139-
holder.cryptoStatus.setVisibility(View.GONE);
140-
95+
private void bindCryptoStatus(Recipient recipient, RecipientTokenHolder holder) {
14196
RecipientCryptoStatus cryptoStatus = recipient.getCryptoStatus();
14297
switch (cryptoStatus) {
14398
case AVAILABLE_TRUSTED:
14499
case AVAILABLE_UNTRUSTED: {
145-
holder.cryptoStatusSimple.setVisibility(View.VISIBLE);
100+
holder.cryptoStatus.setVisibility(View.VISIBLE);
146101
break;
147102
}
148103
case UNAVAILABLE: {
149-
holder.cryptoStatusSimple.setVisibility(View.GONE);
104+
holder.cryptoStatus.setVisibility(View.GONE);
150105
break;
151106
}
152107
}
@@ -179,27 +134,19 @@ protected void publishResults(CharSequence constraint, FilterResults results) {
179134
};
180135
}
181136

182-
public void setShowAdvancedInfo(boolean showAdvancedInfo) {
183-
this.showAdvancedInfo = showAdvancedInfo;
184-
}
185-
186137

187138
private static class RecipientTokenHolder {
188139
public final MaterialTextView name;
189140
public final MaterialTextView email;
190141
final ImageView photo;
191-
final View cryptoStatus;
192-
final ImageView cryptoStatusIcon;
193-
final ImageView cryptoStatusSimple;
142+
final ImageView cryptoStatus;
194143

195144

196145
RecipientTokenHolder(View view) {
197146
name = view.findViewById(R.id.text1);
198147
email = view.findViewById(R.id.text2);
199148
photo = view.findViewById(R.id.contact_photo);
200-
cryptoStatus = view.findViewById(R.id.contact_crypto_status);
201-
cryptoStatusIcon = view.findViewById(R.id.contact_crypto_status_icon);
202-
cryptoStatusSimple = view.findViewById(R.id.contact_crypto_status_icon_simple);
149+
cryptoStatus = view.findViewById(R.id.contact_crypto_status_icon);
203150
}
204151
}
205152

legacy/ui/legacy/src/main/java/com/fsck/k9/activity/compose/RecipientMvpView.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,9 @@ class RecipientMvpView(private val activity: MessageCompose) : View.OnFocusChang
142142
}
143143

144144
fun setCryptoProvider(openPgpProvider: String?) {
145-
// TODO move "show advanced" into settings, or somewhere?
146-
toView.setCryptoProvider(openPgpProvider, false)
147-
ccView.setCryptoProvider(openPgpProvider, false)
148-
bccView.setCryptoProvider(openPgpProvider, false)
145+
toView.setCryptoProvider(openPgpProvider)
146+
ccView.setCryptoProvider(openPgpProvider)
147+
bccView.setCryptoProvider(openPgpProvider)
149148
}
150149

151150
fun requestFocusOnToField() {

legacy/ui/legacy/src/main/java/com/fsck/k9/view/RecipientSelectView.java

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
6767
private RecipientAdapter adapter;
6868
@Nullable
6969
private String cryptoProvider;
70-
private boolean showAdvancedInfo;
7170
private boolean showCryptoEnabled;
7271
@Nullable
7372
private LoaderManager loaderManager;
@@ -164,12 +163,8 @@ private void bindObjectView(Recipient recipient, View view) {
164163

165164
boolean isAvailable = recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_TRUSTED ||
166165
recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_UNTRUSTED;
167-
if (!showAdvancedInfo) {
168-
holder.showSimpleCryptoState(isAvailable, showCryptoEnabled);
169-
} else {
170-
boolean isVerified = recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_TRUSTED;
171-
holder.showAdvancedCryptoState(isAvailable, isVerified);
172-
}
166+
167+
holder.showCryptoState(isAvailable, showCryptoEnabled);
173168
}
174169

175170
@Override
@@ -276,11 +271,8 @@ protected void performFiltering(@NonNull CharSequence text, int keyCode) {
276271
loaderManager.restartLoader(LOADER_ID_FILTERING, args, this);
277272
}
278273

279-
public void setCryptoProvider(@Nullable String cryptoProvider, boolean showAdvancedInfo) {
274+
public void setCryptoProvider(@Nullable String cryptoProvider) {
280275
this.cryptoProvider = cryptoProvider;
281-
this.showAdvancedInfo = showAdvancedInfo;
282-
adapter.setShowAdvancedInfo(showAdvancedInfo);
283-
alternatesAdapter.setShowAdvancedInfo(showAdvancedInfo);
284276
}
285277

286278
public void setShowCryptoEnabled(boolean showCryptoEnabled) {
@@ -595,54 +587,30 @@ public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end,
595587
private static class RecipientTokenViewHolder {
596588
final MaterialTextView vName;
597589
final CircleImageView vContactPhoto;
598-
final View cryptoStatusRed;
599-
final View cryptoStatusOrange;
600-
final View cryptoStatusGreen;
601-
final View cryptoStatusSimple;
602-
final View cryptoStatusSimpleEnabled;
603-
final View cryptoStatusSimpleError;
590+
final View cryptoStatus;
591+
final View cryptoStatusEnabled;
592+
final View cryptoStatusError;
604593

605594

606595
RecipientTokenViewHolder(View view) {
607596
vName = view.findViewById(android.R.id.text1);
608597
vContactPhoto = view.findViewById(R.id.contact_photo);
609-
cryptoStatusRed = view.findViewById(R.id.contact_crypto_status_red);
610-
cryptoStatusOrange = view.findViewById(R.id.contact_crypto_status_orange);
611-
cryptoStatusGreen = view.findViewById(R.id.contact_crypto_status_green);
612-
613-
cryptoStatusSimple = view.findViewById(R.id.contact_crypto_status_icon_simple);
614-
cryptoStatusSimpleEnabled = view.findViewById(R.id.contact_crypto_status_icon_simple_enabled);
615-
cryptoStatusSimpleError = view.findViewById(R.id.contact_crypto_status_icon_simple_error);
616-
}
617-
618-
void showSimpleCryptoState(boolean isAvailable, boolean isShowEnabled) {
619-
cryptoStatusRed.setVisibility(View.GONE);
620-
cryptoStatusOrange.setVisibility(View.GONE);
621-
cryptoStatusGreen.setVisibility(View.GONE);
622598

623-
cryptoStatusSimple.setVisibility(!isShowEnabled && isAvailable ? View.VISIBLE : View.GONE);
624-
cryptoStatusSimpleEnabled.setVisibility(isShowEnabled && isAvailable ? View.VISIBLE : View.GONE);
625-
cryptoStatusSimpleError.setVisibility(isShowEnabled && !isAvailable ? View.VISIBLE : View.GONE);
599+
cryptoStatus = view.findViewById(R.id.contact_crypto_status_icon);
600+
cryptoStatusEnabled = view.findViewById(R.id.contact_crypto_status_icon_enabled);
601+
cryptoStatusError = view.findViewById(R.id.contact_crypto_status_icon_error);
626602
}
627603

628-
void showAdvancedCryptoState(boolean isAvailable, boolean isVerified) {
629-
cryptoStatusRed.setVisibility(!isAvailable ? View.VISIBLE : View.GONE);
630-
cryptoStatusOrange.setVisibility(isAvailable && !isVerified ? View.VISIBLE : View.GONE);
631-
cryptoStatusGreen.setVisibility(isAvailable && isVerified ? View.VISIBLE : View.GONE);
632-
633-
cryptoStatusSimple.setVisibility(View.GONE);
634-
cryptoStatusSimpleEnabled.setVisibility(View.GONE);
635-
cryptoStatusSimpleError.setVisibility(View.GONE);
604+
void showCryptoState(boolean isAvailable, boolean isShowEnabled) {
605+
cryptoStatus.setVisibility(!isShowEnabled && isAvailable ? View.VISIBLE : View.GONE);
606+
cryptoStatusEnabled.setVisibility(isShowEnabled && isAvailable ? View.VISIBLE : View.GONE);
607+
cryptoStatusError.setVisibility(isShowEnabled && !isAvailable ? View.VISIBLE : View.GONE);
636608
}
637609

638610
void hideCryptoState() {
639-
cryptoStatusRed.setVisibility(View.GONE);
640-
cryptoStatusOrange.setVisibility(View.GONE);
641-
cryptoStatusGreen.setVisibility(View.GONE);
642-
643-
cryptoStatusSimple.setVisibility(View.GONE);
644-
cryptoStatusSimpleEnabled.setVisibility(View.GONE);
645-
cryptoStatusSimpleError.setVisibility(View.GONE);
611+
cryptoStatus.setVisibility(View.GONE);
612+
cryptoStatusEnabled.setVisibility(View.GONE);
613+
cryptoStatusError.setVisibility(View.GONE);
646614
}
647615
}
648616

0 commit comments

Comments
 (0)