mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-30 11:45:36 +00:00
Is this a good idea?
This commit is contained in:
parent
ca02055b77
commit
c1ebf5a69a
4 changed files with 30 additions and 1 deletions
|
@ -125,6 +125,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
private boolean hasAccount;
|
||||
private String password;
|
||||
private boolean import_accounts;
|
||||
private boolean import_delete;
|
||||
private boolean import_rules;
|
||||
private boolean import_contacts;
|
||||
private boolean import_answers;
|
||||
|
@ -337,6 +338,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
drawerToggle.setDrawerIndicatorEnabled(savedInstanceState.getBoolean("fair:toggle"));
|
||||
password = savedInstanceState.getString("fair:password");
|
||||
import_accounts = savedInstanceState.getBoolean("fair:import_accounts");
|
||||
import_delete = savedInstanceState.getBoolean("fair:import_delete");
|
||||
import_rules = savedInstanceState.getBoolean("fair:import_rules");
|
||||
import_contacts = savedInstanceState.getBoolean("fair:import_contacts");
|
||||
import_answers = savedInstanceState.getBoolean("fair:import_answers");
|
||||
|
@ -358,6 +360,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
outState.putBoolean("fair:toggle", drawerToggle.isDrawerIndicatorEnabled());
|
||||
outState.putString("fair:password", password);
|
||||
outState.putBoolean("fair:import_accounts", import_accounts);
|
||||
outState.putBoolean("fair:import_delete", import_delete);
|
||||
outState.putBoolean("fair:import_rules", import_rules);
|
||||
outState.putBoolean("fair:import_contacts", import_contacts);
|
||||
outState.putBoolean("fair:import_answers", import_answers);
|
||||
|
@ -807,6 +810,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
args.putParcelable("uri", uri);
|
||||
args.putString("password", this.password);
|
||||
args.putBoolean("import_accounts", this.import_accounts);
|
||||
args.putBoolean("import_delete", this.import_delete);
|
||||
args.putBoolean("import_rules", this.import_rules);
|
||||
args.putBoolean("import_contacts", this.import_contacts);
|
||||
args.putBoolean("import_answers", this.import_answers);
|
||||
|
@ -831,12 +835,14 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
Uri uri = args.getParcelable("uri");
|
||||
String password = args.getString("password");
|
||||
boolean import_accounts = args.getBoolean("import_accounts");
|
||||
boolean import_delete = args.getBoolean("import_delete");
|
||||
boolean import_rules = args.getBoolean("import_rules");
|
||||
boolean import_contacts = args.getBoolean("import_contacts");
|
||||
boolean import_answers = args.getBoolean("import_answers");
|
||||
boolean import_settings = args.getBoolean("import_settings");
|
||||
EntityLog.log(context, "Importing " + uri +
|
||||
" accounts=" + import_accounts +
|
||||
" delete=" + import_delete +
|
||||
" rules=" + import_rules +
|
||||
" contacts=" + import_contacts +
|
||||
" answers=" + import_answers +
|
||||
|
@ -928,6 +934,12 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
EntityAccount account = EntityAccount.fromJSON(jaccount);
|
||||
postProgress(context.getString(R.string.title_importing_account, account.name));
|
||||
|
||||
if (import_delete) {
|
||||
EntityAccount delete = db.account().getAccount(account.auth_type, account.user);
|
||||
if (delete != null)
|
||||
db.account().deleteAccount(delete.id);
|
||||
}
|
||||
|
||||
EntityAccount existing = db.account().getAccountByUUID(account.uuid);
|
||||
if (existing != null) {
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder();
|
||||
|
@ -1718,6 +1730,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_import, null);
|
||||
etPassword1 = dview.findViewById(R.id.tilPassword1);
|
||||
CheckBox cbAccounts = dview.findViewById(R.id.cbAccounts);
|
||||
CheckBox cbDelete = dview.findViewById(R.id.cbDelete);
|
||||
CheckBox cbRules = dview.findViewById(R.id.cbRules);
|
||||
CheckBox cbContacts = dview.findViewById(R.id.cbContacts);
|
||||
CheckBox cbAnswers = dview.findViewById(R.id.cbAnswers);
|
||||
|
@ -1750,6 +1763,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
ActivitySetup activity = (ActivitySetup) getActivity();
|
||||
activity.password = password1;
|
||||
activity.import_accounts = cbAccounts.isChecked();
|
||||
activity.import_delete = cbDelete.isChecked();
|
||||
activity.import_rules = cbRules.isChecked();
|
||||
activity.import_contacts = cbContacts.isChecked();
|
||||
activity.import_answers = cbAnswers.isChecked();
|
||||
|
|
|
@ -147,6 +147,9 @@ public interface DaoAccount {
|
|||
@Query("SELECT * FROM account WHERE uuid = :uuid")
|
||||
EntityAccount getAccountByUUID(String uuid);
|
||||
|
||||
@Query("SELECT * FROM account WHERE auth_type = :auth_type AND user = :user")
|
||||
EntityAccount getAccount(int auth_type, String user);
|
||||
|
||||
@Query("SELECT * FROM account WHERE name = :name")
|
||||
EntityAccount getAccount(String name);
|
||||
|
||||
|
|
|
@ -68,6 +68,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbAccounts" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbDelete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_setup_import_delete"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvImportHint" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbRules"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -77,7 +88,7 @@
|
|||
android:checked="true"
|
||||
android:text="@string/title_setup_import_contacts"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvImportHint" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbDelete" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbContacts"
|
||||
|
|
|
@ -262,6 +262,7 @@
|
|||
<string name="title_setup_password_different">Passwords don\'t match</string>
|
||||
<string name="title_setup_password_invalid">Password invalid</string>
|
||||
<string name="title_setup_import_accounts">Import accounts and identities</string>
|
||||
<string name="title_setup_import_delete" translatable="false">Delete existing accounts</string>
|
||||
<string name="title_setup_import_rules">Import filter rules</string>
|
||||
<string name="title_setup_import_contacts">Import local contacts</string>
|
||||
<string name="title_setup_import_answers">Import reply templates</string>
|
||||
|
|
Loading…
Reference in a new issue