Add recover account
Add documentation for linphone customization
This commit is contained in:
parent
1c1f97e156
commit
b518041fb5
13 changed files with 391 additions and 114 deletions
72
doc/CustomsParameters.txt
Normal file
72
doc/CustomsParameters.txt
Normal file
|
@ -0,0 +1,72 @@
|
|||
**********************************
|
||||
* LINPHONE customs parameters *
|
||||
**********************************
|
||||
|
||||
In res/values/non_localizable_custom.xml (filled with linphone default options):
|
||||
|
||||
1. Global
|
||||
|
||||
* Set the default domain used by the application:
|
||||
<string name="default_domain">sip.linphone.org</string
|
||||
|
||||
2. Assistant
|
||||
|
||||
* Server xmlrpc url for accounts
|
||||
<string name="wizard_url">https://sip3.linphone.org:444/inapp.php</string>
|
||||
|
||||
* In CreateAccount, allow username instead of phone number for creating a new account
|
||||
<bool name="assistant_allow_username">true</bool>
|
||||
|
||||
* Hide buttons in assistant menu
|
||||
<bool name="hide_linphone_accounts_in_assistant">false</bool>
|
||||
<bool name="hide_generic_accounts_in_assistant">false</bool>
|
||||
<bool name="hide_remote_provisioning_in_assistant">false</bool>
|
||||
|
||||
|
||||
3. Inapp
|
||||
|
||||
* Enabled inapp purchase
|
||||
<bool name="enable_in_app_purchase">true</bool>
|
||||
|
||||
* Days before end of trial period that launch daily notification to remind user to buy an account
|
||||
<integer name="days_notification_shown">5</integer>
|
||||
|
||||
* Time between two inapp notifications in seconds
|
||||
<integer name="time_between_inapp_notification">86400</integer>
|
||||
|
||||
* Hide username field in purchase view (automatically get from default account)
|
||||
<bool name="hide_username_in_inapp">true</bool>
|
||||
|
||||
|
||||
In res/raw/linphonerc_factory sections:
|
||||
|
||||
[in-app-purchase]
|
||||
* Server xmlrpc url for inapp
|
||||
server_url=https://sip3.linphone.org:444/inapp.php
|
||||
|
||||
* Item ids from the google play store
|
||||
purchasable_items_ids=test_account_subscription
|
||||
|
||||
[app]
|
||||
|
||||
* Numbers of digits to enter for validation/recover account
|
||||
activation_code_length=4
|
||||
|
||||
|
||||
[assistant]
|
||||
|
||||
* Set the default domain used for account creation :
|
||||
domain=sip.linphone.org
|
||||
|
||||
* Set the default password length (min-max) :
|
||||
password_max_length=-1
|
||||
password_min_length=1
|
||||
|
||||
* Set the default username length (min-max) :
|
||||
username_length=-1
|
||||
username_max_length=64
|
||||
username_min_length=1
|
||||
username_regex=^[a-z0-9_.\-]*$
|
||||
|
||||
* Server xmlrpc url for accounts
|
||||
xmlrpc_url=https://sip3.linphone.org:444/inapp.php
|
|
@ -103,14 +103,14 @@
|
|||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Don't use phone number as username"/>
|
||||
android:text="@string/use_username_instead_or_phone_number"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/use_email"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Don't use phone number for account activation"/>
|
||||
android:text="@string/use_email_for_validation"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -34,64 +34,142 @@
|
|||
android:layout_marginTop="30dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:text="@string/username"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
<LinearLayout
|
||||
android:id="@+id/phone_number_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/assistant_username"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:inputType="text|textNoSuggestions"
|
||||
android:contentDescription="@string/content_description_username_field"
|
||||
<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:orientation="vertical"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/phone_number_label"
|
||||
android:text="@string/phone_number"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dial_code"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:inputType="phone"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/phone_number"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:contentDescription="@string/content_description_phone_number_field"
|
||||
android:inputType="phone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/phone_number_error"
|
||||
android:text="@string/error"
|
||||
style="@style/font20"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sip_uri"
|
||||
style="@style/font9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/use_username"
|
||||
android:visibility="visible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<TextView
|
||||
android:text="@string/password"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
android:paddingTop="20dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/assistant_password"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:inputType="textPassword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/forgot_password"
|
||||
android:layout_gravity="right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"/>
|
||||
android:text="@string/login_with_username"/>
|
||||
|
||||
<TextView
|
||||
android:text="@string/assistant_display_name_optional"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
android:paddingTop="15dp"
|
||||
<LinearLayout
|
||||
android:id="@+id/username_layout"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/assistant_display_name"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:inputType="textPersonName"
|
||||
android:contentDescription="@string/content_description_username_field"
|
||||
<TextView
|
||||
android:text="@string/username"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/assistant_username"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:inputType="text|textNoSuggestions"
|
||||
android:contentDescription="@string/content_description_username_field"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/password_layout"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:text="@string/password"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
android:paddingTop="20dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/assistant_password"
|
||||
android:background="@drawable/resizable_textfield"
|
||||
android:textColor="@color/colorB"
|
||||
android:inputType="textPassword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/forgot_password"
|
||||
android:layout_gravity="right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"/>
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/assistant_apply"
|
||||
|
|
|
@ -7,7 +7,6 @@ contact="Linphone Android" <sip:linphone.android@unknown-host>
|
|||
use_info=0
|
||||
use_ipv6=0
|
||||
keepalive_period=30000
|
||||
rls_uri=sip:rls@sip1.linphone.org
|
||||
use_rls_presence=1
|
||||
|
||||
[video]
|
||||
|
|
|
@ -12,6 +12,7 @@ register_only_when_network_is_up=1
|
|||
auto_net_state_mon=0
|
||||
auto_answer_replacing_calls=1
|
||||
ping_with_options=0
|
||||
rls_uri=sip:rls@sip.linphone.org
|
||||
|
||||
[rtp]
|
||||
audio_rtp_port=7076
|
||||
|
@ -37,7 +38,7 @@ max_calls=10
|
|||
activation_code_length=4
|
||||
|
||||
[in-app-purchase]
|
||||
server_url=http://sip3.linphone.org/inapp.php
|
||||
server_url=https://sip3.linphone.org:444/inapp.php
|
||||
purchasable_items_ids=test_account_subscription
|
||||
|
||||
[assistant]
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<!-- Assistant -->
|
||||
<string name="wizard_url">https://sip3.linphone.org:444/inapp.php</string><!-- Url of the xmlrpc script -->
|
||||
<bool name="assistant_allow_username">false</bool> <!-- Allow to use an username instead of the phone number for account creation -->
|
||||
<bool name="assistant_allow_username">true</bool> <!-- Allow to use an username instead of the phone number for account creation -->
|
||||
<bool name="assistant_use_linphone_login_as_first_fragment">false</bool><!-- Start assistant in loginFragment view instead of menu -->
|
||||
<bool name="replace_assistant_with_old_interface">false</bool>
|
||||
<bool name="hide_assistant">false</bool>
|
||||
|
@ -24,7 +24,6 @@
|
|||
<bool name="hide_generic_accounts_in_assistant">false</bool>
|
||||
<bool name="hide_remote_provisioning_in_assistant">false</bool>
|
||||
<bool name="display_account_assistant_at_first_start">true</bool>
|
||||
<bool name="hide_H264_downloader">false</bool><!-- Set the email field of the wizard with one of the gmail account registered on the device -->
|
||||
|
||||
<!-- Remote provisioning -->
|
||||
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
||||
|
@ -33,9 +32,9 @@
|
|||
<bool name="allow_cancel_remote_provisioning_login_activity">true</bool>
|
||||
|
||||
<!-- Inapp -->
|
||||
<bool name="enabled_in_app_purchase">true</bool>
|
||||
<bool name="in_app_purchase_in_settings">true</bool>
|
||||
<integer name="number_days_reminder">28</integer><!-- Remind to biy account -->
|
||||
<bool name="enable_in_app_purchase">true</bool>
|
||||
<integer name="days_notification_shown">5</integer><!-- Notification shown before end of trial version in days -->
|
||||
<integer name="time_between_inapp_notification">86400</integer><!-- Time between two inapp notifications in seconds -->
|
||||
<bool name="hide_username_in_inapp">true</bool>
|
||||
|
||||
<!-- Push notification settings -->
|
||||
|
|
|
@ -101,6 +101,9 @@
|
|||
<string name="assistant_choose_country">Choose a country</string>
|
||||
<string name="select_your_country">Select your Country</string>
|
||||
<string name="country_code">(%s)</string>
|
||||
<string name="use_username_instead_or_phone_number">Don\'t use phone number as username</string>
|
||||
<string name="use_email_for_validation">Use email address for account validation</string>
|
||||
<string name="login_with_username">Log in with username</string>
|
||||
|
||||
<!-- Status -->
|
||||
<string name="invalid_email">Invalid email</string>
|
||||
|
@ -122,7 +125,8 @@
|
|||
<!-- In-app -->
|
||||
<string name="inapp">In-app</string>
|
||||
<string name="inapp_notification_title">In-app purchase</string>
|
||||
<string name="inapp_notification_content">The trail period expires on %s</string>
|
||||
<string name="inapp_notification_trial_expire">The trail period expires on %s</string>
|
||||
<string name="inapp_notification_account_expire">The subscription period expires on %s</string>
|
||||
|
||||
<!-- Dailer -->
|
||||
<string name="address_bar_hint">Enter a number or an address</string>
|
||||
|
|
|
@ -125,6 +125,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
private Fragment.SavedState dialerSavedState;
|
||||
private boolean newProxyConfig;
|
||||
private boolean emptyFragment = false;
|
||||
private boolean isTrialAccount = false;
|
||||
private OrientationEventListener mOrientationHelper;
|
||||
private LinphoneCoreListenerBase mListener;
|
||||
private LinearLayout mTabBar;
|
||||
|
@ -201,7 +202,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
initButtons();
|
||||
initSideMenu();
|
||||
|
||||
if(getResources().getBoolean(R.bool.enabled_in_app_purchase)){
|
||||
if(getResources().getBoolean(R.bool.enable_in_app_purchase)){
|
||||
isTrialAccount();
|
||||
}
|
||||
|
||||
|
@ -628,7 +629,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
|
||||
public void displayInapp() {
|
||||
checkAndRequestInappPermission();
|
||||
startActivity(new Intent(LinphoneActivity.this, InAppPurchaseActivity.class));
|
||||
}
|
||||
|
||||
|
@ -1470,8 +1470,8 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
public void initSideMenu() {
|
||||
|
||||
sideMenu = (DrawerLayout) findViewById(R.id.side_menu);
|
||||
if(getResources().getBoolean(R.bool.in_app_purchase_in_settings)){
|
||||
sideMenuItems = new String[]{getResources().getString(R.string.menu_assistant),getResources().getString(R.string.menu_settings),getResources().getString(R.string.menu_about), getResources().getString(R.string.inapp)};
|
||||
if(getResources().getBoolean(R.bool.enable_in_app_purchase)){
|
||||
sideMenuItems = new String[]{getResources().getString(R.string.menu_assistant),getResources().getString(R.string.menu_settings),getResources().getString(R.string.inapp), getResources().getString(R.string.menu_about)};
|
||||
} else {
|
||||
sideMenuItems = new String[]{getResources().getString(R.string.menu_assistant),getResources().getString(R.string.menu_settings),getResources().getString(R.string.menu_about)};
|
||||
}
|
||||
|
@ -1492,7 +1492,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
if (sideMenuItemList.getAdapter().getItem(i).toString().equals(getString(R.string.menu_assistant))) {
|
||||
LinphoneActivity.instance().displayAssistant();
|
||||
}
|
||||
if(getResources().getBoolean(R.bool.in_app_purchase_in_settings)){
|
||||
if(getResources().getBoolean(R.bool.enable_in_app_purchase)){
|
||||
if (sideMenuItemList.getAdapter().getItem(i).toString().equals(getString(R.string.inapp))) {
|
||||
LinphoneActivity.instance().displayInapp();
|
||||
}
|
||||
|
@ -1678,10 +1678,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
helper.isTrialAccountAsync(new XmlRpcListenerBase() {
|
||||
@Override
|
||||
public void onTrialAccountFetched(boolean isTrial) {
|
||||
if (isTrial) {
|
||||
getExpirationAccount();
|
||||
}
|
||||
isTrialAccount = isTrial;
|
||||
getExpirationAccount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error){}
|
||||
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
}
|
||||
}
|
||||
|
@ -1699,12 +1701,14 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
calresult.setTimeInMillis(timestamp);
|
||||
|
||||
int diff = getDiffDays(calresult, Calendar.getInstance());
|
||||
if (diff != -1 && diff <= getResources().getInteger(R.integer.number_days_reminder)) {
|
||||
if (diff != -1 && diff <= getResources().getInteger(R.integer.days_notification_shown)) {
|
||||
displayInappNotification(timestampToHumanDate(calresult));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error){}
|
||||
}, LinphonePreferences.instance().getAccountUsername(LinphonePreferences.instance().getDefaultAccountIndex()), LinphonePreferences.instance().getAccountHa1(LinphonePreferences.instance().getDefaultAccountIndex()));
|
||||
}
|
||||
}
|
||||
|
@ -1715,7 +1719,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
} else {
|
||||
LinphonePreferences.instance().setLastDateNotificationShown(timestampToHumanDate(Calendar.getInstance()));
|
||||
}
|
||||
LinphoneService.instance().displayInappNotification(String.format(getString(R.string.inapp_notification_content), date));
|
||||
if(isTrialAccount){
|
||||
LinphoneService.instance().displayInappNotification(String.format(getString(R.string.inapp_notification_trial_expire), date));
|
||||
} else {
|
||||
LinphoneService.instance().displayInappNotification(String.format(getString(R.string.inapp_notification_account_expire), date));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String timestampToHumanDate(Calendar cal) {
|
||||
|
|
|
@ -143,14 +143,6 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
findPreference(getString(R.string.pref_in_app_store_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(LinphoneService.instance(), InAppPurchaseActivity.class);
|
||||
startActivityForResult(intent, STORE_INTENT);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Sets listener for each preference to update the matching value in linphonecore
|
||||
|
@ -174,10 +166,6 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
hidePreference(R.string.pref_add_account_key);
|
||||
}
|
||||
|
||||
if(!getResources().getBoolean(R.bool.in_app_purchase_in_settings)){
|
||||
hidePreference(R.string.pref_in_app_store_key);
|
||||
}
|
||||
|
||||
if (getResources().getBoolean(R.bool.disable_chat)) {
|
||||
findPreference(getString(R.string.pref_image_sharing_server_key)).setLayoutResource(R.layout.hidden);
|
||||
}
|
||||
|
|
|
@ -294,22 +294,22 @@ private static AssistantActivity instance;
|
|||
}
|
||||
}
|
||||
|
||||
private void logIn(String username, String password, String displayName, String domain, TransportType transport, boolean sendEcCalibrationResult) {
|
||||
saveCreatedAccount(username, password, displayName, null, domain, transport);
|
||||
private void logIn(String username, String password, String ha1, String displayName, String domain, TransportType transport, boolean sendEcCalibrationResult) {
|
||||
saveCreatedAccount(username, password, displayName, ha1, domain, transport);
|
||||
}
|
||||
|
||||
public void checkAccount(String username, String password, String displayName, String domain) {
|
||||
saveCreatedAccount(username, password, displayName, null, domain, null);
|
||||
}
|
||||
|
||||
public void linphoneLogIn(String username, String password, String displayName, boolean validate) {
|
||||
public void linphoneLogIn(String username, String password, String ha1, String displayName, boolean validate) {
|
||||
if (validate) {
|
||||
checkAccount(username, password, displayName, getString(R.string.default_domain));
|
||||
} else {
|
||||
if(accountCreated) {
|
||||
retryLogin(username, password, displayName, getString(R.string.default_domain), null);
|
||||
} else {
|
||||
logIn(username, password, displayName, getString(R.string.default_domain), null, true);
|
||||
logIn(username, password, ha1, displayName, getString(R.string.default_domain), null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ private static AssistantActivity instance;
|
|||
if (accountCreated) {
|
||||
retryLogin(username, password, displayName, domain, transport);
|
||||
} else {
|
||||
logIn(username, password, displayName, domain, transport, false);
|
||||
logIn(username, password, null, displayName, domain, transport, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,12 +525,13 @@ private static AssistantActivity instance;
|
|||
back.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void displayAssistantCodeConfirm(String username, String phone) {
|
||||
public void displayAssistantCodeConfirm(String username, String phone, boolean recoverAccount) {
|
||||
CreateAccountCodeActivationFragment fragment = new CreateAccountCodeActivationFragment();
|
||||
newAccount = true;
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("Username", username);
|
||||
extras.putString("Phone", phone);
|
||||
extras.putBoolean("RecoverAccount", recoverAccount);
|
||||
fragment.setArguments(extras);
|
||||
changeFragment(fragment);
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.linphone.mediastream.Log;
|
|||
public class CreateAccountCodeActivationFragment extends Fragment {
|
||||
private String username, phone, ha1;
|
||||
private EditText code;
|
||||
private boolean recoverAccount;
|
||||
private int code_length;
|
||||
private Handler mHandler = new Handler();
|
||||
private Button checkAccount;
|
||||
|
@ -57,6 +58,7 @@ public class CreateAccountCodeActivationFragment extends Fragment {
|
|||
|
||||
username = getArguments().getString("Username");
|
||||
phone = getArguments().getString("Phone");
|
||||
recoverAccount = getArguments().getBoolean("RecoverAccount");
|
||||
code_length = LinphonePreferences.instance().getCodeLength();
|
||||
|
||||
if(username == null || username.length() == 0){
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.linphone.core.LinphoneXmlRpcRequestImpl;
|
|||
import org.linphone.core.LinphoneXmlRpcSession;
|
||||
import org.linphone.core.LinphoneXmlRpcSessionImpl;
|
||||
import org.linphone.xmlrpc.XmlRpcHelper;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.Manifest;
|
||||
import android.accounts.Account;
|
||||
|
@ -104,21 +105,11 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
|
||||
|
||||
accountCreator = new LinphoneAccountCreatorImpl(LinphoneManager.getLc(), getResources().getString(R.string.wizard_url));
|
||||
accountCreator.setDomain(getResources().getString(R.string.default_domain));
|
||||
accountCreator.setListener(this);
|
||||
|
||||
phoneNumberError = (TextView) view.findViewById(R.id.phone_number_error);
|
||||
phoneNumberEdit = (EditText) view.findViewById(R.id.phone_number);
|
||||
phoneNumberEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
});
|
||||
phoneNumberLayout = (LinearLayout) view.findViewById(R.id.phone_number_layout);
|
||||
addPhoneNumberHandler(phoneNumberEdit, null);
|
||||
|
||||
|
@ -225,12 +216,10 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
if(isChecked) {
|
||||
usernameLayout.setVisibility(View.VISIBLE);
|
||||
if(usernameEdit.getText().length() > 0){
|
||||
sipUri.setText("Sip uri is sip:" + usernameEdit.getText().toString() + "@sip.linphone.org");
|
||||
}
|
||||
} else {
|
||||
usernameLayout.setVisibility(View.GONE);
|
||||
if(phoneNumberEdit.getText().length() > 0){
|
||||
sipUri.setText("Sip uri is sip:" + phoneNumberEdit.getText().toString() + "@sip.linphone.org");
|
||||
}
|
||||
}
|
||||
} else if(buttonView.getId() == R.id.use_email){
|
||||
|
@ -340,7 +329,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
}
|
||||
|
||||
private void createAccountWithPhoneNumber(final String username, final String password, final String phone, boolean suscribe) {
|
||||
AssistantActivity.instance().displayAssistantCodeConfirm(username, phone);
|
||||
|
||||
final Runnable runNotOk = new Runnable() {
|
||||
public void run() {
|
||||
//TODO errorMessage.setText(R.string.wizard_failed);
|
||||
|
@ -348,7 +337,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
};
|
||||
final Runnable runOk = new Runnable() {
|
||||
public void run() {
|
||||
AssistantActivity.instance().displayAssistantCodeConfirm(username, phone);
|
||||
AssistantActivity.instance().displayAssistantCodeConfirm(username, phone, false);
|
||||
}
|
||||
};
|
||||
final Runnable runNotReachable = new Runnable() {
|
||||
|
@ -611,6 +600,8 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
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)
|
||||
|
@ -626,18 +617,19 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On
|
|||
@Override
|
||||
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, final Status status) {
|
||||
if(getResources().getBoolean(R.bool.assistant_allow_username) && useUsername.isChecked()){
|
||||
if (status.equals(Status.AccountNotExist)) {
|
||||
usernameOk = true;
|
||||
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
||||
usernameOk = false;
|
||||
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||
} else {
|
||||
usernameOk = false;
|
||||
usernameOk = true;
|
||||
displayError(usernameOk, usernameError, usernameEdit, errorForStatus(status));
|
||||
}
|
||||
createAccount.setEnabled(usernameOk && phoneNumberOk);
|
||||
} else {
|
||||
if (status.equals(Status.AccountNotExist)) {
|
||||
phoneNumberOk = true;
|
||||
if (status.equals(Status.AccountExist) || status.equals(Status.AccountExistWithAlias)) {
|
||||
phoneNumberOk = false;
|
||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||
phoneNumberOk = true;
|
||||
} else {
|
||||
phoneNumberOk = true;
|
||||
displayError(phoneNumberOk, phoneNumberError, phoneNumberEdit, errorForStatus(status));
|
||||
|
|
|
@ -17,8 +17,13 @@ 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 org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.LinphoneAccountCreator;
|
||||
import org.linphone.core.LinphoneAccountCreatorImpl;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
|
@ -30,46 +35,122 @@ import android.view.View;
|
|||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class LinphoneLoginFragment extends Fragment implements OnClickListener, TextWatcher {
|
||||
public class LinphoneLoginFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, OnClickListener, TextWatcher, LinphoneAccountCreator.LinphoneAccountCreatorListener {
|
||||
private EditText login, password, displayName;
|
||||
private Button apply;
|
||||
private CheckBox useUsername, usePassword;
|
||||
private LinearLayout phoneNumberLayout, usernameLayout, passwordLayout;
|
||||
private TextView forgotPassword;
|
||||
|
||||
private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit, dialCode;
|
||||
private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError, emailError, sipUri;
|
||||
private CountryListFragment.Country country;
|
||||
private Boolean recoverAccount = true;
|
||||
|
||||
private LinphoneAccountCreator accountCreator;
|
||||
|
||||
|
||||
@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(), getResources().getString(R.string.wizard_url));
|
||||
accountCreator.setListener(this);
|
||||
|
||||
String url = "http://linphone.org/free-sip-service.html&action=recover";
|
||||
|
||||
login = (EditText) view.findViewById(R.id.assistant_username);
|
||||
login.addTextChangedListener(this);
|
||||
|
||||
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);
|
||||
|
||||
if(getResources().getBoolean(R.bool.assistant_allow_username)) {
|
||||
useUsername = (CheckBox) view.findViewById(R.id.use_username);
|
||||
useUsername.setVisibility(View.VISIBLE);
|
||||
useUsername.setOnCheckedChangeListener(this);
|
||||
|
||||
usernameLayout = (LinearLayout) view.findViewById(R.id.username_layout);
|
||||
}
|
||||
|
||||
password = (EditText) view.findViewById(R.id.assistant_password);
|
||||
password.addTextChangedListener(this);
|
||||
forgotPassword = (TextView) view.findViewById(R.id.forgot_password);
|
||||
forgotPassword.setText(Compatibility.fromHtml("<a href=\"" + url + "\"'>"+ getString(R.string.forgot_password) + "</a>"));
|
||||
forgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
displayName = (EditText) view.findViewById(R.id.assistant_display_name);
|
||||
|
||||
apply = (Button) view.findViewById(R.id.assistant_apply);
|
||||
apply.setEnabled(false);
|
||||
apply.setOnClickListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
private String getPhoneNumber(){
|
||||
LinphoneProxyConfig proxyConfig = LinphoneManager.getLc().createProxyConfig();
|
||||
String countryCode = dialCode.getText().toString();
|
||||
if(countryCode != null && countryCode.startsWith("+")) {
|
||||
countryCode = countryCode.substring(1);
|
||||
}
|
||||
proxyConfig.setDialPrefix(countryCode);
|
||||
return proxyConfig.normalizePhoneNumber(phoneNumberEdit.getText().toString());
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
||||
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), displayName.getText().toString(), getResources().getBoolean(R.bool.assistant_account_validation_mandatory));
|
||||
AssistantActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString(), null, displayName.getText().toString(), getResources().getBoolean(R.bool.assistant_account_validation_mandatory));
|
||||
}
|
||||
|
||||
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);
|
||||
Log.w("Set PhoneNmuber " + status.toString());
|
||||
if (status.equals(LinphoneAccountCreator.Status.Ok)) {
|
||||
status = accountCreator.isAccountUsed();
|
||||
Log.w("Is account activated " + status.toString());
|
||||
if (status.equals(LinphoneAccountCreator.Status.Ok)) {
|
||||
|
||||
}
|
||||
} 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) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,10 +158,18 @@ public class LinphoneLoginFragment extends Fragment implements OnClickListener,
|
|||
int id = v.getId();
|
||||
|
||||
if (id == R.id.assistant_apply) {
|
||||
linphoneLogIn();
|
||||
if(recoverAccount){
|
||||
recoverAccount();
|
||||
} else {
|
||||
linphoneLogIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void recoverAccount() {
|
||||
accountCreator.recoverPhoneAccount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
|
@ -91,4 +180,47 @@ public class LinphoneLoginFragment extends Fragment implements OnClickListener,
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
recoverAccount = true;
|
||||
apply.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
Log.w("IS ACTIVATED " + status.toString());
|
||||
apply.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, LinphoneAccountCreator.Status status) {
|
||||
AssistantActivity.instance().displayAssistantCodeConfirm(getPhoneNumber(), getPhoneNumber(), true);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue