mirror of https://github.com/M66B/FairEmail.git
Check if synchronization enable
This commit is contained in:
parent
7467e88d93
commit
966e3ab20b
|
@ -232,10 +232,14 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||||
if (folder.tbd != null)
|
if (folder.tbd != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean enabled = prefs.getBoolean("enabled", true);
|
||||||
|
|
||||||
PopupMenu popupMenu = new PopupMenu(context, itemView);
|
PopupMenu popupMenu = new PopupMenu(context, itemView);
|
||||||
|
|
||||||
popupMenu.getMenu().add(Menu.NONE, action_synchronize_now, 1, R.string.title_synchronize_now)
|
popupMenu.getMenu().add(Menu.NONE, action_synchronize_now, 1, R.string.title_synchronize_now)
|
||||||
.setEnabled(folder.account != null || "connected".equals(folder.state) /* outbox */);
|
.setEnabled(enabled &&
|
||||||
|
(folder.account != null || "connected".equals(folder.state) /* outbox */));
|
||||||
|
|
||||||
if (folder.account != null)
|
if (folder.account != null)
|
||||||
popupMenu.getMenu().add(Menu.NONE, action_delete_local, 2, R.string.title_delete_local);
|
popupMenu.getMenu().add(Menu.NONE, action_delete_local, 2, R.string.title_delete_local);
|
||||||
|
|
|
@ -2092,6 +2092,10 @@ public class FragmentCompose extends FragmentBase {
|
||||||
if (!attachment.available)
|
if (!attachment.available)
|
||||||
throw new IllegalArgumentException(context.getString(R.string.title_attachments_missing));
|
throw new IllegalArgumentException(context.getString(R.string.title_attachments_missing));
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
if (!prefs.getBoolean("enabled", true))
|
||||||
|
throw new IllegalArgumentException(context.getString(R.string.title_sync_disabled));
|
||||||
|
|
||||||
// Delete draft (cannot move to outbox)
|
// Delete draft (cannot move to outbox)
|
||||||
EntityOperation.queue(context, db, draft, EntityOperation.DELETE);
|
EntityOperation.queue(context, db, draft, EntityOperation.DELETE);
|
||||||
|
|
||||||
|
|
|
@ -491,6 +491,10 @@ public class FragmentMessages extends FragmentBase {
|
||||||
protected Boolean onExecute(Context context, Bundle args) {
|
protected Boolean onExecute(Context context, Bundle args) {
|
||||||
long fid = args.getLong("folder");
|
long fid = args.getLong("folder");
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
if (!prefs.getBoolean("enabled", true))
|
||||||
|
throw new IllegalArgumentException(context.getString(R.string.title_sync_disabled));
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
try {
|
try {
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
@ -538,6 +542,11 @@ public class FragmentMessages extends FragmentBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
|
||||||
|
if (ex instanceof IllegalArgumentException)
|
||||||
|
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||||
|
else
|
||||||
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
||||||
}
|
}
|
||||||
}.execute(FragmentMessages.this, args, "messages:refresh");
|
}.execute(FragmentMessages.this, args, "messages:refresh");
|
||||||
|
|
|
@ -253,6 +253,7 @@
|
||||||
<string name="title_no_move">This provider does not support MOVE</string>
|
<string name="title_no_move">This provider does not support MOVE</string>
|
||||||
<string name="title_no_uidplus">This provider does not support UIDPLUS</string>
|
<string name="title_no_uidplus">This provider does not support UIDPLUS</string>
|
||||||
<string name="title_no_sync">Synchronization errors since %1$s</string>
|
<string name="title_no_sync">Synchronization errors since %1$s</string>
|
||||||
|
<string name="title_sync_disabled">Synchronization is disabled</string>
|
||||||
<string name="title_drafts_required">A drafts folder is required to send messages</string>
|
<string name="title_drafts_required">A drafts folder is required to send messages</string>
|
||||||
<string name="title_account_delete">Delete this account permanently?</string>
|
<string name="title_account_delete">Delete this account permanently?</string>
|
||||||
<string name="title_identity_delete">Delete this identity permanently?</string>
|
<string name="title_identity_delete">Delete this identity permanently?</string>
|
||||||
|
|
Loading…
Reference in New Issue