Fix AccountCreator leak, fix bug on assistant

This commit is contained in:
Erwan Croze 2016-10-19 15:43:30 +02:00
parent 81aeec2e49
commit 1edbeff4c6
17 changed files with 262 additions and 208 deletions

View file

@ -301,10 +301,8 @@ uninstall:
\tadb uninstall $(PACKAGE_NAME)
release: java-clean build copy-libs update-project
\tpatch -p1 < release.patch
\tcat ant.properties | grep version.name > default.properties
\tant release
\tpatch -Rp1 < release.patch
generate-sdk: liblinphone-android-sdk

View file

@ -26,6 +26,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/send_phone_number"
style="@style/font6"
android:paddingTop="10dp"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="@string/assistant_create_account_part_3"
style="@style/font11"
android:paddingTop="10dp"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/assistant_code"
android:background="@drawable/resizable_textfield"

View file

@ -18,7 +18,25 @@
android:layout_height="wrap_content"/>
<TextView
android:text="@string/assistant_validate_account"
android:text="@string/assistant_validate_account_1"
style="@style/font11"
android:paddingTop="10dp"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/send_email"
style="@style/font6"
android:paddingTop="10dp"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="@string/assistant_validate_account_2"
style="@style/font11"
android:paddingTop="10dp"
android:gravity="center"

View file

@ -115,14 +115,13 @@
android:visibility="gone"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_toLeftOf="@id/delete"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:layout_marginRight="20dp"
android:layout_marginRight="10dp"
android:scaleType="centerInside"
android:src="@drawable/linphone_user" />
</RelativeLayout>
</LinearLayout>

View file

@ -52,8 +52,8 @@
<string name="assistant_create_account">Créer un compte</string>
<string name="assistant_link_account">Associer un compte</string>
<string name="assistant_finish">Terminer la configuration</string>
<string name="assistant_validate_account">Votre compte a été créé. Vérifiez vos emails pour valider votre compte.
Lorsque cela est fait, cliquez sur le bouton pour continuer.</string>
<string name="assistant_validate_account_1">Votre compte a été créé. Vérifiez vos emails pour valider votre compte:</string>
<string name="assistant_validate_account_2">Lorsque cela est fait, cliquez sur le bouton pour continuer.</string>
<string name="assistant_welcome_desc">Cet assistant va vous guider pour réaliser des appels à l\'aide d\'un compte SIP.</string>
<string name="assistant_linphone_login_desc">Entrez le nom d\'utilisateur et mot de passe de votre compte Linphone.</string>
<string name="assistant_login_desc">Entrer votre nom d\'utilisateur et mot de passe ainsi que votre domaine SIP</string>
@ -64,7 +64,8 @@ Lorsque cela est fait, cliquez sur le bouton pour continuer.</string>
<string name="assistant_login_generic">Utiliser un compte SIP</string>
<string name="assistant_remote_provisioning">Télécharger la configuration</string>
<string name="assistant_create_account_part_1">Merci de confirmer votre code de pays et de rentrer votre numéro de téléphone</string>
<string name="assistant_create_account_part_2">Nous vous avons envoyé un SMS avec un code de validation.\n\nPour complèter la vérification de votre numéro de téléphone, veuillez entrer les 4 chiffres du code en dessous:\n</string>
<string name="assistant_create_account_part_2">Nous vous avons envoyé un SMS avec un code de validation au numéro :</string>
<string name="assistant_create_account_part_3">Pour complèter la vérification de votre numéro de téléphone, veuillez entrer les 4 chiffres du code en dessous:\n</string>
<string name="assistant_display_name_optional">Nom d\'affichage (optionnel)</string>
<string name="assistant_linphone_account">Utiliser un compte Linphone</string>
<string name="assistant_generic_account">Utiliser un compte SIP</string>

View file

