mirror of https://github.com/M66B/FairEmail.git
Show when no internet connection while required
This commit is contained in:
parent
4706b58232
commit
0a7ac9f9c4
|
@ -113,6 +113,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
private ViewType viewType;
|
private ViewType viewType;
|
||||||
private boolean outgoing;
|
private boolean outgoing;
|
||||||
private int zoom;
|
private int zoom;
|
||||||
|
private boolean internet;
|
||||||
private IProperties properties;
|
private IProperties properties;
|
||||||
|
|
||||||
private boolean threading;
|
private boolean threading;
|
||||||
|
@ -175,8 +176,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
private TextView tvHeaders;
|
private TextView tvHeaders;
|
||||||
private ProgressBar pbHeaders;
|
private ProgressBar pbHeaders;
|
||||||
|
private TextView tvNoInternetHeaders;
|
||||||
|
|
||||||
private RecyclerView rvAttachment;
|
private RecyclerView rvAttachment;
|
||||||
|
private TextView tvNoInternetAttachments;
|
||||||
|
|
||||||
private BottomNavigationView bnvActions;
|
private BottomNavigationView bnvActions;
|
||||||
|
|
||||||
|
@ -185,6 +188,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
private ImageButton ibImages;
|
private ImageButton ibImages;
|
||||||
private TextView tvBody;
|
private TextView tvBody;
|
||||||
private ProgressBar pbBody;
|
private ProgressBar pbBody;
|
||||||
|
private TextView tvNoInternetBody;
|
||||||
|
|
||||||
private Group grpAddress;
|
private Group grpAddress;
|
||||||
private Group grpHeaders;
|
private Group grpHeaders;
|
||||||
|
@ -230,6 +234,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
tvHeaders = itemView.findViewById(R.id.tvHeaders);
|
tvHeaders = itemView.findViewById(R.id.tvHeaders);
|
||||||
pbHeaders = itemView.findViewById(R.id.pbHeaders);
|
pbHeaders = itemView.findViewById(R.id.pbHeaders);
|
||||||
|
tvNoInternetHeaders = itemView.findViewById(R.id.tvNoInternetHeaders);
|
||||||
|
|
||||||
rvAttachment = itemView.findViewById(R.id.rvAttachment);
|
rvAttachment = itemView.findViewById(R.id.rvAttachment);
|
||||||
rvAttachment.setHasFixedSize(false);
|
rvAttachment.setHasFixedSize(false);
|
||||||
|
@ -240,6 +245,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
adapter = new AdapterAttachment(context, owner, true);
|
adapter = new AdapterAttachment(context, owner, true);
|
||||||
rvAttachment.setAdapter(adapter);
|
rvAttachment.setAdapter(adapter);
|
||||||
|
|
||||||
|
tvNoInternetAttachments = itemView.findViewById(R.id.tvNoInternetAttachments);
|
||||||
|
|
||||||
bnvActions = itemView.findViewById(R.id.bnvActions);
|
bnvActions = itemView.findViewById(R.id.bnvActions);
|
||||||
|
|
||||||
btnHtml = itemView.findViewById(R.id.btnHtml);
|
btnHtml = itemView.findViewById(R.id.btnHtml);
|
||||||
|
@ -247,6 +254,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
ibImages = itemView.findViewById(R.id.ibImages);
|
ibImages = itemView.findViewById(R.id.ibImages);
|
||||||
tvBody = itemView.findViewById(R.id.tvBody);
|
tvBody = itemView.findViewById(R.id.tvBody);
|
||||||
pbBody = itemView.findViewById(R.id.pbBody);
|
pbBody = itemView.findViewById(R.id.pbBody);
|
||||||
|
tvNoInternetBody = itemView.findViewById(R.id.tvNoInternetBody);
|
||||||
|
|
||||||
grpAddress = itemView.findViewById(R.id.grpAddress);
|
grpAddress = itemView.findViewById(R.id.grpAddress);
|
||||||
grpHeaders = itemView.findViewById(R.id.grpHeaders);
|
grpHeaders = itemView.findViewById(R.id.grpHeaders);
|
||||||
|
@ -299,11 +307,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
tvKeywords.setVisibility(View.GONE);
|
tvKeywords.setVisibility(View.GONE);
|
||||||
|
|
||||||
pbHeaders.setVisibility(View.GONE);
|
pbHeaders.setVisibility(View.GONE);
|
||||||
|
tvNoInternetHeaders.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tvNoInternetAttachments.setVisibility(View.GONE);
|
||||||
|
|
||||||
bnvActions.setVisibility(View.GONE);
|
bnvActions.setVisibility(View.GONE);
|
||||||
btnHtml.setVisibility(View.GONE);
|
btnHtml.setVisibility(View.GONE);
|
||||||
ibQuotes.setVisibility(View.GONE);
|
ibQuotes.setVisibility(View.GONE);
|
||||||
ibImages.setVisibility(View.GONE);
|
ibImages.setVisibility(View.GONE);
|
||||||
pbBody.setVisibility(View.GONE);
|
pbBody.setVisibility(View.GONE);
|
||||||
|
tvNoInternetBody.setVisibility(View.GONE);
|
||||||
|
|
||||||
grpAddress.setVisibility(View.GONE);
|
grpAddress.setVisibility(View.GONE);
|
||||||
ivAddContact.setVisibility(View.GONE);
|
ivAddContact.setVisibility(View.GONE);
|
||||||
|
@ -412,6 +425,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
ivAnswered.setVisibility(message.ui_answered ? View.VISIBLE : View.GONE);
|
ivAnswered.setVisibility(message.ui_answered ? View.VISIBLE : View.GONE);
|
||||||
ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
|
ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
tvNoInternetAttachments.setVisibility(View.GONE);
|
||||||
tvSubject.setText(message.subject);
|
tvSubject.setText(message.subject);
|
||||||
|
|
||||||
if (viewType == ViewType.THREAD || viewType == ViewType.SEARCH)
|
if (viewType == ViewType.THREAD || viewType == ViewType.SEARCH)
|
||||||
|
@ -466,7 +480,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
grpAddress.setVisibility(viewType == ViewType.THREAD && show_expanded && show_addresses ? View.VISIBLE : View.GONE);
|
grpAddress.setVisibility(viewType == ViewType.THREAD && show_expanded && show_addresses ? View.VISIBLE : View.GONE);
|
||||||
tvKeywords.setVisibility(View.GONE);
|
tvKeywords.setVisibility(View.GONE);
|
||||||
ivAddContact.setVisibility(viewType == ViewType.THREAD && show_expanded && show_addresses && contacts && message.from != null ? View.VISIBLE : View.GONE);
|
ivAddContact.setVisibility(viewType == ViewType.THREAD && show_expanded && show_addresses && contacts && message.from != null ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
if (show_headers && show_expanded && message.headers == null) {
|
||||||
|
pbHeaders.setVisibility(internet ? View.VISIBLE : View.GONE);
|
||||||
|
tvNoInternetHeaders.setVisibility(internet ? View.GONE : View.VISIBLE);
|
||||||
|
} else {
|
||||||
pbHeaders.setVisibility(View.GONE);
|
pbHeaders.setVisibility(View.GONE);
|
||||||
|
tvNoInternetHeaders.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
grpHeaders.setVisibility(show_headers && show_expanded ? View.VISIBLE : View.GONE);
|
grpHeaders.setVisibility(show_headers && show_expanded ? View.VISIBLE : View.GONE);
|
||||||
grpAttachments.setVisibility(message.attachments > 0 && show_expanded ? View.VISIBLE : View.GONE);
|
grpAttachments.setVisibility(message.attachments > 0 && show_expanded ? View.VISIBLE : View.GONE);
|
||||||
bnvActions.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.INVISIBLE : View.GONE);
|
bnvActions.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.INVISIBLE : View.GONE);
|
||||||
|
@ -474,6 +496,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
ibQuotes.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.INVISIBLE : View.GONE);
|
ibQuotes.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.INVISIBLE : View.GONE);
|
||||||
ibImages.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.INVISIBLE : View.GONE);
|
ibImages.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.INVISIBLE : View.GONE);
|
||||||
pbBody.setVisibility(View.GONE);
|
pbBody.setVisibility(View.GONE);
|
||||||
|
tvNoInternetBody.setVisibility(View.GONE);
|
||||||
|
|
||||||
bnvActions.setTag(null);
|
bnvActions.setTag(null);
|
||||||
|
|
||||||
|
@ -521,7 +544,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
Spanned body = properties.getBody(message.id);
|
Spanned body = properties.getBody(message.id);
|
||||||
tvBody.setText(body);
|
tvBody.setText(body);
|
||||||
tvBody.setMovementMethod(new UrlHandler());
|
tvBody.setMovementMethod(new UrlHandler());
|
||||||
|
if (internet || message.content)
|
||||||
pbBody.setVisibility(View.VISIBLE);
|
pbBody.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tvNoInternetBody.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (body == null && message.content) {
|
if (body == null && message.content) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
@ -538,6 +564,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
adapter.set(attachments);
|
adapter.set(attachments);
|
||||||
|
|
||||||
|
boolean downloading = false;
|
||||||
|
for (EntityAttachment attachment : attachments)
|
||||||
|
if (attachment.progress != null) {
|
||||||
|
downloading = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tvNoInternetAttachments.setVisibility(downloading && !internet ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
if (message.content) {
|
if (message.content) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putSerializable("message", message);
|
args.putSerializable("message", message);
|
||||||
|
@ -1228,7 +1263,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
properties.setValue("headers", data.message.id, show_headers);
|
properties.setValue("headers", data.message.id, show_headers);
|
||||||
if (show_headers && data.message.headers == null) {
|
if (show_headers && data.message.headers == null) {
|
||||||
grpHeaders.setVisibility(View.VISIBLE);
|
grpHeaders.setVisibility(View.VISIBLE);
|
||||||
|
if (internet)
|
||||||
pbHeaders.setVisibility(View.VISIBLE);
|
pbHeaders.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tvNoInternetHeaders.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong("id", data.message.id);
|
args.putLong("id", data.message.id);
|
||||||
|
@ -1644,6 +1682,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
this.viewType = viewType;
|
this.viewType = viewType;
|
||||||
this.outgoing = outgoing;
|
this.outgoing = outgoing;
|
||||||
this.zoom = zoom;
|
this.zoom = zoom;
|
||||||
|
this.internet = (Helper.isMetered(context, false) != null);
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
@ -1682,6 +1721,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkInternet() {
|
||||||
|
boolean internet = (Helper.isMetered(context, false) != null);
|
||||||
|
if (this.internet != internet) {
|
||||||
|
this.internet = internet;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return differ.getItemCount();
|
return differ.getItemCount();
|
||||||
|
|
|
@ -30,6 +30,10 @@ import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
|
import android.net.NetworkRequest;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -129,7 +133,9 @@ public class FragmentCompose extends FragmentEx {
|
||||||
private ImageView ivBccAdd;
|
private ImageView ivBccAdd;
|
||||||
private EditText etSubject;
|
private EditText etSubject;
|
||||||
private RecyclerView rvAttachment;
|
private RecyclerView rvAttachment;
|
||||||
|
private TextView tvNoInternetAttachments;
|
||||||
private EditText etBody;
|
private EditText etBody;
|
||||||
|
private TextView tvNoInternet;
|
||||||
private TextView tvSignature;
|
private TextView tvSignature;
|
||||||
private TextView tvReference;
|
private TextView tvReference;
|
||||||
private BottomNavigationView edit_bar;
|
private BottomNavigationView edit_bar;
|
||||||
|
@ -178,7 +184,9 @@ public class FragmentCompose extends FragmentEx {
|
||||||
ivBccAdd = view.findViewById(R.id.ivBccAdd);
|
ivBccAdd = view.findViewById(R.id.ivBccAdd);
|
||||||
etSubject = view.findViewById(R.id.etSubject);
|
etSubject = view.findViewById(R.id.etSubject);
|
||||||
rvAttachment = view.findViewById(R.id.rvAttachment);
|
rvAttachment = view.findViewById(R.id.rvAttachment);
|
||||||
|
tvNoInternetAttachments = view.findViewById(R.id.tvNoInternetAttachments);
|
||||||
etBody = view.findViewById(R.id.etBody);
|
etBody = view.findViewById(R.id.etBody);
|
||||||
|
tvNoInternet = view.findViewById(R.id.tvNoInternet);
|
||||||
tvSignature = view.findViewById(R.id.tvSignature);
|
tvSignature = view.findViewById(R.id.tvSignature);
|
||||||
tvReference = view.findViewById(R.id.tvReference);
|
tvReference = view.findViewById(R.id.tvReference);
|
||||||
edit_bar = view.findViewById(R.id.edit_bar);
|
edit_bar = view.findViewById(R.id.edit_bar);
|
||||||
|
@ -302,12 +310,13 @@ public class FragmentCompose extends FragmentEx {
|
||||||
setSubtitle(R.string.title_compose);
|
setSubtitle(R.string.title_compose);
|
||||||
tvExtraPrefix.setText(null);
|
tvExtraPrefix.setText(null);
|
||||||
tvExtraSuffix.setText(null);
|
tvExtraSuffix.setText(null);
|
||||||
|
etBody.setText(null);
|
||||||
|
|
||||||
grpHeader.setVisibility(View.GONE);
|
grpHeader.setVisibility(View.GONE);
|
||||||
grpExtra.setVisibility(View.GONE);
|
grpExtra.setVisibility(View.GONE);
|
||||||
grpAddresses.setVisibility(View.GONE);
|
grpAddresses.setVisibility(View.GONE);
|
||||||
grpAttachments.setVisibility(View.GONE);
|
grpAttachments.setVisibility(View.GONE);
|
||||||
etBody.setVisibility(View.GONE);
|
tvNoInternet.setVisibility(View.GONE);
|
||||||
grpSignature.setVisibility(View.GONE);
|
grpSignature.setVisibility(View.GONE);
|
||||||
grpReference.setVisibility(View.GONE);
|
grpReference.setVisibility(View.GONE);
|
||||||
edit_bar.setVisibility(View.GONE);
|
edit_bar.setVisibility(View.GONE);
|
||||||
|
@ -386,6 +395,8 @@ public class FragmentCompose extends FragmentEx {
|
||||||
adapter = new AdapterAttachment(getContext(), getViewLifecycleOwner(), false);
|
adapter = new AdapterAttachment(getContext(), getViewLifecycleOwner(), false);
|
||||||
rvAttachment.setAdapter(adapter);
|
rvAttachment.setAdapter(adapter);
|
||||||
|
|
||||||
|
tvNoInternetAttachments.setVisibility(View.GONE);
|
||||||
|
|
||||||
pgpService = new OpenPgpServiceConnection(getContext(), "org.sufficientlysecure.keychain");
|
pgpService = new OpenPgpServiceConnection(getContext(), "org.sufficientlysecure.keychain");
|
||||||
pgpService.bindToService();
|
pgpService.bindToService();
|
||||||
|
|
||||||
|
@ -455,6 +466,11 @@ public class FragmentCompose extends FragmentEx {
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||||
|
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||||
|
cm.registerNetworkCallback(builder.build(), networkCallback);
|
||||||
|
|
||||||
if (!pgpService.isBound())
|
if (!pgpService.isBound())
|
||||||
pgpService.bindToService();
|
pgpService.bindToService();
|
||||||
}
|
}
|
||||||
|
@ -463,7 +479,48 @@ public class FragmentCompose extends FragmentEx {
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
if (autosave)
|
if (autosave)
|
||||||
onAction(R.id.action_save);
|
onAction(R.id.action_save);
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
cm.unregisterNetworkCallback(networkCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
|
||||||
|
@Override
|
||||||
|
public void onAvailable(Network network) {
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLost(Network network) {
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check() {
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||||
|
checkInternet();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private void checkInternet() {
|
||||||
|
boolean internet = (Helper.isMetered(getContext(), false) != null);
|
||||||
|
|
||||||
|
Boolean content = (Boolean) tvNoInternet.getTag();
|
||||||
|
tvNoInternet.setVisibility(!internet && content != null && !content ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
Boolean downloading = (Boolean) rvAttachment.getTag();
|
||||||
|
tvNoInternetAttachments.setVisibility(!internet && downloading != null && downloading ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1448,6 +1505,16 @@ public class FragmentCompose extends FragmentEx {
|
||||||
|
|
||||||
adapter.set(attachments);
|
adapter.set(attachments);
|
||||||
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
boolean downloading = false;
|
||||||
|
for (EntityAttachment attachment : attachments)
|
||||||
|
if (attachment.progress != null) {
|
||||||
|
downloading = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
rvAttachment.setTag(downloading);
|
||||||
|
checkInternet();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1457,7 +1524,11 @@ public class FragmentCompose extends FragmentEx {
|
||||||
// Draft was deleted
|
// Draft was deleted
|
||||||
if (draft == null || draft.ui_hide)
|
if (draft == null || draft.ui_hide)
|
||||||
finish();
|
finish();
|
||||||
else if (draft.content && state == State.NONE) {
|
else {
|
||||||
|
tvNoInternet.setTag(draft.content);
|
||||||
|
checkInternet();
|
||||||
|
|
||||||
|
if (draft.content && state == State.NONE) {
|
||||||
state = State.LOADING;
|
state = State.LOADING;
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
@ -1498,7 +1569,6 @@ public class FragmentCompose extends FragmentEx {
|
||||||
autosave = true;
|
autosave = true;
|
||||||
|
|
||||||
pbWait.setVisibility(View.GONE);
|
pbWait.setVisibility(View.GONE);
|
||||||
etBody.setVisibility(View.VISIBLE);
|
|
||||||
grpReference.setVisibility(texts[1] == null ? View.GONE : View.VISIBLE);
|
grpReference.setVisibility(texts[1] == null ? View.GONE : View.VISIBLE);
|
||||||
edit_bar.setVisibility(View.VISIBLE);
|
edit_bar.setVisibility(View.VISIBLE);
|
||||||
bottom_navigation.setVisibility(View.VISIBLE);
|
bottom_navigation.setVisibility(View.VISIBLE);
|
||||||
|
@ -1526,6 +1596,7 @@ public class FragmentCompose extends FragmentEx {
|
||||||
}.load(FragmentCompose.this, args);
|
}.load(FragmentCompose.this, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ import android.content.SharedPreferences;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
|
import android.net.NetworkRequest;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -1422,8 +1426,48 @@ public class FragmentMessages extends FragmentEx {
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
grpSupport.setVisibility(Helper.isPro(getContext()) ? View.GONE : View.VISIBLE);
|
grpSupport.setVisibility(Helper.isPro(getContext()) ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||||
|
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||||
|
cm.registerNetworkCallback(builder.build(), networkCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
cm.unregisterNetworkCallback(networkCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
|
||||||
|
@Override
|
||||||
|
public void onAvailable(Network network) {
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLost(Network network) {
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check() {
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||||
|
adapter.checkInternet();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.menu_messages, menu);
|
inflater.inflate(R.menu.menu_messages, menu);
|
||||||
|
|
|
@ -185,6 +185,16 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
|
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoInternetAttachments"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_internet"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/rvAttachment"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/rvAttachment"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rvAttachment" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparator"
|
android:id="@+id/vSeparator"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -192,7 +202,7 @@
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="6dp"
|
||||||
android:background="?attr/colorSeparator"
|
android:background="?attr/colorSeparator"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/rvAttachment" />
|
app:layout_constraintTop_toBottomOf="@+id/tvNoInternetAttachments" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/etBody"
|
android:id="@+id/etBody"
|
||||||
|
@ -210,6 +220,17 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
|
app:layout_constraintTop_toBottomOf="@id/vSeparator" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoInternet"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_internet"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/etBody"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/etBody"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/etBody"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/etBody" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparatorSignature"
|
android:id="@+id/vSeparatorSignature"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -513,6 +513,17 @@
|
||||||
app:layout_constraintStart_toStartOf="@id/tvHeaders"
|
app:layout_constraintStart_toStartOf="@id/tvHeaders"
|
||||||
app:layout_constraintTop_toTopOf="@id/tvHeaders" />
|
app:layout_constraintTop_toTopOf="@id/tvHeaders" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoInternetHeaders"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_internet"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/tvHeaders"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/tvHeaders"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tvHeaders"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tvHeaders" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparatorAttachments"
|
android:id="@+id/vSeparatorAttachments"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -536,6 +547,16 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
|
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoInternetAttachments"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_internet"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/rvAttachment"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/rvAttachment"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rvAttachment" />
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/bnvActions"
|
android:id="@+id/bnvActions"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -547,7 +568,7 @@
|
||||||
app:labelVisibilityMode="labeled"
|
app:labelVisibilityMode="labeled"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/rvAttachment"
|
app:layout_constraintTop_toBottomOf="@id/tvNoInternetAttachments"
|
||||||
app:menu="@menu/action_message" />
|
app:menu="@menu/action_message" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -617,6 +638,17 @@
|
||||||
app:layout_constraintStart_toStartOf="@id/tvBody"
|
app:layout_constraintStart_toStartOf="@id/tvBody"
|
||||||
app:layout_constraintTop_toTopOf="@id/tvBody" />
|
app:layout_constraintTop_toTopOf="@id/tvBody" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoInternetBody"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_internet"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/tvBody"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/tvBody"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tvBody"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tvBody" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparator"
|
android:id="@+id/vSeparator"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -510,6 +510,17 @@
|
||||||
app:layout_constraintStart_toStartOf="@id/tvHeaders"
|
app:layout_constraintStart_toStartOf="@id/tvHeaders"
|
||||||
app:layout_constraintTop_toTopOf="@id/tvHeaders" />
|
app:layout_constraintTop_toTopOf="@id/tvHeaders" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoInternetHeaders"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_internet"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/tvHeaders"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/tvHeaders"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tvHeaders"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tvHeaders" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparatorAttachments"
|
android:id="@+id/vSeparatorAttachments"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -533,6 +544,16 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
|
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoInternetAttachments"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_internet"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/rvAttachment"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/rvAttachment"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rvAttachment" />
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/bnvActions"
|
android:id="@+id/bnvActions"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -544,7 +565,7 @@
|
||||||
app:labelVisibilityMode="labeled"
|
app:labelVisibilityMode="labeled"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/rvAttachment"
|
app:layout_constraintTop_toBottomOf="@id/tvNoInternetAttachments"
|
||||||
app:menu="@menu/action_message" />
|
app:menu="@menu/action_message" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -614,6 +635,17 @@
|
||||||
app:layout_constraintStart_toStartOf="@id/tvBody"
|
app:layout_constraintStart_toStartOf="@id/tvBody"
|
||||||
app:layout_constraintTop_toTopOf="@id/tvBody" />
|
app:layout_constraintTop_toTopOf="@id/tvBody" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNoInternetBody"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/title_no_internet"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/tvBody"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/tvBody"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/tvBody"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/tvBody" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparator"
|
android:id="@+id/vSeparator"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -273,6 +273,7 @@
|
||||||
<string name="title_no_saf">Storage access framework not available</string>
|
<string name="title_no_saf">Storage access framework not available</string>
|
||||||
<string name="title_no_stream">An outdated app sent a file path instead of a file stream</string>
|
<string name="title_no_stream">An outdated app sent a file path instead of a file stream</string>
|
||||||
<string name="title_no_contacts">Contact picker not available</string>
|
<string name="title_no_contacts">Contact picker not available</string>
|
||||||
|
<string name="title_no_internet">No internet connection</string>
|
||||||
<string name="title_attachment_saved">Attachment saved</string>
|
<string name="title_attachment_saved">Attachment saved</string>
|
||||||
<string name="title_attachment_unavailable">Some attachments are not downloaded and will not be added, continue?</string>
|
<string name="title_attachment_unavailable">Some attachments are not downloaded and will not be added, continue?</string>
|
||||||
<string name="title_image_unavailable">Some images are not downloaded and will not be added, continue?</string>
|
<string name="title_image_unavailable">Some images are not downloaded and will not be added, continue?</string>
|
||||||
|
|
Loading…
Reference in New Issue