Add errors in assistant

This commit is contained in:
Margaux Clerc 2015-10-26 19:07:13 +01:00
parent 57f8e5dc68
commit b9f6cbd3b7
11 changed files with 337 additions and 150 deletions

View file

@ -22,14 +22,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/assistant_error"
android:textColor="@color/colorI"
android:paddingTop="10dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -38,86 +30,145 @@
android:gravity="center"
android:orientation="vertical">
<TextView
android:text="@string/username"
style="@style/font13"
android:textAllCaps="true"
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content">
<EditText
android:id="@+id/assistant_username"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:textCursorDrawable="@null"
android:inputType="textEmailAddress"
<TextView
android:id="@+id/username_label"
android:text="@string/username"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/username"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="text|textEmailAddress"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/username_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
android:layout_height="wrap_content">
<TextView
android:text="@string/password"
style="@style/font13"
android:textAllCaps="true"
android:paddingTop="10dp"
<TextView
android:id="@+id/password_label"
style="@style/font13"
android:text="@string/password"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/password"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/password_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content">
<TextView
android:id="@+id/confirm_password_label"
android:text="@string/confirm_password"
style="@style/font13"
android:textAllCaps="true"
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:textCursorDrawable="@null"
android:inputType="textPassword"
<EditText
android:id="@+id/confirm_password"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/confirm_password_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
android:layout_height="wrap_content">
<TextView
android:text="@string/assistant_password_confirm"
style="@style/font13"
android:textAllCaps="true"
android:paddingTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/email_label"
android:text="@string/email"
style="@style/font13"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/email"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="text|textEmailAddress"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<EditText
android:id="@+id/assistant_password_confirm"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:textCursorDrawable="@null"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
<TextView
android:id="@+id/email_error"
android:text="@string/error"
style="@style/font20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"/>
<TextView
android:text="@string/email"
style="@style/font13"
android:textAllCaps="true"
android:paddingTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/assistant_email"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:textCursorDrawable="@null"
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"/>
</LinearLayout>
<Button
android:id="@+id/assistant_create"
@ -127,9 +178,9 @@
android:contentDescription="@string/content_description_validate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_margin="5dp"
android:layout_centerVertical="true"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<TextView
android:id="@+id/customText"
style="@style/font14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"/>
<EditText
android:id="@+id/password"
android:background="@drawable/resizable_textfield"
android:textColor="@color/colorB"
android:inputType="textPassword"
android:hint="@string/password"
android:textCursorDrawable="@null"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="20dp"
android:singleLine="true"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/cancel"
android:text="@string/cancel"
android:background="@drawable/resizable_cancel_button"
style="@style/font8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
<Button
android:id="@+id/retry"
android:text="@string/retry"
android:background="@drawable/resizable_confirm_delete_button"
style="@style/font15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,7 +1,7 @@
package org.linphone.assistant;
/*
SetupActivity.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
AssistantActivity.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -21,28 +21,39 @@ import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.LinphonePreferences.AccountBuilder;
import org.linphone.LinphoneUtils;
import org.linphone.R;
import org.linphone.StatusFragment;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAddress.TransportType;
import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.mediastream.Log;
import android.app.Activity;
import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
/**
* @author Sylvain Berfini
@ -70,7 +81,7 @@ public class AssistantActivity extends Activity implements OnClickListener {
initUI();
firstFragment = getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment) ?
AssistantFragmentsEnum.LINPHONE_LOGIN : AssistantFragmentsEnum.MENU;
AssistantFragmentsEnum.LINPHONE_LOGIN : AssistantFragmentsEnum.WELCOME;
if (findViewById(R.id.fragmentContainer) != null) {
if (savedInstanceState == null) {
display(firstFragment);
@ -87,10 +98,12 @@ public class AssistantActivity extends Activity implements OnClickListener {
if(address != null && address.asString().equals(cfg.getIdentity()) ) {
if (state == RegistrationState.RegistrationOk) {
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
launchEchoCancellerCalibration(true);
//launchEchoCancellerCalibration(true);
success();
}
} else if (state == RegistrationState.RegistrationFailed) {
Toast.makeText(AssistantActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
//showDialog(cfg);
//Toast.makeText(AssistantActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
}
}
}
@ -174,15 +187,15 @@ public class AssistantActivity extends Activity implements OnClickListener {
setResult(Activity.RESULT_CANCELED);
finish();
}
} else if (currentFragment == AssistantFragmentsEnum.GENERIC_LOGIN
} else if (currentFragment == AssistantFragmentsEnum.LOGIN
|| currentFragment == AssistantFragmentsEnum.LINPHONE_LOGIN
|| currentFragment == AssistantFragmentsEnum.CREATE_ACCOUNT
|| currentFragment == AssistantFragmentsEnum.REMOTE_PROVISIONING) {
WelcomeFragment fragment = new WelcomeFragment();
changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.MENU;
currentFragment = AssistantFragmentsEnum.WELCOME;
back.setVisibility(View.GONE);
} else if (currentFragment == AssistantFragmentsEnum.MENU) {
} else if (currentFragment == AssistantFragmentsEnum.WELCOME) {
finish();
}
}
@ -198,7 +211,7 @@ public class AssistantActivity extends Activity implements OnClickListener {
back.setVisibility(View.VISIBLE);
cancel.setEnabled(false);
} else {
success();
}
}
@ -211,7 +224,7 @@ public class AssistantActivity extends Activity implements OnClickListener {
saveCreatedAccount(username, password, displayName, domain);
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
launchEchoCancellerCalibration(sendEcCalibrationResult);
//launchEchoCancellerCalibration(sendEcCalibrationResult);
}
}
@ -233,12 +246,12 @@ public class AssistantActivity extends Activity implements OnClickListener {
private void display(AssistantFragmentsEnum fragment) {
switch (fragment) {
case MENU:
displayMenu();
break;
case LINPHONE_LOGIN:
displayLoginLinphone();
break;
case WELCOME:
displayMenu();
break;
case LINPHONE_LOGIN:
displayLoginLinphone();
break;
default:
throw new IllegalStateException("Can't handle " + fragment);
}
@ -247,14 +260,14 @@ public class AssistantActivity extends Activity implements OnClickListener {
public void displayMenu() {
fragment = new WelcomeFragment();
changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.MENU;
currentFragment = AssistantFragmentsEnum.WELCOME;
back.setVisibility(View.GONE);
}
public void displayLoginGeneric() {
fragment = new LoginFragment();
changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.GENERIC_LOGIN;
currentFragment = AssistantFragmentsEnum.LOGIN;
back.setVisibility(View.VISIBLE);
}
@ -265,8 +278,6 @@ public class AssistantActivity extends Activity implements OnClickListener {
//LinphoneManager.getInstance().resetLinphoneCore(this);
//Log.w(LinphoneManager.getLc().getConfig().getString("proxy_default_values","reg_proxy","loool"));
changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.LINPHONE_LOGIN;
back.setVisibility(View.VISIBLE);
@ -285,6 +296,15 @@ public class AssistantActivity extends Activity implements OnClickListener {
currentFragment = AssistantFragmentsEnum.REMOTE_PROVISIONING;
back.setVisibility(View.VISIBLE);
}
public void retryLogin(LinphoneProxyConfig proxy, String password){
LinphoneAuthInfo info = LinphoneManager.getLc().findAuthInfo(LinphoneUtils.getUsernameFromAddress(proxy.getIdentity()),proxy.getRealm(),proxy.getDomain());
if(info != null) {
info.setPassword(password);
LinphoneManager.getLc().addAuthInfo(info);
}
LinphoneManager.getLc().refreshRegisters();
}
public void saveCreatedAccount(String username, String password, String displayName, String domain) {
if (accountCreated)
@ -317,6 +337,7 @@ public class AssistantActivity extends Activity implements OnClickListener {
AccountBuilder builder = new AccountBuilder(LinphoneManager.getLc())
.setUsername(username)
.setDomain(domain)
.setDisplayName(displayName)
.setPassword(password);
if (isMainAccountLinphoneDotOrg && useLinphoneDotOrgCustomPorts) {
@ -342,7 +363,7 @@ public class AssistantActivity extends Activity implements OnClickListener {
mPrefs.setStunServer(getString(R.string.default_stun));
mPrefs.setIceEnabled(true);
} else {
String forcedProxy = getResources().getString(R.string.setup_forced_proxy);
String forcedProxy = "";
if (!TextUtils.isEmpty(forcedProxy)) {
builder.setProxy(forcedProxy)
.setOutboundProxyEnabled(true)
@ -375,20 +396,60 @@ public class AssistantActivity extends Activity implements OnClickListener {
fragment.setArguments(extras);
changeFragment(fragment);
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_CONFIRM;
currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_ACTIVATION;
back.setVisibility(View.GONE);
}
public void isAccountVerified(String username) {
Toast.makeText(this, getString(R.string.setup_account_validated), Toast.LENGTH_LONG).show();
LinphoneManager.getLcIfManagerNotDestroyedOrNull().refreshRegisters();
launchEchoCancellerCalibration(true);
//launchEchoCancellerCalibration(true);
}
public void isEchoCalibrationFinished() {
mPrefs.setAccountEnabled(mPrefs.getAccountCount() - 1, true);
success();
}
public Dialog displayWrongPasswordDialog(){
Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Drawable d = new ColorDrawable(getResources().getColor(R.color.colorC));
d.setAlpha(200);
dialog.setContentView(R.layout.input_dialog);
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(d);
TextView customText = (TextView) dialog.findViewById(R.id.customText);
customText.setText(getString(R.string.error_bad_credentials));
return dialog;
}
public void showDialog(final LinphoneProxyConfig proxy){
final Dialog dialog = displayWrongPasswordDialog();
Button retry = (Button) dialog.findViewById(R.id.retry);
Button cancel = (Button) dialog.findViewById(R.id.cancel);
retry.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
String newPassword = ((EditText) dialog.findViewById(R.id.password)).getText().toString();
retryLogin(proxy, newPassword);
dialog.dismiss();
}
});
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
success();
dialog.dismiss();
}
});
dialog.show();
}
public void success() {
mPrefs.firstLaunchSuccessful();

View file

@ -1,7 +1,7 @@
package org.linphone.assistant;
/*
SetupFragments.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
AssistantFragmentsEnum.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -21,11 +21,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* @author Sylvain Berfini
*/
public enum AssistantFragmentsEnum {
MENU,
WELCOME,
CREATE_ACCOUNT,
CREATE_ACCOUNT_CONFIRM,
CREATE_ACCOUNT_ACTIVATION,
LINPHONE_LOGIN,
GENERIC_LOGIN,
LOGIN,
REMOTE_PROVISIONING,
ECHO_CANCELLER_CALIBRATION;
}