@ -69,7 +69,8 @@
<string name="assistant_continue">Continue</string>
<string name="assistant_activate">Activate your account</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_1">Your account is created. Please check your mails to validate your account:</string>
<string name="assistant_validate_account_2">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_linphone_login_desc">Please enter your username and password of Linphone account</string>
<string name="assistant_login_desc">Please enter your username and password with your SIP domain</string>
@ -80,7 +81,8 @@
<string name="assistant_login_generic">Use SIP account</string>
<string name="assistant_remote_provisioning">Fetch remote configuration</string>
<string name="assistant_create_account_part_1">Please confirm your country code and enter your phone number</string>
<string name="assistant_create_account_part_2">We have sent you a SMS with a validation code.\n\nTo complete your phone number verification, please enter the 4 digit code below:\n</string>
<string name="assistant_create_account_part_2">We have sent you a SMS with a validation code to your phone number:</string>
<string name="assistant_create_account_part_3">To complete your phone number verification, please enter the 4 digit code below:\n</string>
<string name="assistant_create_account_part_email">Please enter an username, email and password for your Linphone account</string>
<string name="assistant_display_name_optional">Display name (optional)</string>
<string name="assistant_linphone_account">Use your Linphone account</string>

View file

@ -184,7 +184,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
String value = newValue.toString();
preference.setSummary(value);
if (isNewAccount) {
//TODO accpunt builder ste prefix
builder.setPrefix(value);
} else {
mPrefs.setPrefix(n, value);
}
@ -357,7 +357,6 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
if(!isNewAccount){
String prefixValue = mPrefs.getPrefix(n);
prefix.setText(prefixValue);
prefix.setOnPreferenceChangeListener(prefixChangedListener);
}
CheckBoxPreference avpf = (CheckBoxPreference) advanced.getPreference(5);

View file

