1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-24 07:01:05 +00:00

Suppress expand notice on unmetered connections

This commit is contained in:
M66B 2019-10-21 09:01:24 +02:00
parent 1990384398
commit af318125d1

View file

@ -172,7 +172,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private Context context; private Context context;
private LifecycleOwner owner; private LifecycleOwner owner;
private LayoutInflater inflater; private LayoutInflater inflater;
private boolean suitable; private boolean suitable;
private boolean unmetered;
private int dp36; private int dp36;
private int colorPrimary; private int colorPrimary;
@ -1018,13 +1020,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
private void bindExpandWarning(TupleMessageEx message, boolean expanded) { private void bindExpandWarning(TupleMessageEx message, boolean expanded) {
tvExpand.setText( if (viewType != ViewType.THREAD || expanded || message.content || message.uid == null || unmetered)
message.size == null ? null : context.getString(R.string.title_expand_warning, tvExpand.setVisibility(View.GONE);
Helper.humanReadableByteCount(message.size, true))); else {
tvExpand.setVisibility( tvExpand.setText(context.getString(R.string.title_expand_warning,
viewType == ViewType.THREAD && !expanded && message.size == null ? "?" : Helper.humanReadableByteCount(message.size, true)));
message.size != null && !message.content && message.uid != null tvExpand.setVisibility(View.VISIBLE);
? View.VISIBLE : View.GONE); }
} }
private void bindExpanded(final TupleMessageEx message, final boolean scroll) { private void bindExpanded(final TupleMessageEx message, final boolean scroll) {
@ -3513,11 +3515,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.context = parentFragment.getContext(); this.context = parentFragment.getContext();
this.owner = parentFragment.getViewLifecycleOwner(); this.owner = parentFragment.getViewLifecycleOwner();
this.suitable = ConnectionHelper.getNetworkState(context).isSuitable();
this.inflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.TF = Helper.getTimeInstance(context, SimpleDateFormat.SHORT); this.TF = Helper.getTimeInstance(context, SimpleDateFormat.SHORT);
this.DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.LONG, SimpleDateFormat.LONG); this.DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.LONG, SimpleDateFormat.LONG);
ConnectionHelper.NetworkState state = ConnectionHelper.getNetworkState(context);
this.suitable = state.isSuitable();
this.unmetered = state.isUnmetered();
this.dp36 = Helper.dp2pixels(context, 36); this.dp36 = Helper.dp2pixels(context, 36);
this.colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary); this.colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
this.colorAccent = Helper.resolveColor(context, R.attr.colorAccent); this.colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
@ -3688,9 +3693,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
void checkInternet() { void checkInternet() {
boolean suitable = ConnectionHelper.getNetworkState(context).isSuitable(); ConnectionHelper.NetworkState state = ConnectionHelper.getNetworkState(context);
if (this.suitable != suitable) { if (this.suitable != state.isSuitable() || this.unmetered != state.isUnmetered()) {
this.suitable = suitable; this.suitable = state.isSuitable();
this.unmetered = state.isUnmetered();
notifyDataSetChanged(); notifyDataSetChanged();
} }
} }