Reload on OAuth update

This commit is contained in:
M66B 2021-08-13 15:09:14 +02:00
parent 207f61d9c3
commit 4fd0e02d10
2 changed files with 20 additions and 8 deletions

View File

@ -445,11 +445,11 @@ public class FragmentGmail extends FragmentBase {
max_size = iservice.getMaxSize();
}
EntityAccount update = null;
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityAccount update = null;
if (args.getBoolean("update"))
update = db.account().getAccount(user, AUTH_TYPE_GMAIL);
if (update == null) {
@ -521,7 +521,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", -1);
args.putLong("account", update.id);
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);
@ -532,14 +532,20 @@ public class FragmentGmail extends FragmentBase {
db.endTransaction();
}
ServiceSynchronize.eval(context, "Gmail");
if (update == null)
ServiceSynchronize.eval(context, "Gmail");
else {
args.putBoolean("updated", true);
ServiceSynchronize.reload(context, update.id, true, "Gmail");
}
return null;
}
@Override
protected void onExecuted(Bundle args, Void data) {
if (args.getLong("account") < 0) {
boolean updated = args.getBoolean("updated");
if (updated) {
finish();
ToastEx.makeText(getContext(), R.string.title_setup_oauth_updated, Toast.LENGTH_LONG).show();
} else {

View File

@ -670,11 +670,11 @@ public class FragmentOAuth extends FragmentBase {
Log.i("OAuth passed provider=" + provider.id);
EntityAccount update = null;
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityAccount update = null;
if (args.getBoolean("update"))
update = db.account().getAccount(username, AUTH_TYPE_OAUTH);
if (update == null) {
@ -755,7 +755,7 @@ public class FragmentOAuth extends FragmentBase {
EntityLog.log(context, "OAuth identity=" + ident.name + " email=" + ident.email);
}
} else {
args.putLong("account", -1);
args.putLong("account", update.id);
EntityLog.log(context, "OAuth update account=" + update.name);
db.account().setAccountPassword(update.id, state);
db.identity().setIdentityPassword(update.id, update.user, state, update.auth_type);
@ -766,7 +766,12 @@ public class FragmentOAuth extends FragmentBase {
db.endTransaction();
}
ServiceSynchronize.eval(context, "OAuth");
if (update == null)
ServiceSynchronize.eval(context, "OAuth");
else {
args.putBoolean("updated", true);
ServiceSynchronize.reload(context, update.id, true, "OAuth");
}
return null;
}
@ -775,7 +780,8 @@ public class FragmentOAuth extends FragmentBase {
protected void onExecuted(Bundle args, Void data) {
pbOAuth.setVisibility(View.GONE);
if (args.getLong("account") < 0) {
boolean updated = args.getBoolean("updated");
if (updated) {
finish();
ToastEx.makeText(getContext(), R.string.title_setup_oauth_updated, Toast.LENGTH_LONG).show();
} else {