Improved review account

pull/194/head
M66B 4 years ago
parent fe559f7c84
commit 1400afb7ca

@ -164,6 +164,11 @@ public interface DaoFolder {
" AND type <> '" + EntityFolder.USER + "'") " AND type <> '" + EntityFolder.USER + "'")
List<EntityFolder> getSystemFolders(long account); List<EntityFolder> getSystemFolders(long account);
@Query("SELECT * FROM folder" +
" WHERE folder.account = :account" +
" AND type <> '" + EntityFolder.USER + "'")
LiveData<List<EntityFolder>> liveSystemFolders(long account);
@Query("SELECT * FROM folder" + @Query("SELECT * FROM folder" +
" WHERE folder.account = :account" + " WHERE folder.account = :account" +
" AND folder.selectable" + " AND folder.selectable" +

@ -20,8 +20,10 @@ package eu.faircode.email;
*/ */
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -34,6 +36,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
@ -42,10 +45,31 @@ public class FragmentReview extends FragmentDialogBase {
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_review_account, null); final Context context = getContext();
TextView tvLeft = dview.findViewById(R.id.tvLeft);
TextView tvRight = dview.findViewById(R.id.tvRight); final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_review_account, null);
Button btnAccount = dview.findViewById(R.id.btnAccount); final TextView tvInbox = dview.findViewById(R.id.tvInbox);
final TextView tvDrafts = dview.findViewById(R.id.tvDrafts);
final TextView tvSent = dview.findViewById(R.id.tvSent);
final TextView tvTrash = dview.findViewById(R.id.tvTrash);
final TextView tvJunk = dview.findViewById(R.id.tvJunk);
final TextView tvArchive = dview.findViewById(R.id.tvArchive);
final TextView tvLeft = dview.findViewById(R.id.tvLeft);
final TextView tvRight = dview.findViewById(R.id.tvRight);
final Button btnAccount = dview.findViewById(R.id.btnAccount);
final Drawable check = context.getDrawable(R.drawable.twotone_check_24);
final Drawable close = context.getDrawable(R.drawable.twotone_close_24);
check.setBounds(0, 0, check.getIntrinsicWidth(), check.getIntrinsicHeight());
close.setBounds(0, 0, close.getIntrinsicWidth(), close.getIntrinsicHeight());
tvInbox.setCompoundDrawablesRelative(null, null, null, null);
tvDrafts.setCompoundDrawablesRelative(null, null, null, null);
tvSent.setCompoundDrawablesRelative(null, null, null, null);
tvTrash.setCompoundDrawablesRelative(null, null, null, null);
tvJunk.setCompoundDrawablesRelative(null, null, null, null);
tvArchive.setCompoundDrawablesRelative(null, null, null, null);
tvLeft.setText(""); tvLeft.setText("");
tvRight.setText(""); tvRight.setText("");
@ -56,7 +80,7 @@ public class FragmentReview extends FragmentDialogBase {
btnAccount.setOnClickListener(new View.OnClickListener() { btnAccount.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast( lbm.sendBroadcast(
new Intent(ActivitySetup.ACTION_EDIT_ACCOUNT) new Intent(ActivitySetup.ACTION_EDIT_ACCOUNT)
.putExtra("id", account) .putExtra("id", account)
@ -65,7 +89,7 @@ public class FragmentReview extends FragmentDialogBase {
} }
}); });
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(context);
db.account().liveAccountSwipes(account).observe(this, new Observer<List<TupleAccountSwipes>>() { db.account().liveAccountSwipes(account).observe(this, new Observer<List<TupleAccountSwipes>>() {
@Override @Override
public void onChanged(List<TupleAccountSwipes> swipes) { public void onChanged(List<TupleAccountSwipes> swipes) {
@ -81,7 +105,43 @@ public class FragmentReview extends FragmentDialogBase {
} }
}); });
return new AlertDialog.Builder(getContext()) db.folder().liveSystemFolders(account).observe(this, new Observer<List<EntityFolder>>() {
@Override
public void onChanged(List<EntityFolder> folders) {
if (folders == null)
folders = new ArrayList<>();
List<String> types = new ArrayList<>();
for (EntityFolder folder : folders)
if (!folder.local)
types.add(folder.type);
tvInbox.setCompoundDrawablesRelative(
types.contains(EntityFolder.INBOX) ? check : close, null, null, null);
tvDrafts.setCompoundDrawablesRelative(
types.contains(EntityFolder.DRAFTS) ? check : close, null, null, null);
tvSent.setCompoundDrawablesRelative(
types.contains(EntityFolder.SENT) ? check : close, null, null, null);
tvTrash.setCompoundDrawablesRelative(
types.contains(EntityFolder.TRASH) ? check : close, null, null, null);
tvJunk.setCompoundDrawablesRelative(
types.contains(EntityFolder.JUNK) ? check : close, null, null, null);
tvArchive.setCompoundDrawablesRelative(
types.contains(EntityFolder.ARCHIVE) ? check : close, null, null, null);
int textColorPrimary = Helper.resolveColor(context, android.R.attr.textColorPrimary);
int colorWarning = Helper.resolveColor(context, R.attr.colorWarning);
tvInbox.setTextColor(types.contains(EntityFolder.INBOX) ? textColorPrimary : colorWarning);
tvDrafts.setTextColor(types.contains(EntityFolder.DRAFTS) ? textColorPrimary : colorWarning);
tvSent.setTextColor(types.contains(EntityFolder.SENT) ? textColorPrimary : colorWarning);
tvTrash.setTextColor(types.contains(EntityFolder.TRASH) ? textColorPrimary : colorWarning);
tvJunk.setTextColor(types.contains(EntityFolder.JUNK) ? textColorPrimary : colorWarning);
tvArchive.setTextColor(types.contains(EntityFolder.ARCHIVE) ? textColorPrimary : colorWarning);
}
});
return new AlertDialog.Builder(context)
.setView(dview) .setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override

@ -20,6 +20,84 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvInbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:drawableStart="@drawable/twotone_check_24"
android:drawablePadding="12dp"
android:text="@string/title_folder_inbox"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvSuccess" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvDrafts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableStart="@drawable/twotone_check_24"
android:drawablePadding="12dp"
android:text="@string/title_folder_drafts"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvInbox" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableStart="@drawable/twotone_check_24"
android:drawablePadding="12dp"
android:text="@string/title_folder_sent"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvDrafts" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvTrash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableStart="@drawable/twotone_close_24"
android:drawablePadding="12dp"
android:text="@string/title_folder_trash"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvSent" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvJunk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableStart="@drawable/twotone_close_24"
android:drawablePadding="12dp"
android:text="@string/title_folder_junk"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvTrash" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvArchive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableStart="@drawable/twotone_close_24"
android:drawablePadding="12dp"
android:text="@string/title_folder_all"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvJunk" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvLeftTitle" android:id="@+id/tvLeftTitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -58,7 +136,7 @@
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/barrier" app:layout_constraintStart_toEndOf="@id/barrier"
app:layout_constraintTop_toBottomOf="@id/tvSuccess" /> app:layout_constraintTop_toBottomOf="@id/tvArchive" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvRight" android:id="@+id/tvRight"

Loading…
Cancel
Save