Detailed changes
@@ -88,9 +88,9 @@ public abstract class Jid implements Comparable<Jid>, Serializable, CharSequence
}
/**
- *
* @param jid a string representation of the jid to parse
- * @param fallback indicates whether an attempt should be made to parse a bare version of the jid
+ * @param fallback indicates whether an attempt should be made to parse a bare version of the
+ * jid
* @return an instance of Jid; may be Jid.Invalid
*/
public static Jid ofOrInvalid(final String jid, final boolean fallback) {
@@ -1,11 +1,9 @@
package eu.siacs.conversations.services;
import android.util.Log;
-
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.google.firebase.messaging.FirebaseMessaging;
-
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
@@ -15,7 +13,6 @@ import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.forms.Data;
-
import im.conversations.android.xmpp.model.stanza.Iq;
public class PushManagementService {
@@ -53,7 +50,7 @@ public class PushManagementService {
if (response.getType() == Iq.Type.RESULT && data != null) {
final Jid jid;
try {
- jid = Jid.ofEscaped(data.getValue("jid"));
+ jid = Jid.of(data.getValue("jid"));
} catch (final IllegalArgumentException e) {
Log.d(
Config.LOGTAG,
@@ -70,7 +67,8 @@ public class PushManagementService {
Log.d(
Config.LOGTAG,
account.getJid().asBareJid()
- + ": failed to enable push. invalid response from app server "
+ + ": failed to enable push. invalid response"
+ + " from app server "
+ response);
}
});
@@ -123,7 +121,8 @@ public class PushManagementService {
} catch (Exception e) {
Log.d(
Config.LOGTAG,
- "unable to get Firebase instance token due to bug in library ",
+ "unable to get Firebase instance token due to bug in"
+ + " library ",
e);
return;
}
@@ -1,21 +1,16 @@
package eu.siacs.conversations.entities;
import android.util.Base64;
-
import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
+import eu.siacs.conversations.android.PhoneNumberContact;
+import eu.siacs.conversations.xml.Element;
+import eu.siacs.conversations.xmpp.Jid;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import eu.siacs.conversations.android.PhoneNumberContact;
-import eu.siacs.conversations.xml.Element;
-import eu.siacs.conversations.xmpp.Jid;
-
public class Entry implements Comparable<Entry> {
private final List<Jid> jids;
private final String number;
@@ -47,23 +42,25 @@ public class Entry implements Comparable<Entry> {
return entries;
}
- public static String statusQuo(final Collection<PhoneNumberContact> phoneNumberContacts, Collection<Contact> systemContacts) {
+ public static String statusQuo(
+ final Collection<PhoneNumberContact> phoneNumberContacts,
+ Collection<Contact> systemContacts) {
return statusQuo(ofPhoneNumberContactsAndContacts(phoneNumberContacts, systemContacts));
}
private static String statusQuo(final List<Entry> entries) {
Collections.sort(entries);
StringBuilder builder = new StringBuilder();
- for(Entry entry : entries) {
+ for (Entry entry : entries) {
if (builder.length() != 0) {
builder.append('\u001d');
}
builder.append(entry.getNumber());
List<Jid> jids = entry.getJids();
Collections.sort(jids);
- for(Jid jid : jids) {
+ for (Jid jid : jids) {
builder.append('\u001e');
- builder.append(jid.asBareJid().toEscapedString());
+ builder.append(jid.asBareJid().toString());
}
}
@SuppressWarnings("deprecation")
@@ -71,12 +68,16 @@ public class Entry implements Comparable<Entry> {
return new String(Base64.encode(sha1, Base64.DEFAULT)).trim();
}
- private static List<Entry> ofPhoneNumberContactsAndContacts(final Collection<PhoneNumberContact> phoneNumberContacts, Collection<Contact> systemContacts) {
+ private static List<Entry> ofPhoneNumberContactsAndContacts(
+ final Collection<PhoneNumberContact> phoneNumberContacts,
+ Collection<Contact> systemContacts) {
final ArrayList<Entry> entries = new ArrayList<>();
- for(Contact contact : systemContacts) {
- final PhoneNumberContact phoneNumberContact = PhoneNumberContact.findByUri(phoneNumberContacts, contact.getSystemAccount());
+ for (Contact contact : systemContacts) {
+ final PhoneNumberContact phoneNumberContact =
+ PhoneNumberContact.findByUri(phoneNumberContacts, contact.getSystemAccount());
if (phoneNumberContact != null && phoneNumberContact.getPhoneNumber() != null) {
- Entry entry = findOrCreateByPhoneNumber(entries, phoneNumberContact.getPhoneNumber());
+ Entry entry =
+ findOrCreateByPhoneNumber(entries, phoneNumberContact.getPhoneNumber());
entry.jids.add(contact.getJid().asBareJid());
}
}
@@ -84,7 +85,7 @@ public class Entry implements Comparable<Entry> {
}
private static Entry findOrCreateByPhoneNumber(final List<Entry> entries, String number) {
- for(Entry entry : entries) {
+ for (Entry entry : entries) {
if (entry.number.equals(number)) {
return entry;
}
@@ -3,16 +3,13 @@ package eu.siacs.conversations.ui;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
-
import androidx.databinding.DataBindingUtil;
-
import eu.siacs.conversations.R;
import eu.siacs.conversations.databinding.ActivityEnterNameBinding;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.AbstractQuickConversationsService;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.AccountUtils;
-
import java.util.concurrent.atomic.AtomicBoolean;
public class EnterNameActivity extends XmppActivity
@@ -46,12 +43,12 @@ public class EnterNameActivity extends XmppActivity
if (AbstractQuickConversationsService.isQuicksyPlayStore()) {
intent = new Intent(getApplicationContext(), StartConversationActivity.class);
intent.putExtra("init", true);
- intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
+ intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toString());
} else {
intent = new Intent(this, PublishProfilePictureActivity.class);
intent.putExtra("setup", true);
}
- intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
+ intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toString());
startActivity(intent);
finish();
}
@@ -1,22 +1,18 @@
package eu.siacs.conversations.utils;
import android.content.Context;
-import android.telephony.TelephonyManager;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
import eu.siacs.conversations.xmpp.Jid;
import io.michaelrocks.libphonenumber.android.NumberParseException;
import io.michaelrocks.libphonenumber.android.PhoneNumberUtil;
import io.michaelrocks.libphonenumber.android.Phonenumber;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
public class PhoneNumberUtilWrapper {
private static volatile PhoneNumberUtil instance;
-
public static String getCountryForCode(String code) {
Locale locale = new Locale("", code);
return locale.getDisplayCountry();
@@ -24,20 +20,28 @@ public class PhoneNumberUtilWrapper {
public static String toFormattedPhoneNumber(Context context, Jid jid) {
try {
- return getInstance(context).format(toPhoneNumber(context, jid), PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL).replace(' ','\u202F');
+ return getInstance(context)
+ .format(
+ toPhoneNumber(context, jid),
+ PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL)
+ .replace(' ', '\u202F');
} catch (Exception e) {
- return jid.getEscapedLocal();
+ return jid.getLocal();
}
}
- public static Phonenumber.PhoneNumber toPhoneNumber(Context context, Jid jid) throws NumberParseException {
- return getInstance(context).parse(jid.getEscapedLocal(), "de");
+ public static Phonenumber.PhoneNumber toPhoneNumber(Context context, Jid jid)
+ throws NumberParseException {
+ return getInstance(context).parse(jid.getLocal(), "de");
}
- public static String normalize(Context context, String input) throws IllegalArgumentException, NumberParseException {
- final Phonenumber.PhoneNumber number = getInstance(context).parse(input, LocationProvider.getUserCountry(context));
+ public static String normalize(Context context, String input)
+ throws IllegalArgumentException, NumberParseException {
+ final Phonenumber.PhoneNumber number =
+ getInstance(context).parse(input, LocationProvider.getUserCountry(context));
if (!getInstance(context).isValidNumber(number)) {
- throw new IllegalArgumentException(String.format("%s is not a valid phone number", input));
+ throw new IllegalArgumentException(
+ String.format("%s is not a valid phone number", input));
}
return normalize(context, number);
}
@@ -54,7 +58,6 @@ public class PhoneNumberUtilWrapper {
if (localInstance == null) {
instance = localInstance = PhoneNumberUtil.createInstance(context);
}
-
}
}
return localInstance;
@@ -63,10 +66,10 @@ public class PhoneNumberUtilWrapper {
public static List<Country> getCountries(final Context context) {
List<Country> countries = new ArrayList<>();
for (String region : getInstance(context).getSupportedRegions()) {
- countries.add(new Country(region, getInstance(context).getCountryCodeForRegion(region)));
+ countries.add(
+ new Country(region, getInstance(context).getCountryCodeForRegion(region)));
}
return countries;
-
}
public static class Country implements Comparable<Country> {
@@ -97,5 +100,4 @@ public class PhoneNumberUtilWrapper {
return name.compareTo(o.name);
}
}
-
}