@ -568,7 +568,7 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
holder.delete.setChecked(false);
}
} else {
holder.delete.setVisibility(View.GONE);
holder.delete.setVisibility(View.INVISIBLE);
}
/*LinphoneFriend[] friends = LinphoneManager.getLc().getFriendList();

View file

@ -211,6 +211,7 @@ public class ContactsManager extends ContentObserver {
for (LinphoneNumberOrAddress noa: c.getNumbersOrAddresses()) {
String normalized = null;
if (lpc != null) {
lpc.setDialPrefix("");
normalized = lpc.normalizePhoneNumber(noa.getValue());
}
String alias = c.getPresenceModelForUri(noa.getValue());

View file

@ -32,7 +32,6 @@ import org.linphone.assistant.AssistantActivity;
import org.linphone.assistant.RemoteProvisioningLoginActivity;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.CallDirection;
import org.linphone.core.LinphoneAccountCreator;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCall;
@ -98,7 +97,7 @@ import android.widget.Toast;
/**
* @author Sylvain Berfini
*/
public class LinphoneActivity extends Activity implements OnClickListener, ContactPicked, ActivityCompat.OnRequestPermissionsResultCallback, LinphoneAccountCreator.LinphoneAccountCreatorListener {
public class LinphoneActivity extends Activity implements OnClickListener, ContactPicked, ActivityCompat.OnRequestPermissionsResultCallback {
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
private static final int SETTINGS_ACTIVITY = 123;
private static final int CALL_ACTIVITY = 19;
@ -230,7 +229,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if(state.equals(RegistrationState.RegistrationOk) && LinphonePreferences.instance().getLinkPopupTime() != ""){
if(getResources().getBoolean(R.bool.use_phone_number_validation)) {
if (LinphonePreferences.instance().getLinkPopupTime() == null || (LinphonePreferences.instance().getLinkPopupTime() != null)){
isAccountWithAlias();
LinphoneManager.getInstance().isAccountWithAlias();
}
}
}
@ -625,14 +624,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
startActivity(new Intent(LinphoneActivity.this, AssistantActivity.class));
}
public void displayLinkPhoneNumber() {
LinphoneAccountCreator accountCreator;
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setDomain(getResources().getString(R.string.default_domain));
accountCreator.setListener(this);
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
accountCreator.isAccountLinked();
}
public void displayInapp() {
startActivity(new Intent(LinphoneActivity.this, InAppPurchaseActivity.class));
@ -1705,19 +1697,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
}
private void isAccountWithAlias(){
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
LinphoneAccountCreator accountCreator;
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setDomain(getResources().getString(R.string.default_domain));
accountCreator.setListener(this);
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
accountCreator.isAccountUsed();
} else {
LinphonePreferences.instance().setLinkPopupTime(null);
}
}
//Inapp Purchase
private void isTrialAccount() {
if(LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphonePreferences.instance().getInappPopupTime() != null) {
@ -1793,75 +1772,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
return -1;
}
private void askLinkWithPhoneNumber(){
long now = Calendar.getInstance().getTimeInMillis();
long newDate = now + (getResources().getInteger(R.integer.popup_time_interval)*60);
if (LinphonePreferences.instance().getLinkPopupTime() != null && Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) > now) {
return;
} else {
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
}
final Dialog dialog = displayDialog(String.format(getResources().getString(R.string.link_account_popup), LinphoneManager.getLc().getDefaultProxyConfig().getAddress().asStringUriOnly()));
Button delete = (Button) dialog.findViewById(R.id.delete_button);
delete.setText(getResources().getString(R.string.link));
Button cancel = (Button) dialog.findViewById(R.id.cancel);
cancel.setText(getResources().getString(R.string.maybe_later));
delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
displayLinkPhoneNumber();
dialog.dismiss();
}
});
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
@Override
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
if (status.equals(LinphoneAccountCreator.Status.AccountExist)) {
accountCreator.isAccountLinked();
}
}
@Override
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
if (status.equals(LinphoneAccountCreator.Status.AccountNotLinked)) {
askLinkWithPhoneNumber();
}
}
@Override
public void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
}
interface ContactPicked {

View file

@ -30,11 +30,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.linphone.core.CallDirection;
import org.linphone.core.LinphoneAccountCreator;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneBuffer;
import org.linphone.core.LinphoneCall;
@ -77,6 +79,7 @@ import org.linphone.tools.OpenH264DownloadHelper;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@ -99,6 +102,8 @@ import android.preference.CheckBoxPreference;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
/**
@ -116,7 +121,7 @@ import android.widget.Toast;
* @author Guillaume Beraudo
*
*/
public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessage.LinphoneChatMessageListener {
public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessage.LinphoneChatMessageListener, LinphoneAccountCreator.LinphoneAccountCreatorListener {
private static LinphoneManager instance;
private Context mServiceContext;
@ -138,6 +143,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
private IntentFilter mKeepAliveIntentFilter;
private Handler mHandler = new Handler();
private WakeLock mIncallWakeLock;
private LinphoneAccountCreator accountCreator;
private static List<LinphoneChatMessage> mPendingChatFileMessage;
private static LinphoneChatMessage mUploadPendingFileMessage;
@ -799,6 +805,10 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
updateNetworkReachability();
resetCameraFromPreferences();
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setDomain(getString(R.string.default_domain));
accountCreator.setListener(this);
}
private void copyAssetsFromPackage() throws IOException {
@ -1432,8 +1442,52 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
return incomingPending ? currentCall : null;
}
public void displayLinkPhoneNumber() {
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
accountCreator.isAccountLinked();
}
public void isAccountWithAlias(){
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
accountCreator.isAccountUsed();
} else {
LinphonePreferences.instance().setLinkPopupTime(null);
}
}
private void askLinkWithPhoneNumber(){
long now = Calendar.getInstance().getTimeInMillis();
long newDate = now + (LinphoneActivity.instance().getResources().getInteger(R.integer.popup_time_interval)*60);
if (LinphonePreferences.instance().getLinkPopupTime() != null && Long.parseLong(LinphonePreferences.instance().getLinkPopupTime()) > now) {
return;
} else {
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
}
final Dialog dialog = LinphoneActivity.instance().displayDialog(String.format(getString(R.string.link_account_popup), LinphoneManager.getLc().getDefaultProxyConfig().getAddress().asStringUriOnly()));
Button delete = (Button) dialog.findViewById(R.id.delete_button);
delete.setText(getString(R.string.link));
Button cancel = (Button) dialog.findViewById(R.id.cancel);
cancel.setText(getString(R.string.maybe_later));
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LinphoneManager.getInstance().displayLinkPhoneNumber();
dialog.dismiss();
}
});
LinphonePreferences.instance().setLinkPopupTime(String.valueOf(newDate));
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
@SuppressWarnings("serial")
public static class LinphoneConfigException extends LinphoneException {
@ -1568,4 +1622,40 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
// TODO Auto-generated method stub
}
@Override
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
if (status.equals(LinphoneAccountCreator.Status.AccountExist)) {
accountCreator.isAccountLinked();
}
}
@Override
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {}
@Override
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
if (status.equals(LinphoneAccountCreator.Status.AccountNotLinked)) {
askLinkWithPhoneNumber();
}
}
@Override
public void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
}

