Rework Generic Login fragment - close #64
-Add user id -Go to default login when it's the default domain
This commit is contained in:
parent
3724d143cf
commit
1ca5ea2b7a
6 changed files with 63 additions and 49 deletions
|
@ -51,6 +51,24 @@
|
|||
android:layout_height="40dp"
|
||||
android:maxLines="1"/>
|
||||
|
||||
<TextView
|
||||
android:text="@string/userid"
|
||||
style="@style/font13"
|
||||
android:textAllCaps="true"
|
||||
android:paddingTop="20dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/assistant_userid"
|
||||
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:maxLines="1"/>
|
||||
|
||||
<TextView
|
||||
android:text="@string/password"
|
||||
style="@style/font13"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
<!-- Common -->
|
||||
<string name="username">Username</string>
|
||||
<string name="userid">User-id (optional)</string>
|
||||
<string name="phone_number">Phone number</string>
|
||||
<string name="display_name">Display name</string>
|
||||
<string name="password">Password</string>
|
||||
|
|
|
@ -285,7 +285,7 @@ private static AssistantActivity instance;
|
|||
finish();
|
||||
} else if (currentFragment == AssistantFragmentsEnum.COUNTRY_CHOOSER){
|
||||
if(lastFragment.equals(AssistantFragmentsEnum.LINPHONE_LOGIN)){
|
||||
displayLoginLinphone();
|
||||
displayLoginLinphone(null, null);
|
||||
} else {
|
||||
displayCreateAccount();
|
||||
}
|
||||
|
@ -347,10 +347,6 @@ private static AssistantActivity instance;
|
|||
}
|
||||
}
|
||||
|
||||
private void logIn(String username, String password, String ha1, String prefix, String domain, TransportType transport) {
|
||||
saveCreatedAccount(username, password, ha1, prefix, domain, transport);
|
||||
}
|
||||
|
||||
public void configureLinphoneProxyConfig(LinphoneAccountCreator accountCreator) {
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
LinphoneProxyConfig proxyConfig = lc.createProxyConfig();
|
||||
|
@ -417,12 +413,8 @@ private static AssistantActivity instance;
|
|||
configureLinphoneProxyConfig(accountCreator);
|
||||
}
|
||||
|
||||
public void genericLogIn(String username, String password, String prefix, String domain, TransportType transport) {
|
||||
if (accountCreated) {
|
||||
retryLogin(username, password, prefix, domain, transport);
|
||||
} else {
|
||||
logIn(username, password, null, prefix, domain, transport);
|
||||
}
|
||||
public void genericLogIn(String username, String userid, String password, String prefix, String domain, TransportType transport) {
|
||||
saveCreatedAccount(username, userid, password, null, prefix, domain, transport);
|
||||
}
|
||||
|
||||
private void display(AssistantFragmentsEnum fragment) {
|
||||
|
@ -431,7 +423,7 @@ private static AssistantActivity instance;
|
|||
displayMenu();
|
||||
break;
|
||||
case LINPHONE_LOGIN:
|
||||
displayLoginLinphone();
|
||||
displayLoginLinphone(null, null);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Can't handle " + fragment);
|
||||
|
@ -453,11 +445,13 @@ private static AssistantActivity instance;
|
|||
back.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void displayLoginLinphone() {
|
||||
public void displayLoginLinphone(String username, String password) {
|
||||
fragment = new LinphoneLoginFragment();
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("Phone", null);
|
||||
extras.putString("Dialcode", null);
|
||||
extras.putString("Username", username);
|
||||
extras.putString("Password", password);
|
||||
fragment.setArguments(extras);
|
||||
changeFragment(fragment);
|
||||
currentFragment = AssistantFragmentsEnum.LINPHONE_LOGIN;
|
||||
|
@ -490,11 +484,6 @@ private static AssistantActivity instance;
|
|||
back.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void retryLogin(String username, String password, String prefix, String domain, TransportType transport) {
|
||||
accountCreated = false;
|
||||
saveCreatedAccount(username, password, null, prefix, domain, transport);
|
||||
}
|
||||
|
||||
private void launchDownloadCodec() {
|
||||
if (LinphoneManager.getLc().downloadOpenH264Enabled()) {
|
||||
OpenH264DownloadHelper downloadHelper = LinphoneCoreFactory.instance().createOpenH264DownloadHelper();
|
||||
|
@ -521,9 +510,7 @@ private static AssistantActivity instance;
|
|||
return phoneNumberWithCountry;
|
||||
}
|
||||
|
||||
public void saveCreatedAccount(String username, String password, String ha1, String prefix, String domain, TransportType transport) {
|
||||
if (accountCreated)
|
||||
return;
|
||||
public void saveCreatedAccount(String username, String userid, String password, String ha1, String prefix, String domain, TransportType transport) {
|
||||
|
||||
username = LinphoneUtils.getDisplayableUsernameFromAddress(username);
|
||||
domain = LinphoneUtils.getDisplayableUsernameFromAddress(domain);
|
||||
|
@ -539,6 +526,7 @@ private static AssistantActivity instance;
|
|||
.setUsername(username)
|
||||
.setDomain(domain)
|
||||
.setHa1(ha1)
|
||||
.setUserId(userid)
|
||||
.setPassword(password);
|
||||
|
||||
if (prefix != null) {
|
||||
|
@ -555,23 +543,14 @@ private static AssistantActivity instance;
|
|||
builder.setTransport(transport);
|
||||
}
|
||||
|
||||
if (getResources().getBoolean(R.bool.enable_push_id)) {
|
||||
String regId = mPrefs.getPushNotificationRegistrationID();
|
||||
String appId = getString(R.string.push_sender_id);
|
||||
if (regId != null && mPrefs.isPushNotificationEnabled()) {
|
||||
String contactInfos = "app-id=" + appId + ";pn-type=" + getString(R.string.push_type) + ";pn-tok=" + regId;
|
||||
builder.setContactParameters(contactInfos);
|
||||
}
|
||||
|
||||
try {
|
||||
builder.saveNewAccount();
|
||||
if (!newAccount) {
|
||||
displayRegistrationInProgressDialog();
|
||||
}
|
||||
accountCreated = true;
|
||||
} catch (LinphoneCoreException e) {
|
||||
Log.e(e);
|
||||
try {
|
||||
builder.saveNewAccount();
|
||||
if (!newAccount) {
|
||||
displayRegistrationInProgressDialog();
|
||||
}
|
||||
accountCreated = true;
|
||||
} catch (LinphoneCoreException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
|||
private Boolean recoverAccount;
|
||||
private LinphoneAccountCreator accountCreator;
|
||||
private int countryCode;
|
||||
private String phone, dialcode;
|
||||
private String phone, dialcode, username, pwd;
|
||||
private ImageView phoneNumberInfo;
|
||||
|
||||
@Override
|
||||
|
@ -170,6 +170,16 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
|||
passwordLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// When we come from generic login fragment
|
||||
username = getArguments().getString("Username");
|
||||
pwd = getArguments().getString("Password");
|
||||
if (username != null && pwd != null) {
|
||||
useUsername.setChecked(true);
|
||||
onCheckedChanged(useUsername, true);
|
||||
login.setText(username);
|
||||
password.setText(pwd);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
accountCreator.setLanguage(Locale.getDefault().toLanguageTag());
|
||||
}
|
||||
|
|
|
@ -36,17 +36,19 @@ import android.widget.Toast;
|
|||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class LoginFragment extends Fragment implements OnClickListener, TextWatcher {
|
||||
private EditText login, password, domain;
|
||||
private EditText login, userid, password, domain;
|
||||
private RadioGroup transports;
|
||||
private Button apply;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.assistant_login, container, false);
|
||||
|
||||
|
||||
login = (EditText) view.findViewById(R.id.assistant_username);
|
||||
login.addTextChangedListener(this);
|
||||
userid = (EditText) view.findViewById(R.id.assistant_userid);
|
||||
userid.addTextChangedListener(this);
|
||||
password = (EditText) view.findViewById(R.id.assistant_password);
|
||||
password.addTextChangedListener(this);
|
||||
domain = (EditText) view.findViewById(R.id.assistant_domain);
|
||||
|
@ -55,14 +57,14 @@ public class LoginFragment extends Fragment implements OnClickListener, TextWatc
|
|||
apply = (Button) view.findViewById(R.id.assistant_apply);
|
||||
apply.setEnabled(false);
|
||||
apply.setOnClickListener(this);
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
||||
|
||||
if (id == R.id.assistant_apply) {
|
||||
if (login.getText() == null || login.length() == 0 || password.getText() == null || password.length() == 0 || domain.getText() == null || domain.length() == 0) {
|
||||
Toast.makeText(getActivity(), getString(R.string.first_launch_no_login_password), Toast.LENGTH_LONG).show();
|
||||
|
@ -80,7 +82,11 @@ public class LoginFragment extends Fragment implements OnClickListener, TextWatc
|
|||
}
|
||||
}
|
||||
|
||||
AssistantActivity.instance().genericLogIn(login.getText().toString(), password.getText().toString(), null, domain.getText().toString(), transport);
|
||||
if (domain.getText().toString().compareTo(getString(R.string.default_domain)) == 0) {
|
||||
AssistantActivity.instance().displayLoginLinphone(login.getText().toString(), password.getText().toString());
|
||||
} else {
|
||||
AssistantActivity.instance().genericLogIn(login.getText().toString(), userid.getText().toString(), password.getText().toString(), null, domain.getText().toString(), transport);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import android.widget.Button;
|
|||
*/
|
||||
public class WelcomeFragment extends Fragment implements OnClickListener {
|
||||
private Button createAccount, logLinphoneAccount, logGenericAccount, remoteProvisioning;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -47,21 +47,21 @@ public class WelcomeFragment extends Fragment implements OnClickListener {
|
|||
} else {
|
||||
logLinphoneAccount.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
logGenericAccount = (Button) view.findViewById(R.id.login_generic);
|
||||
if (getResources().getBoolean(R.bool.hide_generic_accounts_in_assistant)) {
|
||||
logGenericAccount.setVisibility(View.GONE);
|
||||
} else {
|
||||
logGenericAccount.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
remoteProvisioning = (Button) view.findViewById(R.id.remote_provisioning);
|
||||
if (getResources().getBoolean(R.bool.hide_remote_provisioning_in_assistant)) {
|
||||
remoteProvisioning.setVisibility(View.GONE);
|
||||
} else {
|
||||
remoteProvisioning.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class WelcomeFragment extends Fragment implements OnClickListener {
|
|||
if (id == R.id.login_generic) {
|
||||
AssistantActivity.instance().displayLoginGeneric();
|
||||
} else if (id == R.id.login_linphone) {
|
||||
AssistantActivity.instance().displayLoginLinphone();
|
||||
AssistantActivity.instance().displayLoginLinphone(null, null);
|
||||
} else if (id == R.id.create_account) {
|
||||
AssistantActivity.instance().displayCreateAccount();
|
||||
} else if (id == R.id.remote_provisioning) {
|
||||
|
|
Loading…
Reference in a new issue