View file

@ -1,7 +1,7 @@
package org.linphone.assistant;
/*
WizardConfirmFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
CreateAccountActivationFragment.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License

View file

@ -1,7 +1,7 @@
package org.linphone.assistant;
/*
WizardFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
CreateAccountFragment.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -56,14 +56,14 @@ import de.timroes.axmlrpc.XMLRPCServerException;
*/
public class CreateAccountFragment extends Fragment {
private Handler mHandler = new Handler();
private EditText username, password, passwordConfirm, email;
private EditText usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit;
private TextView usernameError, passwordError, passwordConfirmError, emailError;
private boolean usernameOk = false;
private boolean passwordOk = false;
private boolean emailOk = false;
private boolean confirmPasswordOk = false;
private Button createAccount;
private TextView errorMessage;
private char[] acceptedChars = new char[]{ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '_', '-' };
@ -71,7 +71,7 @@ public class CreateAccountFragment extends Fragment {
private String inputFilterCharacters;
private String getUsername() {
String username = this.username.getText().toString();
String username = usernameEdit.getText().toString();
if (getResources().getBoolean(R.bool.allow_only_phone_numbers_in_wizard)) {
LinphoneProxyConfig lpc = LinphoneManager.getLc().createProxyConfig();
username = lpc.normalizePhoneNumber(username);
@ -82,9 +82,20 @@ public class CreateAccountFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_account_creation, container, false);
username = (EditText) view.findViewById(R.id.assistant_username);
addXMLRPCUsernameHandler(username, null);
usernameError = (TextView) view.findViewById(R.id.username_error);
usernameEdit = (EditText) view.findViewById(R.id.username);
passwordError = (TextView) view.findViewById(R.id.password_error);
passwordEdit = (EditText) view.findViewById(R.id.password);
passwordConfirmError = (TextView) view.findViewById(R.id.confirm_password_error);
passwordConfirmEdit = (EditText) view.findViewById(R.id.confirm_password);
emailError = (TextView) view.findViewById(R.id.email_error);
emailEdit = (EditText) view.findViewById(R.id.email);
addXMLRPCUsernameHandler(usernameEdit, null);
inputFilterCharacters = new String(acceptedChars);
if (getResources().getBoolean(R.bool.allow_only_phone_numbers_in_wizard)) {
@ -103,19 +114,12 @@ public class CreateAccountFragment extends Fragment {
return null;
}
};
username.setFilters(new InputFilter[] { filter });
usernameEdit.setFilters(new InputFilter[] { filter });
password = (EditText) view.findViewById(R.id.assistant_password);
passwordConfirm = (EditText) view.findViewById(R.id.assistant_password_confirm);
addXMLRPCPasswordHandler(passwordEdit, null);
addXMLRPCConfirmPasswordHandler(passwordEdit, passwordConfirmEdit, null);
addXMLRPCEmailHandler(emailEdit, null);
addXMLRPCPasswordHandler(password, null);
addXMLRPCConfirmPasswordHandler(password, passwordConfirm, null);
email = (EditText) view.findViewById(R.id.assistant_email);
addXMLRPCEmailHandler(email, null);
errorMessage = (TextView) view.findViewById(R.id.assistant_error);
createAccount = (Button) view.findViewById(R.id.assistant_create);
createAccount.setEnabled(false);
createAccount.setOnClickListener(new OnClickListener() {
@ -123,7 +127,7 @@ public class CreateAccountFragment extends Fragment {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
createAccount(getUsername(), password.getText().toString(), email.getText().toString(), false);
createAccount(getUsername(), passwordEdit.getText().toString(), emailEdit.getText().toString(), false);
}
});
builder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
@ -142,7 +146,7 @@ public class CreateAccountFragment extends Fragment {
for (Account account: accounts) {
if (isEmailCorrect(account.name)) {
String possibleEmail = account.name;
email.setText(possibleEmail);
emailEdit.setText(possibleEmail);
break;
}
}
@ -150,6 +154,18 @@ public class CreateAccountFragment extends Fragment {
return view;
}
private void displayError(Boolean isOk, TextView error, EditText editText, String errorText){
if(isOk){
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 isUsernameCorrect(String username) {
if (getResources().getBoolean(R.bool.allow_only_phone_numbers_in_wizard)) {
@ -160,11 +176,11 @@ public class CreateAccountFragment extends Fragment {
}
}
private void isUsernameRegistred(String username, final ImageView icon) {
private void isUsernameRegistred(final String username, final ImageView icon) {
final Runnable runNotReachable = new Runnable() {
public void run() {
errorMessage.setText(R.string.wizard_server_unavailable);
usernameOk = false;
displayError(usernameOk, usernameError, usernameEdit, getResources().getString(R.string.wizard_server_unavailable));
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}
};
@ -175,16 +191,16 @@ public class CreateAccountFragment extends Fragment {
XMLRPCCallback listener = new XMLRPCCallback() {
Runnable runNotOk = new Runnable() {
public void run() {
errorMessage.setText(R.string.wizard_username_unavailable);
usernameOk = false;
displayError(usernameOk, usernameError, usernameEdit, getResources().getString(R.string.wizard_username_unavailable));
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}
};
Runnable runOk = new Runnable() {
public void run() {
errorMessage.setText("");
usernameOk = true;
displayError(usernameOk, usernameError, usernameEdit, "");
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}
};
@ -227,7 +243,7 @@ public class CreateAccountFragment extends Fragment {
private void createAccount(final String username, final String password, String email, boolean suscribe) {
final Runnable runNotReachable = new Runnable() {
public void run() {
errorMessage.setText(R.string.wizard_server_unavailable);
//TODO errorMessage.setText(R.string.wizard_server_unavailable);
}
};
@ -239,7 +255,7 @@ public class CreateAccountFragment extends Fragment {
XMLRPCCallback listener = new XMLRPCCallback() {
Runnable runNotOk = new Runnable() {
public void run() {
errorMessage.setText(R.string.wizard_failed);
//TODO errorMessage.setText(R.string.wizard_failed);
}
};
@ -295,7 +311,7 @@ public class CreateAccountFragment extends Fragment {
}
isUsernameRegistred(username, icon);
} else {
errorMessage.setText(R.string.wizard_username_incorrect);
displayError(usernameOk, usernameError, usernameEdit, getResources().getString(R.string.wizard_username_incorrect));
}
}
});
@ -316,10 +332,10 @@ public class CreateAccountFragment extends Fragment {
emailOk = false;
if (isEmailCorrect(field.getText().toString())) {
emailOk = true;
errorMessage.setText("");
displayError(emailOk, emailError, emailEdit, "");
}
else {
errorMessage.setText(R.string.wizard_email_incorrect);
displayError(emailOk, emailError, emailEdit, getString(R.string.wizard_email_incorrect));
}
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}
@ -341,10 +357,10 @@ public class CreateAccountFragment extends Fragment {
passwordOk = false;
if (isPasswordCorrect(field1.getText().toString())) {
passwordOk = true;
errorMessage.setText("");
displayError(passwordOk, passwordError, passwordEdit, "");
}
else {
errorMessage.setText(R.string.wizard_password_incorrect);
displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
}
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}
@ -370,14 +386,14 @@ public class CreateAccountFragment extends Fragment {
confirmPasswordOk = true;
if (!isPasswordCorrect(field1.getText().toString())) {
errorMessage.setText(R.string.wizard_password_incorrect);
displayError(passwordOk, passwordError, passwordEdit, getString(R.string.wizard_password_incorrect));
}
else {
errorMessage.setText("");
displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, "");
}
}
else {
errorMessage.setText(R.string.wizard_passwords_unmatched);
displayError(confirmPasswordOk, passwordConfirmError, passwordConfirmEdit, getString(R.string.wizard_passwords_unmatched));
}
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
}

View file

@ -2,7 +2,7 @@ package org.linphone.assistant;
/*
EchoCancellerCalibrationFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License

View file

@ -1,7 +1,7 @@
package org.linphone.assistant;
/*
LinphoneLoginFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License

View file

@ -1,7 +1,7 @@
package org.linphone.assistant;
/*
GenericLoginFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
LoginFragment.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License

View file

@ -1,7 +1,7 @@
package org.linphone.assistant;
/*
RemoteProvisioningFragment.java
Copyright (C) 2014 Belledonne Communications, Grenoble, France
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License

View file

@ -1,7 +1,7 @@
package org.linphone.assistant;
/*
MenuFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
WelcomeFragment.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License