use escaped jid for EXTRA_ACCOUNT

This commit is contained in:
Daniel Gultsch 2020-05-20 20:14:13 +02:00
parent 304411fc09
commit aa1e69d277
11 changed files with 24 additions and 24 deletions

View file

@ -85,7 +85,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
String jid = savedInstanceState.getString(STATE_SELECTED_ACCOUNT); String jid = savedInstanceState.getString(STATE_SELECTED_ACCOUNT);
if (jid != null) { if (jid != null) {
try { try {
this.selectedAccountJid = Jid.of(jid); this.selectedAccountJid = Jid.ofEscaped(jid);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
this.selectedAccountJid = null; this.selectedAccountJid = null;
} }
@ -111,7 +111,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
@Override @Override
public void onSaveInstanceState(final Bundle savedInstanceState) { public void onSaveInstanceState(final Bundle savedInstanceState) {
if (selectedAccount != null) { if (selectedAccount != null) {
savedInstanceState.putString(STATE_SELECTED_ACCOUNT, selectedAccount.getJid().asBareJid().toString()); savedInstanceState.putString(STATE_SELECTED_ACCOUNT, selectedAccount.getJid().asBareJid().toEscapedString());
} }
super.onSaveInstanceState(savedInstanceState); super.onSaveInstanceState(savedInstanceState);
} }
@ -286,7 +286,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
private void publishAvatar(Account account) { private void publishAvatar(Account account) {
Intent intent = new Intent(getApplicationContext(), Intent intent = new Intent(getApplicationContext(),
PublishProfilePictureActivity.class); PublishProfilePictureActivity.class);
intent.putExtra(EXTRA_ACCOUNT, account.getJid().toString()); intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
startActivity(intent); startActivity(intent);
} }

View file

@ -222,7 +222,7 @@ public class ChannelDiscoveryService {
continue; continue;
} }
for (final String mucService : xmppConnection.getMucServers()) { for (final String mucService : xmppConnection.getMucServers()) {
Jid jid = Jid.of(mucService); Jid jid = Jid.ofEscaped(mucService);
if (!localMucServices.containsKey(jid)) { if (!localMucServices.containsKey(jid)) {
localMucServices.put(jid, account); localMucServices.put(jid, account);
} }

View file

@ -35,7 +35,7 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
@Override @Override
public void onBackendConnected() { public void onBackendConnected() {
for (final Account account : xmppConnectionService.getAccounts()) { for (final Account account : xmppConnectionService.getAccounts()) {
if (account.getJid().toString().equals(getIntent().getStringExtra(EXTRA_ACCOUNT))) { if (account.getJid().toEscapedString().equals(getIntent().getStringExtra(EXTRA_ACCOUNT))) {
this.account = account; this.account = account;
break; break;
} }

View file

@ -73,7 +73,7 @@ public class ChooseAccountForProfilePictureActivity extends XmppActivity {
final Uri uri = startIntent == null ? null : startIntent.getData(); final Uri uri = startIntent == null ? null : startIntent.getData();
if (uri != null) { if (uri != null) {
Intent intent = new Intent(this, PublishProfilePictureActivity.class); Intent intent = new Intent(this, PublishProfilePictureActivity.class);
intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toString()); intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
intent.setData(uri); intent.setData(uri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try { try {

View file

@ -75,7 +75,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im
intent.putExtra(EXTRA_CONVERSATION, conversation.getUuid()); intent.putExtra(EXTRA_CONVERSATION, conversation.getUuid());
intent.putExtra(EXTRA_SELECT_MULTIPLE, true); intent.putExtra(EXTRA_SELECT_MULTIPLE, true);
intent.putExtra(EXTRA_SHOW_ENTER_JID, true); intent.putExtra(EXTRA_SHOW_ENTER_JID, true);
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString()); intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toEscapedString());
return intent; return intent;
} }
@ -321,7 +321,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im
final Intent request = getIntent(); final Intent request = getIntent();
final Intent data = new Intent(); final Intent data = new Intent();
data.putExtra("contact", contactJid.toString()); data.putExtra("contact", contactJid.toString());
data.putExtra(EXTRA_ACCOUNT, accountJid.toString()); data.putExtra(EXTRA_ACCOUNT, accountJid.toEscapedString());
data.putExtra(EXTRA_SELECT_MULTIPLE, false); data.putExtra(EXTRA_SELECT_MULTIPLE, false);
copy(request, data); copy(request, data);
setResult(RESULT_OK, data); setResult(RESULT_OK, data);
@ -401,7 +401,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im
data.putExtra("contact", item.getJid().toString()); data.putExtra("contact", item.getJid().toString());
String account = request.getStringExtra(EXTRA_ACCOUNT); String account = request.getStringExtra(EXTRA_ACCOUNT);
if (account == null && item instanceof Contact) { if (account == null && item instanceof Contact) {
account = ((Contact) item).getAccount().getJid().asBareJid().toString(); account = ((Contact) item).getAccount().getJid().asBareJid().toEscapedString();
} }
data.putExtra(EXTRA_ACCOUNT, account); data.putExtra(EXTRA_ACCOUNT, account);
data.putExtra(EXTRA_SELECT_MULTIPLE, false); data.putExtra(EXTRA_SELECT_MULTIPLE, false);

View file

@ -188,11 +188,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo", false); showInactiveOmemo = savedInstanceState != null && savedInstanceState.getBoolean("show_inactive_omemo", false);
if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) { if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
try { try {
this.accountJid = Jid.of(getIntent().getExtras().getString(EXTRA_ACCOUNT)); this.accountJid = Jid.ofEscaped(getIntent().getExtras().getString(EXTRA_ACCOUNT));
} catch (final IllegalArgumentException ignored) { } catch (final IllegalArgumentException ignored) {
} }
try { try {
this.contactJid = Jid.of(getIntent().getExtras().getString("contact")); this.contactJid = Jid.ofEscaped(getIntent().getExtras().getString("contact"));
} catch (final IllegalArgumentException ignored) { } catch (final IllegalArgumentException ignored) {
} }
} }

View file

@ -772,7 +772,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
contacts[i] = targets.get(i).toString(); contacts[i] = targets.get(i).toString();
} }
intent.putExtra("contacts", contacts); intent.putExtra("contacts", contacts);
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toString()); intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().asBareJid().toEscapedString());
intent.putExtra("conversation", conversation.getUuid()); intent.putExtra("conversation", conversation.getUuid());
startActivityForResult(intent, requestCode); startActivityForResult(intent, requestCode);
return true; return true;

View file

@ -121,7 +121,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
public void onClick(final View view) { public void onClick(final View view) {
if (mAccount != null) { if (mAccount != null) {
final Intent intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); final Intent intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class);
intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toString()); intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString());
startActivity(intent); startActivity(intent);
} }
} }
@ -445,7 +445,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString()); intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString());
} else { } else {
intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class);
intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toString()); intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString());
intent.putExtra("setup", true); intent.putExtra("setup", true);
} }
if (wasFirstAccount) { if (wasFirstAccount) {
@ -693,7 +693,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
recreate(); recreate();
} else if (intent != null) { } else if (intent != null) {
try { try {
this.jidToEdit = Jid.of(intent.getStringExtra("jid")); this.jidToEdit = Jid.ofEscaped(intent.getStringExtra("jid"));
} catch (final IllegalArgumentException | NullPointerException ignored) { } catch (final IllegalArgumentException | NullPointerException ignored) {
this.jidToEdit = null; this.jidToEdit = null;
} }
@ -754,7 +754,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
@Override @Override
public void onSaveInstanceState(final Bundle savedInstanceState) { public void onSaveInstanceState(final Bundle savedInstanceState) {
if (mAccount != null) { if (mAccount != null) {
savedInstanceState.putString("account", mAccount.getJid().asBareJid().toString()); savedInstanceState.putString("account", mAccount.getJid().asBareJid().toEscapedString());
savedInstanceState.putBoolean("initMode", mInitMode); savedInstanceState.putBoolean("initMode", mInitMode);
savedInstanceState.putBoolean("showMoreTable", binding.serverInfoMore.getVisibility() == View.VISIBLE); savedInstanceState.putBoolean("showMoreTable", binding.serverInfoMore.getVisibility() == View.VISIBLE);
} }
@ -765,7 +765,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
boolean init = true; boolean init = true;
if (mSavedInstanceAccount != null) { if (mSavedInstanceAccount != null) {
try { try {
this.mAccount = xmppConnectionService.findAccountByJid(Jid.of(mSavedInstanceAccount)); this.mAccount = xmppConnectionService.findAccountByJid(Jid.ofEscaped(mSavedInstanceAccount));
this.mInitMode = mSavedInstanceInit; this.mInitMode = mSavedInstanceInit;
init = false; init = false;
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -833,7 +833,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
break; break;
case R.id.action_show_block_list: case R.id.action_show_block_list:
final Intent showBlocklistIntent = new Intent(this, BlocklistActivity.class); final Intent showBlocklistIntent = new Intent(this, BlocklistActivity.class);
showBlocklistIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toString()); showBlocklistIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toEscapedString());
startActivity(showBlocklistIntent); startActivity(showBlocklistIntent);
break; break;
case R.id.action_server_info_show_more: case R.id.action_server_info_show_more:
@ -882,7 +882,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
private void gotoChangePassword(String newPassword) { private void gotoChangePassword(String newPassword) {
final Intent changePasswordIntent = new Intent(this, ChangePasswordActivity.class); final Intent changePasswordIntent = new Intent(this, ChangePasswordActivity.class);
changePasswordIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toString()); changePasswordIntent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().toEscapedString());
if (newPassword != null) { if (newPassword != null) {
changePasswordIntent.putExtra("password", newPassword); changePasswordIntent.putExtra("password", newPassword);
} }

View file

@ -165,7 +165,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
final Conversation conversation; final Conversation conversation;
Account account; Account account;
try { try {
account = xmppConnectionService.findAccountByJid(Jid.of(share.account)); account = xmppConnectionService.findAccountByJid(Jid.ofEscaped(share.account));
} catch (final IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
account = null; account = null;
} }

View file

@ -1000,7 +1000,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
intent.putExtra(ChooseContactActivity.EXTRA_SHOW_ENTER_JID, false); intent.putExtra(ChooseContactActivity.EXTRA_SHOW_ENTER_JID, false);
intent.putExtra(ChooseContactActivity.EXTRA_SELECT_MULTIPLE, true); intent.putExtra(ChooseContactActivity.EXTRA_SELECT_MULTIPLE, true);
intent.putExtra(ChooseContactActivity.EXTRA_GROUP_CHAT_NAME, name.trim()); intent.putExtra(ChooseContactActivity.EXTRA_GROUP_CHAT_NAME, name.trim());
intent.putExtra(ChooseContactActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toString()); intent.putExtra(ChooseContactActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
intent.putExtra(ChooseContactActivity.EXTRA_TITLE_RES_ID, R.string.choose_participants); intent.putExtra(ChooseContactActivity.EXTRA_TITLE_RES_ID, R.string.choose_participants);
startActivityForResult(intent, REQUEST_CREATE_CONFERENCE); startActivityForResult(intent, REQUEST_CREATE_CONFERENCE);
} }

View file

@ -522,8 +522,8 @@ public abstract class XmppActivity extends ActionBarActivity {
public void switchToContactDetails(Contact contact, String messageFingerprint) { public void switchToContactDetails(Contact contact, String messageFingerprint) {
Intent intent = new Intent(this, ContactDetailsActivity.class); Intent intent = new Intent(this, ContactDetailsActivity.class);
intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT); intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
intent.putExtra(EXTRA_ACCOUNT, contact.getAccount().getJid().asBareJid().toString()); intent.putExtra(EXTRA_ACCOUNT, contact.getAccount().getJid().asBareJid().toEscapedString());
intent.putExtra("contact", contact.getJid().toString()); intent.putExtra("contact", contact.getJid().toEscapedString());
intent.putExtra("fingerprint", messageFingerprint); intent.putExtra("fingerprint", messageFingerprint);
startActivity(intent); startActivity(intent);
} }
@ -538,7 +538,7 @@ public abstract class XmppActivity extends ActionBarActivity {
public void switchToAccount(Account account, boolean init, String fingerprint) { public void switchToAccount(Account account, boolean init, String fingerprint) {
Intent intent = new Intent(this, EditAccountActivity.class); Intent intent = new Intent(this, EditAccountActivity.class);
intent.putExtra("jid", account.getJid().asBareJid().toString()); intent.putExtra("jid", account.getJid().asBareJid().toEscapedString());
intent.putExtra("init", init); intent.putExtra("init", init);
if (init) { if (init) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);