mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Added review dialog
This commit is contained in:
parent
0bffc2b0f4
commit
ebc7c98425
7 changed files with 177 additions and 71 deletions
|
@ -93,11 +93,14 @@ public interface DaoAccount {
|
|||
" WHERE account.synchronize) AS operations")
|
||||
LiveData<TupleAccountStats> liveStats();
|
||||
|
||||
@Query("SELECT account.id, account.swipe_left, l.type AS left_type, account.swipe_right, r.type AS right_type" +
|
||||
@Query("SELECT account.id" +
|
||||
", account.swipe_left, l.type AS left_type, l.name AS left_name" +
|
||||
", account.swipe_right, r.type AS right_type, r.name AS right_name" +
|
||||
" FROM account" +
|
||||
" LEFT JOIN folder l ON l.id = account.swipe_left" +
|
||||
" LEFT JOIN folder r ON r.id = account.swipe_right")
|
||||
LiveData<List<TupleAccountSwipes>> liveAccountSwipes();
|
||||
" LEFT JOIN folder r ON r.id = account.swipe_right" +
|
||||
" WHERE :account IS NULL OR account.id = :account")
|
||||
LiveData<List<TupleAccountSwipes>> liveAccountSwipes(Long account);
|
||||
|
||||
@Insert
|
||||
long insertAccount(EntityAccount account);
|
||||
|
|
|
@ -25,9 +25,7 @@ import android.accounts.AccountManager;
|
|||
import android.accounts.AccountManagerCallback;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
|
@ -49,15 +47,12 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static android.accounts.AccountManager.newChooseAccountIntent;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
public class FragmentGmail extends FragmentBase {
|
||||
private ViewGroup view;
|
||||
|
@ -380,10 +375,10 @@ public class FragmentGmail extends FragmentBase {
|
|||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Void data) {
|
||||
FragmentDialogDone fragment = new FragmentDialogDone();
|
||||
FragmentReview fragment = new FragmentReview();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(FragmentGmail.this, ActivitySetup.REQUEST_DONE);
|
||||
fragment.show(getFragmentManager(), "quick:done");
|
||||
fragment.show(getFragmentManager(), "quick:review");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -400,30 +395,4 @@ public class FragmentGmail extends FragmentBase {
|
|||
}
|
||||
}.execute(this, args, "setup:gmail");
|
||||
}
|
||||
|
||||
public static class FragmentDialogDone extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setMessage(R.string.title_setup_quick_success)
|
||||
.setPositiveButton(R.string.title_review, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Bundle args = getArguments();
|
||||
long account = args.getLong("account");
|
||||
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
lbm.sendBroadcast(
|
||||
new Intent(ActivitySetup.ACTION_EDIT_ACCOUNT)
|
||||
.putExtra("id", account)
|
||||
.putExtra("pop", false));
|
||||
|
||||
sendResult(RESULT_OK);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2226,7 +2226,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}
|
||||
});
|
||||
|
||||
db.account().liveAccountSwipes().observe(getViewLifecycleOwner(), new Observer<List<TupleAccountSwipes>>() {
|
||||
db.account().liveAccountSwipes(null).observe(getViewLifecycleOwner(), new Observer<List<TupleAccountSwipes>>() {
|
||||
@Override
|
||||
public void onChanged(List<TupleAccountSwipes> swipes) {
|
||||
if (swipes == null)
|
||||
|
|
|
@ -19,9 +19,7 @@ package eu.faircode.email;
|
|||
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
@ -44,9 +42,7 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
|
@ -56,8 +52,6 @@ import java.util.List;
|
|||
|
||||
import javax.mail.AuthenticationFailedException;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
public class FragmentQuickSetup extends FragmentBase {
|
||||
private ViewGroup view;
|
||||
private ScrollView scroll;
|
||||
|
@ -359,10 +353,10 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
: result.smtp.host + ":" + result.smtp.port + (result.smtp.starttls ? " starttls" : " ssl"));
|
||||
grpSetup.setVisibility(result == null ? View.GONE : View.VISIBLE);
|
||||
} else {
|
||||
FragmentDialogDone fragment = new FragmentDialogDone();
|
||||
FragmentReview fragment = new FragmentReview();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(FragmentQuickSetup.this, ActivitySetup.REQUEST_DONE);
|
||||
fragment.show(getFragmentManager(), "quick:done");
|
||||
fragment.show(getFragmentManager(), "quick:review");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,30 +410,4 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
Log.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FragmentDialogDone extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setMessage(R.string.title_setup_quick_success)
|
||||
.setPositiveButton(R.string.title_review, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Bundle args = getArguments();
|
||||
long account = args.getLong("account");
|
||||
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
lbm.sendBroadcast(
|
||||
new Intent(ActivitySetup.ACTION_EDIT_ACCOUNT)
|
||||
.putExtra("id", account)
|
||||
.putExtra("pop", false));
|
||||
|
||||
sendResult(RESULT_OK);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
75
app/src/main/java/eu/faircode/email/FragmentReview.java
Normal file
75
app/src/main/java/eu/faircode/email/FragmentReview.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package eu.faircode.email;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
public class FragmentReview extends FragmentDialogBase {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_review, null);
|
||||
TextView tvLeft = dview.findViewById(R.id.tvLeft);
|
||||
TextView tvRight = dview.findViewById(R.id.tvRight);
|
||||
Button btnAccount = dview.findViewById(R.id.btnAccount);
|
||||
|
||||
tvLeft.setText("");
|
||||
tvRight.setText("");
|
||||
|
||||
Bundle args = getArguments();
|
||||
final long account = args.getLong("account");
|
||||
|
||||
btnAccount.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
lbm.sendBroadcast(
|
||||
new Intent(ActivitySetup.ACTION_EDIT_ACCOUNT)
|
||||
.putExtra("id", account)
|
||||
.putExtra("pop", false));
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
DB db = DB.getInstance(getContext());
|
||||
db.account().liveAccountSwipes(account).observe(this, new Observer<List<TupleAccountSwipes>>() {
|
||||
@Override
|
||||
public void onChanged(List<TupleAccountSwipes> swipes) {
|
||||
if (swipes != null && swipes.size() == 1) {
|
||||
String left = swipes.get(0).left_name;
|
||||
String right = swipes.get(0).right_name;
|
||||
tvLeft.setText(left == null ? "-" : left);
|
||||
tvRight.setText(right == null ? "-" : right);
|
||||
} else {
|
||||
tvLeft.setText("?");
|
||||
tvRight.setText("?");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
sendResult(RESULT_OK);
|
||||
}
|
||||
})
|
||||
.create();
|
||||
}
|
||||
}
|
|
@ -23,6 +23,8 @@ public class TupleAccountSwipes {
|
|||
public long id;
|
||||
public Long swipe_left;
|
||||
public String left_type;
|
||||
public String left_name;
|
||||
public Long swipe_right;
|
||||
public String right_type;
|
||||
public String right_name;
|
||||
}
|
||||
|
|
89
app/src/main/res/layout/dialog_review.xml
Normal file
89
app/src/main/res/layout/dialog_review.xml
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="24dp"
|
||||
android:scrollbarStyle="outsideOverlay">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSuccess"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_setup_quick_success"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLeftTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_account_left"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvLeft"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvLeft" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvRightTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_account_right"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvRight"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvRight" />
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/barrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="end"
|
||||
app:constraint_referenced_ids="tvLeftTitle,tvRightTitle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLeft"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Archive"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/barrier"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvSuccess" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvRight"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="Trash"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/barrier"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvLeft" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAccount"
|
||||
style="@style/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:minWidth="0dp"
|
||||
android:minHeight="0dp"
|
||||
android:tag="disable"
|
||||
android:text="@string/title_edit_account"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvRight" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
Loading…
Reference in a new issue