Works on assitant
This commit is contained in:
parent
d1e56dd6c9
commit
576c42a8d1
17 changed files with 802 additions and 520 deletions
|
@ -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" />
|
||||
|
||||
<TextView
|
||||
android:text="@string/assistant_create_account_part_2"
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"/>
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/message_phone_number" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -36,22 +37,13 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/phone_number_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/select_country"
|
||||
style="@style/font8"
|
||||
android:text="@string/select_your_country"
|
||||
android:background="@drawable/resizable_assistant_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
@ -63,6 +55,35 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/info_phone_number"
|
||||
android:src="@drawable/info"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/select_country"
|
||||
style="@style/font8"
|
||||
android:text="@string/select_your_country"
|
||||
android:background="@drawable/resizable_assistant_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -93,15 +114,17 @@
|
|||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/use_username"
|
||||
android:visibility="visible"
|
||||
android:layout_marginTop="20dp"
|
||||
<TextView
|
||||
android:id="@+id/phone_number_error_2"
|
||||
android:text="@string/error"
|
||||
style="@style/font20"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/login_with_username"/>
|
||||
android:visibility="invisible"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/username_layout"
|
||||
|
@ -158,8 +181,17 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/use_username"
|
||||
android:visibility="visible"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/login_with_username"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/assistant_apply"
|
||||
android:text="@string/assistant_login"
|
||||
|
|
|
@ -43,12 +43,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"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:stretchColumns="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="@string/call_stats_encoder_name"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/colorB"
|
||||
android:textSize="12sp"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:stretchColumns="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/encoder_audio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:gravity="right|center_vertical"
|
||||
android:textColor="@color/colorB"
|
||||
android:textSize="12sp"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:stretchColumns="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="@string/call_stats_decoder_name"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/colorB"
|
||||
android:textSize="12sp"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:stretchColumns="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/decoder_audio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:gravity="right|center_vertical"
|
||||
android:textColor="@color/colorB"
|
||||
android:textSize="12sp"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
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"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:stretchColumns="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="@string/call_stats_encoder_name"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/colorB"
|
||||
android:textSize="12sp"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:stretchColumns="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/encoder_video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:gravity="right|center_vertical"
|
||||
android:textColor="@color/colorB"
|
||||
android:textSize="12sp"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:stretchColumns="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="@string/call_stats_decoder_name"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/colorB"
|
||||
android:textSize="12sp"/>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:stretchColumns="0"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/decoder_video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:gravity="right|center_vertical"
|
||||
android:textColor="@color/colorB"
|
||||
android:textSize="12sp"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -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"/>
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<string name="welcome">Bienvenue</string>
|
||||
<string name="assistant">Assistant</string>
|
||||
<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>
|
||||
|
@ -58,14 +59,15 @@ Lorsque cela est fait, cliquez sur le bouton pour continuer.</string>
|
|||
<string name="assistant_login_desc">Entrer votre nom d\'utilisateur et mot de passe ainsi que votre domaine SIP</string>
|
||||
<string name="assistant_remote_provisioning_desc">Veuillez fournir votre URL de configuration.</string>
|
||||
<string name="transport">Transport</string>
|
||||
<string name="assistant_create_account_phone_number_address">Votre address SIP est</string>
|
||||
<string name="assistant_login_linphone">Utiliser un compte Linphone</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">1/2</string>
|
||||
<string name="assistant_create_account_part_2">2/2</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_display_name_optional">Nom d\'affichage (optionnel)</string>
|
||||
<string name="assistant_linphone_account">Configurer un compte Linphone</string>
|
||||
<string name="assistant_generic_account">Configure un compte SIP</string>
|
||||
<string name="assistant_linphone_account">Utiliser un compte Linphone</string>
|
||||
<string name="assistant_generic_account">Utiliser un compte SIP</string>
|
||||
<string name="assistant_remote_provisioning_title">Télécharger la configuration</string>
|
||||
<string name="assistant_fetch_apply">Télécharger et appliquer</string>
|
||||
<string name="assistant_login">Connexion</string>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<string name="no">No</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="link_account">Link account</string>
|
||||
<string name="link_account">Link your account</string>
|
||||
|
||||
<!-- Launch screen -->
|
||||
<string name="app_description">the <i>libre</i> SIP client</string>
|
||||
|
@ -65,8 +65,9 @@
|
|||
<string name="welcome">Welcome</string>
|
||||
<string name="assistant">Assistant</string>
|
||||
<string name="assistant_create_account">Create account</string>
|
||||
<string name="assistant_link_account">Link account</string>
|
||||
<string name="assistant_continue">Continue</string>
|
||||
<string name="assistant_activate">Activate account</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_welcome_desc">This assistant will help you configure and use your SIP account.</string>
|
||||
|
@ -74,6 +75,7 @@
|
|||
<string name="assistant_login_desc">Enter your username and password with your SIP domain</string>
|
||||
<string name="assistant_remote_provisioning_desc">Please provide your provisioning URL</string>
|
||||
<string name="transport">Transport</string>
|
||||
<string name="assistant_create_account_phone_number_address">Your SIP address is</string>
|
||||
<string name="assistant_login_linphone">Use Linphone account</string>
|
||||
<string name="assistant_login_generic">Use SIP account</string>
|
||||
<string name="assistant_remote_provisioning">Fetch remote configuration</string>
|
||||
|
@ -81,14 +83,14 @@
|
|||
<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_display_name_optional">Display name (optional)</string>
|
||||
<string name="assistant_linphone_account">Use your Linphone account</string>
|
||||
<string name="assistant_generic_account">Configure SIP account</string>
|
||||
<string name="assistant_generic_account">Use SIP account</string>
|
||||
<string name="assistant_remote_provisioning_title">Fetch remote configuration</string>
|
||||
<string name="assistant_fetch_apply">Fetch and apply</string>
|
||||
<string name="assistant_login">Login</string>
|
||||
<string name="assistant_ec_calibration">Echo canceler calibration in progress</string>
|
||||
<string name="assistant_remote_provisioning_login">Enter your login</string>
|
||||
<string name="assistant_account_not_validated">Your account has not been validated yet.</string>
|
||||
<string name="assistant_error_confirmation_code"></string>
|
||||
<string name="assistant_error_confirmation_code">The confirmation code is invalid.\r\nPlease check your SMS and try again.</string>
|
||||
<string name="assistant_account_validated">Your account has been validated.</string>
|
||||
<string name="assistant_error_bad_credentials">Incorrect username or password</string>
|
||||
<string name="assistant_codec_down_question">Do you agree to download OpenH264 Video Codec provided by Cisco Systems, Inc.?</string>
|
||||
|
@ -97,7 +99,7 @@
|
|||
<string name="wizard_failed">An error occurred, try again later.</string>
|
||||
<string name="wizard_server_unavailable">Server unreachable, verify your network connection.</string>
|
||||
<string name="wizard_username_unavailable">This username is already in use.</string>
|
||||
<string name="assistant_phone_number_unavailable">This phone number is already in use.</string>
|
||||
<string name="assistant_phone_number_unavailable">This phone number is already in used.\r\nPlease type a different number or delete your existing account if you want to reuse your number.</string>
|
||||
<string name="wizard_username_incorrect">Your username is invalid.</string>
|
||||
<string name="assistant_phone_number_incorrect">Your phone number is invalid.</string>
|
||||
<string name="wizard_email_incorrect">Your email is invalid.</string>
|
||||
|
@ -114,7 +116,8 @@
|
|||
<string name="login_with_username">Use your username and password instead of your phone number</string>
|
||||
<string name="phone_number_info_title">What will my phone number be used for?</string>
|
||||
<string name="phone_number_info_content">\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</string>
|
||||
<string name="phone_number_link_info_content">\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</string>
|
||||
<string name="phone_number_link_info_content">\nYour friends will find you more easily if you link your account to your phone number\n\nYou will see in your address book who is using Linphone and your friends will know that they can reach you on Linphone as well.\n</string>
|
||||
<string name="phone_number_link_info_content_already_account">You can only use your phone number with one linphone account.\n\nIf you had already linked your number to an other account but you prefer to use this one simply link it now and your number will automatically be moved to this account.</string>
|
||||
|
||||
<!-- Status -->
|
||||
<string name="invalid_email">Invalid email</string>
|
||||
|
@ -132,6 +135,7 @@
|
|||
<string name="password_too_long">Password too long</string>
|
||||
<string name="request_failed">Failed to query the server. Please try again later</string>
|
||||
<string name="transport_unsupported">Unsupported transport</string>
|
||||
<string name="country_code_invalid">Country code invalid</string>
|
||||
|
||||
<!-- In-app -->
|
||||
<string name="inapp">In-app</string>
|
||||
|
@ -208,6 +212,8 @@
|
|||
<string name="call_stats_video_resolution_received">Received video resolution:</string>
|
||||
<string name="call_stats_sender_loss_rate">Sender loss rate</string>
|
||||
<string name="call_stats_receiver_loss_rate">Receiver loss rate</string>
|
||||
<string name="call_stats_encoder_name">Encoder:</string>
|
||||
<string name="call_stats_decoder_name">Decoder:</string>
|
||||
<string name="call">Call</string>
|
||||
|
||||
<!-- About -->
|
||||
|
@ -261,7 +267,7 @@
|
|||
<string name="pref_avpf_rr_interval"> AVPF regular RTCP interval in seconds (between 1 and 5)</string>
|
||||
<string name="pref_escape_plus">Replace + by 00</string>
|
||||
<string name="pref_friendlist_subscribe">Friendlist subscribe</string>
|
||||
<string name="pref_link_account">Link account</string>
|
||||
<string name="pref_link_account">Link your account</string>
|
||||
<string name="pref_auth_userid">Auth userid</string>
|
||||
<string name="pref_help_auth_userid">Enter authentication userid (optional)</string>
|
||||
<string name="pref_display_name">Display name</string>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,10 +131,12 @@ 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
|
||||
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, RegistrationState state, String smessage) {
|
||||
|
@ -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<Country> allCountries;
|
||||
private List<Country> filteredCountries;
|
||||
private Context context;
|
||||
|
||||
public CountryListAdapter(int jsonId, Context ctx) {
|
||||
context = ctx;
|
||||
allCountries = new ArrayList<Country>();
|
||||
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<Country> filteredCountries = new ArrayList<Country>();
|
||||
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<Country>) 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Country> allCountries;
|
||||
private List<Country> filteredCountries;
|
||||
private Context context;
|
||||
|
||||
public CountryListAdapter(int jsonId, Context ctx) {
|
||||
context = ctx;
|
||||
allCountries = new ArrayList<Country>();
|
||||
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<Country> filteredCountries = new ArrayList<Country>();
|
||||
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<Country>) results.values;
|
||||
CountryListAdapter.this.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -131,22 +132,21 @@ 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 ) {
|
||||
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)) {
|
||||
useUsername.setVisibility(View.VISIBLE);
|
||||
useUsername.setEnabled(false);
|
||||
useUsername.setOnCheckedChangeListener(this);
|
||||
}
|
||||
addPhoneNumberHandler(phoneNumberEdit, null);
|
||||
addPhoneNumberHandler(dialCode, null);
|
||||
}
|
||||
|
||||
//Password & email address
|
||||
|
@ -154,10 +154,6 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
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,6 +167,10 @@ 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
|
||||
|
@ -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,31 +223,6 @@ 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) {
|
||||
|
@ -256,9 +231,11 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
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) {
|
||||
|
@ -266,7 +243,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
passwordLayout.setVisibility(View.VISIBLE);
|
||||
passwordConfirmLayout.setVisibility(View.VISIBLE);
|
||||
usernameLayout.setVisibility(View.VISIBLE);
|
||||
useUsername.setEnabled(false);
|
||||
|
||||
} else {
|
||||
if (!useUsername.isChecked()) {
|
||||
usernameLayout.setVisibility(View.GONE);
|
||||
|
@ -275,7 +252,6 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
passwordLayout.setVisibility(View.GONE);
|
||||
passwordConfirmLayout.setVisibility(View.GONE);
|
||||
usernameLayout.setVisibility(View.GONE);
|
||||
useUsername.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +273,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
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())
|
||||
|
@ -319,18 +295,6 @@ 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();
|
||||
|
@ -342,22 +306,107 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
|
||||
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("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPhoneNumberHandler(final EditText field, final ImageView icon) {
|
||||
field.addTextChangedListener(new TextWatcher() {
|
||||
|
@ -366,23 +415,7 @@ 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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,12 +440,13 @@ 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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,94 +522,8 @@ 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
|
||||
|
@ -588,10 +532,10 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -602,14 +546,14 @@ 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);
|
||||
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);
|
||||
AssistantActivity.instance().displayAssistantCodeConfirm(getUsername(), phoneNumberEdit.getText().toString(), LinphoneUtils.getCountryCode(dialCode), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ) {
|
||||
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) {
|
||||
switch(id) {
|
||||
case R.id.assistant_apply: {
|
||||
if (recoverAccount) {
|
||||
recoverAccount();
|
||||
} else {
|
||||
linphoneLogIn();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (id == R.id.select_country) {
|
||||
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() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 71345f5ae6b4ac042b4ddf6fad3043b5ee368cb3
|
||||
Subproject commit ed8748422bdb0c8c3790ce6fea0b6e894d8adea4
|
|
@ -1 +1 @@
|
|||
Subproject commit c2002e29a58cbb94ebed369add966929d1481076
|
||||
Subproject commit 6caf23eb5ce9c7c14e107a95cd4d3255ecc3a8c0
|
Loading…
Reference in a new issue