Skip identity selection if one

This commit is contained in:
M66B 2021-02-04 13:56:01 +01:00
parent 83f5f3f74b
commit 66ff193d84
1 changed files with 32 additions and 14 deletions

View File

@ -2607,21 +2607,39 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void onCompose() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean identities_asked = prefs.getBoolean("identities_asked", false);
if (identities_asked)
startActivity(new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "new")
.putExtra("account", account)
);
else {
Bundle args = new Bundle();
args.putLong("account", account);
new SimpleTask<Boolean>() {
@Override
protected Boolean onExecute(Context context, Bundle args) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean identities_asked = prefs.getBoolean("identities_asked", false);
if (identities_asked)
return false;
DB db = DB.getInstance(context);
List<TupleIdentityEx> identities = db.identity().getComposableIdentities(null);
return (identities != null && identities.size() > 1);
}
@Override
protected void onExecuted(Bundle args, Boolean ask) {
if (ask) {
FragmentDialogIdentity fragment = new FragmentDialogIdentity();
fragment.setArguments(args);
fragment.show(getParentFragmentManager(), "messages:identities");
} else
startActivity(new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "new")
.putExtra("account", account));
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "message:compose");
}
private void onMore() {