Account creator changes
This commit is contained in:
parent
1db05c0178
commit
1cd6da3eea
11 changed files with 141 additions and 116 deletions
|
@ -436,7 +436,7 @@ public class LinphoneManager implements SensorEventListener {
|
||||||
mTimer = new Timer("Linphone scheduler");
|
mTimer = new Timer("Linphone scheduler");
|
||||||
mTimer.schedule(lTask, 0, 20);
|
mTimer.schedule(lTask, 0, 20);
|
||||||
|
|
||||||
initLiblinphone(mCore);
|
initLiblinphone();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(e, "[Manager] Cannot start linphone");
|
Log.e(e, "[Manager] Cannot start linphone");
|
||||||
}
|
}
|
||||||
|
@ -445,8 +445,7 @@ public class LinphoneManager implements SensorEventListener {
|
||||||
H264Helper.setH264Mode(H264Helper.MODE_AUTO, mCore);
|
H264Helper.setH264Mode(H264Helper.MODE_AUTO, mCore);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void initLiblinphone(Core core) {
|
private synchronized void initLiblinphone() {
|
||||||
mCore = core;
|
|
||||||
mAudioManager = new AndroidAudioManager(mContext);
|
mAudioManager = new AndroidAudioManager(mContext);
|
||||||
|
|
||||||
mCore.setZrtpSecretsFile(mBasePath + "/zrtp_secrets");
|
mCore.setZrtpSecretsFile(mBasePath + "/zrtp_secrets");
|
||||||
|
@ -543,16 +542,28 @@ public class LinphoneManager implements SensorEventListener {
|
||||||
|
|
||||||
/* Account linking */
|
/* Account linking */
|
||||||
|
|
||||||
|
public AccountCreator getAccountCreator() {
|
||||||
|
if (mAccountCreator == null) {
|
||||||
|
Log.w("[Manager] Account creator shouldn't be null !");
|
||||||
|
mAccountCreator =
|
||||||
|
mCore.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
|
||||||
|
mAccountCreator.setListener(mAccountCreatorListener);
|
||||||
|
}
|
||||||
|
return mAccountCreator;
|
||||||
|
}
|
||||||
|
|
||||||
public void isAccountWithAlias() {
|
public void isAccountWithAlias() {
|
||||||
if (mCore.getDefaultProxyConfig() != null) {
|
if (mCore.getDefaultProxyConfig() != null) {
|
||||||
long now = new Timestamp(new Date().getTime()).getTime();
|
long now = new Timestamp(new Date().getTime()).getTime();
|
||||||
if (mAccountCreator != null && LinphonePreferences.instance().getLinkPopupTime() == null
|
AccountCreator accountCreator = getAccountCreator();
|
||||||
|
if (LinphonePreferences.instance().getLinkPopupTime() == null
|
||||||
|| Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) < now) {
|
|| Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) < now) {
|
||||||
mAccountCreator.setUsername(
|
accountCreator.reset();
|
||||||
|
accountCreator.setUsername(
|
||||||
LinphonePreferences.instance()
|
LinphonePreferences.instance()
|
||||||
.getAccountUsername(
|
.getAccountUsername(
|
||||||
LinphonePreferences.instance().getDefaultAccountIndex()));
|
LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||||
mAccountCreator.isAccountExist();
|
accountCreator.isAccountExist();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LinphonePreferences.instance().setLinkPopupTime(null);
|
LinphonePreferences.instance().setLinkPopupTime(null);
|
||||||
|
|
|
@ -72,17 +72,22 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
AccountCreator accountCreator = getAccountCreator();
|
||||||
|
accountCreator.reset();
|
||||||
mConnect.setEnabled(false);
|
mConnect.setEnabled(false);
|
||||||
|
|
||||||
if (mUsernameConnectionSwitch.isChecked()) {
|
if (mUsernameConnectionSwitch.isChecked()) {
|
||||||
mAccountCreator.setUsername(mUsername.getText().toString());
|
accountCreator.setUsername(mUsername.getText().toString());
|
||||||
mAccountCreator.setPassword(mPassword.getText().toString());
|
accountCreator.setPassword(mPassword.getText().toString());
|
||||||
|
|
||||||
createProxyConfigAndLeaveAssistant();
|
createProxyConfigAndLeaveAssistant();
|
||||||
} else {
|
} else {
|
||||||
mAccountCreator.setUsername(mPhoneNumber.getText().toString());
|
accountCreator.setPhoneNumber(
|
||||||
|
mPhoneNumber.getText().toString(),
|
||||||
|
mPrefix.getText().toString());
|
||||||
|
accountCreator.setUsername(accountCreator.getPhoneNumber());
|
||||||
|
|
||||||
AccountCreator.Status status = mAccountCreator.recoverAccount();
|
AccountCreator.Status status = accountCreator.recoverAccount();
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"[Account Connection Assistant] recoverAccount returned "
|
"[Account Connection Assistant] recoverAccount returned "
|
||||||
|
@ -221,18 +226,18 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Core core = LinphoneManager.getCore();
|
|
||||||
if (core != null) {
|
|
||||||
reloadLinphoneAccountCreatorConfig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
mAccountCreator.addListener(mListener);
|
Core core = LinphoneManager.getCore();
|
||||||
|
if (core != null) {
|
||||||
|
reloadLinphoneAccountCreatorConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
getAccountCreator().addListener(mListener);
|
||||||
|
|
||||||
DialPlan dp = getDialPlanForCurrentCountry();
|
DialPlan dp = getDialPlanForCurrentCountry();
|
||||||
displayDialPlan(dp);
|
displayDialPlan(dp);
|
||||||
|
@ -246,7 +251,7 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mAccountCreator.removeListener(mListener);
|
getAccountCreator().removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,19 +21,18 @@ package org.linphone.assistant;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import java.util.Locale;
|
||||||
import org.linphone.LinphoneContext;
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.DialerActivity;
|
import org.linphone.activities.DialerActivity;
|
||||||
import org.linphone.activities.LinphoneGenericActivity;
|
import org.linphone.activities.LinphoneGenericActivity;
|
||||||
import org.linphone.core.AccountCreator;
|
import org.linphone.core.AccountCreator;
|
||||||
import org.linphone.core.Config;
|
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.DialPlan;
|
import org.linphone.core.DialPlan;
|
||||||
import org.linphone.core.Factory;
|
import org.linphone.core.Factory;
|
||||||
|
@ -43,25 +42,11 @@ import org.linphone.settings.LinphonePreferences;
|
||||||
|
|
||||||
public abstract class AssistantActivity extends LinphoneGenericActivity
|
public abstract class AssistantActivity extends LinphoneGenericActivity
|
||||||
implements CountryPicker.CountryPickedListener {
|
implements CountryPicker.CountryPickedListener {
|
||||||
static AccountCreator mAccountCreator;
|
|
||||||
|
|
||||||
protected ImageView mBack;
|
protected ImageView mBack;
|
||||||
private AlertDialog mCountryPickerDialog;
|
private AlertDialog mCountryPickerDialog;
|
||||||
|
|
||||||
private CountryPicker mCountryPicker;
|
private CountryPicker mCountryPicker;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
if (mAccountCreator == null) {
|
|
||||||
String url = LinphonePreferences.instance().getXmlrpcUrl();
|
|
||||||
Core core = LinphoneManager.getCore();
|
|
||||||
core.loadConfigFromXml(LinphonePreferences.instance().getDefaultDynamicConfigFile());
|
|
||||||
mAccountCreator = core.createAccountCreator(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -105,18 +90,17 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AccountCreator getAccountCreator() {
|
||||||
|
return LinphoneManager.getInstance().getAccountCreator();
|
||||||
|
}
|
||||||
|
|
||||||
private void reloadAccountCreatorConfig(String path) {
|
private void reloadAccountCreatorConfig(String path) {
|
||||||
Core core = LinphoneManager.getCore();
|
Core core = LinphoneManager.getCore();
|
||||||
if (core != null) {
|
if (core != null) {
|
||||||
core.loadConfigFromXml(path);
|
core.loadConfigFromXml(path);
|
||||||
if (mAccountCreator != null) {
|
AccountCreator accountCreator = getAccountCreator();
|
||||||
// Below two settings are applied to account creator when it is built.
|
accountCreator.reset();
|
||||||
// Reloading Core config after won't change the account creator configuration,
|
accountCreator.setLanguage(Locale.getDefault().getLanguage());
|
||||||
// hence the manual reload
|
|
||||||
Config config = LinphonePreferences.instance().getConfig();
|
|
||||||
mAccountCreator.setDomain(config.getString("assistant", "domain", null));
|
|
||||||
mAccountCreator.setAlgorithm(config.getString("assistant", "algorithm", null));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,28 +115,41 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
void createProxyConfigAndLeaveAssistant() {
|
void createProxyConfigAndLeaveAssistant() {
|
||||||
|
createProxyConfigAndLeaveAssistant(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void createProxyConfigAndLeaveAssistant(boolean isGenericAccount) {
|
||||||
Core core = LinphoneManager.getCore();
|
Core core = LinphoneManager.getCore();
|
||||||
boolean useLinphoneDefaultValues =
|
boolean useLinphoneDefaultValues =
|
||||||
getString(R.string.default_domain).equals(mAccountCreator.getDomain());
|
getString(R.string.default_domain).equals(getAccountCreator().getDomain());
|
||||||
if (useLinphoneDefaultValues) {
|
|
||||||
Log.i("[Assistant] Default domain found, reloading configuration");
|
if (isGenericAccount) {
|
||||||
core.loadConfigFromXml(LinphonePreferences.instance().getLinphoneDynamicConfigFile());
|
if (useLinphoneDefaultValues) {
|
||||||
} else {
|
Log.i(
|
||||||
Log.i("[Assistant] Third party domain found, keeping default values");
|
"[Assistant] Default domain found for generic connection, reloading configuration");
|
||||||
|
core.loadConfigFromXml(
|
||||||
|
LinphonePreferences.instance().getLinphoneDynamicConfigFile());
|
||||||
|
} else {
|
||||||
|
Log.i("[Assistant] Third party domain found, keeping default values");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyConfig proxyConfig = mAccountCreator.createProxyConfig();
|
ProxyConfig proxyConfig = getAccountCreator().createProxyConfig();
|
||||||
|
|
||||||
if (useLinphoneDefaultValues) {
|
if (isGenericAccount) {
|
||||||
// Restore default values
|
if (useLinphoneDefaultValues) {
|
||||||
Log.i("[Assistant] Restoring default assistant configuration");
|
// Restore default values
|
||||||
core.loadConfigFromXml(LinphonePreferences.instance().getDefaultDynamicConfigFile());
|
Log.i("[Assistant] Restoring default assistant configuration");
|
||||||
} else {
|
core.loadConfigFromXml(
|
||||||
// If this isn't a sip.linphone.org account, disable push notifications and enable
|
LinphonePreferences.instance().getDefaultDynamicConfigFile());
|
||||||
// service notification, otherwise incoming calls won't work (most probably)
|
} else {
|
||||||
Log.w("[Assistant] Unknown domain used, push probably won't work, enable service mode");
|
// If this isn't a sip.linphone.org account, disable push notifications and enable
|
||||||
LinphonePreferences.instance().setServiceNotificationVisibility(true);
|
// service notification, otherwise incoming calls won't work (most probably)
|
||||||
LinphoneContext.instance().getNotificationManager().startForeground();
|
Log.w(
|
||||||
|
"[Assistant] Unknown domain used, push probably won't work, enable service mode");
|
||||||
|
LinphonePreferences.instance().setServiceNotificationVisibility(true);
|
||||||
|
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxyConfig == null) {
|
if (proxyConfig == null) {
|
||||||
|
@ -237,6 +234,9 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
|
||||||
case PhoneNumberOverused:
|
case PhoneNumberOverused:
|
||||||
message = getString(R.string.phone_number_overuse);
|
message = getString(R.string.phone_number_overuse);
|
||||||
break;
|
break;
|
||||||
|
case AccountNotExist:
|
||||||
|
message = getString(R.string.account_doesnt_exist);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
message = getString(R.string.error_unknown);
|
message = getString(R.string.error_unknown);
|
||||||
break;
|
break;
|
||||||
|
@ -302,7 +302,7 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
String phoneNumber = phoneNumberEditText.getText().toString();
|
String phoneNumber = phoneNumberEditText.getText().toString();
|
||||||
return mAccountCreator.setPhoneNumber(phoneNumber, prefix);
|
return getAccountCreator().setPhoneNumber(phoneNumber, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getErrorFromPhoneNumberStatus(int status) {
|
String getErrorFromPhoneNumberStatus(int status) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
AccountCreator.UsernameStatus status =
|
AccountCreator.UsernameStatus status =
|
||||||
mAccountCreator.setUsername(s.toString());
|
getAccountCreator().setUsername(s.toString());
|
||||||
mUsernameError.setVisibility(
|
mUsernameError.setVisibility(
|
||||||
status == AccountCreator.UsernameStatus.Ok
|
status == AccountCreator.UsernameStatus.Ok
|
||||||
? View.INVISIBLE
|
? View.INVISIBLE
|
||||||
|
@ -90,7 +90,7 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
AccountCreator.PasswordStatus status =
|
AccountCreator.PasswordStatus status =
|
||||||
mAccountCreator.setPassword(s.toString());
|
getAccountCreator().setPassword(s.toString());
|
||||||
mPasswordError.setVisibility(
|
mPasswordError.setVisibility(
|
||||||
status == AccountCreator.PasswordStatus.Ok
|
status == AccountCreator.PasswordStatus.Ok
|
||||||
? View.INVISIBLE
|
? View.INVISIBLE
|
||||||
|
@ -148,7 +148,8 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
AccountCreator.EmailStatus status = mAccountCreator.setEmail(s.toString());
|
AccountCreator.EmailStatus status =
|
||||||
|
getAccountCreator().setEmail(s.toString());
|
||||||
mEmailError.setVisibility(
|
mEmailError.setVisibility(
|
||||||
status == AccountCreator.EmailStatus.Ok
|
status == AccountCreator.EmailStatus.Ok
|
||||||
? View.INVISIBLE
|
? View.INVISIBLE
|
||||||
|
@ -164,7 +165,7 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
enableButtonsAndFields(false);
|
enableButtonsAndFields(false);
|
||||||
|
|
||||||
AccountCreator.Status status = mAccountCreator.isAccountExist();
|
AccountCreator.Status status = getAccountCreator().isAccountExist();
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
enableButtonsAndFields(true);
|
enableButtonsAndFields(true);
|
||||||
Log.e(
|
Log.e(
|
||||||
|
@ -188,7 +189,7 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
showAccountAlreadyExistsDialog();
|
showAccountAlreadyExistsDialog();
|
||||||
enableButtonsAndFields(true);
|
enableButtonsAndFields(true);
|
||||||
} else if (status.equals(AccountCreator.Status.AccountNotExist)) {
|
} else if (status.equals(AccountCreator.Status.AccountNotExist)) {
|
||||||
status = mAccountCreator.createAccount();
|
status = getAccountCreator().createAccount();
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"[Email Account Creation Assistant] createAccount returned "
|
"[Email Account Creation Assistant] createAccount returned "
|
||||||
|
@ -219,11 +220,6 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Core core = LinphoneManager.getCore();
|
|
||||||
if (core != null) {
|
|
||||||
reloadLinphoneAccountCreatorConfig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableButtonsAndFields(boolean enable) {
|
private void enableButtonsAndFields(boolean enable) {
|
||||||
|
@ -249,7 +245,12 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
mAccountCreator.addListener(mListener);
|
Core core = LinphoneManager.getCore();
|
||||||
|
if (core != null) {
|
||||||
|
reloadLinphoneAccountCreatorConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
getAccountCreator().addListener(mListener);
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) {
|
if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) {
|
||||||
Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");
|
Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");
|
||||||
|
@ -266,6 +267,6 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mAccountCreator.removeListener(mListener);
|
getAccountCreator().removeListener(mListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class EmailAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
setContentView(R.layout.assistant_email_account_validation);
|
setContentView(R.layout.assistant_email_account_validation);
|
||||||
|
|
||||||
TextView email = findViewById(R.id.send_email);
|
TextView email = findViewById(R.id.send_email);
|
||||||
email.setText(mAccountCreator.getEmail());
|
email.setText(getAccountCreator().getEmail());
|
||||||
|
|
||||||
mFinishCreation = findViewById(R.id.assistant_check);
|
mFinishCreation = findViewById(R.id.assistant_check);
|
||||||
mFinishCreation.setOnClickListener(
|
mFinishCreation.setOnClickListener(
|
||||||
|
@ -50,7 +50,7 @@ public class EmailAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mFinishCreation.setEnabled(false);
|
mFinishCreation.setEnabled(false);
|
||||||
|
|
||||||
AccountCreator.Status status = mAccountCreator.isAccountActivated();
|
AccountCreator.Status status = getAccountCreator().isAccountActivated();
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"[Email Account Validation Assistant] activateAccount returned "
|
"[Email Account Validation Assistant] activateAccount returned "
|
||||||
|
@ -89,7 +89,7 @@ public class EmailAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mAccountCreator.addListener(mListener);
|
getAccountCreator().addListener(mListener);
|
||||||
|
|
||||||
// Prevent user to go back, it won't be able to come back here after...
|
// Prevent user to go back, it won't be able to come back here after...
|
||||||
mBack.setEnabled(false);
|
mBack.setEnabled(false);
|
||||||
|
@ -98,6 +98,6 @@ public class EmailAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mAccountCreator.removeListener(mListener);
|
getAccountCreator().removeListener(mListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
import org.linphone.core.AccountCreator;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.TransportType;
|
import org.linphone.core.TransportType;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
|
@ -63,33 +64,34 @@ public class GenericConnectionAssistantActivity extends AssistantActivity implem
|
||||||
mDomain = findViewById(R.id.assistant_domain);
|
mDomain = findViewById(R.id.assistant_domain);
|
||||||
mDomain.addTextChangedListener(this);
|
mDomain.addTextChangedListener(this);
|
||||||
mTransport = findViewById(R.id.assistant_transports);
|
mTransport = findViewById(R.id.assistant_transports);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureAccount() {
|
||||||
Core core = LinphoneManager.getCore();
|
Core core = LinphoneManager.getCore();
|
||||||
if (core != null) {
|
if (core != null) {
|
||||||
Log.i("[Generic Connection Assistant] Reloading configuration with default");
|
Log.i("[Generic Connection Assistant] Reloading configuration with default");
|
||||||
reloadDefaultAccountCreatorConfig();
|
reloadDefaultAccountCreatorConfig();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void configureAccount() {
|
AccountCreator accountCreator = getAccountCreator();
|
||||||
mAccountCreator.setUsername(mUsername.getText().toString());
|
accountCreator.setUsername(mUsername.getText().toString());
|
||||||
mAccountCreator.setDomain(mDomain.getText().toString());
|
accountCreator.setDomain(mDomain.getText().toString());
|
||||||
mAccountCreator.setPassword(mPassword.getText().toString());
|
accountCreator.setPassword(mPassword.getText().toString());
|
||||||
mAccountCreator.setDisplayName(mDisplayName.getText().toString());
|
accountCreator.setDisplayName(mDisplayName.getText().toString());
|
||||||
|
|
||||||
switch (mTransport.getCheckedRadioButtonId()) {
|
switch (mTransport.getCheckedRadioButtonId()) {
|
||||||
case R.id.transport_udp:
|
case R.id.transport_udp:
|
||||||
mAccountCreator.setTransport(TransportType.Udp);
|
accountCreator.setTransport(TransportType.Udp);
|
||||||
break;
|
break;
|
||||||
case R.id.transport_tcp:
|
case R.id.transport_tcp:
|
||||||
mAccountCreator.setTransport(TransportType.Tcp);
|
accountCreator.setTransport(TransportType.Tcp);
|
||||||
break;
|
break;
|
||||||
case R.id.transport_tls:
|
case R.id.transport_tls:
|
||||||
mAccountCreator.setTransport(TransportType.Tls);
|
accountCreator.setTransport(TransportType.Tls);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
createProxyConfigAndLeaveAssistant();
|
createProxyConfigAndLeaveAssistant(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -69,15 +69,16 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
AccountCreator accountCreator = getAccountCreator();
|
||||||
enableButtonsAndFields(false);
|
enableButtonsAndFields(false);
|
||||||
|
|
||||||
if (mUseUsernameInsteadOfPhoneNumber.isChecked()) {
|
if (mUseUsernameInsteadOfPhoneNumber.isChecked()) {
|
||||||
mAccountCreator.setUsername(mUsername.getText().toString());
|
accountCreator.setUsername(mUsername.getText().toString());
|
||||||
} else {
|
} else {
|
||||||
mAccountCreator.setUsername(mAccountCreator.getPhoneNumber());
|
accountCreator.setUsername(accountCreator.getPhoneNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountCreator.Status status = mAccountCreator.isAccountExist();
|
AccountCreator.Status status = accountCreator.isAccountExist();
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"[Phone Account Creation Assistant] isAccountExists returned "
|
"[Phone Account Creation Assistant] isAccountExists returned "
|
||||||
|
@ -178,7 +179,7 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
showAccountAlreadyExistsDialog();
|
showAccountAlreadyExistsDialog();
|
||||||
enableButtonsAndFields(true);
|
enableButtonsAndFields(true);
|
||||||
} else if (status.equals(AccountCreator.Status.AccountNotExist)) {
|
} else if (status.equals(AccountCreator.Status.AccountNotExist)) {
|
||||||
status = mAccountCreator.createAccount();
|
status = getAccountCreator().createAccount();
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"[Phone Account Creation Assistant] createAccount returned "
|
"[Phone Account Creation Assistant] createAccount returned "
|
||||||
|
@ -209,18 +210,18 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Core core = LinphoneManager.getCore();
|
|
||||||
if (core != null) {
|
|
||||||
reloadLinphoneAccountCreatorConfig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
mAccountCreator.addListener(mListener);
|
Core core = LinphoneManager.getCore();
|
||||||
|
if (core != null) {
|
||||||
|
reloadLinphoneAccountCreatorConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
getAccountCreator().addListener(mListener);
|
||||||
|
|
||||||
DialPlan dp = getDialPlanForCurrentCountry();
|
DialPlan dp = getDialPlanForCurrentCountry();
|
||||||
displayDialPlan(dp);
|
displayDialPlan(dp);
|
||||||
|
@ -234,7 +235,7 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mAccountCreator.removeListener(mListener);
|
getAccountCreator().removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -261,7 +262,7 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
if (status == AccountCreator.PhoneNumberStatus.Ok.toInt()) {
|
if (status == AccountCreator.PhoneNumberStatus.Ok.toInt()) {
|
||||||
if (mUseUsernameInsteadOfPhoneNumber.isChecked()) {
|
if (mUseUsernameInsteadOfPhoneNumber.isChecked()) {
|
||||||
AccountCreator.UsernameStatus usernameStatus =
|
AccountCreator.UsernameStatus usernameStatus =
|
||||||
mAccountCreator.setUsername(mUsername.getText().toString());
|
getAccountCreator().setUsername(mUsername.getText().toString());
|
||||||
if (usernameStatus != AccountCreator.UsernameStatus.Ok) {
|
if (usernameStatus != AccountCreator.UsernameStatus.Ok) {
|
||||||
mCreate.setEnabled(false);
|
mCreate.setEnabled(false);
|
||||||
mError.setText(getErrorFromUsernameStatus(usernameStatus));
|
mError.setText(getErrorFromUsernameStatus(usernameStatus));
|
||||||
|
@ -278,7 +279,7 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
if (mUseUsernameInsteadOfPhoneNumber.isChecked()) {
|
if (mUseUsernameInsteadOfPhoneNumber.isChecked()) {
|
||||||
username = mUsername.getText().toString();
|
username = mUsername.getText().toString();
|
||||||
} else {
|
} else {
|
||||||
username = mAccountCreator.getPhoneNumber();
|
username = getAccountCreator().getPhoneNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (username != null) {
|
if (username != null) {
|
||||||
|
|
|
@ -63,6 +63,7 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
||||||
ProxyConfig[] proxyConfigs = core.getProxyConfigList();
|
ProxyConfig[] proxyConfigs = core.getProxyConfigList();
|
||||||
if (proxyConfigIndex >= 0 && proxyConfigIndex < proxyConfigs.length) {
|
if (proxyConfigIndex >= 0 && proxyConfigIndex < proxyConfigs.length) {
|
||||||
ProxyConfig mProxyConfig = proxyConfigs[proxyConfigIndex];
|
ProxyConfig mProxyConfig = proxyConfigs[proxyConfigIndex];
|
||||||
|
AccountCreator accountCreator = getAccountCreator();
|
||||||
|
|
||||||
Address identity = mProxyConfig.getIdentityAddress();
|
Address identity = mProxyConfig.getIdentityAddress();
|
||||||
if (identity == null) {
|
if (identity == null) {
|
||||||
|
@ -75,14 +76,15 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
||||||
+ mProxyConfig.getDomain());
|
+ mProxyConfig.getDomain());
|
||||||
unexpectedError();
|
unexpectedError();
|
||||||
}
|
}
|
||||||
mAccountCreator.setUsername(identity.getUsername());
|
accountCreator.setUsername(identity.getUsername());
|
||||||
|
|
||||||
AuthInfo authInfo = mProxyConfig.findAuthInfo();
|
AuthInfo authInfo = mProxyConfig.findAuthInfo();
|
||||||
if (authInfo == null) {
|
if (authInfo == null) {
|
||||||
Log.e("[Account Linking Assistant] Auth info not found");
|
Log.e("[Account Linking Assistant] Auth info not found");
|
||||||
unexpectedError();
|
unexpectedError();
|
||||||
}
|
}
|
||||||
mAccountCreator.setHa1(authInfo.getHa1());
|
accountCreator.setHa1(authInfo.getHa1());
|
||||||
|
accountCreator.setAlgorithm((authInfo.getAlgorithm()));
|
||||||
} else {
|
} else {
|
||||||
Log.e(
|
Log.e(
|
||||||
"[Account Linking Assistant] Proxy config index out of bounds: "
|
"[Account Linking Assistant] Proxy config index out of bounds: "
|
||||||
|
@ -112,7 +114,7 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
enableButtonsAndFields(false);
|
enableButtonsAndFields(false);
|
||||||
|
|
||||||
AccountCreator.Status status = mAccountCreator.isAliasUsed();
|
AccountCreator.Status status = getAccountCreator().isAliasUsed();
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"[Phone Account Linking Assistant] isAliasUsed returned "
|
"[Phone Account Linking Assistant] isAliasUsed returned "
|
||||||
|
@ -184,7 +186,7 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
||||||
"[Phone Account Linking Assistant] onIsAliasUsed status is "
|
"[Phone Account Linking Assistant] onIsAliasUsed status is "
|
||||||
+ status);
|
+ status);
|
||||||
if (status.equals(AccountCreator.Status.AliasNotExist)) {
|
if (status.equals(AccountCreator.Status.AliasNotExist)) {
|
||||||
status = mAccountCreator.linkAccount();
|
status = getAccountCreator().linkAccount();
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
Log.e(
|
Log.e(
|
||||||
"[Phone Account Linking Assistant] linkAccount returned "
|
"[Phone Account Linking Assistant] linkAccount returned "
|
||||||
|
@ -222,18 +224,18 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Core core = LinphoneManager.getCore();
|
|
||||||
if (core != null) {
|
|
||||||
reloadLinphoneAccountCreatorConfig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
mAccountCreator.addListener(mListener);
|
Core core = LinphoneManager.getCore();
|
||||||
|
if (core != null) {
|
||||||
|
reloadLinphoneAccountCreatorConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
getAccountCreator().addListener(mListener);
|
||||||
|
|
||||||
DialPlan dp = getDialPlanForCurrentCountry();
|
DialPlan dp = getDialPlanForCurrentCountry();
|
||||||
displayDialPlan(dp);
|
displayDialPlan(dp);
|
||||||
|
@ -247,7 +249,7 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mAccountCreator.removeListener(mListener);
|
getAccountCreator().removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class PhoneAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
getResources().getInteger(R.integer.phone_number_validation_code_length);
|
getResources().getInteger(R.integer.phone_number_validation_code_length);
|
||||||
|
|
||||||
TextView phoneNumber = findViewById(R.id.phone_number);
|
TextView phoneNumber = findViewById(R.id.phone_number);
|
||||||
phoneNumber.setText(mAccountCreator.getPhoneNumber());
|
phoneNumber.setText(getAccountCreator().getPhoneNumber());
|
||||||
|
|
||||||
mSmsCode = findViewById(R.id.sms_code);
|
mSmsCode = findViewById(R.id.sms_code);
|
||||||
mSmsCode.addTextChangedListener(
|
mSmsCode.addTextChangedListener(
|
||||||
|
@ -88,16 +88,17 @@ public class PhoneAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
AccountCreator accountCreator = getAccountCreator();
|
||||||
mFinishCreation.setEnabled(false);
|
mFinishCreation.setEnabled(false);
|
||||||
mAccountCreator.setActivationCode(mSmsCode.getText().toString());
|
accountCreator.setActivationCode(mSmsCode.getText().toString());
|
||||||
|
|
||||||
AccountCreator.Status status;
|
AccountCreator.Status status;
|
||||||
if (mIsLinking) {
|
if (mIsLinking) {
|
||||||
status = mAccountCreator.activateAlias();
|
status = accountCreator.activateAlias();
|
||||||
} else if (mIsLogin) {
|
} else if (mIsLogin) {
|
||||||
status = mAccountCreator.loginLinphoneAccount();
|
status = accountCreator.loginLinphoneAccount();
|
||||||
} else {
|
} else {
|
||||||
status = mAccountCreator.activateAccount();
|
status = accountCreator.activateAccount();
|
||||||
}
|
}
|
||||||
if (status != AccountCreator.Status.RequestOk) {
|
if (status != AccountCreator.Status.RequestOk) {
|
||||||
Log.e(
|
Log.e(
|
||||||
|
@ -173,7 +174,7 @@ public class PhoneAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mAccountCreator.addListener(mListener);
|
getAccountCreator().addListener(mListener);
|
||||||
|
|
||||||
// Prevent user to go back, it won't be able to come back here after...
|
// Prevent user to go back, it won't be able to come back here after...
|
||||||
mBack.setEnabled(false);
|
mBack.setEnabled(false);
|
||||||
|
@ -182,7 +183,7 @@ public class PhoneAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mAccountCreator.removeListener(mListener);
|
getAccountCreator().removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onError(AccountCreator.Status status) {
|
private void onError(AccountCreator.Status status) {
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
Vos amis pourront vous joindre plus facilement si vous associez votre compte à votre numéro de téléphone\n\nVous verrez dans votre carnet d\'adresses les contacts qui utilisent Linphone et vos amis sauront qu\'ils peuvent vous contacter.\n</string>
|
Vos amis pourront vous joindre plus facilement si vous associez votre compte à votre numéro de téléphone\n\nVous verrez dans votre carnet d\'adresses les contacts qui utilisent Linphone et vos amis sauront qu\'ils peuvent vous contacter.\n</string>
|
||||||
<string name="phone_number_link_info_content_already_account">Vous ne pouvez associer votre numéro qu\'à un seul compte Linphone.\n\nSi vous avez déjà associé votre numéro à un autre compte mais préférez utiliser ce compte-ci, suivez la procédure d\'association et votre numéro sera automatiquement transféré à ce compte.</string>
|
<string name="phone_number_link_info_content_already_account">Vous ne pouvez associer votre numéro qu\'à un seul compte Linphone.\n\nSi vous avez déjà associé votre numéro à un autre compte mais préférez utiliser ce compte-ci, suivez la procédure d\'association et votre numéro sera automatiquement transféré à ce compte.</string>
|
||||||
<string name="phone_number_overuse">Trop de SMS ont été envoyés vers ce numéro en un court laps de temps, veuillez attendre 24h avant de réessayer.</string>
|
<string name="phone_number_overuse">Trop de SMS ont été envoyés vers ce numéro en un court laps de temps, veuillez attendre 24h avant de réessayer.</string>
|
||||||
|
<string name="account_doesnt_exist">Ce compte n\'existe pas</string>
|
||||||
<!--Status-->
|
<!--Status-->
|
||||||
<string name="invalid_email">Mail non valide</string>
|
<string name="invalid_email">Mail non valide</string>
|
||||||
<string name="account_already_exist">Ce compte existe déjà</string>
|
<string name="account_already_exist">Ce compte existe déjà</string>
|
||||||
|
|
|
@ -134,6 +134,7 @@
|
||||||
<string name="phone_number_link_info_content">\nYour friends will find you more easily if you link your account to your phone number\n\nYou will see in your address book who is using Linphone and your friends will know that they can reach you on Linphone as well.\n</string>
|
<string name="phone_number_link_info_content">\nYour friends will find you more easily if you link your account to your phone number\n\nYou will see in your address book who is using Linphone and your friends will know that they can reach you on Linphone as well.\n</string>
|
||||||
<string name="phone_number_link_info_content_already_account">You can only use your phone number with one Linphone account.\n\nIf you had already linked your number to an other account but you prefer to use this one, simply link it now and your number will automatically be moved to this account.</string>
|
<string name="phone_number_link_info_content_already_account">You can only use your phone number with one Linphone account.\n\nIf you had already linked your number to an other account but you prefer to use this one, simply link it now and your number will automatically be moved to this account.</string>
|
||||||
<string name="phone_number_overuse">Too much SMS have been sent to this number in a short period of time, try again in 24 hours.</string>
|
<string name="phone_number_overuse">Too much SMS have been sent to this number in a short period of time, try again in 24 hours.</string>
|
||||||
|
<string name="account_doesnt_exist">Account doesn\'t exist</string>
|
||||||
|
|
||||||
<!-- Status -->
|
<!-- Status -->
|
||||||
<string name="invalid_email">Invalid email</string>
|
<string name="invalid_email">Invalid email</string>
|
||||||
|
|
Loading…
Reference in a new issue