aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/utils/PhoneHelper.java46
-rw-r--r--src/main/java/de/pixart/messenger/xml/Element.java5
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java2
4 files changed, 18 insertions, 37 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index 43e81b1f9..deff3b11c 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -364,7 +364,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
Bookmark bookmark = (Bookmark) conferences.get(position);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_TEXT, "xmpp:" + bookmark.getJid().asBareJid().toString() + "?join");
+ shareIntent.putExtra(Intent.EXTRA_TEXT, "xmpp:" + bookmark.getJid().asBareJid().toEscapedString() + "?join");
shareIntent.setType("text/plain");
try {
startActivity(Intent.createChooser(shareIntent, getText(R.string.share_uri_with)));
diff --git a/src/main/java/de/pixart/messenger/utils/PhoneHelper.java b/src/main/java/de/pixart/messenger/utils/PhoneHelper.java
index a8c53f699..452a31adc 100644
--- a/src/main/java/de/pixart/messenger/utils/PhoneHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/PhoneHelper.java
@@ -3,8 +3,6 @@ package de.pixart.messenger.utils;
import android.Manifest;
import android.content.Context;
import android.content.CursorLoader;
-import android.content.Loader;
-import android.content.Loader.OnLoadCompleteListener;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
@@ -41,36 +39,22 @@ public class PhoneHelper {
CursorLoader mCursorLoader = new NotThrowCursorLoader(context,
ContactsContract.Data.CONTENT_URI, PROJECTION, SELECTION, null,
null);
- mCursorLoader.registerListener(0, new OnLoadCompleteListener<Cursor>() {
-
- @Override
- public void onLoadComplete(Loader<Cursor> arg0, Cursor cursor) {
- if (cursor != null) {
- while (cursor.moveToNext()) {
- Bundle contact = new Bundle();
- contact.putInt("phoneid", cursor.getInt(cursor
- .getColumnIndex(ContactsContract.Data._ID)));
- contact.putString(
- "displayname",
- cursor.getString(cursor
- .getColumnIndex(ContactsContract.Data.DISPLAY_NAME)));
- contact.putString("photouri", cursor.getString(cursor
- .getColumnIndex(ContactsContract.Data.PHOTO_URI)));
- contact.putString("lookup", cursor.getString(cursor
- .getColumnIndex(ContactsContract.Data.LOOKUP_KEY)));
-
- contact.putString(
- "jid",
- cursor.getString(cursor
- .getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA)));
- phoneContacts.add(contact);
- }
- cursor.close();
+ mCursorLoader.registerListener(0, (arg0, c) -> {
+ if (c != null) {
+ while (c.moveToNext()) {
+ Bundle contact = new Bundle();
+ contact.putInt("phoneid", c.getInt(c.getColumnIndex(ContactsContract.Data._ID)));
+ contact.putString("displayname", c.getString(c.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)));
+ contact.putString("photouri", c.getString(c.getColumnIndex(ContactsContract.Data.PHOTO_URI)));
+ contact.putString("lookup", c.getString(c.getColumnIndex(ContactsContract.Data.LOOKUP_KEY)));
+ contact.putString("jid", c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA)));
+ phoneContacts.add(contact);
}
+ c.close();
+ }
- if (listener != null) {
- listener.onPhoneContactsLoaded(phoneContacts);
- }
+ if (listener != null) {
+ listener.onPhoneContactsLoaded(phoneContacts);
}
});
try {
@@ -91,7 +75,7 @@ public class PhoneHelper {
final Cursor cursor;
try {
cursor = context.getContentResolver().query(Profile.CONTENT_URI, projection, null, null, null);
- } catch (SecurityException e) {
+ } catch (Throwable e) {
return null;
}
if (cursor == null) {
diff --git a/src/main/java/de/pixart/messenger/xml/Element.java b/src/main/java/de/pixart/messenger/xml/Element.java
index 5ceb19c66..c2cb2a3b6 100644
--- a/src/main/java/de/pixart/messenger/xml/Element.java
+++ b/src/main/java/de/pixart/messenger/xml/Element.java
@@ -1,7 +1,6 @@
package de.pixart.messenger.xml;
import android.support.annotation.NonNull;
-import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
@@ -9,7 +8,6 @@ import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
-import de.pixart.messenger.Config;
import de.pixart.messenger.utils.XmlHelper;
import rocks.xmpp.addr.Jid;
@@ -151,9 +149,8 @@ public class Element {
final String jid = this.getAttribute(name);
if (jid != null && !jid.isEmpty()) {
try {
- return Jid.of(jid);
+ return Jid.ofEscaped(jid);
} catch (final IllegalArgumentException e) {
- Log.e(Config.LOGTAG, "could not parse jid " + jid);
return null;
}
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index cb289db64..0cab67922 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -1049,7 +1049,7 @@ public class XmppConnection implements Runnable {
final Element jid = bind.findChild("jid");
if (jid != null && jid.getContent() != null) {
try {
- Jid assignedJid = Jid.of(jid.getContent());
+ Jid assignedJid = Jid.ofEscaped(jid.getContent());
if (!account.getJid().getDomain().equals(assignedJid.getDomain())) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": server tried to re-assign domain to " + assignedJid.getDomain());
throw new StateChangingError(Account.State.BIND_FAILURE);