|
|
@ -1,9 +1,11 @@
|
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
@ -104,17 +106,23 @@ public class RegistrationActivity extends SherlockActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initializeNumber() {
|
|
|
|
private void initializeNumber() {
|
|
|
|
|
|
|
|
PhoneNumberUtil numberUtil = PhoneNumberUtil.getInstance();
|
|
|
|
String localNumber = org.whispersystems.textsecure.util.Util.getDeviceE164Number(this);
|
|
|
|
String localNumber = org.whispersystems.textsecure.util.Util.getDeviceE164Number(this);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (!Util.isEmpty(localNumber)) {
|
|
|
|
if (!Util.isEmpty(localNumber)) {
|
|
|
|
PhoneNumberUtil numberUtil = PhoneNumberUtil.getInstance();
|
|
|
|
|
|
|
|
Phonenumber.PhoneNumber localNumberObject = numberUtil.parse(localNumber, null);
|
|
|
|
Phonenumber.PhoneNumber localNumberObject = numberUtil.parse(localNumber, null);
|
|
|
|
|
|
|
|
|
|
|
|
if (localNumberObject != null) {
|
|
|
|
if (localNumberObject != null) {
|
|
|
|
this.countryCode.setText(localNumberObject.getCountryCode()+"");
|
|
|
|
this.countryCode.setText(localNumberObject.getCountryCode()+"");
|
|
|
|
this.number.setText(localNumberObject.getNationalNumber()+"");
|
|
|
|
this.number.setText(localNumberObject.getNationalNumber()+"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
String simCountryIso = ((TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE)).getSimCountryIso();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Util.isEmpty(simCountryIso)) {
|
|
|
|
|
|
|
|
this.countryCode.setText(numberUtil.getCountryCodeForRegion(simCountryIso.toUpperCase())+"");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (NumberParseException npe) {
|
|
|
|
} catch (NumberParseException npe) {
|
|
|
|
Log.w("CreateAccountActivity", npe);
|
|
|
|
Log.w("CreateAccountActivity", npe);
|
|
|
|