Default identity selection

This commit is contained in:
M66B 2019-09-29 11:58:51 +02:00
parent 01b0476050
commit 2cc701f481
1 changed files with 21 additions and 0 deletions

View File

@ -759,7 +759,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
.putExtra("account", account)
);
else {
Bundle args = new Bundle();
args.putLong("account", account);
FragmentDialogIdentity fragment = new FragmentDialogIdentity();
fragment.setArguments(args);
fragment.show(getFragmentManager(), "messages:identities");
}
}
@ -4690,6 +4694,23 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
AdapterIdentitySelect iadapter = new AdapterIdentitySelect(getContext(), identities);
spIdentity.setAdapter(iadapter);
Integer fallback = null;
long account = getArguments().getLong("account");
for (int pos = 0; pos < identities.size(); pos++) {
EntityIdentity identity = identities.get(pos);
if (identity.account.equals(account)) {
if (identity.primary) {
fallback = null;
spIdentity.setSelection(pos);
break;
}
if (fallback == null)
fallback = pos;
}
}
if (fallback != null)
spIdentity.setSelection(fallback);
grpIdentities.setVisibility(identities.size() > 0 ? View.VISIBLE : View.GONE);
grpNoIdentities.setVisibility(identities.size() > 0 ? View.GONE : View.VISIBLE);
}