diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/StartConversationActivity.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/StartConversationActivity.java | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 52bff613c..5b337abb6 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -26,10 +26,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.text.Editable; -import android.text.SpannableString; -import android.text.Spanned; import android.text.TextWatcher; -import android.text.style.TypefaceSpan; import android.util.Log; import android.util.Pair; import android.view.ContextMenu; @@ -71,6 +68,7 @@ import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.services.XmppConnectionService.OnRosterUpdate; import de.pixart.messenger.ui.adapter.ListItemAdapter; import de.pixart.messenger.ui.interfaces.OnBackendConnected; +import de.pixart.messenger.ui.util.JidDialog; import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.ui.util.SoftKeyboardUtils; import de.pixart.messenger.utils.MenuDoubleTabUtil; @@ -429,7 +427,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setNegativeButton(R.string.cancel, null); builder.setTitle(R.string.action_delete_contact); - builder.setMessage(getString(R.string.remove_contact_text, contact.getJid())); + builder.setMessage(JidDialog.style(this, R.string.remove_contact_text, contact.getJid().toEscapedString())); builder.setPositiveButton(R.string.delete, (dialog, which) -> { xmppConnectionService.deleteContactOnServer(contact); filter(mSearchEditText.getText().toString()); @@ -444,7 +442,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setNegativeButton(R.string.cancel, null); builder.setTitle(R.string.delete_bookmark); - builder.setMessage(getString(R.string.remove_bookmark_text, bookmark.getJid())); + builder.setMessage(JidDialog.style(this, R.string.remove_bookmark_text, bookmark.getJid().toEscapedString())); builder.setPositiveButton(R.string.delete, (dialog, which) -> { bookmark.setConversation(null); Account account = bookmark.getAccount(); @@ -495,7 +493,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne contact.setServerName(invite.getName()); } if (contact.isSelf()) { - switchToConversation(contact, null); + switchToConversation(contact); return true; } else if (contact.showInRoster()) { throw new EnterJidDialog.JidError(getString(R.string.contact_already_exists)); @@ -504,7 +502,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne if (invite != null && invite.hasFingerprints()) { xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints()); } - switchToConversation(contact, invite == null ? null : invite.getBody()); + switchToConversationDoNotAppend(contact, invite == null ? null : invite.getBody()); return true; } }); @@ -552,9 +550,14 @@ public class StartConversationActivity extends XmppActivity implements XmppConne return xmppConnectionService.findAccountByJid(jid); } - protected void switchToConversation(Contact contact, String body) { + protected void switchToConversation(Contact contact) { Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false, true); - switchToConversation(conversation, body, false); + switchToConversation(conversation); + } + + protected void switchToConversationDoNotAppend(Contact contact, String body) { + Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false, true); + switchToConversationDoNotAppend(conversation, body); } @Override @@ -790,7 +793,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne if (invite.isAction(XmppUri.ACTION_JOIN)) { Conversation muc = xmppConnectionService.findFirstMuc(invite.getJid()); if (muc != null) { - switchToConversation(muc, invite.getBody(), false); + switchToConversationDoNotAppend(muc, invite.getBody()); return true; } else { showJoinConferenceDialog(invite.getJid().asBareJid().toString()); @@ -812,7 +815,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne if (invite.account != null) { xmppConnectionService.getShortcutService().report(contact); } - switchToConversation(contact, invite.getBody()); + switchToConversationDoNotAppend(contact, invite.getBody()); } return true; } else { @@ -834,19 +837,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne View view = getLayoutInflater().inflate(R.layout.dialog_verify_fingerprints, null); final CheckBox isTrustedSource = view.findViewById(R.id.trusted_source); TextView warning = view.findViewById(R.id.warning); - String jid = contact.getJid().asBareJid().toString(); - SpannableString spannable = new SpannableString(getString(R.string.verifying_omemo_keys_trusted_source, jid, contact.getDisplayName())); - int start = spannable.toString().indexOf(jid); - if (start >= 0) { - spannable.setSpan(new TypefaceSpan("monospace"), start, start + jid.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } - warning.setText(spannable); + warning.setText(JidDialog.style(this, R.string.verifying_omemo_keys_trusted_source, contact.getJid().asBareJid().toEscapedString(), contact.getDisplayName())); builder.setView(view); builder.setPositiveButton(R.string.confirm, (dialog, which) -> { if (isTrustedSource.isChecked() && invite.hasFingerprints()) { xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints()); } - switchToConversation(contact, invite.getBody()); + switchToConversationDoNotAppend(contact, invite.getBody()); }); builder.setNegativeButton(R.string.cancel, (dialog, which) -> StartConversationActivity.this.finish()); AlertDialog dialog = builder.create(); @@ -1128,13 +1125,13 @@ public class StartConversationActivity extends XmppActivity implements XmppConne @Override public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { - assert (0 <= position && position < fragments.length); FragmentTransaction trans = fragmentManager.beginTransaction(); trans.remove(fragments[position]); trans.commit(); fragments[position] = null; } + @NonNull @Override public Fragment instantiateItem(@NonNull ViewGroup container, int position) { Fragment fragment = getItem(position); @@ -1167,8 +1164,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } } - public Fragment getItem(int position) { - assert (0 <= position && position < fragments.length); + Fragment getItem(int position) { if (fragments[position] == null) { final MyListFragment listFragment = new MyListFragment(); if (position == 1) { |