mirror of https://github.com/M66B/FairEmail.git
Improved review account
This commit is contained in:
parent
fe559f7c84
commit
1400afb7ca
|
@ -164,6 +164,11 @@ public interface DaoFolder {
|
|||
" AND type <> '" + EntityFolder.USER + "'")
|
||||
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" +
|
||||
" WHERE folder.account = :account" +
|
||||
" AND folder.selectable" +
|
||||
|
|
|
@ -20,8 +20,10 @@ package eu.faircode.email;
|
|||
*/
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -34,6 +36,7 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import androidx.lifecycle.Observer;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
@ -42,10 +45,31 @@ public class FragmentReview extends FragmentDialogBase {
|
|||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_review_account, null);
|
||||
TextView tvLeft = dview.findViewById(R.id.tvLeft);
|
||||
TextView tvRight = dview.findViewById(R.id.tvRight);
|
||||
Button btnAccount = dview.findViewById(R.id.btnAccount);
|
||||
final Context context = getContext();
|
||||
|
||||
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_review_account, null);
|
||||
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("");
|
||||
tvRight.setText("");
|
||||
|
@ -56,7 +80,7 @@ public class FragmentReview extends FragmentDialogBase {
|
|||
btnAccount.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
new Intent(ActivitySetup.ACTION_EDIT_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>>() {
|
||||
@Override
|
||||
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)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,84 @@
|
|||
app:layout_constraintStart_toStartOf="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
|
||||
android:id="@+id/tvLeftTitle"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -58,7 +136,7 @@
|
|||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/barrier"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSuccess" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvArchive" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvRight"
|
||||
|
|
Loading…
Reference in New Issue