fork-5.53.8
Moxie Marlinspike 2013-07-09 16:36:15 -07:00
rodzic 7eef93c829
commit 0958c30400
2 zmienionych plików z 53 dodań i 26 usunięć

Wyświetl plik

@ -186,6 +186,35 @@
exchanges\' setting disabled.
</string>
<!-- RegistrationActivity -->
<string name="RegistrationActivity_connect_with_textsecure">Connect With TextSecure</string>
<string name="RegistrationActivity_select_your_country">Select Your Country</string>
<string name="RegistrationActivity_you_must_specify_your_country_code">You must specify your
country code
</string>
<string name="RegistrationActivity_you_must_specify_your_phone_number">You must specify your
phone number
</string>
<string name="RegistrationActivity_invalid_number">Invalid number</string>
<string name="RegistrationActivity_the_number_you_specified_s_is_invalid">The number you
specified (%s) is invalid.
</string>
<string name="RegistrationActivity_unsupported">Unsupported</string>
<string name="RegistrationActivity_sorry_this_device_is_not_supported_for_data_messaging">Sorry,
this device is not supported for data messaging. Devices running versions of Android older
than 4.0 must have a registered Google Account. Devices running Android 4.0 or newer do not
require a Google Account, but must have the Play Store app installed.
</string>
<string name="RegistrationActivity_we_will_now_verify_that_the_following_number_is_associated_with_your_device_s">
We will now verify that the following number is associated with this device:
%s
Is this number correct, or would you like to edit it before continuing?
</string>
<string name="RegistrationActivity_continue">Continue</string>
<string name="RegistrationActivity_edit">Edit</string>
<!-- RegistrationProblemsActivity -->
<string name="RegistrationProblemsActivity_possible_problems">Possible Problems</string>

Wyświetl plik

@ -28,25 +28,21 @@ import org.thoughtcrime.securesms.util.PhoneNumberFormatter;
import org.thoughtcrime.securesms.util.Util;
/**
* The create account activity. Kicks off an account creation event, then waits
* the server to respond with a challenge via SMS, receives the challenge, and
* verifies it with the server.
* The register account activity. Begins the account registration process.
*
* @author Moxie Marlinspike
*
*/
public class RegistrationActivity extends SherlockActivity {
private static final int PICK_COUNTRY = 1;
private AsYouTypeFormatter countryFormatter;
private AsYouTypeFormatter countryFormatter;
private ArrayAdapter<String> countrySpinnerAdapter;
private Spinner countrySpinner;
private TextView countryCode;
private Spinner countrySpinner;
private TextView countryCode;
private TextView number;
private Button createButton;
private Button createButton;
@Override
public void onCreate(Bundle icicle) {
@ -54,7 +50,7 @@ public class RegistrationActivity extends SherlockActivity {
setContentView(R.layout.registration_activity);
ActionBar actionBar = this.getSupportActionBar();
actionBar.setTitle("Connect With TextSecure");
actionBar.setTitle(getString(R.string.RegistrationActivity_connect_with_textsecure));
initializeResources();
initializeNumber();
@ -77,7 +73,7 @@ public class RegistrationActivity extends SherlockActivity {
this.countrySpinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
this.countrySpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
setCountryDisplay("Select Your Country");
setCountryDisplay(getString(R.string.RegistrationActivity_select_your_country));
this.countrySpinner.setAdapter(this.countrySpinnerAdapter);
this.countrySpinner.setOnTouchListener(new View.OnTouchListener() {
@ -99,7 +95,7 @@ public class RegistrationActivity extends SherlockActivity {
private void initializeNumber() {
String localNumber = ((TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE))
.getLine1Number();
.getLine1Number();
if (!Util.isEmpty(localNumber) && !localNumber.startsWith("+")) {
if (localNumber.length() == 10) localNumber = "+1" + localNumber;
@ -130,11 +126,8 @@ public class RegistrationActivity extends SherlockActivity {
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
String regionCode = util.getRegionCodeForCountryCode(countryCode);
if (regionCode == null) {
this.countryFormatter = null;
} else {
this.countryFormatter = util.getAsYouTypeFormatter(regionCode);
}
if (regionCode == null) this.countryFormatter = null;
else this.countryFormatter = util.getAsYouTypeFormatter(regionCode);
}
private String getConfiguredE164Number() {
@ -148,13 +141,15 @@ public class RegistrationActivity extends SherlockActivity {
final RegistrationActivity self = RegistrationActivity.this;
if (Util.isEmpty(countryCode.getText())) {
Toast.makeText(self, "You must specify your country code",
Toast.makeText(self,
getString(R.string.RegistrationActivity_you_must_specify_your_country_code),
Toast.LENGTH_LONG).show();
return;
}
if (Util.isEmpty(number.getText())) {
Toast.makeText(self, "You must specify your phone number",
Toast.makeText(self,
getString(R.string.RegistrationActivity_you_must_specify_your_phone_number),
Toast.LENGTH_LONG).show();
return;
}
@ -163,22 +158,24 @@ public class RegistrationActivity extends SherlockActivity {
if (!PhoneNumberFormatter.isValidNumber(e164number)) {
Util.showAlertDialog(self,
"Invalid number",
String.format("The number you specified (%s) is invalid.", e164number));
getString(R.string.RegistrationActivity_invalid_number),
String.format(getString(R.string.RegistrationActivity_the_number_you_specified_s_is_invalid),
e164number));
return;
}
try {
GCMRegistrar.checkDevice(self);
} catch (UnsupportedOperationException uoe) {
Util.showAlertDialog(self, "Unsupported", "Sorry, this device is not supported for data messaging. Devices running versions of Android older than 4.0 must have a registered Google Account. Devices running Android 4.0 or newer do not require a Google Account, but must have the Play Store app installed.");
Util.showAlertDialog(self, getString(R.string.RegistrationActivity_unsupported),
getString(R.string.RegistrationActivity_sorry_this_device_is_not_supported_for_data_messaging));
return;
}
AlertDialog.Builder dialog = new AlertDialog.Builder(self);
dialog.setMessage(String.format("We will now verify that the following number is associated with this device:\n\n%s\n\nIs this number correct, or would you like to edit it before continuing?",
dialog.setMessage(String.format(getString(R.string.RegistrationActivity_we_will_now_verify_that_the_following_number_is_associated_with_your_device_s),
PhoneNumberFormatter.getInternationalFormatFromE164(e164number)));
dialog.setPositiveButton("Continue",
dialog.setPositiveButton(getString(R.string.RegistrationActivity_continue),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -188,7 +185,7 @@ public class RegistrationActivity extends SherlockActivity {
finish();
}
});
dialog.setNegativeButton("Edit", null);
dialog.setNegativeButton(getString(R.string.RegistrationActivity_edit), null);
dialog.show();
}
}
@ -197,13 +194,14 @@ public class RegistrationActivity extends SherlockActivity {
@Override
public void afterTextChanged(Editable s) {
if (Util.isEmpty(s)) {
setCountryDisplay("Select your country");
setCountryDisplay(getString(R.string.RegistrationActivity_select_your_country));
countryFormatter = null;
return;
}
int countryCode = Integer.parseInt(s.toString());
String regionCode = PhoneNumberUtil.getInstance().getRegionCodeForCountryCode(countryCode);
setCountryFormatter(countryCode);
setCountryDisplay(PhoneNumberFormatter.getRegionDisplayName(regionCode));