Show number unread inbox for accounts

pull/187/head
M66B 5 years ago
parent 4c6aeab96b
commit d21f9e6edb

@ -88,6 +88,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private ImageView ivNotify; private ImageView ivNotify;
private TextView tvName; private TextView tvName;
private ImageView ivSync; private ImageView ivSync;
private TextView tvInbox;
private ImageButton ibInbox; private ImageButton ibInbox;
private TextView tvUser; private TextView tvUser;
private ImageView ivState; private ImageView ivState;
@ -110,6 +111,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
view = itemView.findViewById(R.id.clItem); view = itemView.findViewById(R.id.clItem);
vwColor = itemView.findViewById(R.id.vwColor); vwColor = itemView.findViewById(R.id.vwColor);
ivSync = itemView.findViewById(R.id.ivSync); ivSync = itemView.findViewById(R.id.ivSync);
tvInbox = itemView.findViewById(R.id.tvInbox);
ibInbox = itemView.findViewById(R.id.ibInbox); ibInbox = itemView.findViewById(R.id.ibInbox);
ivOAuth = itemView.findViewById(R.id.ivOAuth); ivOAuth = itemView.findViewById(R.id.ivOAuth);
ivPrimary = itemView.findViewById(R.id.ivPrimary); ivPrimary = itemView.findViewById(R.id.ivPrimary);
@ -132,6 +134,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private void wire() { private void wire() {
view.setOnClickListener(this); view.setOnClickListener(this);
view.setOnLongClickListener(this); view.setOnLongClickListener(this);
tvInbox.setOnClickListener(this);
ibInbox.setOnClickListener(this); ibInbox.setOnClickListener(this);
btnHelp.setOnClickListener(this); btnHelp.setOnClickListener(this);
} }
@ -139,6 +142,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private void unwire() { private void unwire() {
view.setOnClickListener(null); view.setOnClickListener(null);
view.setOnLongClickListener(null); view.setOnLongClickListener(null);
tvInbox.setOnClickListener(null);
ibInbox.setOnClickListener(null); ibInbox.setOnClickListener(null);
btnHelp.setOnClickListener(null); btnHelp.setOnClickListener(null);
} }
@ -166,6 +170,10 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
tvName.setTypeface(account.unseen > 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT); tvName.setTypeface(account.unseen > 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
tvName.setTextColor(account.unseen > 0 ? colorUnread : textColorSecondary); tvName.setTextColor(account.unseen > 0 ? colorUnread : textColorSecondary);
tvInbox.setText(NF.format(account.inbox));
tvInbox.setTypeface(account.inbox > 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
tvInbox.setTextColor(account.inbox > 0 ? colorUnread : textColorSecondary);
} }
tvUser.setText(account.user); tvUser.setText(account.user);
@ -211,6 +219,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE); tvError.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
btnHelp.setVisibility(account.error == null ? View.GONE : View.VISIBLE); btnHelp.setVisibility(account.error == null ? View.GONE : View.VISIBLE);
tvInbox.setVisibility(settings ? View.GONE : View.VISIBLE);
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);
} }
@ -228,7 +237,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
if (account.tbd != null) if (account.tbd != null)
return; return;
if (view.getId() == R.id.ibInbox) { int id = view.getId();
if (id == R.id.tvInbox || id == R.id.ibInbox) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", account.id); args.putLong("id", account.id);
@ -263,7 +273,9 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
} else { } else {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
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));
} }

@ -62,6 +62,13 @@ public interface DaoAccount {
" AND folder.type <> '" + EntityFolder.OUTBOX + "'" + " AND folder.type <> '" + EntityFolder.OUTBOX + "'" +
" AND NOT ui_seen" + " AND NOT ui_seen" +
" AND NOT ui_hide) AS unseen" + " AND NOT ui_hide) AS unseen" +
", (SELECT COUNT(DISTINCT message.id)" +
" FROM message" +
" JOIN folder ON folder.id = message.folder" +
" WHERE message.account = account.id" +
" AND folder.type = '" + EntityFolder.INBOX + "'" +
" AND NOT ui_seen" +
" AND NOT ui_hide) AS inbox" +
", (SELECT COUNT(identity.id)" + ", (SELECT COUNT(identity.id)" +
" FROM identity" + " FROM identity" +
" WHERE identity.account = account.id" + " WHERE identity.account = account.id" +

@ -23,6 +23,7 @@ import java.util.Objects;
public class TupleAccountEx extends EntityAccount { public class TupleAccountEx extends EntityAccount {
public int unseen; public int unseen;
public int inbox;
public int identities; // synchronizing public int identities; // synchronizing
public Long drafts; public Long drafts;
@ -32,6 +33,7 @@ public class TupleAccountEx extends EntityAccount {
TupleAccountEx other = (TupleAccountEx) obj; TupleAccountEx other = (TupleAccountEx) obj;
return (super.equals(obj) && return (super.equals(obj) &&
this.unseen == other.unseen && this.unseen == other.unseen &&
this.inbox == other.inbox &&
this.identities == other.identities && this.identities == other.identities &&
Objects.equals(this.drafts, other.drafts)); Objects.equals(this.drafts, other.drafts));
} else } else

@ -100,10 +100,22 @@
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:contentDescription="@string/title_legend_synchronize_on" android:contentDescription="@string/title_legend_synchronize_on"
app:layout_constraintBottom_toBottomOf="@+id/tvName" app:layout_constraintBottom_toBottomOf="@+id/tvName"
app:layout_constraintEnd_toStartOf="@+id/ibInbox" app:layout_constraintEnd_toStartOf="@+id/tvInbox"
app:layout_constraintTop_toTopOf="@+id/tvName" app:layout_constraintTop_toTopOf="@+id/tvName"
app:srcCompat="@drawable/twotone_sync_24" /> app:srcCompat="@drawable/twotone_sync_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvInbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="start"
android:singleLine="true"
android:text="123"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="@+id/tvName"
app:layout_constraintEnd_toStartOf="@id/ibInbox"
app:layout_constraintTop_toTopOf="@+id/tvName" />
<ImageButton <ImageButton
android:id="@+id/ibInbox" android:id="@+id/ibInbox"
android:layout_width="36dp" android:layout_width="36dp"

Loading…
Cancel
Save