|
|
@ -91,7 +91,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
private int textColorTertiary;
|
|
|
|
private int textColorTertiary;
|
|
|
|
private boolean debug;
|
|
|
|
private boolean debug;
|
|
|
|
|
|
|
|
|
|
|
|
private List<TupleAccountEx> items = new ArrayList<>();
|
|
|
|
private List<TupleAccountFolder> items = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
private NumberFormat NF = NumberFormat.getNumberInstance();
|
|
|
|
private NumberFormat NF = NumberFormat.getNumberInstance();
|
|
|
|
private DateFormat DTF;
|
|
|
|
private DateFormat DTF;
|
|
|
@ -196,7 +196,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
btnHelp.setOnClickListener(null);
|
|
|
|
btnHelp.setOnClickListener(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void bindTo(TupleAccountEx account) {
|
|
|
|
private void bindTo(TupleAccountFolder account) {
|
|
|
|
|
|
|
|
if (account.folderName == null) {
|
|
|
|
view.setActivated(account.tbd != null);
|
|
|
|
view.setActivated(account.tbd != null);
|
|
|
|
view.setAlpha(account.synchronize ? 1.0f : Helper.LOW_LIGHT);
|
|
|
|
view.setAlpha(account.synchronize ? 1.0f : Helper.LOW_LIGHT);
|
|
|
|
vwColor.setBackgroundColor(account.color == null ? Color.TRANSPARENT : account.color);
|
|
|
|
vwColor.setBackgroundColor(account.color == null ? Color.TRANSPARENT : account.color);
|
|
|
@ -204,6 +205,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
|
|
|
|
|
|
|
|
ivSync.setImageResource(account.synchronize ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24);
|
|
|
|
ivSync.setImageResource(account.synchronize ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24);
|
|
|
|
ivSync.setContentDescription(context.getString(account.synchronize ? R.string.title_legend_synchronize_on : R.string.title_legend_synchronize_off));
|
|
|
|
ivSync.setContentDescription(context.getString(account.synchronize ? R.string.title_legend_synchronize_on : R.string.title_legend_synchronize_off));
|
|
|
|
|
|
|
|
ivSync.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
ivOAuth.setImageDrawable(ContextCompat.getDrawable(context, account.auth_type == AUTH_TYPE_GMAIL
|
|
|
|
ivOAuth.setImageDrawable(ContextCompat.getDrawable(context, account.auth_type == AUTH_TYPE_GMAIL
|
|
|
|
? R.drawable.twotone_android_24 : R.drawable.twotone_security_24));
|
|
|
|
? R.drawable.twotone_android_24 : R.drawable.twotone_security_24));
|
|
|
@ -230,6 +232,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
if (account.provider != null && (BuildConfig.DEBUG || debug))
|
|
|
|
if (account.provider != null && (BuildConfig.DEBUG || debug))
|
|
|
|
user.append(" (").append(account.provider).append(')');
|
|
|
|
user.append(" (").append(account.provider).append(')');
|
|
|
|
tvUser.setText(user);
|
|
|
|
tvUser.setText(user);
|
|
|
|
|
|
|
|
tvUser.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
if ("connected".equals(account.state)) {
|
|
|
|
if ("connected".equals(account.state)) {
|
|
|
|
ivState.setImageResource(R.drawable.twotone_cloud_done_24);
|
|
|
|
ivState.setImageResource(R.drawable.twotone_cloud_done_24);
|
|
|
@ -256,6 +259,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
account.port,
|
|
|
|
account.port,
|
|
|
|
EmailService.getEncryptionName(account.encryption)));
|
|
|
|
EmailService.getEncryptionName(account.encryption)));
|
|
|
|
tvHost.setTextColor(account.insecure ? colorWarning : textColorTertiary);
|
|
|
|
tvHost.setTextColor(account.insecure ? colorWarning : textColorTertiary);
|
|
|
|
|
|
|
|
tvHost.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
tvCreated.setVisibility(debug ? View.VISIBLE : View.GONE);
|
|
|
|
tvCreated.setVisibility(debug ? View.VISIBLE : View.GONE);
|
|
|
|
tvCreated.setText(context.getString(R.string.title_created_at,
|
|
|
|
tvCreated.setText(context.getString(R.string.title_created_at,
|
|
|
|
account.created == null ? null : DTF.format(account.created)));
|
|
|
|
account.created == null ? null : DTF.format(account.created)));
|
|
|
@ -316,13 +321,66 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
|
|
|
|
|
|
|
|
ibInbox.setVisibility(settings ? View.GONE : View.VISIBLE);
|
|
|
|
ibInbox.setVisibility(settings ? View.GONE : View.VISIBLE);
|
|
|
|
grpSettings.setVisibility(settings ? View.VISIBLE : View.GONE);
|
|
|
|
grpSettings.setVisibility(settings ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
view.setActivated(account.tbd != null);
|
|
|
|
|
|
|
|
view.setAlpha(account.synchronize ? 1.0f : Helper.LOW_LIGHT);
|
|
|
|
|
|
|
|
vwColor.setBackgroundColor(account.folderColor == null ? Color.TRANSPARENT : account.folderColor);
|
|
|
|
|
|
|
|
vwColor.setVisibility(ActivityBilling.isPro(context) ? View.VISIBLE : View.INVISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ivSync.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ivOAuth.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
ivPrimary.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
ivNotify.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (account.unseen > 0)
|
|
|
|
|
|
|
|
tvName.setText(context.getString(R.string.title_name_count,
|
|
|
|
|
|
|
|
account.getName(context), NF.format(account.unseen)));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
tvName.setText(account.getName(context));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvName.setTypeface(account.unseen > 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
|
|
|
|
|
|
|
|
tvName.setTextColor(account.unseen > 0 ? colorUnread : textColorSecondary);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvUser.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ivState.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvHost.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvCreated.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
tvLast.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvBackoff.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvUsage.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
tvQuota.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvMaxSize.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvId.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvCapabilities.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvIdentity.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
tvDrafts.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
tvSent.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvWarning.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvError.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
btnHelp.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ibInbox.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
grpSettings.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
public void onClick(View view) {
|
|
|
|
if (view.getId() == R.id.btnHelp) {
|
|
|
|
if (view.getId() == R.id.btnHelp) {
|
|
|
|
int pos = getAdapterPosition();
|
|
|
|
int pos = getAdapterPosition();
|
|
|
|
TupleAccountEx account = (pos == RecyclerView.NO_POSITION ? null : items.get(pos));
|
|
|
|
TupleAccountFolder account = (pos == RecyclerView.NO_POSITION ? null : items.get(pos));
|
|
|
|
if (account == null)
|
|
|
|
if (account == null)
|
|
|
|
Helper.viewFAQ(context, 22);
|
|
|
|
Helper.viewFAQ(context, 22);
|
|
|
|
else {
|
|
|
|
else {
|
|
|
@ -345,7 +403,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
if (pos == RecyclerView.NO_POSITION)
|
|
|
|
if (pos == RecyclerView.NO_POSITION)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
TupleAccountEx account = items.get(pos);
|
|
|
|
TupleAccountFolder account = items.get(pos);
|
|
|
|
if (account.tbd != null)
|
|
|
|
if (account.tbd != null)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
@ -383,10 +441,17 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
}.execute(context, owner, args, "account:inbox");
|
|
|
|
}.execute(context, owner, args, "account:inbox");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
|
|
|
|
if (account.folderName == null)
|
|
|
|
lbm.sendBroadcast(
|
|
|
|
lbm.sendBroadcast(
|
|
|
|
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
|
|
|
|
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
|
|
|
|
.putExtra("id", account.id)
|
|
|
|
.putExtra("id", account.id)
|
|
|
|
.putExtra("protocol", account.protocol));
|
|
|
|
.putExtra("protocol", account.protocol));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
lbm.sendBroadcast(
|
|
|
|
|
|
|
|
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
|
|
|
|
|
|
|
|
.putExtra("account", account.id)
|
|
|
|
|
|
|
|
.putExtra("folder", account.folderId)
|
|
|
|
|
|
|
|
.putExtra("type", account.folderType));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -396,8 +461,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
if (pos == RecyclerView.NO_POSITION)
|
|
|
|
if (pos == RecyclerView.NO_POSITION)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
final TupleAccountEx account = items.get(pos);
|
|
|
|
final TupleAccountFolder account = items.get(pos);
|
|
|
|
if (account.tbd != null)
|
|
|
|
if (account.tbd != null || account.folderName != null)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, view);
|
|
|
|
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, view);
|
|
|
@ -811,7 +876,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
|
|
|
|
|
|
|
|
this.DTF = Helper.getDateTimeInstance(context, DateFormat.SHORT, DateFormat.MEDIUM);
|
|
|
|
this.DTF = Helper.getDateTimeInstance(context, DateFormat.SHORT, DateFormat.MEDIUM);
|
|
|
|
|
|
|
|
|
|
|
|
setHasStableIds(true);
|
|
|
|
setHasStableIds(false);
|
|
|
|
|
|
|
|
|
|
|
|
owner.getLifecycle().addObserver(new LifecycleObserver() {
|
|
|
|
owner.getLifecycle().addObserver(new LifecycleObserver() {
|
|
|
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
|
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
|
@ -823,9 +888,12 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void set(@NonNull List<TupleAccountEx> accounts) {
|
|
|
|
public void set(@NonNull List<TupleAccountFolder> accounts) {
|
|
|
|
Log.i("Set accounts=" + accounts.size());
|
|
|
|
Log.i("Set accounts=" + accounts.size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (accounts.size() > 0)
|
|
|
|
|
|
|
|
TupleAccountFolder.sort(accounts, true, context);
|
|
|
|
|
|
|
|
|
|
|
|
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, accounts), false);
|
|
|
|
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, accounts), false);
|
|
|
|
|
|
|
|
|
|
|
|
items = accounts;
|
|
|
|
items = accounts;
|
|
|
@ -865,10 +933,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static class DiffCallback extends DiffUtil.Callback {
|
|
|
|
private static class DiffCallback extends DiffUtil.Callback {
|
|
|
|
private List<TupleAccountEx> prev = new ArrayList<>();
|
|
|
|
private List<TupleAccountFolder> prev = new ArrayList<>();
|
|
|
|
private List<TupleAccountEx> next = new ArrayList<>();
|
|
|
|
private List<TupleAccountFolder> next = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
DiffCallback(List<TupleAccountEx> prev, List<TupleAccountEx> next) {
|
|
|
|
DiffCallback(List<TupleAccountFolder> prev, List<TupleAccountFolder> next) {
|
|
|
|
this.prev.addAll(prev);
|
|
|
|
this.prev.addAll(prev);
|
|
|
|
this.next.addAll(next);
|
|
|
|
this.next.addAll(next);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -885,15 +953,15 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
|
|
|
|
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
|
|
|
|
TupleAccountEx f1 = prev.get(oldItemPosition);
|
|
|
|
TupleAccountFolder f1 = prev.get(oldItemPosition);
|
|
|
|
TupleAccountEx f2 = next.get(newItemPosition);
|
|
|
|
TupleAccountFolder f2 = next.get(newItemPosition);
|
|
|
|
return f1.id.equals(f2.id);
|
|
|
|
return f1.id.equals(f2.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
|
|
|
|
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
|
|
|
|
TupleAccountEx f1 = prev.get(oldItemPosition);
|
|
|
|
TupleAccountFolder f1 = prev.get(oldItemPosition);
|
|
|
|
TupleAccountEx f2 = next.get(newItemPosition);
|
|
|
|
TupleAccountFolder f2 = next.get(newItemPosition);
|
|
|
|
return f1.equals(f2);
|
|
|
|
return f1.equals(f2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -903,7 +971,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
return items.get(position).id;
|
|
|
|
return items.get(position).id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TupleAccountEx getItemAtPosition(int pos) {
|
|
|
|
public TupleAccountFolder getItemAtPosition(int pos) {
|
|
|
|
if (pos >= 0 && pos < items.size())
|
|
|
|
if (pos >= 0 && pos < items.size())
|
|
|
|
return items.get(pos);
|
|
|
|
return items.get(pos);
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -923,7 +991,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
|
|
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
|
|
|
TupleAccountEx account = items.get(position);
|
|
|
|
TupleAccountFolder account = items.get(position);
|
|
|
|
holder.powner.recreate(account == null ? null : account.id);
|
|
|
|
holder.powner.recreate(account == null ? null : account.id);
|
|
|
|
|
|
|
|
|
|
|
|
holder.unwire();
|
|
|
|
holder.unwire();
|
|
|
|