mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 21:58:52 +02:00
Improved re OAuth
This commit is contained in:
@@ -42,6 +42,7 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
@@ -68,6 +69,7 @@ public class FragmentGmail extends FragmentBase {
|
||||
private Button btnGrant;
|
||||
private TextView tvGranted;
|
||||
private EditText etName;
|
||||
private CheckBox cbUpdate;
|
||||
private Button btnSelect;
|
||||
private ContentLoadingProgressBar pbSelect;
|
||||
|
||||
@@ -89,6 +91,7 @@ public class FragmentGmail extends FragmentBase {
|
||||
btnGrant = view.findViewById(R.id.btnGrant);
|
||||
tvGranted = view.findViewById(R.id.tvGranted);
|
||||
etName = view.findViewById(R.id.etName);
|
||||
cbUpdate = view.findViewById(R.id.cbUpdate);
|
||||
btnSelect = view.findViewById(R.id.btnSelect);
|
||||
pbSelect = view.findViewById(R.id.pbSelect);
|
||||
|
||||
@@ -232,6 +235,7 @@ public class FragmentGmail extends FragmentBase {
|
||||
}
|
||||
|
||||
etName.setEnabled(granted);
|
||||
cbUpdate.setEnabled(granted);
|
||||
btnSelect.setEnabled(granted);
|
||||
|
||||
getMainHandler().post(new Runnable() {
|
||||
@@ -322,6 +326,7 @@ public class FragmentGmail extends FragmentBase {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString("name", etName.getText().toString().trim());
|
||||
args.putBoolean("update", cbUpdate.isChecked());
|
||||
args.putString("user", user);
|
||||
args.putString("password", state.jsonSerializeString());
|
||||
|
||||
@@ -329,6 +334,7 @@ public class FragmentGmail extends FragmentBase {
|
||||
@Override
|
||||
protected void onPreExecute(Bundle args) {
|
||||
etName.setEnabled(false);
|
||||
cbUpdate.setEnabled(false);
|
||||
btnSelect.setEnabled(false);
|
||||
pbSelect.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@@ -336,6 +342,7 @@ public class FragmentGmail extends FragmentBase {
|
||||
@Override
|
||||
protected void onPostExecute(Bundle args) {
|
||||
etName.setEnabled(true);
|
||||
cbUpdate.setEnabled(true);
|
||||
btnSelect.setEnabled(true);
|
||||
pbSelect.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -396,7 +403,9 @@ public class FragmentGmail extends FragmentBase {
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
EntityAccount update = db.account().getAccount(user, AUTH_TYPE_GMAIL);
|
||||
EntityAccount update = null;
|
||||
if (args.getBoolean("update"))
|
||||
update = db.account().getAccount(user, AUTH_TYPE_GMAIL);
|
||||
if (update == null) {
|
||||
EntityAccount primary = db.account().getPrimaryAccount();
|
||||
|
||||
@@ -465,7 +474,7 @@ public class FragmentGmail extends FragmentBase {
|
||||
identity.id = db.identity().insertIdentity(identity);
|
||||
EntityLog.log(context, "Gmail identity=" + identity.name + " email=" + identity.email);
|
||||
} else {
|
||||
args.putLong("account", update.id);
|
||||
args.putLong("account", -1);
|
||||
EntityLog.log(context, "Gmail update account=" + update.name);
|
||||
db.account().setAccountPassword(update.id, password);
|
||||
db.identity().setIdentityPassword(update.id, update.user, password, update.auth_type);
|
||||
@@ -483,10 +492,15 @@ public class FragmentGmail extends FragmentBase {
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Void data) {
|
||||
FragmentReview fragment = new FragmentReview();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(FragmentGmail.this, ActivitySetup.REQUEST_DONE);
|
||||
fragment.show(getParentFragmentManager(), "quick:review");
|
||||
if (args.getLong("account") < 0) {
|
||||
finish();
|
||||
ToastEx.makeText(getContext(), R.string.title_setup_oauth_updated, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
FragmentReview fragment = new FragmentReview();
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(FragmentGmail.this, ActivitySetup.REQUEST_DONE);
|
||||
fragment.show(getParentFragmentManager(), "quick:review");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user