diff --git a/res/layout/assistant_account_creation_code_activation.xml b/res/layout/assistant_account_creation_code_activation.xml
index d9609bfcb..8d70717f1 100644
--- a/res/layout/assistant_account_creation_code_activation.xml
+++ b/res/layout/assistant_account_creation_code_activation.xml
@@ -15,7 +15,8 @@
style="@style/font6"
android:textAllCaps="true"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:id="@+id/title_account_activation" />
+ android:layout_gravity="center"
+ android:id="@+id/message_phone_number" />
+ android:layout_height="wrap_content">
-
-
-
@@ -63,46 +55,77 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
+
+
+
+
+
+
+
+
-
-
-
+ android:layout_height="wrap_content">
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -67,7 +129,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -91,7 +153,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -115,7 +177,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -139,7 +201,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -163,7 +225,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -209,12 +271,74 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -233,7 +357,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -257,7 +381,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -281,7 +405,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -305,7 +429,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -329,7 +453,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -354,7 +478,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
@@ -379,7 +503,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
- android:gravity="left|center_vertical"
+ android:gravity="right|center_vertical"
android:textColor="@color/colorB"
android:textSize="12sp"/>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index e95fd7b80..202a0eb1c 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -50,6 +50,7 @@
Bienvenue
Assistant
Créer un compte
+ Associer un compte
Terminer la configuration
Votre compte a été créé. Vérifiez vos emails pour valider votre compte.
Lorsque cela est fait, cliquez sur le bouton pour continuer.
@@ -58,14 +59,15 @@ Lorsque cela est fait, cliquez sur le bouton pour continuer.
Entrer votre nom d\'utilisateur et mot de passe ainsi que votre domaine SIP
Veuillez fournir votre URL de configuration.
Transport
+ Votre address SIP est
Utiliser un compte Linphone
Utiliser un compte SIP
Télécharger la configuration
- 1/2
- 2/2
+ Merci de confirmer votre code de pays et de rentrer votre numéro de téléphone
+ 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
Nom d\'affichage (optionnel)
- Configurer un compte Linphone
- Configure un compte SIP
+ Utiliser un compte Linphone
+ Utiliser un compte SIP
Télécharger la configuration
Télécharger et appliquer
Connexion
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 426496df3..71d74ef40 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -56,7 +56,7 @@
No
Ok
Yes
- Link account
+ Link your account
the libre SIP client
@@ -65,8 +65,9 @@
Welcome
Assistant
Create account
+ Link account
Continue
- Activate account
+ Activate your account
Finish configuration
Your account is created. Please check your mails to validate your account. Once it is done, come back here and click on the button.
This assistant will help you configure and use your SIP account.
@@ -74,6 +75,7 @@
Enter your username and password with your SIP domain
Please provide your provisioning URL
Transport
+ Your SIP address is
Use Linphone account
Use SIP account
Fetch remote configuration
@@ -81,14 +83,14 @@
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
Display name (optional)
Use your Linphone account
- Configure SIP account
+ Use SIP account
Fetch remote configuration
Fetch and apply
Login
Echo canceler calibration in progress
Enter your login
Your account has not been validated yet.
-
+ The confirmation code is invalid.\r\nPlease check your SMS and try again.
Your account has been validated.
Incorrect username or password
Do you agree to download OpenH264 Video Codec provided by Cisco Systems, Inc.?
@@ -97,7 +99,7 @@
An error occurred, try again later.
Server unreachable, verify your network connection.
This username is already in use.
- This phone number is already in use.
+ 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.
Your username is invalid.
Your phone number is invalid.
Your email is invalid.
@@ -113,8 +115,9 @@
Use email address for account validation
Use your username and password instead of your phone number
What will my phone number be used for?
- \nThanks to your phone number, your friends will find you more easily.\n\nYou will see in your addressbook who is using Linphone and your friends will know that they can rach you on Linphone as well.\n
- \nYour friends will find your more easily if you link your account to your phone number\n\nYou will see in your addressbook who is using Linphone and your friends will know that they can rach you on Linphone as well.\n
+ \nThanks to your phone number, your friends will find you more easily.\n\n You will see in your addressbook who is using Linphone and your friends will know that they can rach you on Linphone as well.\n
+ \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
+ 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.
Invalid email
@@ -132,6 +135,7 @@
Password too long
Failed to query the server. Please try again later
Unsupported transport
+ Country code invalid
In-app
@@ -208,6 +212,8 @@
Received video resolution:
Sender loss rate
Receiver loss rate
+ Encoder:
+ Decoder:
Call
@@ -261,7 +267,7 @@
AVPF regular RTCP interval in seconds (between 1 and 5)
Replace + by 00
Friendlist subscribe
- Link account
+ Link your account
Auth userid
Enter authentication userid (optional)
Display name
diff --git a/src/org/linphone/ContactsListFragment.java b/src/org/linphone/ContactsListFragment.java
index 22dd4256c..9e8b93f2e 100644
--- a/src/org/linphone/ContactsListFragment.java
+++ b/src/org/linphone/ContactsListFragment.java
@@ -610,7 +610,7 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
if (fullName == null || fullName.isEmpty()) {
return 0;
}
- String letter = fullName.substring(0, 1);
+ String letter = fullName.substring(0, 1).toUpperCase(Locale.getDefault());
return sectionsList.indexOf(letter);
}
}
diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java
index e8e08f729..2692b5a9e 100644
--- a/src/org/linphone/LinphoneActivity.java
+++ b/src/org/linphone/LinphoneActivity.java
@@ -33,7 +33,6 @@ import org.linphone.assistant.RemoteProvisioningLoginActivity;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.CallDirection;
import org.linphone.core.LinphoneAccountCreator;
-import org.linphone.core.LinphoneAccountCreatorImpl;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCall;
@@ -1692,7 +1691,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
private void isAccountWithAlias(){
if(LinphoneManager.getLc().getDefaultProxyConfig() != null) {
LinphoneAccountCreator accountCreator;
- accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
+ 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()));
diff --git a/src/org/linphone/LinphonePreferences.java b/src/org/linphone/LinphonePreferences.java
index 7970a119b..39f94461e 100644
--- a/src/org/linphone/LinphonePreferences.java
+++ b/src/org/linphone/LinphonePreferences.java
@@ -27,7 +27,6 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import org.linphone.core.LinphoneAccountCreator;
-import org.linphone.core.LinphoneAccountCreatorImpl;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAddress.TransportType;
import org.linphone.core.LinphoneAuthInfo;
@@ -194,11 +193,6 @@ public class LinphonePreferences {
getLc().addAuthInfo(authInfo);
}
-
- public LinphoneAccountCreator AccountCreator(LinphoneCore lc, String server_url) {
- return new LinphoneAccountCreatorImpl(lc, server_url);
- }
-
public static class AccountBuilder {
private LinphoneCore lc;
private String tempUsername;
diff --git a/src/org/linphone/LinphoneUtils.java b/src/org/linphone/LinphoneUtils.java
index 76b8afcce..bd8ad342a 100644
--- a/src/org/linphone/LinphoneUtils.java
+++ b/src/org/linphone/LinphoneUtils.java
@@ -42,6 +42,11 @@ import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
+import android.app.AlertDialog;
+import android.widget.*;
+import org.linphone.assistant.AssistantActivity;
+import org.linphone.assistant.CountryListFragment;
+import org.linphone.core.LinphoneAccountCreator;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State;
@@ -73,7 +78,6 @@ import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
-import android.widget.ImageView;
/**
* Helpers.
@@ -81,6 +85,7 @@ import android.widget.ImageView;
*
*/
public final class LinphoneUtils {
+ private static Context context = null;
private LinphoneUtils(){}
@@ -564,5 +569,110 @@ public final class LinphoneUtils {
Log.e(e);
}
}
+
+ private static Context getContext() {
+ if (context == null && LinphoneManager.isInstanciated())
+ context = LinphoneManager.getInstance().getContext();
+ return context;
+ }
+
+ public static void displayError(boolean isOk, TextView error, String errorText) {
+ if (isOk) {
+ error.setVisibility(View.INVISIBLE);
+ error.setText("");
+ } else {
+ error.setVisibility(View.VISIBLE);
+ error.setText(errorText);
+ }
+ }
+
+ public static String errorForStatus(LinphoneAccountCreator.Status status) {
+ Context ctxt = getContext();
+ if (ctxt != null) {
+ if (status.equals(LinphoneAccountCreator.Status.EmailInvalid))
+ return ctxt.getString(R.string.invalid_email);
+ if (status.equals(LinphoneAccountCreator.Status.UsernameInvalid)) {
+ return ctxt.getString(R.string.invalid_username);
+ }
+ if (status.equals(LinphoneAccountCreator.Status.UsernameTooShort)) {
+ return ctxt.getString(R.string.username_too_short);
+ }
+ if (status.equals(LinphoneAccountCreator.Status.UsernameTooLong)) {
+ return ctxt.getString(R.string.username_too_long);
+ }
+ if (status.equals(LinphoneAccountCreator.Status.UsernameInvalidSize))
+ return ctxt.getString(R.string.username_invalid_size);
+ if (status.equals(LinphoneAccountCreator.Status.PhoneNumberTooShort))
+ return ctxt.getString(R.string.phone_number_too_short);
+ if (status.equals(LinphoneAccountCreator.Status.PhoneNumberTooLong))
+ return ctxt.getString(R.string.phone_number_too_long);
+ if (status.equals(LinphoneAccountCreator.Status.PhoneNumberInvalid))
+ return ctxt.getString(R.string.phone_number_invalid);
+ if (status.equals(LinphoneAccountCreator.Status.PasswordTooShort))
+ return ctxt.getString(R.string.username_too_short);
+ if (status.equals(LinphoneAccountCreator.Status.PasswordTooLong))
+ return ctxt.getString(R.string.username_too_long);
+ if (status.equals(LinphoneAccountCreator.Status.DomainInvalid))
+ return ctxt.getString(R.string.invalid_domain);
+ if (status.equals(LinphoneAccountCreator.Status.RouteInvalid))
+ return ctxt.getString(R.string.invalid_route);
+ if (status.equals(LinphoneAccountCreator.Status.DisplayNameInvalid))
+ return ctxt.getString(R.string.invalid_route);
+ if (status.equals(LinphoneAccountCreator.Status.Failed))
+ return ctxt.getString(R.string.request_failed);
+ if (status.equals(LinphoneAccountCreator.Status.TransportNotSupported))
+ return ctxt.getString(R.string.transport_unsupported);
+ if (status.equals(LinphoneAccountCreator.Status.AccountExist))
+ return ctxt.getString(R.string.account_already_exist);
+ if (status.equals(LinphoneAccountCreator.Status.AccountExistWithAlias))
+ return ctxt.getString(R.string.account_already_exist);
+ if (status.equals(LinphoneAccountCreator.Status.CountryCodeInvalid))
+ return ctxt.getString(R.string.country_code_invalid);
+ if (status.equals(LinphoneAccountCreator.Status.AccountCreated)
+ || status.equals(LinphoneAccountCreator.Status.AccountNotCreated)
+ || status.equals(LinphoneAccountCreator.Status.AccountNotExist)
+ || status.equals(LinphoneAccountCreator.Status.AccountNotActivated)
+ || status.equals(LinphoneAccountCreator.Status.AccountAlreadyActivated)
+ || status.equals(LinphoneAccountCreator.Status.AccountActivated)
+ || status.equals(LinphoneAccountCreator.Status.Ok)) {
+ return "";
+ }
+ }
+ return null;
+ }
+
+ public static String getCountryCode(EditText dialCode) {
+ if(dialCode != null) {
+ String code = dialCode.getText().toString();
+ if(code != null && code.startsWith("+")) {
+ code = code.substring(1);
+ }
+ return code;
+ }
+ return null;
+ }
+
+ public static void setCountry(AssistantActivity.Country c, EditText dialCode, Button selectCountry, int countryCode) {
+ if( c != null && dialCode != null && selectCountry != null) {
+ dialCode.setText(c.dial_code);
+ selectCountry.setText(c.name);
+ } else {
+ if(countryCode != -1){
+ dialCode.setText("+" + countryCode);
+ } else {
+ dialCode.setText("+");
+ }
+ }
+ }
+
+ public static void displayErrorAlert(String msg, Context ctxt) {
+ if (ctxt != null) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);
+ builder.setMessage(msg)
+ .setCancelable(false)
+ .setNeutralButton("Ok", null)
+ .show();
+ }
+ }
}
diff --git a/src/org/linphone/StatusFragment.java b/src/org/linphone/StatusFragment.java
index ec18f659e..7a01d2ec8 100644
--- a/src/org/linphone/StatusFragment.java
+++ b/src/org/linphone/StatusFragment.java
@@ -33,6 +33,7 @@ import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.PayloadType;
import org.linphone.mediastream.Log;
+import org.w3c.dom.Text;
import android.app.Activity;
import android.app.Dialog;
@@ -441,7 +442,8 @@ public class StatusFragment extends Fragment {
private void displayMediaStats(LinphoneCallParams params, LinphoneCallStats stats
, PayloadType media , View layout, TextView title, TextView codec, TextView dl
, TextView ul, TextView ice, TextView senderLossRate, TextView receiverLossRate
- , TextView videoResolutionSent, TextView videoResolutionReceived, boolean isVideo) {
+ , TextView enc, TextView dec, TextView videoResolutionSent
+ , TextView videoResolutionReceived, boolean isVideo) {
if (stats != null) {
layout.setVisibility(View.VISIBLE);
title.setVisibility(TextView.VISIBLE);
@@ -454,6 +456,8 @@ public class StatusFragment extends Fragment {
}
codec.setText(mime + " / " + (media.getRate() / 1000) + "kHz");
}
+ enc.setText(stats.getEncoderName(media));
+ dec.setText(stats.getDecoderName(media));
dl.setText(String.valueOf((int) stats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) stats.getUploadBandwidth()) + " kbits/s");
ice.setText(stats.getIceState().toString());
@@ -485,28 +489,24 @@ public class StatusFragment extends Fragment {
final TextView titleAudio = (TextView) view.findViewById(R.id.call_stats_audio);
final TextView titleVideo = (TextView) view.findViewById(R.id.call_stats_video);
-
final TextView codecAudio = (TextView) view.findViewById(R.id.codec_audio);
final TextView codecVideo = (TextView) view.findViewById(R.id.codec_video);
-
+ final TextView encoderAudio = (TextView) view.findViewById(R.id.encoder_audio);
+ final TextView decoderAudio = (TextView) view.findViewById(R.id.decoder_audio);
+ final TextView encoderVideo = (TextView) view.findViewById(R.id.encoder_video);
+ final TextView decoderVideo = (TextView) view.findViewById(R.id.decoder_video);
final TextView dlAudio = (TextView) view.findViewById(R.id.downloadBandwith_audio);
final TextView ulAudio = (TextView) view.findViewById(R.id.uploadBandwith_audio);
-
final TextView dlVideo = (TextView) view.findViewById(R.id.downloadBandwith_video);
final TextView ulVideo = (TextView) view.findViewById(R.id.uploadBandwith_video);
-
final TextView iceAudio = (TextView) view.findViewById(R.id.ice_audio);
final TextView iceVideo = (TextView) view.findViewById(R.id.ice_video);
-
final TextView videoResolutionSent = (TextView) view.findViewById(R.id.video_resolution_sent);
final TextView videoResolutionReceived = (TextView) view.findViewById(R.id.video_resolution_received);
-
final TextView senderLossRateAudio = (TextView) view.findViewById(R.id.senderLossRateAudio);
final TextView receiverLossRateAudio = (TextView) view.findViewById(R.id.receiverLossRateAudio);
-
final TextView senderLossRateVideo = (TextView) view.findViewById(R.id.senderLossRateVideo);
final TextView receiverLossRateVideo = (TextView) view.findViewById(R.id.receiverLossRateVideo);
-
final View videoLayout = view.findViewById(R.id.callStatsVideo);
final View audioLayout = view.findViewById(R.id.callStatsAudio);
@@ -535,12 +535,14 @@ public class StatusFragment extends Fragment {
displayMediaStats(params, audioStats, payloadAudio, audioLayout
, titleAudio, codecAudio, dlAudio, ulAudio, iceAudio
- , senderLossRateAudio, receiverLossRateAudio, null, null
+ , senderLossRateAudio, receiverLossRateAudio
+ , encoderAudio, decoderAudio, null, null
, false);
displayMediaStats(params, videoStats, payloadVideo, videoLayout
, titleVideo, codecVideo, dlVideo, ulVideo, iceVideo
, senderLossRateVideo, receiverLossRateVideo
+ , encoderVideo, decoderVideo
, videoResolutionSent, videoResolutionReceived
, true);
}
diff --git a/src/org/linphone/assistant/AssistantActivity.java b/src/org/linphone/assistant/AssistantActivity.java
index b6e4518e0..03d9aaca7 100644
--- a/src/org/linphone/assistant/AssistantActivity.java
+++ b/src/org/linphone/assistant/AssistantActivity.java
@@ -18,6 +18,12 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import android.view.LayoutInflater;
+import android.view.ViewGroup;
+import android.widget.*;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
@@ -26,7 +32,6 @@ import org.linphone.LinphonePreferences.AccountBuilder;
import org.linphone.R;
import org.linphone.StatusFragment;
import org.linphone.core.LinphoneAccountCreator;
-import org.linphone.core.LinphoneAccountCreatorImpl;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAddress.TransportType;
import org.linphone.core.LinphoneCore;
@@ -61,8 +66,11 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
-import android.widget.ImageView;
-import android.widget.Toast;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Sylvain Berfini
@@ -85,8 +93,9 @@ private static AssistantActivity instance;
private boolean echoCancellerAlreadyDone;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
private LinphoneAccountCreator accountCreator;
+ private CountryListAdapter countryListAdapter;
- public CountryListFragment.Country country;
+ public Country country;
public String phone_number;
public String email;
public String activation_code;
@@ -122,9 +131,11 @@ private static AssistantActivity instance;
mPrefs = LinphonePreferences.instance();
status.enableSideMenu(false);
- accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
+ accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setDomain(getResources().getString(R.string.default_domain));
accountCreator.setListener(this);
+
+ countryListAdapter = new CountryListAdapter(R.raw.countries, getApplicationContext());
mListener = new LinphoneCoreListenerBase() {
@Override
@@ -668,4 +679,151 @@ private static AssistantActivity instance;
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
}
+
+ public CountryListAdapter getCountryListAdapter() {
+ return countryListAdapter;
+ }
+
+ /**
+ * This class reads a JSON file containing Country-specific phone number description,
+ * and allows to present them into a ListView
+ */
+ public class CountryListAdapter extends BaseAdapter implements Filterable {
+
+ private LayoutInflater mInflater;
+ private List allCountries;
+ private List filteredCountries;
+ private Context context;
+
+ public CountryListAdapter(int jsonId, Context ctx) {
+ context = ctx;
+ allCountries = new ArrayList();
+ String jsonString = loadJSONFromAsset(R.raw.countries);
+ try {
+ JSONArray c = new JSONArray(jsonString);
+ for( int i = 0; i < c.length(); i++) {
+ allCountries.add(new Country(c.getJSONObject(i)));
+ }
+ filteredCountries = allCountries;
+ } catch (JSONException e){
+ e.printStackTrace();
+ }
+ }
+
+ public void setInflater(LayoutInflater inf) {
+ mInflater = inf;
+ }
+
+ public String loadJSONFromAsset(int id) {
+ String json = null;
+ if (context != null) {
+ try {
+ InputStream is = context.getResources().openRawResource(id);
+ int size = is.available();
+ byte[] buffer = new byte[size];
+ is.read(buffer);
+ is.close();
+ json = new String(buffer, "UTF-8");
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+ return json;
+ }
+
+ public boolean countryExist(String countryCode) {
+ for (Country c : allCountries) {
+ if (c.dial_code.equals("+"+countryCode)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int getCount() {
+ return filteredCountries.size();
+ }
+
+ @Override
+ public Country getItem(int position) {
+ return filteredCountries.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent){
+ View view;
+
+ if (convertView != null) {
+ view = convertView;
+ } else {
+ view = mInflater.inflate(R.layout.country_cell, parent, false);
+ }
+
+ Country c = filteredCountries.get(position);
+
+ TextView name = (TextView) view.findViewById(R.id.country_name);
+ name.setText(c.name);
+
+ TextView dial_code = (TextView) view.findViewById(R.id.country_prefix);
+ if (context != null)
+ dial_code.setText(String.format(context.getString(R.string.country_code),c.dial_code));
+
+ view.setTag(c);
+ return view;
+ }
+
+ @Override
+ public Filter getFilter() {
+ return new Filter() {
+ @Override
+ protected FilterResults performFiltering(CharSequence constraint) {
+ ArrayList filteredCountries = new ArrayList();
+ for (Country c : allCountries) {
+ if (c.name.toLowerCase().contains(constraint) || c.dial_code.contains(constraint)){
+ filteredCountries.add(c);
+ }
+ }
+ FilterResults filterResults = new FilterResults();
+ filterResults.values = filteredCountries;
+ return filterResults;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void publishResults(CharSequence constraint, FilterResults results) {
+ filteredCountries = (List) results.values;
+ CountryListAdapter.this.notifyDataSetChanged();
+ }
+ };
+ }
+ }
+
+ /**
+ * This class represents a Country. There's a name, dial_code, code and max number of digits.
+ * It is constructed from a JSON object containing all these parameters.
+ */
+ public class Country {
+ public String name;
+ public String dial_code;
+ public String code;
+ public int maxNum;
+
+ public Country(JSONObject obj ){
+ try {
+ name = obj.getString("name");
+ dial_code = obj.getString("dial_code");
+ code = obj.getString("code");
+ maxNum = obj.getInt("maxNum");
+ } catch (JSONException e){
+ e.printStackTrace();
+ }
+ }
+ }
}
diff --git a/src/org/linphone/assistant/CountryListFragment.java b/src/org/linphone/assistant/CountryListFragment.java
index 8e1344f0a..eafdad72f 100644
--- a/src/org/linphone/assistant/CountryListFragment.java
+++ b/src/org/linphone/assistant/CountryListFragment.java
@@ -8,20 +8,12 @@ import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.EditText;
-import android.widget.Filter;
-import android.widget.Filterable;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
+import android.widget.*;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.linphone.R;
-import org.linphone.mediastream.Log;
import java.io.IOException;
import java.io.InputStream;
@@ -34,7 +26,7 @@ public class CountryListFragment extends Fragment implements AdapterView.OnItemC
private ListView list;
private EditText search;
private ImageView clearSearchField;
- private CountryListAdapter adapter;
+ private AssistantActivity.CountryListAdapter adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -42,7 +34,8 @@ public class CountryListFragment extends Fragment implements AdapterView.OnItemC
mInflater = inflater;
View view = inflater.inflate(R.layout.assistant_country_list, container, false);
- adapter = new CountryListAdapter(R.raw.countries, getActivity().getApplicationContext());
+ adapter = AssistantActivity.instance().getCountryListAdapter();
+ adapter.setInflater(inflater);
search = (EditText)view.findViewById(R.id.search_country);
clearSearchField = (ImageView) view.findViewById(R.id.clearSearchField);
@@ -73,7 +66,7 @@ public class CountryListFragment extends Fragment implements AdapterView.OnItemC
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
- Country c = (Country)view.getTag();
+ AssistantActivity.Country c = (AssistantActivity.Country)view.getTag();
AssistantActivity.instance().country = c;
AssistantActivity.instance().onBackPressed();
}
@@ -84,130 +77,4 @@ public class CountryListFragment extends Fragment implements AdapterView.OnItemC
search.setText("");
}
}
-
- /**
- * This class represents a Country. There's a name, dial_code, code and max number of digits.
- * It is constructed from a JSON object containing all these parameters.
- */
- public class Country {
- public String name;
- public String dial_code;
- public String code;
- public int maxNum;
-
- public Country(JSONObject obj ){
- try {
- name = obj.getString("name");
- dial_code = obj.getString("dial_code");
- code = obj.getString("code");
- maxNum = obj.getInt("maxNum");
- } catch (JSONException e){
- e.printStackTrace();
- }
- }
- }
-
- /**
- * This class reads a JSON file containing Country-specific phone number description,
- * and allows to present them into a ListView
- */
- private class CountryListAdapter extends BaseAdapter implements Filterable {
-
- private List allCountries;
- private List filteredCountries;
- private Context context;
-
- public CountryListAdapter(int jsonId, Context ctx) {
- context = ctx;
- allCountries = new ArrayList();
- String jsonString = loadJSONFromAsset(R.raw.countries);
- try {
- JSONArray c = new JSONArray(jsonString);
- for( int i = 0; i < c.length(); i++) {
- allCountries.add(new Country(c.getJSONObject(i)));
- }
- filteredCountries = allCountries;
- } catch (JSONException e){
- e.printStackTrace();
- }
- }
-
- public String loadJSONFromAsset(int id) {
- String json = null;
- try {
- InputStream is = getResources().openRawResource(id);
- int size = is.available();
- byte[] buffer = new byte[size];
- is.read(buffer);
- is.close();
- json = new String(buffer, "UTF-8");
- } catch (IOException ex) {
- ex.printStackTrace();
- return null;
- }
- return json;
- }
-
- @Override
- public int getCount() {
- return filteredCountries.size();
- }
-
- @Override
- public Country getItem(int position) {
- return filteredCountries.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent){
- View view = null;
-
- if (convertView != null) {
- view = convertView;
- } else {
- view = mInflater.inflate(R.layout.country_cell, parent, false);
- }
-
- Country c = filteredCountries.get(position);
-
- TextView name = (TextView) view.findViewById(R.id.country_name);
- name.setText(c.name);
-
- TextView dial_code = (TextView) view.findViewById(R.id.country_prefix);
- dial_code.setText(String.format(getString(R.string.country_code),c.dial_code));
-
- view.setTag(c);
- return view;
- }
-
- @Override
- public Filter getFilter() {
- return new Filter() {
- @Override
- protected FilterResults performFiltering(CharSequence constraint) {
- ArrayList filteredCountries = new ArrayList();
- for (Country c : allCountries) {
- if (c.name.toLowerCase().contains(constraint) || c.dial_code.contains(constraint)){
- filteredCountries.add(c);
- }
- }
- FilterResults filterResults = new FilterResults();
- filterResults.values = filteredCountries;
- return filterResults;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- protected void publishResults(CharSequence constraint, FilterResults results) {
- filteredCountries = (List) results.values;
- CountryListAdapter.this.notifyDataSetChanged();
- }
- };
- }
- }
}
diff --git a/src/org/linphone/assistant/CreateAccountCodeActivationFragment.java b/src/org/linphone/assistant/CreateAccountCodeActivationFragment.java
index 6dc8a9ba6..721e4fb2d 100644
--- a/src/org/linphone/assistant/CreateAccountCodeActivationFragment.java
+++ b/src/org/linphone/assistant/CreateAccountCodeActivationFragment.java
@@ -28,24 +28,25 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.TextView;
import android.widget.Toast;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.R;
import org.linphone.core.LinphoneAccountCreator;
-import org.linphone.mediastream.Log;
-import org.linphone.core.LinphoneAccountCreatorImpl;
+import org.linphone.core.LinphoneCoreFactory;
import static org.linphone.core.LinphoneAccountCreator.*;
public class CreateAccountCodeActivationFragment extends Fragment implements LinphoneAccountCreatorListener {
private String username, phone, dialcode, ha1;
+ private TextView title;
private EditText code;
private boolean recoverAccount = false, linkAccount = false;
private int code_length;
- private Button checkAccount;
+ private Button checkAccount, back;
private LinphoneAccountCreator accountCreator;
@Override
@@ -60,12 +61,24 @@ public class CreateAccountCodeActivationFragment extends Fragment implements Lin
linkAccount = getArguments().getBoolean("LinkAccount");
code_length = LinphonePreferences.instance().getCodeLength();
- accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
+ accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setDomain(getResources().getString(R.string.default_domain));
accountCreator.setListener(this);
accountCreator.setUsername(username);
accountCreator.setPhoneNumber(phone, dialcode);
+
+ back = (Button) view.findViewById(R.id.cancel);
+ if (back != null)
+ back.setVisibility(Button.INVISIBLE);
+
+ title = (TextView) view.findViewById(R.id.title_account_activation);
+ if (linkAccount) {
+ title.setText(getString(R.string.assistant_link_account));
+ } else if (recoverAccount) {
+ title.setText(getString(R.string.assistant_linphone_account));
+ }
+
code = (EditText) view.findViewById(R.id.assistant_code);
code.addTextChangedListener(new TextWatcher() {
@Override
@@ -133,14 +146,14 @@ public class CreateAccountCodeActivationFragment extends Fragment implements Lin
if(!recoverAccount){
AssistantActivity.instance().isAccountVerified(accountCreator.getUsername());
} else {
- AssistantActivity.instance().finish();
+ AssistantActivity.instance().success();
}
} else {
AssistantActivity.instance().saveCreatedAccount(accountCreator.getPhoneNumber(), null, dialcode, accountCreator.getHa1(), getString(R.string.default_domain), null);
if(!recoverAccount) {
AssistantActivity.instance().isAccountVerified(accountCreator.getPhoneNumber());
} else {
- AssistantActivity.instance().finish();
+ AssistantActivity.instance().success();
}
}
} else if (status.equals(LinphoneAccountCreator.Status.Failed)) {
diff --git a/src/org/linphone/assistant/CreateAccountFragment.java b/src/org/linphone/assistant/CreateAccountFragment.java
index 9dd377494..8278cf65c 100644
--- a/src/org/linphone/assistant/CreateAccountFragment.java
+++ b/src/org/linphone/assistant/CreateAccountFragment.java
@@ -22,11 +22,13 @@ import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
+import org.linphone.LinphoneUtils;
import org.linphone.R;
import org.linphone.core.LinphoneAccountCreator;
-import org.linphone.core.LinphoneAccountCreatorImpl;
+import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.mediastream.Log;
@@ -50,7 +52,6 @@ import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-import android.widget.Toast;
import static org.linphone.core.LinphoneAccountCreator.*;
@@ -70,10 +71,10 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
private boolean linkAccount = false;
private Button createAccount, selectCountry;
private CheckBox useUsername, useEmail;
+ private String addressSip = "";
private int countryCode;
private LinearLayout phoneNumberLayout, usernameLayout, emailLayout, passwordLayout, passwordConfirmLayout;
private final Pattern UPPER_CASE_REGEX = Pattern.compile("[A-Z]");
- private CountryListFragment.Country country;
private LinphoneAccountCreator accountCreator;
@Override
@@ -81,7 +82,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
//Initialize accountCreator
- accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
+ accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setDomain(getResources().getString(R.string.default_domain));
accountCreator.setListener(this);
@@ -121,7 +122,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
skip = (TextView) view.findViewById(R.id.assistant_skip);
//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
TelephonyManager tm = (TelephonyManager) getActivity().getApplicationContext().getSystemService(getActivity().getApplicationContext().TELEPHONY_SERVICE);
String countryIso = tm.getNetworkCountryIso();
@@ -131,33 +132,28 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
phoneNumberLayout.setVisibility(View.VISIBLE);
phoneNumberInfo.setOnClickListener(this);
- addPhoneNumberHandler(phoneNumberEdit, null);
- addPhoneNumberHandler(dialCode, null);
selectCountry.setOnClickListener(this);
String previousPhone = AssistantActivity.instance().phone_number;
- if(previousPhone != null ){
+ if (previousPhone != null ) {
phoneNumberEdit.setText(previousPhone);
}
- setCountry(AssistantActivity.instance().country);
+ 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) ) {
+ if (getResources().getBoolean(R.bool.assistant_allow_username)) {
useUsername.setVisibility(View.VISIBLE);
- useUsername.setEnabled(false);
useUsername.setOnCheckedChangeListener(this);
}
+ addPhoneNumberHandler(phoneNumberEdit, null);
+ addPhoneNumberHandler(dialCode, null);
}
//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.setOnCheckedChangeListener(this);
- addPasswordHandler(passwordEdit, null);
- addConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
- addEmailHandler(emailEdit, null);
-
if (getResources().getBoolean(R.bool.pre_fill_email_in_assistant)) {
Account[] accounts = AccountManager.get(getActivity()).getAccountsByType("com.google");
@@ -171,10 +167,14 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
}
}
+
+ addPasswordHandler(passwordEdit, null);
+ addConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
+ addEmailHandler(emailEdit, null);
}
//Hide phone number and display username/email/password
- if(!getResources().getBoolean(R.bool.use_phone_number_validation)){
+ if (!getResources().getBoolean(R.bool.use_phone_number_validation)) {
useEmail.setVisibility(View.GONE);
useUsername.setVisibility(View.GONE);
@@ -185,7 +185,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
//Link account with phone number
- if(getArguments().getBoolean("LinkPhoneNumber")){
+ if (getArguments().getBoolean("LinkPhoneNumber")) {
linkAccount = true;
useEmail.setVisibility(View.GONE);
useUsername.setVisibility(View.GONE);
@@ -203,7 +203,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
addUsernameHandler(usernameEdit, null);
- createAccount.setEnabled(false);
+ createAccount.setEnabled(true);
createAccount.setOnClickListener(this);
return view;
@@ -223,66 +223,42 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
return null;
}
- private String getCountryCode() {
- if(dialCode != null) {
- String code = dialCode.getText().toString();
- if(code != null && code.startsWith("+")) {
- code = code.substring(1);
- }
- return code;
- }
- return null;
- }
-
- public void setCountry(CountryListFragment.Country c) {
- country = c;
- if( c!= null) {
- dialCode.setText(c.dial_code);
- selectCountry.setText(c.name);
- } else {
- if(countryCode != -1){
- dialCode.setText("+" + countryCode);
- } else {
- dialCode.setText("+");
- }
- }
- }
-
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if(buttonView.getId() == R.id.use_username) {
- if(isChecked) {
+ if (buttonView.getId() == R.id.use_username) {
+ if (isChecked) {
usernameLayout.setVisibility(View.VISIBLE);
- if(getResources().getBoolean(R.bool.isTablet)){
+ if (getResources().getBoolean(R.bool.isTablet)) {
passwordLayout.setVisibility(View.INVISIBLE);
}
+ onTextChanged2();
} else {
usernameLayout.setVisibility(View.GONE);
accountCreator.setUsername(null);
+ onTextChanged2();
}
- } else if(buttonView.getId() == R.id.use_email){
- if(isChecked) {
+ } else if (buttonView.getId() == R.id.use_email) {
+ if (isChecked) {
emailLayout.setVisibility(View.VISIBLE);
passwordLayout.setVisibility(View.VISIBLE);
passwordConfirmLayout.setVisibility(View.VISIBLE);
usernameLayout.setVisibility(View.VISIBLE);
- useUsername.setEnabled(false);
+
} else {
- if(!useUsername.isChecked()) {
+ if (!useUsername.isChecked()) {
usernameLayout.setVisibility(View.GONE);
}
emailLayout.setVisibility(View.GONE);
passwordLayout.setVisibility(View.GONE);
passwordConfirmLayout.setVisibility(View.GONE);
usernameLayout.setVisibility(View.GONE);
- useUsername.setEnabled(true);
}
}
}
@Override
public void onClick(View v) {
- switch (v.getId()){
+ switch (v.getId()) {
case R.id.select_country: {
AssistantActivity.instance().displayCountryChooser();
break;
@@ -294,10 +270,10 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
case R.id.info_phone_number: {
- if(linkAccount){
+ if (linkAccount) {
new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.phone_number_info_title))
- .setMessage(getString(R.string.phone_number_link_info_content))
+ .setMessage(getString(R.string.phone_number_link_info_content) + "\n" + getString(R.string.phone_number_link_info_content_already_account))
.show();
} else {
new AlertDialog.Builder(getActivity())
@@ -309,7 +285,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
case R.id.assistant_create: {
- if(linkAccount){
+ if (linkAccount) {
addAlias();
} else {
createAccount();
@@ -319,44 +295,117 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
}
- private void displayError(Boolean isOk, TextView error, EditText editText, String errorText){
- if(isOk || editText.getText().toString().equals("")){
- error.setVisibility(View.INVISIBLE);
- error.setText(errorText);
- editText.setBackgroundResource(R.drawable.resizable_textfield);
- } else {
- error.setVisibility(View.VISIBLE);
- error.setText(errorText);
- editText.setBackgroundResource(R.drawable.resizable_textfield_error);
- }
- }
-
private boolean isEmailCorrect(String email) {
Pattern emailPattern = Patterns.EMAIL_ADDRESS;
return emailPattern.matcher(email).matches();
}
-
+
private boolean isPasswordCorrect(String password) {
return password.length() >= 1;
}
private void addAlias() {
accountCreator.setUsername(LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()));
- String countryCode = dialCode.getText().toString();
- if(countryCode != null && countryCode.startsWith("+")) {
- countryCode = countryCode.substring(1);
- }
- Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), getCountryCode());
- if(status.equals(Status.Ok)){
+ Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
+ boolean isOk = status.equals(LinphoneAccountCreator.Status.Ok);
+ if (isOk) {
accountCreator.linkPhoneNumberWithAccount();
+ } else {
+ LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), getContext());
+ LinphoneUtils.displayError(isOk, phoneNumberError, LinphoneUtils.errorForStatus(status));
}
}
private void createAccount() {
- if(accountCreator.getUsername() == null && !useUsername.isChecked()){
- accountCreator.setUsername(accountCreator.getPhoneNumber());
+ if (getResources().getBoolean(R.bool.isTablet) || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
+ Status emailStatus;
+ Status passwordStatus;
+
+ passwordStatus = accountCreator.setPassword(passwordEdit.getText().toString());
+ emailStatus = accountCreator.setEmail(emailEdit.getText().toString());
+
+ if (!emailOk) {
+ LinphoneUtils.displayError(false, emailError, LinphoneUtils.errorForStatus(emailStatus));
+ LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(emailStatus), getContext());
+ } else if (!passwordOk) {
+ LinphoneUtils.displayError(false, passwordError, LinphoneUtils.errorForStatus(passwordStatus));
+ LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(passwordStatus), getContext());
+ } else if (!confirmPasswordOk) {
+ String msg;
+ if (passwordConfirmEdit.getText().toString().equals(passwordEdit.getText().toString())) {
+ msg = getString(R.string.wizard_password_incorrect);
+ } else {
+ msg = getString(R.string.wizard_passwords_unmatched);
+ }
+ LinphoneUtils.displayError(false, passwordError, msg);
+ LinphoneUtils.displayErrorAlert(msg, getContext());
+ } else {
+ accountCreator.createAccount();
+ }
+ } else {
+ if (phoneNumberEdit.length() > 0 || dialCode.length() > 1) {
+ Status phoneStatus;
+ boolean isOk;
+ phoneStatus = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
+ isOk = phoneStatus.equals(LinphoneAccountCreator.Status.Ok);
+ if (!useUsername.isChecked() && accountCreator.getUsername() == null) {
+ accountCreator.setUsername(accountCreator.getPhoneNumber());
+ } else {
+ accountCreator.setUsername(usernameEdit.getText().toString());
+ accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), dialCode.getText().toString());
+ }
+ if (isOk) {
+ accountCreator.createAccount();
+ } else {
+ LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(phoneStatus), getContext());
+ LinphoneUtils.displayError(isOk, phoneNumberError, LinphoneUtils.errorForStatus(phoneStatus));
+ }
+ } else {
+ LinphoneUtils.displayErrorAlert(getString(R.string.assistant_create_account_part_1), getContext());
+ }
+ }
+ }
+
+ private LinphoneAccountCreator.Status getPhoneNumberStatus() {
+ LinphoneAccountCreator.Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
+ addressSip = accountCreator.getPhoneNumber();
+ return status;
+ }
+
+ public void onTextChanged2() {
+ String msg;
+ LinphoneAccountCreator.Status status = getPhoneNumberStatus();
+ boolean isOk = status.equals(LinphoneAccountCreator.Status.Ok);
+ LinphoneUtils.displayError(isOk, phoneNumberError, LinphoneUtils.errorForStatus(status));
+
+ // Username or phone number
+ if (getResources().getBoolean(R.bool.assistant_allow_username) && useUsername.isChecked()
+ || (getResources().getBoolean(R.bool.isTablet) || useEmail.isChecked()
+ || !getResources().getBoolean(R.bool.use_phone_number_validation))) {
+ addressSip = getUsername();
+ }
+
+ if (!isOk) {
+ if (status.equals(LinphoneAccountCreator.Status.CountryCodeInvalid)) {
+ dialCode.setBackgroundResource(R.drawable.resizable_textfield_error);
+ phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
+ sipUri.setText("");
+ } else {
+ dialCode.setBackgroundResource(R.drawable.resizable_textfield);
+ phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield_error);
+ sipUri.setText("");
+ }
+ } else {
+ dialCode.setBackgroundResource(R.drawable.resizable_textfield);
+ phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
+ if (!linkAccount && addressSip.length() > 0) {
+ msg = getResources().getString(R.string.assistant_create_account_phone_number_address)
+ + " <" + addressSip + "@" + getResources().getString(R.string.default_domain) + ">";
+ sipUri.setText(msg);
+ } else {
+ sipUri.setText("");
+ }
}
- accountCreator.createAccount();
}
private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
@@ -366,27 +415,11 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int count, int after) {
- if (s.length() > 0) {
- phoneNumberOk = false;
- Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), getCountryCode());
- if(status.equals(Status.Ok)){
- if(useUsername.isChecked()){
- accountCreator.setUsername(usernameEdit.getText().toString());
- }
- accountCreator.isAccountUsed();
- } else {
- useUsername.setEnabled(phoneNumberOk);
- displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
- sipUri.setText("");
- }
- } else {
- useUsername.setEnabled(phoneNumberOk);
- displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, "");
- }
+ onTextChanged2();
}
});
}
-
+
private void addUsernameHandler(final EditText field, final ImageView icon) {
field.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
@@ -398,7 +431,6 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
-
}
public void onTextChanged(CharSequence s, int start, int count, int after) {
@@ -408,16 +440,17 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
if(status.equals(Status.Ok)){
accountCreator.isAccountUsed();
} else {
- displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
+ LinphoneUtils.displayError(usernameOk, usernameError, LinphoneUtils.errorForStatus(status));
sipUri.setText("");
}
} else {
- displayError(true, usernameError, usernameEdit, "");
+ LinphoneUtils.displayError(true, usernameError, "");
}
+ onTextChanged2();
}
});
}
-
+
private void addEmailHandler(final EditText field, final ImageView icon) {
field.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
@@ -425,12 +458,11 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
Status status = accountCreator.setEmail(field.getText().toString());
if (status.equals(Status.Ok)) {
emailOk = true;
- displayError(emailOk, emailError, emailEdit, "");
+ LinphoneUtils.displayError(emailOk, emailError, "");
}
else {
- displayError(emailOk, emailError, emailEdit, errorForStatus(status));
+ LinphoneUtils.displayError(emailOk, emailError, LinphoneUtils.errorForStatus(status));
}
- createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -440,7 +472,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
}
});
}
-
+
private void addPasswordHandler(final EditText field1, final ImageView icon) {
TextWatcher passwordListener = new TextWatcher() {
public void afterTextChanged(Editable s) {
@@ -448,12 +480,11 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
Status status = accountCreator.setPassword(field1.getText().toString());
if (isPasswordCorrect(field1.getText().toString())) {
passwordOk = true;
- displayError(passwordOk, passwordError, passwordEdit, "");
+ LinphoneUtils.displayError(passwordOk, passwordError, "");
}
else {
- displayError(passwordOk, passwordError, passwordEdit, errorForStatus(status));
+ LinphoneUtils.displayError(passwordOk, passwordError, LinphoneUtils.errorForStatus(status));
}
- createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -462,10 +493,10 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
public void onTextChanged(CharSequence s, int start, int count, int after) {
}
};
-
+
field1.addTextChangedListener(passwordListener);
}
-
+
private void addConfirmPasswordHandler(final EditText field1, final EditText field2, final ImageView icon) {
TextWatcher passwordListener = new TextWatcher() {
public void afterTextChanged(Editable s) {
@@ -473,14 +504,13 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
if (field1.getText().toString().equals(field2.getText().toString())) {
confirmPasswordOk = true;
if (!isPasswordCorrect(field1.getText().toString())) {
- displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
+ LinphoneUtils.displayError(passwordOk, passwordError, getString(R.string.wizard_password_incorrect));
} else {
- displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, "");
+ LinphoneUtils.displayError(confirmPasswordOk, passwordConfirmError, "");
}
} else {
- displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, getString(R.string.wizard_passwords_unmatched));
+ LinphoneUtils.displayError(confirmPasswordOk, passwordConfirmError, getString(R.string.wizard_passwords_unmatched));
}
- createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -492,106 +522,20 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
field2.addTextChangedListener(passwordListener);
}
- String errorForStatus(Status status) {
- if (status.equals(Status.EmailInvalid))
- return getString(R.string.invalid_email);
- if (status.equals(Status.UsernameInvalid)){
- return getString(R.string.invalid_username);
- }
- if (status.equals(Status.UsernameTooShort)){
- return getString(R.string.username_too_short);
- }
- if (status.equals(Status.UsernameTooLong)){
- return getString(R.string.username_too_long);
- }
- if (status.equals(Status.UsernameInvalidSize))
- return getString(R.string.username_invalid_size);
- if (status.equals(Status.PhoneNumberTooShort))
- return getString(R.string.phone_number_too_short);
- if (status.equals(Status.PhoneNumberTooLong))
- return getString(R.string.phone_number_too_long);
- if (status.equals(Status.PhoneNumberInvalid))
- return getString(R.string.phone_number_invalid);
- if (status.equals(Status.PasswordTooShort))
- return getString(R.string.username_too_short);
- if (status.equals(Status.PasswordTooLong))
- return getString(R.string.username_too_long);
- if (status.equals(Status.DomainInvalid))
- return getString(R.string.invalid_domain);
- if (status.equals(Status.RouteInvalid))
- return getString(R.string.invalid_route);
- if (status.equals(Status.DisplayNameInvalid))
- return getString(R.string.invalid_route);
- if (status.equals(Status.Failed))
- return getString(R.string.request_failed);
- if (status.equals(Status.TransportNotSupported))
- return getString(R.string.transport_unsupported);
- if (status.equals(Status.AccountExist))
- return getString(R.string.account_already_exist);
- if (status.equals(Status.AccountExistWithAlias))
- return getString(R.string.account_already_exist);
- if (status.equals(Status.AccountCreated)
- || status.equals(Status.AccountNotCreated)
- || status.equals(Status.AccountNotExist)
- || status.equals(Status.AccountNotActivated)
- || status.equals(Status.AccountAlreadyActivated)
- || status.equals(Status.AccountActivated)
- || status.equals(Status.Ok)){
- return "";
- }
- return null;
- }
-
@Override
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, final Status status) {
- if(getResources().getBoolean(R.bool.isTablet) || useEmail.isChecked() || !getResources().getBoolean(R.bool.use_phone_number_validation)){
- if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
- usernameOk = false;
- displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
- sipUri.setText("");
- } else {
- usernameOk = true;
- displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
- sipUri.setText("Sip uri is sip:" + accountCreator.getUsername() + "@" + getResources().getString(R.string.default_domain));
- }
- createAccount.setEnabled(usernameOk && emailOk);
- }
- if(getResources().getBoolean(R.bool.assistant_allow_username) && useUsername.isChecked()){
- if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
- usernameOk = false;
- displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
- sipUri.setText("");
- } else {
- usernameOk = true;
- displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
- sipUri.setText("Sip uri is sip:" + accountCreator.getUsername() + "@" + getResources().getString(R.string.default_domain));
- }
- createAccount.setEnabled(usernameOk && phoneNumberOk);
- } else {
- if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
- phoneNumberOk = false;
- displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
- sipUri.setText("");
- } else {
- phoneNumberOk = true;
- displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
- sipUri.setText("Sip uri is sip:" + accountCreator.getPhoneNumber() + "@" + getResources().getString(R.string.default_domain));
- }
- createAccount.setEnabled(phoneNumberOk);
- useUsername.setEnabled(phoneNumberOk);
- }
}
@Override
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, Status status) {
- if(status.equals(Status.AccountCreated)) {
- if(useEmail.isChecked() || !getResources().getBoolean(R.bool.use_phone_number_validation)){
+ if (status.equals(Status.AccountCreated)) {
+ if (useEmail.isChecked() || !getResources().getBoolean(R.bool.use_phone_number_validation)) {
AssistantActivity.instance().displayAssistantConfirm(getUsername(), passwordEdit.getText().toString());
} else {
- AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), false);
+ AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), false);
}
} else {
- Toast.makeText(getActivity().getApplicationContext(), errorForStatus(status), Toast.LENGTH_SHORT);
+ LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), getContext());
}
}
@@ -601,15 +545,15 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
@Override
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status) {
- if(status.equals(Status.Ok)){
- AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), false);
+ if (status.equals(Status.Ok)) {
+ AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), false);
}
}
@Override
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status) {
- if(status.equals(Status.Ok)){
- AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), false);
+ if (status.equals(Status.Ok)) {
+ AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), false);
}
}
diff --git a/src/org/linphone/assistant/LinphoneLoginFragment.java b/src/org/linphone/assistant/LinphoneLoginFragment.java
index 44aab5560..9bc26a5d4 100644
--- a/src/org/linphone/assistant/LinphoneLoginFragment.java
+++ b/src/org/linphone/assistant/LinphoneLoginFragment.java
@@ -17,14 +17,15 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import android.app.AlertDialog;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
+import org.linphone.LinphoneUtils;
import org.linphone.R;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.LinphoneAccountCreator;
-import org.linphone.core.LinphoneAccountCreatorImpl;
+import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneProxyConfig;
-import org.linphone.mediastream.Log;
import android.app.Fragment;
import android.os.Bundle;
@@ -43,7 +44,6 @@ import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-import android.widget.Toast;
/**
* @author Sylvain Berfini
*/
@@ -52,18 +52,19 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
private Button apply, selectCountry;
private CheckBox useUsername, usePassword;
private LinearLayout phoneNumberLayout, usernameLayout, passwordLayout;
- private TextView forgotPassword;
- private CountryListFragment.Country country;
- private Boolean recoverAccount = false;
+ private TextView forgotPassword, messagePhoneNumber, phoneNumberError;
+ private Boolean recoverAccount;
private LinphoneAccountCreator accountCreator;
+ private AssistantActivity.Country country;
private int countryCode;
+ private ImageView phoneNumberInfo;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_linphone_login, container, false);
- accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
+ accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setListener(this);
String url = "http://linphone.org/free-sip-service.html&action=recover";
@@ -71,21 +72,30 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
login = (EditText) view.findViewById(R.id.assistant_username);
login.addTextChangedListener(this);
+ recoverAccount = true;
+
dialCode = (EditText) view.findViewById(R.id.dial_code);
phoneNumberEdit = (EditText) view.findViewById(R.id.phone_number);
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
- addPhoneNumberHandler(phoneNumberEdit, null);
+ phoneNumberError = (TextView) view.findViewById(R.id.phone_number_error_2);
+
+ phoneNumberInfo = (ImageView) view.findViewById(R.id.info_phone_number);
useUsername = (CheckBox) view.findViewById(R.id.use_username);
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
passwordLayout = (LinearLayout) view.findViewById(R.id.password_layout);
password = (EditText) view.findViewById(R.id.assistant_password);
displayName = (EditText) view.findViewById(R.id.assistant_display_name);
+ messagePhoneNumber = (TextView) view.findViewById(R.id.message_phone_number);
forgotPassword = (TextView) view.findViewById(R.id.forgot_password);
selectCountry = (Button) view.findViewById(R.id.select_country);
+ apply = (Button) view.findViewById(R.id.assistant_apply);
+ apply.setEnabled(true);
+ apply.setOnClickListener(this);
+
//Phone number
if(getResources().getBoolean(R.bool.use_phone_number_validation)){
//Automatically get the country code from the phone
@@ -96,12 +106,14 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
phoneNumberLayout.setVisibility(View.VISIBLE);
selectCountry.setOnClickListener(this);
+ phoneNumberInfo.setOnClickListener(this);
String previousPhone = AssistantActivity.instance().phone_number;
- if(previousPhone != null ){
+ if (previousPhone != null ) {
phoneNumberEdit.setText(previousPhone);
}
- setCountry(AssistantActivity.instance().country);
+
+ 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) ) {
@@ -127,38 +139,12 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
passwordLayout.setVisibility(View.VISIBLE);
}
- apply = (Button) view.findViewById(R.id.assistant_apply);
- apply.setEnabled(false);
- apply.setOnClickListener(this);
+ addPhoneNumberHandler(dialCode, null);
+ addPhoneNumberHandler(phoneNumberEdit, null);
return view;
}
- private String getCountryCode() {
- if(dialCode != null) {
- String code = dialCode.getText().toString();
- if(code != null && code.startsWith("+")) {
- code = code.substring(1);
- }
- return code;
- }
- return null;
- }
-
- public void setCountry(CountryListFragment.Country c) {
- country = c;
- if( c!= null) {
- dialCode.setText(c.dial_code);
- selectCountry.setText(c.name);
- } else {
- if(countryCode != -1){
- dialCode.setText("+" + countryCode);
- } else {
- dialCode.setText("+");
- }
- }
- }
-
private String getPhoneNumber(){
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
String countryCode = dialCode.getText().toString();
@@ -172,69 +158,108 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
public void linphoneLogIn() {
if (login.getText() == null || login.length() == 0 || password.getText() == null || password.length() == 0) {
- Toast.makeText(getActivity(), getString(R.string.first_launch_no_login_password), Toast.LENGTH_LONG).show();
+ LinphoneUtils.displayErrorAlert(getString(R.string.first_launch_no_login_password), getContext());
return;
}
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), null, null, getResources().getBoolean(R.bool.assistant_account_validation_mandatory));
}
+ private LinphoneAccountCreator.Status getPhoneNumberStatus() {
+ return accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode));
+ }
+
private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
field.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
- if (s.length() > 0) {
- //phoneNumberOk = false;
- String countryCode = dialCode.getText().toString();
- if (countryCode != null && countryCode.startsWith("+")) {
- countryCode = countryCode.substring(1);
- }
- LinphoneAccountCreator.Status status = accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), countryCode);
- if (status.equals(LinphoneAccountCreator.Status.Ok)) {
- status = accountCreator.isAccountUsed();
- if (status.equals(LinphoneAccountCreator.Status.Ok)) {
- recoverAccount = true;
- }
- } else {
- //displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
- }
- } else {
- //displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, "");
- }
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int count, int after) {
+ onTextChanged2();
}
});
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ if (useUsername != null && useUsername.isChecked())
+ recoverAccount = false;
+ else
+ recoverAccount = true;
+ }
+
@Override
public void onClick(View v) {
int id = v.getId();
- if (id == R.id.assistant_apply) {
- if(recoverAccount){
- recoverAccount();
- } else {
- linphoneLogIn();
+ switch(id) {
+ case R.id.assistant_apply: {
+ if (recoverAccount) {
+ recoverAccount();
+ } else {
+ linphoneLogIn();
+ }
+ break;
}
- }
- if (id == R.id.select_country) {
- AssistantActivity.instance().displayCountryChooser();
+ case R.id.info_phone_number: {
+ new AlertDialog.Builder(getActivity())
+ .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))
+ .show();
+ break;
+ }
+ case R.id.select_country: {
+ AssistantActivity.instance().displayCountryChooser();
+ break;
+ }
+ default:
+ break;
}
}
private void recoverAccount() {
- accountCreator.recoverPhoneAccount();
+ if (phoneNumberEdit.length() > 0 || dialCode.length() > 1) {
+ LinphoneAccountCreator.Status status = getPhoneNumberStatus();
+ boolean isOk = status.equals(LinphoneAccountCreator.Status.Ok);
+ if (isOk) {
+ accountCreator.recoverPhoneAccount();
+ } else {
+ LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), getContext());
+ LinphoneUtils.displayError(isOk, phoneNumberError, LinphoneUtils.errorForStatus(status));
+ }
+ } else {
+ LinphoneUtils.displayErrorAlert(getString(R.string.assistant_create_account_part_1), getContext());
+ }
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
+ public void onTextChanged2() {
+ LinphoneAccountCreator.Status status = getPhoneNumberStatus();
+ boolean isOk = status.equals(LinphoneAccountCreator.Status.Ok);
+ LinphoneUtils.displayError(isOk, phoneNumberError, LinphoneUtils.errorForStatus(status));
+ if (!isOk) {
+ if (status.equals(LinphoneAccountCreator.Status.CountryCodeInvalid)) {
+ dialCode.setBackgroundResource(R.drawable.resizable_textfield_error);
+ phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
+ } else {
+ dialCode.setBackgroundResource(R.drawable.resizable_textfield);
+ phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield_error);
+ }
+ } else {
+ accountCreator.setPhoneNumber(phoneNumberEdit.getText().toString(), dialCode.getText().toString());
+ dialCode.setBackgroundResource(R.drawable.resizable_textfield);
+ phoneNumberEdit.setBackgroundResource(R.drawable.resizable_textfield);
+ }
+ }
+
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
- apply.setEnabled(!login.getText().toString().isEmpty() && !password.getText().toString().isEmpty());
+ onTextChanged2();
}
@Override
@@ -246,17 +271,23 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
if(isChecked) {
usernameLayout.setVisibility(View.VISIBLE);
passwordLayout.setVisibility(View.VISIBLE);
+ phoneNumberEdit.setVisibility(EditText.GONE);
+ phoneNumberLayout.setVisibility(LinearLayout.GONE);
+ messagePhoneNumber.setText(getString(R.string.assistant_linphone_login_desc));
recoverAccount = false;
} else {
usernameLayout.setVisibility(View.GONE);
- passwordLayout.setVisibility(View.INVISIBLE);
+ passwordLayout.setVisibility(View.GONE);
+ phoneNumberEdit.setVisibility(EditText.VISIBLE);
+ phoneNumberLayout.setVisibility(LinearLayout.VISIBLE);
+ messagePhoneNumber.setText(getString(R.string.assistant_create_account_part_1));
+ recoverAccount = true;
}
}
}
@Override
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
- apply.setEnabled(true);
}
@Override
@@ -281,11 +312,10 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
@Override
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
- apply.setEnabled(true);
}
@Override
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
- AssistantActivity.instance().displayAssistantCodeConfirm(accountCreator.getUsername(), phoneNumberEdit.getText().toString(), getCountryCode(), true);
+ AssistantActivity.instance().displayAssistantCodeConfirm(accountCreator.getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), true);
}
}
diff --git a/submodules/cmake-builder b/submodules/cmake-builder
index 71345f5ae..ed8748422 160000
--- a/submodules/cmake-builder
+++ b/submodules/cmake-builder
@@ -1 +1 @@
-Subproject commit 71345f5ae6b4ac042b4ddf6fad3043b5ee368cb3
+Subproject commit ed8748422bdb0c8c3790ce6fea0b6e894d8adea4
diff --git a/submodules/linphone b/submodules/linphone
index c2002e29a..6caf23eb5 160000
--- a/submodules/linphone
+++ b/submodules/linphone
@@ -1 +1 @@
-Subproject commit c2002e29a58cbb94ebed369add966929d1481076
+Subproject commit 6caf23eb5ce9c7c14e107a95cd4d3255ecc3a8c0