Added account warning when no drafts folder

This commit is contained in:
M66B 2019-03-27 08:29:44 +00:00
parent 3acb07b916
commit b244c419b2
4 changed files with 26 additions and 3 deletions

View File

@ -70,6 +70,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private ImageView ivState;
private TextView tvHost;
private TextView tvLast;
private TextView tvDrafts;
private TextView tvWarning;
private TextView tvError;
private Group grpSettings;
@ -87,6 +88,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
ivState = itemView.findViewById(R.id.ivState);
tvHost = itemView.findViewById(R.id.tvHost);
tvLast = itemView.findViewById(R.id.tvLast);
tvDrafts = itemView.findViewById(R.id.tvDrafts);
tvWarning = itemView.findViewById(R.id.tvWarning);
tvError = itemView.findViewById(R.id.tvError);
grpSettings = itemView.findViewById(R.id.grpSettings);
@ -137,6 +139,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
tvLast.setText(context.getString(R.string.title_last_connected,
account.last_connected == null ? "-" : df.format(account.last_connected)));
tvDrafts.setVisibility(account.drafts || !settings ? View.GONE : View.VISIBLE);
tvWarning.setText(account.warning);
tvWarning.setVisibility(account.warning == null || !settings ? View.GONE : View.VISIBLE);

View File

@ -59,8 +59,10 @@ public interface DaoAccount {
" AND folder.type = '" + EntityFolder.OUTBOX + "'" +
" AND NOT ui_seen" +
" AND NOT ui_hide) AS unsent" +
", CASE WHEN drafts.id IS NULL THEN 0 ELSE 1 END AS drafts" +
" FROM account" +
" LEFT JOIN operation ON operation.account = account.id" +
" LEFT JOIN folder AS drafts ON drafts.account = account.id AND drafts.type = '" + EntityFolder.DRAFTS + "'" +
" WHERE :all OR account.synchronize" +
" GROUP BY account.id")
LiveData<List<TupleAccountEx>> liveAccountsEx(boolean all);

View File

@ -23,12 +23,14 @@ public class TupleAccountEx extends EntityAccount {
public int unseen;
public int unsent;
public int operations;
public boolean drafts;
public boolean uiEquals(Object obj) {
if (obj instanceof TupleAccountEx) {
TupleAccountEx other = (TupleAccountEx) obj;
return (super.equals(obj) &&
this.unseen == other.unseen);
this.unseen == other.unseen &&
this.drafts == other.drafts);
} else
return false;
}
@ -40,7 +42,8 @@ public class TupleAccountEx extends EntityAccount {
return (super.equals(obj) &&
this.unseen == other.unseen &&
this.unsent == other.unsent &&
this.operations == other.operations);
this.operations == other.operations &&
this.drafts == other.drafts);
} else
return false;
}

View File

@ -126,6 +126,20 @@
app:layout_constraintStart_toEndOf="@+id/ivState"
app:layout_constraintTop_toBottomOf="@id/tvHost" />
<TextView
android:id="@+id/tvDrafts"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:text="@string/title_drafts_required"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/tvLast" />
<TextView
android:id="@+id/tvWarning"
android:layout_width="0dp"
@ -138,7 +152,7 @@
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/tvLast" />
app:layout_constraintTop_toBottomOf="@id/tvDrafts" />
<TextView
android:id="@+id/tvError"