View file

@ -551,12 +551,13 @@ private static AssistantActivity instance;
progress.show();
}
public void displayAssistantConfirm(String username, String password) {
public void displayAssistantConfirm(String username, String password, String email) {
CreateAccountActivationFragment fragment = new CreateAccountActivationFragment();
newAccount = true;
Bundle extras = new Bundle();
extras.putString("Username", username);
extras.putString("Password", password);
extras.putString("Email", email);
fragment.setArguments(extras);
changeFragment(fragment);
@ -582,7 +583,8 @@ private static AssistantActivity instance;
public void isAccountVerified(String username) {
Toast.makeText(this, getString(R.string.assistant_account_validated), Toast.LENGTH_LONG).show();
launchEchoCancellerCalibration(true);
hideKeyboard();
success();
}
public void isEchoCalibrationFinished() {

View file

@ -20,91 +20,106 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.R;
import org.linphone.core.LinphoneXmlRpcRequest;
import org.linphone.core.LinphoneXmlRpcRequest.LinphoneXmlRpcRequestListener;
import org.linphone.core.LinphoneXmlRpcRequestImpl;
import org.linphone.core.LinphoneXmlRpcSession;
import org.linphone.core.LinphoneXmlRpcSessionImpl;
import org.linphone.core.LinphoneAccountCreator;
import org.linphone.core.LinphoneAccountCreator.LinphoneAccountCreatorListener;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.mediastream.Log;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
/**
* @author Sylvain Berfini
*/
public class CreateAccountActivationFragment extends Fragment implements LinphoneXmlRpcRequestListener {
public class CreateAccountActivationFragment extends Fragment implements OnClickListener, LinphoneAccountCreatorListener {
private String username, password;
private Handler mHandler = new Handler();
private Button checkAccount;
private LinphoneXmlRpcSession xmlRpcSession;
private LinphoneXmlRpcRequest xmlRpcRequest;
private Runnable runNotOk, runOk, runNotReachable;
private TextView email;
private LinphoneAccountCreator accountCreator;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_account_creation_email_activation, container, false);
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc()
, LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setDomain(getResources().getString(R.string.default_domain));
accountCreator.setListener(this);
username = getArguments().getString("Username");
password = getArguments().getString("Password");
accountCreator.setUsername(username);
accountCreator.setPassword(password);
email = (TextView) view.findViewById(R.id.send_email);
email.setText(getArguments().getString("Email"));
checkAccount = (Button) view.findViewById(R.id.assistant_check);
checkAccount.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
checkAccount.setEnabled(false);
isAccountVerified(username);
}
});
runNotOk = new Runnable() {
public void run() {
checkAccount.setEnabled(true);
Toast.makeText(getActivity(), getString(R.string.assistant_account_not_validated), Toast.LENGTH_LONG).show();
}
};
runOk = new Runnable() {
public void run() {
checkAccount.setEnabled(true);
AssistantActivity.instance().saveCreatedAccount(username, password, null, null, getString(R.string.default_domain),null);
AssistantActivity.instance().isAccountVerified(username);
}
};
runNotReachable = new Runnable() {
public void run() {
Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG).show();
}
};
xmlRpcSession = new LinphoneXmlRpcSessionImpl(LinphoneManager.getLcIfManagerNotDestroyedOrNull(), LinphonePreferences.instance().getXmlrpcUrl());
xmlRpcRequest = new LinphoneXmlRpcRequestImpl("check_account_validated", LinphoneXmlRpcRequest.ArgType.Int);
xmlRpcRequest.setListener(this);
checkAccount.setOnClickListener(this);
return view;
}
@Override
public void onXmlRpcRequestResponse(LinphoneXmlRpcRequest request) {
if (request.getStatus() == LinphoneXmlRpcRequest.Status.Ok) {
int response = request.getIntResponse();
if (response != 1) {
mHandler.post(runNotOk);
} else {
mHandler.post(runOk);
public void onClick(View v) {
switch (v.getId()) {
case R.id.assistant_check: {
checkAccount.setEnabled(false);
accountCreator.isAccountActivated();
break;
}
} else if (request.getStatus() == LinphoneXmlRpcRequest.Status.Failed) {
mHandler.post(runNotReachable);
}
}
private void isAccountVerified(final String username) {
xmlRpcRequest.addStringArg(username + "@" + getString(R.string.default_domain));
xmlRpcSession.sendRequest(xmlRpcRequest);
@Override
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
@Override
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
@Override
public void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
@Override
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
@Override
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
@Override
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
if (status.equals(LinphoneAccountCreator.Status.AccountNotActivated)) {
Toast.makeText(getActivity(), getString(R.string.assistant_account_not_validated), Toast.LENGTH_LONG).show();
} else if (status.equals(LinphoneAccountCreator.Status.AccountActivated)) {
AssistantActivity.instance().saveCreatedAccount(username, password, null, null, getString(R.string.default_domain), null);
AssistantActivity.instance().isAccountVerified(username);
} else {
Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG).show();
}
checkAccount.setEnabled(true);
}
@Override
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
@Override
public void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
@Override
public void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
}

View file

@ -41,7 +41,7 @@ import android.widget.Toast;
public class CreateAccountCodeActivationFragment extends Fragment implements LinphoneAccountCreatorListener {
private String username, phone, dialcode;
private TextView title;
private TextView title, phonenumber;
private EditText code;
private boolean recoverAccount = false, linkAccount = false;
private int code_length;
@ -78,6 +78,9 @@ public class CreateAccountCodeActivationFragment extends Fragment implements Lin
title.setText(getString(R.string.assistant_linphone_account));
}
phonenumber = (TextView) view.findViewById(R.id.send_phone_number);
phonenumber.setText(phone);
code = (EditText) view.findViewById(R.id.assistant_code);
code.addTextChangedListener(new TextWatcher() {
@Override

View file

@ -32,7 +32,6 @@ import org.linphone.core.LinphoneAccountCreator.LinphoneAccountCreatorListener;
import org.linphone.core.LinphoneAccountCreator.Status;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneProxyConfig;
import org.w3c.dom.Text;
import android.accounts.Account;
import android.accounts.AccountManager;
@ -152,7 +151,6 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
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
if (getResources().getBoolean(R.bool.assistant_allow_username)) {
@ -320,7 +318,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
if (linkAccount) {
addAlias();
} else {
if (getUsername().length() > 0) {
if (!getResources().getBoolean(R.bool.isTablet) || getUsername().length() > 0) {
accountCreator.isAccountUsed();
} else {
LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(Status.UsernameTooShort)
@ -601,7 +599,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
if (status.equals(Status.AccountCreated)) {
if (useEmail.isChecked() || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
AssistantActivity.instance().displayAssistantConfirm(getUsername()
, passwordEdit.getText().toString());
, passwordEdit.getText().toString(), emailEdit.getText().toString());
} else {
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername()
, phoneNumberEdit.getText().toString()

View file

@ -40,6 +40,7 @@ import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
@ -103,13 +104,16 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
if(getResources().getBoolean(R.bool.use_phone_number_validation)){
getActivity().getApplicationContext();
//Automatically get the country code from the phone
TelephonyManager tm = (TelephonyManager) getActivity().getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
TelephonyManager tm =
(TelephonyManager) getActivity().getApplicationContext().getSystemService(
Context.TELEPHONY_SERVICE);
String countryIso = tm.getNetworkCountryIso();
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
countryCode = proxyConfig.lookupCCCFromIso(countryIso.toUpperCase());
AssistantActivity.Country c = AssistantActivity.instance().getCountryListAdapter()
.getCountryFromCountryCode(dialCode.getText().toString());
.getCountryFromCountryCode(String.valueOf(countryCode));
if (c != null) {
AssistantActivity.instance().country = c;
selectCountry.setText(c.name);
@ -124,8 +128,6 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
phoneNumberEdit.setText(previousPhone);
}
LinphoneUtils.setCountry(AssistantActivity.instance().country, dialCode, selectCountry, countryCode);
//Allow user to enter a username instead use the phone number as username
if(getResources().getBoolean(R.bool.assistant_allow_username) ) {
useUsername.setVisibility(View.VISIBLE);

@ -1 +1 @@
Subproject commit a5a65227b36d0cfb6d4b34b93521986bc371b685
Subproject commit 5529671088b6711b90c5abc21d972a3d20e5f124