mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Quick setup review account
This commit is contained in:
parent
5b670a61bc
commit
984800c191
3 changed files with 27 additions and 6 deletions
|
@ -47,6 +47,7 @@ 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;
|
||||
|
||||
|
@ -309,6 +310,7 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
account.last_connected = account.created;
|
||||
|
||||
account.id = db.account().insertAccount(account);
|
||||
args.putLong("account", account.id);
|
||||
EntityLog.log(context, "Quick added account=" + account.name);
|
||||
|
||||
// Create folders
|
||||
|
@ -343,6 +345,7 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
identity.primary = true;
|
||||
|
||||
identity.id = db.identity().insertIdentity(identity);
|
||||
args.putLong("identity", identity.id);
|
||||
EntityLog.log(context, "Quick added identity=" + identity.name + " email=" + identity.email);
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
|
@ -366,6 +369,7 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
grpSetup.setVisibility(result == null ? View.GONE : View.VISIBLE);
|
||||
} else {
|
||||
FragmentDialogDone fragment = new FragmentDialogDone();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(FragmentQuickSetup.this, REQUEST_DONE);
|
||||
fragment.show(getFragmentManager(), "quick:done");
|
||||
}
|
||||
|
@ -429,9 +433,18 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setMessage(R.string.title_setup_quick_success)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
.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);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -64,6 +64,7 @@ import androidx.preference.PreferenceManager;
|
|||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -551,12 +552,11 @@ public class FragmentSetup extends FragmentBase {
|
|||
String password = args.getString("password");
|
||||
|
||||
if (!user.contains("@"))
|
||||
throw new IllegalArgumentException(user);
|
||||
throw new IllegalArgumentException(
|
||||
context.getString(R.string.title_email_invalid, user));
|
||||
|
||||
String domain = user.split("@")[1];
|
||||
EmailProvider provider = EmailProvider.fromDomain(context, domain, EmailProvider.Discover.ALL);
|
||||
if (provider == null)
|
||||
throw new IllegalArgumentException(user);
|
||||
|
||||
List<EntityFolder> folders;
|
||||
|
||||
|
@ -567,7 +567,8 @@ public class FragmentSetup extends FragmentBase {
|
|||
folders = iservice.getFolders();
|
||||
|
||||
if (folders == null)
|
||||
throw new IllegalArgumentException(domain);
|
||||
throw new IllegalArgumentException(
|
||||
context.getString(R.string.title_setup_no_settings, domain));
|
||||
}
|
||||
|
||||
String iprotocol = provider.smtp.starttls ? "smtp" : "smtps";
|
||||
|
@ -600,6 +601,7 @@ public class FragmentSetup extends FragmentBase {
|
|||
account.last_connected = account.created;
|
||||
|
||||
account.id = db.account().insertAccount(account);
|
||||
args.putLong("account", account.id);
|
||||
EntityLog.log(context, "Gmail account=" + account.name);
|
||||
|
||||
// Create folders
|
||||
|
@ -646,6 +648,7 @@ public class FragmentSetup extends FragmentBase {
|
|||
identity.primary = true;
|
||||
|
||||
identity.id = db.identity().insertIdentity(identity);
|
||||
args.putLong("identity", identity.id);
|
||||
EntityLog.log(context, "Gmail identity=" + identity.name + " email=" + identity.email);
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
|
@ -661,12 +664,16 @@ public class FragmentSetup extends FragmentBase {
|
|||
@Override
|
||||
protected void onExecuted(Bundle args, Void data) {
|
||||
FragmentQuickSetup.FragmentDialogDone fragment = new FragmentQuickSetup.FragmentDialogDone();
|
||||
fragment.setArguments(args);
|
||||
fragment.show(getFragmentManager(), "gmail:done");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(getFragmentManager(), ex);
|
||||
if (ex instanceof IllegalArgumentException || ex instanceof UnknownHostException)
|
||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Snackbar.make(view, Helper.formatThrowable(ex, false), Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}.execute(this, args, "setup:gmail");
|
||||
}
|
||||
|
|
|
@ -420,6 +420,7 @@
|
|||
<string name="title_oauth_support">OAuth is not supported</string>
|
||||
<string name="title_authorize">Authorize</string>
|
||||
<string name="title_authorizing">Authorizing …</string>
|
||||
<string name="title_review">Review</string>
|
||||
|
||||
<string name="title_synchronize_now">Synchronize now</string>
|
||||
<string name="title_synchronize_all">Synchronize all messages</string>
|
||||
|
|
Loading…
Reference in a new issue