Work on assistant account creation
This commit is contained in:
parent
aabb281c97
commit
a1f9d6680a
9 changed files with 134 additions and 49 deletions
|
@ -15,7 +15,7 @@
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center_vertical|center_horizontal|center"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -71,8 +71,8 @@
|
||||||
<string name="assistant_finish">Finish configuration</string>
|
<string name="assistant_finish">Finish configuration</string>
|
||||||
<string name="assistant_validate_account">Your account is created. Please check your mails to validate your account. Once it is done, come back here and click on the button.</string>
|
<string name="assistant_validate_account">Your account is created. Please check your mails to validate your account. Once it is done, come back here and click on the button.</string>
|
||||||
<string name="assistant_welcome_desc">This assistant will help you configure and use your SIP account.</string>
|
<string name="assistant_welcome_desc">This assistant will help you configure and use your SIP account.</string>
|
||||||
<string name="assistant_linphone_login_desc">Enter your username and password of Linphone account</string>
|
<string name="assistant_linphone_login_desc">Please enter your username and password of Linphone account</string>
|
||||||
<string name="assistant_login_desc">Enter your username and password with your SIP domain</string>
|
<string name="assistant_login_desc">Please enter your username and password with your SIP domain</string>
|
||||||
<string name="assistant_remote_provisioning_desc">Please provide your provisioning URL</string>
|
<string name="assistant_remote_provisioning_desc">Please provide your provisioning URL</string>
|
||||||
<string name="transport">Transport</string>
|
<string name="transport">Transport</string>
|
||||||
<string name="assistant_create_account_phone_number_address">Your SIP address is</string>
|
<string name="assistant_create_account_phone_number_address">Your SIP address is</string>
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
<string name="wizard_failed">An error occurred, try again later.</string>
|
<string name="wizard_failed">An error occurred, try again later.</string>
|
||||||
<string name="wizard_server_unavailable">Server unreachable, verify your network connection.</string>
|
<string name="wizard_server_unavailable">Server unreachable, verify your network connection.</string>
|
||||||
<string name="wizard_username_unavailable">This username is already in use.</string>
|
<string name="wizard_username_unavailable">This username is already in use.</string>
|
||||||
<string name="assistant_phone_number_unavailable">This phone number is already in used.\r\nPlease type a different number or delete your existing account if you want to reuse your number.</string>
|
<string name="assistant_phone_number_unavailable">This phone number is already in used.\r\nPlease type a different number.\r\nYou can delete your existing account if you want to reuse your phone number.</string>
|
||||||
<string name="wizard_username_incorrect">Your username is invalid.</string>
|
<string name="wizard_username_incorrect">Your username is invalid.</string>
|
||||||
<string name="assistant_phone_number_incorrect">Your phone number is invalid.</string>
|
<string name="assistant_phone_number_incorrect">Your phone number is invalid.</string>
|
||||||
<string name="wizard_email_incorrect">Your email is invalid.</string>
|
<string name="wizard_email_incorrect">Your email is invalid.</string>
|
||||||
|
@ -125,6 +125,7 @@
|
||||||
<string name="invalid_username">Invalid username</string>
|
<string name="invalid_username">Invalid username</string>
|
||||||
<string name="invalid_domain">Invalid domain</string>
|
<string name="invalid_domain">Invalid domain</string>
|
||||||
<string name="invalid_route">Invalid route</string>
|
<string name="invalid_route">Invalid route</string>
|
||||||
|
<string name="invalid_display_name">Invalid display name</string>
|
||||||
<string name="username_too_short">Username too short</string>
|
<string name="username_too_short">Username too short</string>
|
||||||
<string name="username_too_long">Username too long</string>
|
<string name="username_too_long">Username too long</string>
|
||||||
<string name="username_invalid_size">Username length invalid</string>
|
<string name="username_invalid_size">Username length invalid</string>
|
||||||
|
|
|
@ -1853,6 +1853,11 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ContactPicked {
|
interface ContactPicked {
|
||||||
|
|
|
@ -606,15 +606,15 @@ public final class LinphoneUtils {
|
||||||
if (status.equals(LinphoneAccountCreator.Status.PhoneNumberInvalid))
|
if (status.equals(LinphoneAccountCreator.Status.PhoneNumberInvalid))
|
||||||
return ctxt.getString(R.string.phone_number_invalid);
|
return ctxt.getString(R.string.phone_number_invalid);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.PasswordTooShort))
|
if (status.equals(LinphoneAccountCreator.Status.PasswordTooShort))
|
||||||
return ctxt.getString(R.string.username_too_short);
|
return ctxt.getString(R.string.password_too_short);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.PasswordTooLong))
|
if (status.equals(LinphoneAccountCreator.Status.PasswordTooLong))
|
||||||
return ctxt.getString(R.string.username_too_long);
|
return ctxt.getString(R.string.password_too_long);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.DomainInvalid))
|
if (status.equals(LinphoneAccountCreator.Status.DomainInvalid))
|
||||||
return ctxt.getString(R.string.invalid_domain);
|
return ctxt.getString(R.string.invalid_domain);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.RouteInvalid))
|
if (status.equals(LinphoneAccountCreator.Status.RouteInvalid))
|
||||||
return ctxt.getString(R.string.invalid_route);
|
return ctxt.getString(R.string.invalid_route);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.DisplayNameInvalid))
|
if (status.equals(LinphoneAccountCreator.Status.DisplayNameInvalid))
|
||||||
return ctxt.getString(R.string.invalid_route);
|
return ctxt.getString(R.string.invalid_display_name);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.Failed))
|
if (status.equals(LinphoneAccountCreator.Status.Failed))
|
||||||
return ctxt.getString(R.string.request_failed);
|
return ctxt.getString(R.string.request_failed);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.TransportNotSupported))
|
if (status.equals(LinphoneAccountCreator.Status.TransportNotSupported))
|
||||||
|
@ -625,15 +625,17 @@ public final class LinphoneUtils {
|
||||||
return ctxt.getString(R.string.account_already_exist);
|
return ctxt.getString(R.string.account_already_exist);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.CountryCodeInvalid))
|
if (status.equals(LinphoneAccountCreator.Status.CountryCodeInvalid))
|
||||||
return ctxt.getString(R.string.country_code_invalid);
|
return ctxt.getString(R.string.country_code_invalid);
|
||||||
if (status.equals(LinphoneAccountCreator.Status.AccountCreated)
|
if (status.equals(LinphoneAccountCreator.Status.PhoneNumberUsedAccount)
|
||||||
|
|| status.equals(LinphoneAccountCreator.Status.PhoneNumberUsedAlias))
|
||||||
|
return ctxt.getString(R.string.assistant_phone_number_unavailable);
|
||||||
|
if (status.equals(LinphoneAccountCreator.Status.PhoneNumberNotUsed)
|
||||||
|| status.equals(LinphoneAccountCreator.Status.AccountNotCreated)
|
|| status.equals(LinphoneAccountCreator.Status.AccountNotCreated)
|
||||||
|| status.equals(LinphoneAccountCreator.Status.AccountNotExist)
|
|| status.equals(LinphoneAccountCreator.Status.AccountNotExist)
|
||||||
|| status.equals(LinphoneAccountCreator.Status.AccountNotActivated)
|
|| status.equals(LinphoneAccountCreator.Status.AccountNotActivated)
|
||||||
|| status.equals(LinphoneAccountCreator.Status.AccountAlreadyActivated)
|
|| status.equals(LinphoneAccountCreator.Status.AccountAlreadyActivated)
|
||||||
|| status.equals(LinphoneAccountCreator.Status.AccountActivated)
|
|| status.equals(LinphoneAccountCreator.Status.AccountActivated)
|
||||||
|| status.equals(LinphoneAccountCreator.Status.Ok)) {
|
|| status.equals(LinphoneAccountCreator.Status.Ok))
|
||||||
return "";
|
return "";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -683,6 +683,11 @@ private static AssistantActivity instance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public CountryListAdapter getCountryListAdapter() {
|
public CountryListAdapter getCountryListAdapter() {
|
||||||
return countryListAdapter;
|
return countryListAdapter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class CreateAccountCodeActivationFragment extends Fragment implements Lin
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.assistant_account_creation_code_activation, container, false);
|
View view = inflater.inflate(R.layout.assistant_account_creation_code_activation, container, false);
|
||||||
|
|
||||||
username = getArguments().getString("Username");
|
username = getArguments().getString("Username");
|
||||||
phone = getArguments().getString("Phone");
|
phone = getArguments().getString("Phone");
|
||||||
dialcode = getArguments().getString("Dialcode");
|
dialcode = getArguments().getString("Dialcode");
|
||||||
|
@ -190,4 +190,9 @@ public class CreateAccountCodeActivationFragment extends Fragment implements Lin
|
||||||
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,13 +58,14 @@ import static org.linphone.core.LinphoneAccountCreator.*;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class CreateAccountFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener, LinphoneAccountCreatorListener {
|
public class CreateAccountFragment extends Fragment implements CompoundButton.OnCheckedChangeListener
|
||||||
private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit, dialCode;
|
, OnClickListener, LinphoneAccountCreatorListener {
|
||||||
private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError, emailError, assisstantTitle, sipUri, skip;
|
private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit
|
||||||
|
, emailEdit, dialCode;
|
||||||
|
private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError
|
||||||
|
, emailError, assisstantTitle, sipUri, skip;
|
||||||
private ImageView phoneNumberInfo;
|
private ImageView phoneNumberInfo;
|
||||||
|
|
||||||
private boolean phoneNumberOk = false;
|
|
||||||
private boolean usernameOk = false;
|
|
||||||
private boolean passwordOk = false;
|
private boolean passwordOk = false;
|
||||||
private boolean emailOk = false;
|
private boolean emailOk = false;
|
||||||
private boolean confirmPasswordOk = false;
|
private boolean confirmPasswordOk = false;
|
||||||
|
@ -82,7 +83,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
|
View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
|
||||||
|
|
||||||
//Initialize accountCreator
|
//Initialize accountCreator
|
||||||
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
|
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc()
|
||||||
|
, LinphonePreferences.instance().getXmlrpcUrl());
|
||||||
accountCreator.setDomain(getResources().getString(R.string.default_domain));
|
accountCreator.setDomain(getResources().getString(R.string.default_domain));
|
||||||
accountCreator.setListener(this);
|
accountCreator.setListener(this);
|
||||||
|
|
||||||
|
@ -124,7 +126,9 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
//Phone number
|
//Phone number
|
||||||
if (getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
if (getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
||||||
//Automatically get the country code from the phone
|
//Automatically get the country code from the phone
|
||||||
TelephonyManager tm = (TelephonyManager) getActivity().getApplicationContext().getSystemService(getActivity().getApplicationContext().TELEPHONY_SERVICE);
|
TelephonyManager tm =
|
||||||
|
(TelephonyManager) getActivity().getApplicationContext().getSystemService(
|
||||||
|
getActivity().getApplicationContext().TELEPHONY_SERVICE);
|
||||||
String countryIso = tm.getNetworkCountryIso();
|
String countryIso = tm.getNetworkCountryIso();
|
||||||
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
||||||
countryCode = proxyConfig.lookupCCCFromIso(countryIso.toUpperCase());
|
countryCode = proxyConfig.lookupCCCFromIso(countryIso.toUpperCase());
|
||||||
|
@ -138,7 +142,13 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
if (previousPhone != null ) {
|
if (previousPhone != null ) {
|
||||||
phoneNumberEdit.setText(previousPhone);
|
phoneNumberEdit.setText(previousPhone);
|
||||||
}
|
}
|
||||||
LinphoneUtils.setCountry(AssistantActivity.instance().country, dialCode, selectCountry, countryCode);
|
AssistantActivity.Country c = AssistantActivity.instance().getCountryListAdapter()
|
||||||
|
.getCountryFromCountryCode(String.valueOf(countryCode));
|
||||||
|
if (c != null) {
|
||||||
|
AssistantActivity.instance().country = c;
|
||||||
|
selectCountry.setText(c.name);
|
||||||
|
}
|
||||||
|
LinphoneUtils.setCountry(c, dialCode, selectCountry, countryCode);
|
||||||
|
|
||||||
//Allow user to enter a username instead use the phone number as username
|
//Allow user to enter a username instead use the phone number as username
|
||||||
if (getResources().getBoolean(R.bool.assistant_allow_username)) {
|
if (getResources().getBoolean(R.bool.assistant_allow_username)) {
|
||||||
|
@ -150,7 +160,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
}
|
}
|
||||||
|
|
||||||
//Password & email address
|
//Password & email address
|
||||||
if (getResources().getBoolean(R.bool.isTablet) || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
if (getResources().getBoolean(R.bool.isTablet)
|
||||||
|
|| !getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
||||||
useEmail.setVisibility(View.VISIBLE);
|
useEmail.setVisibility(View.VISIBLE);
|
||||||
useEmail.setOnCheckedChangeListener(this);
|
useEmail.setOnCheckedChangeListener(this);
|
||||||
|
|
||||||
|
@ -273,7 +284,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
if (linkAccount) {
|
if (linkAccount) {
|
||||||
new AlertDialog.Builder(getActivity())
|
new AlertDialog.Builder(getActivity())
|
||||||
.setTitle(getString(R.string.phone_number_info_title))
|
.setTitle(getString(R.string.phone_number_info_title))
|
||||||
.setMessage(getString(R.string.phone_number_link_info_content) + "\n" + getString(R.string.phone_number_link_info_content_already_account))
|
.setMessage(getString(R.string.phone_number_link_info_content) + "\n"
|
||||||
|
+ getString(R.string.phone_number_link_info_content_already_account))
|
||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
new AlertDialog.Builder(getActivity())
|
new AlertDialog.Builder(getActivity())
|
||||||
|
@ -285,7 +297,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
}
|
}
|
||||||
|
|
||||||
case R.id.assistant_create: {
|
case R.id.assistant_create: {
|
||||||
accountCreator.isAccountActivated();
|
accountCreator.isAccountUsed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,8 +313,11 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAlias() {
|
private void addAlias() {
|
||||||
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
|
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(
|
||||||
Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
|
LinphonePreferences.instance().getDefaultAccountIndex())
|
||||||
|
);
|
||||||
|
Status status = accountCreator.setPhoneNumber(
|
||||||
|
phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
|
||||||
boolean isOk = status.equals(LinphoneAccountCreator.Status.Ok);
|
boolean isOk = status.equals(LinphoneAccountCreator.Status.Ok);
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
accountCreator.linkPhoneNumberWithAccount();
|
accountCreator.linkPhoneNumberWithAccount();
|
||||||
|
@ -313,7 +328,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAccount() {
|
private void createAccount() {
|
||||||
if (getResources().getBoolean(R.bool.isTablet) || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
if (getResources().getBoolean(R.bool.isTablet)
|
||||||
|
|| !getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
||||||
Status emailStatus;
|
Status emailStatus;
|
||||||
Status passwordStatus;
|
Status passwordStatus;
|
||||||
|
|
||||||
|
@ -342,28 +358,34 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
if (phoneNumberEdit.length() > 0 || dialCode.length() > 1) {
|
if (phoneNumberEdit.length() > 0 || dialCode.length() > 1) {
|
||||||
Status phoneStatus;
|
Status phoneStatus;
|
||||||
boolean isOk;
|
boolean isOk;
|
||||||
phoneStatus = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
|
phoneStatus = accountCreator.setPhoneNumber(
|
||||||
|
phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
|
||||||
isOk = phoneStatus.equals(LinphoneAccountCreator.Status.Ok);
|
isOk = phoneStatus.equals(LinphoneAccountCreator.Status.Ok);
|
||||||
if (!useUsername.isChecked() && accountCreator.getUsername() == null) {
|
if (!useUsername.isChecked() && accountCreator.getUsername() == null) {
|
||||||
accountCreator.setUsername(accountCreator.getPhoneNumber());
|
accountCreator.setUsername(accountCreator.getPhoneNumber());
|
||||||
} else {
|
} else {
|
||||||
accountCreator.setUsername(usernameEdit.getText().toString());
|
accountCreator.setUsername(usernameEdit.getText().toString());
|
||||||
accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), dialCode.getText().toString());
|
accountCreator.setPhoneNumber(
|
||||||
|
phoneNumberEdit.getText().toString(), dialCode.getText().toString());
|
||||||
}
|
}
|
||||||
if (isOk) {
|
if (isOk) {
|
||||||
accountCreator.createAccount();
|
accountCreator.createAccount();
|
||||||
} else {
|
} else {
|
||||||
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(phoneStatus), getContext());
|
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(phoneStatus)
|
||||||
LinphoneUtils.displayError(isOk, phoneNumberError, LinphoneUtils.errorForStatus(phoneStatus));
|
, getContext());
|
||||||
|
LinphoneUtils.displayError(isOk, phoneNumberError
|
||||||
|
, LinphoneUtils.errorForStatus(phoneStatus));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LinphoneUtils.displayErrorAlert(getString(R.string.assistant_create_account_part_1), getContext());
|
LinphoneUtils.displayErrorAlert(getString(R.string.assistant_create_account_part_1)
|
||||||
|
, getContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinphoneAccountCreator.Status getPhoneNumberStatus() {
|
private LinphoneAccountCreator.Status getPhoneNumberStatus() {
|
||||||
LinphoneAccountCreator.Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
|
LinphoneAccountCreator.Status status = accountCreator.setPhoneNumber(
|
||||||
|
phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
|
||||||
addressSip = accountCreator.getPhoneNumber();
|
addressSip = accountCreator.getPhoneNumber();
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +432,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
field.addTextChangedListener(new TextWatcher() {
|
field.addTextChangedListener(new TextWatcher() {
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
if (field.equals(dialCode)) {
|
if (field.equals(dialCode)) {
|
||||||
AssistantActivity.Country c = AssistantActivity.instance().getCountryListAdapter().getCountryFromCountryCode(dialCode.getText().toString());
|
AssistantActivity.Country c = AssistantActivity.instance().getCountryListAdapter()
|
||||||
|
.getCountryFromCountryCode(dialCode.getText().toString());
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
AssistantActivity.instance().country = c;
|
AssistantActivity.instance().country = c;
|
||||||
selectCountry.setText(c.name);
|
selectCountry.setText(c.name);
|
||||||
|
@ -457,7 +480,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
LinphoneUtils.displayError(emailOk, emailError, "");
|
LinphoneUtils.displayError(emailOk, emailError, "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LinphoneUtils.displayError(emailOk, emailError, LinphoneUtils.errorForStatus(status));
|
LinphoneUtils.displayError(emailOk
|
||||||
|
, emailError, LinphoneUtils.errorForStatus(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +503,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
LinphoneUtils.displayError(passwordOk, passwordError, "");
|
LinphoneUtils.displayError(passwordOk, passwordError, "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LinphoneUtils.displayError(passwordOk, passwordError, LinphoneUtils.errorForStatus(status));
|
LinphoneUtils.displayError(passwordOk
|
||||||
|
, passwordError, LinphoneUtils.errorForStatus(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,12 +525,14 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
if (field1.getText().toString().equals(field2.getText().toString())) {
|
if (field1.getText().toString().equals(field2.getText().toString())) {
|
||||||
confirmPasswordOk = true;
|
confirmPasswordOk = true;
|
||||||
if (!isPasswordCorrect(field1.getText().toString())) {
|
if (!isPasswordCorrect(field1.getText().toString())) {
|
||||||
LinphoneUtils.displayError(passwordOk, passwordError, getString(R.string.wizard_password_incorrect));
|
LinphoneUtils.displayError(passwordOk
|
||||||
|
, passwordError, getString(R.string.wizard_password_incorrect));
|
||||||
} else {
|
} else {
|
||||||
LinphoneUtils.displayError(confirmPasswordOk, passwordConfirmError, "");
|
LinphoneUtils.displayError(confirmPasswordOk, passwordConfirmError, "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LinphoneUtils.displayError(confirmPasswordOk, passwordConfirmError, getString(R.string.wizard_passwords_unmatched));
|
LinphoneUtils.displayError(confirmPasswordOk
|
||||||
|
, passwordConfirmError, getString(R.string.wizard_passwords_unmatched));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,15 +547,23 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, final Status status) {
|
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, final Status status) {
|
||||||
|
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
||||||
|
accountCreator.isPhoneNumberUsed();
|
||||||
|
} else {
|
||||||
|
createAccount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
if (status.equals(Status.AccountCreated)) {
|
if (status.equals(Status.AccountCreated)) {
|
||||||
if (useEmail.isChecked() || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
if (useEmail.isChecked() || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
||||||
AssistantActivity.instance().displayAssistantConfirm(getUsername(), passwordEdit.getText().toString());
|
AssistantActivity.instance().displayAssistantConfirm(getUsername()
|
||||||
|
, passwordEdit.getText().toString());
|
||||||
} else {
|
} else {
|
||||||
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), false);
|
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername()
|
||||||
|
, phoneNumberEdit.getText().toString()
|
||||||
|
, LinphoneUtils.getCountryCode(dialCode), false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), getContext());
|
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), getContext());
|
||||||
|
@ -542,39 +577,59 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
if (status.equals(Status.Ok)) {
|
if (status.equals(Status.Ok)) {
|
||||||
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), false);
|
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername()
|
||||||
|
, phoneNumberEdit.getText().toString()
|
||||||
|
, LinphoneUtils.getCountryCode(dialCode), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
if (status.equals(Status.Ok)) {
|
if (status.equals(Status.Ok)) {
|
||||||
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), false);
|
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername()
|
||||||
|
, phoneNumberEdit.getText().toString()
|
||||||
|
, LinphoneUtils.getCountryCode(dialCode), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
if (status.equals(Status.AccountNotActivated)) {
|
if (status.equals(Status.AccountNotActivated)) {
|
||||||
if (useEmail.isChecked() || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
if (getResources().getBoolean(R.bool.isTablet)
|
||||||
AssistantActivity.instance().displayAssistantConfirm(getUsername(), passwordEdit.getText().toString());
|
|| !getResources().getBoolean(R.bool.use_phone_number_validation)) {
|
||||||
|
//accountCreator.activateAccount(); // Resend email TODO
|
||||||
} else {
|
} else {
|
||||||
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), false);
|
accountCreator.recoverPhoneAccount(); // Resend SMS
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (linkAccount) {
|
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), getContext());
|
||||||
addAlias();
|
|
||||||
} else {
|
|
||||||
createAccount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
|
if (status.equals(Status.Ok)) {
|
||||||
|
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername()
|
||||||
|
, dialCode.getText().toString() , phoneNumberEdit.getText().toString(), false);
|
||||||
|
} else {
|
||||||
|
//SMS error
|
||||||
|
LinphoneUtils.displayErrorAlert(getString(R.string.request_failed), getContext());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status) {
|
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator ac, Status status) {
|
||||||
|
if (status.equals(Status.PhoneNumberUsedAccount) || status.equals(Status.PhoneNumberUsedAlias)) {
|
||||||
|
if (accountCreator.getPhoneNumber().compareTo(accountCreator.getUsername()) == 0)
|
||||||
|
accountCreator.isAccountActivated();
|
||||||
|
else
|
||||||
|
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), getContext());
|
||||||
|
} else {
|
||||||
|
accountCreator.isAccountActivated();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,13 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
||||||
countryCode = proxyConfig.lookupCCCFromIso(countryIso.toUpperCase());
|
countryCode = proxyConfig.lookupCCCFromIso(countryIso.toUpperCase());
|
||||||
|
|
||||||
|
AssistantActivity.Country c = AssistantActivity.instance().getCountryListAdapter()
|
||||||
|
.getCountryFromCountryCode(dialCode.getText().toString());
|
||||||
|
if (c != null) {
|
||||||
|
AssistantActivity.instance().country = c;
|
||||||
|
selectCountry.setText(c.name);
|
||||||
|
}
|
||||||
|
|
||||||
phoneNumberLayout.setVisibility(View.VISIBLE);
|
phoneNumberLayout.setVisibility(View.VISIBLE);
|
||||||
selectCountry.setOnClickListener(this);
|
selectCountry.setOnClickListener(this);
|
||||||
phoneNumberInfo.setOnClickListener(this);
|
phoneNumberInfo.setOnClickListener(this);
|
||||||
|
@ -332,4 +339,9 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 38c95f6b2a11c48be593b0a23879c60100b118b6
|
Subproject commit 1f28e348db77c416a4402eed72be59af0c16f601
|
Loading…
Reference in a new issue