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:layout_height="40dp"
|
||||||
android:maxLines="1"/>
|
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
|
<TextView
|
||||||
android:text="@string/password"
|
android:text="@string/password"
|
||||||
style="@style/font13"
|
style="@style/font13"
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
<!-- Common -->
|
<!-- Common -->
|
||||||
<string name="username">Username</string>
|
<string name="username">Username</string>
|
||||||
|
<string name="userid">User-id (optional)</string>
|
||||||
<string name="phone_number">Phone number</string>
|
<string name="phone_number">Phone number</string>
|
||||||
<string name="display_name">Display name</string>
|
<string name="display_name">Display name</string>
|
||||||
<string name="password">Password</string>
|
<string name="password">Password</string>
|
||||||
|
|
|
@ -285,7 +285,7 @@ private static AssistantActivity instance;
|
||||||
finish();
|
finish();
|
||||||
} else if (currentFragment == AssistantFragmentsEnum.COUNTRY_CHOOSER){
|
} else if (currentFragment == AssistantFragmentsEnum.COUNTRY_CHOOSER){
|
||||||
if(lastFragment.equals(AssistantFragmentsEnum.LINPHONE_LOGIN)){
|
if(lastFragment.equals(AssistantFragmentsEnum.LINPHONE_LOGIN)){
|
||||||
displayLoginLinphone();
|
displayLoginLinphone(null, null);
|
||||||
} else {
|
} else {
|
||||||
displayCreateAccount();
|
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) {
|
public void configureLinphoneProxyConfig(LinphoneAccountCreator accountCreator) {
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
LinphoneProxyConfig proxyConfig = lc.createProxyConfig();
|
LinphoneProxyConfig proxyConfig = lc.createProxyConfig();
|
||||||
|
@ -417,12 +413,8 @@ private static AssistantActivity instance;
|
||||||
configureLinphoneProxyConfig(accountCreator);
|
configureLinphoneProxyConfig(accountCreator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void genericLogIn(String username, String password, String prefix, String domain, TransportType transport) {
|
public void genericLogIn(String username, String userid, String password, String prefix, String domain, TransportType transport) {
|
||||||
if (accountCreated) {
|
saveCreatedAccount(username, userid, password, null, prefix, domain, transport);
|
||||||
retryLogin(username, password, prefix, domain, transport);
|
|
||||||
} else {
|
|
||||||
logIn(username, password, null, prefix, domain, transport);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(AssistantFragmentsEnum fragment) {
|
private void display(AssistantFragmentsEnum fragment) {
|
||||||
|
@ -431,7 +423,7 @@ private static AssistantActivity instance;
|
||||||
displayMenu();
|
displayMenu();
|
||||||
break;
|
break;
|
||||||
case LINPHONE_LOGIN:
|
case LINPHONE_LOGIN:
|
||||||
displayLoginLinphone();
|
displayLoginLinphone(null, null);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Can't handle " + fragment);
|
throw new IllegalStateException("Can't handle " + fragment);
|
||||||
|
@ -453,11 +445,13 @@ private static AssistantActivity instance;
|
||||||
back.setVisibility(View.VISIBLE);
|
back.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayLoginLinphone() {
|
public void displayLoginLinphone(String username, String password) {
|
||||||
fragment = new LinphoneLoginFragment();
|
fragment = new LinphoneLoginFragment();
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putString("Phone", null);
|
extras.putString("Phone", null);
|
||||||
extras.putString("Dialcode", null);
|
extras.putString("Dialcode", null);
|
||||||
|
extras.putString("Username", username);
|
||||||
|
extras.putString("Password", password);
|
||||||
fragment.setArguments(extras);
|
fragment.setArguments(extras);
|
||||||
changeFragment(fragment);
|
changeFragment(fragment);
|
||||||
currentFragment = AssistantFragmentsEnum.LINPHONE_LOGIN;
|
currentFragment = AssistantFragmentsEnum.LINPHONE_LOGIN;
|
||||||
|
@ -490,11 +484,6 @@ private static AssistantActivity instance;
|
||||||
back.setVisibility(View.VISIBLE);
|
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() {
|
private void launchDownloadCodec() {
|
||||||
if (LinphoneManager.getLc().downloadOpenH264Enabled()) {
|
if (LinphoneManager.getLc().downloadOpenH264Enabled()) {
|
||||||
OpenH264DownloadHelper downloadHelper = LinphoneCoreFactory.instance().createOpenH264DownloadHelper();
|
OpenH264DownloadHelper downloadHelper = LinphoneCoreFactory.instance().createOpenH264DownloadHelper();
|
||||||
|
@ -521,9 +510,7 @@ private static AssistantActivity instance;
|
||||||
return phoneNumberWithCountry;
|
return phoneNumberWithCountry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveCreatedAccount(String username, String password, String ha1, String prefix, String domain, TransportType transport) {
|
public void saveCreatedAccount(String username, String userid, String password, String ha1, String prefix, String domain, TransportType transport) {
|
||||||
if (accountCreated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
username = LinphoneUtils.getDisplayableUsernameFromAddress(username);
|
username = LinphoneUtils.getDisplayableUsernameFromAddress(username);
|
||||||
domain = LinphoneUtils.getDisplayableUsernameFromAddress(domain);
|
domain = LinphoneUtils.getDisplayableUsernameFromAddress(domain);
|
||||||
|
@ -539,6 +526,7 @@ private static AssistantActivity instance;
|
||||||
.setUsername(username)
|
.setUsername(username)
|
||||||
.setDomain(domain)
|
.setDomain(domain)
|
||||||
.setHa1(ha1)
|
.setHa1(ha1)
|
||||||
|
.setUserId(userid)
|
||||||
.setPassword(password);
|
.setPassword(password);
|
||||||
|
|
||||||
if (prefix != null) {
|
if (prefix != null) {
|
||||||
|
@ -555,23 +543,14 @@ private static AssistantActivity instance;
|
||||||
builder.setTransport(transport);
|
builder.setTransport(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.enable_push_id)) {
|
try {
|
||||||
String regId = mPrefs.getPushNotificationRegistrationID();
|
builder.saveNewAccount();
|
||||||
String appId = getString(R.string.push_sender_id);
|
if (!newAccount) {
|
||||||
if (regId != null && mPrefs.isPushNotificationEnabled()) {
|
displayRegistrationInProgressDialog();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
accountCreated = true;
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
Log.e(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
private Boolean recoverAccount;
|
private Boolean recoverAccount;
|
||||||
private LinphoneAccountCreator accountCreator;
|
private LinphoneAccountCreator accountCreator;
|
||||||
private int countryCode;
|
private int countryCode;
|
||||||
private String phone, dialcode;
|
private String phone, dialcode, username, pwd;
|
||||||
private ImageView phoneNumberInfo;
|
private ImageView phoneNumberInfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,6 +170,16 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On
|
||||||
passwordLayout.setVisibility(View.VISIBLE);
|
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) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
accountCreator.setLanguage(Locale.getDefault().toLanguageTag());
|
accountCreator.setLanguage(Locale.getDefault().toLanguageTag());
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,17 +36,19 @@ import android.widget.Toast;
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class LoginFragment extends Fragment implements OnClickListener, TextWatcher {
|
public class LoginFragment extends Fragment implements OnClickListener, TextWatcher {
|
||||||
private EditText login, password, domain;
|
private EditText login, userid, password, domain;
|
||||||
private RadioGroup transports;
|
private RadioGroup transports;
|
||||||
private Button apply;
|
private Button apply;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.assistant_login, container, false);
|
View view = inflater.inflate(R.layout.assistant_login, container, false);
|
||||||
|
|
||||||
login = (EditText) view.findViewById(R.id.assistant_username);
|
login = (EditText) view.findViewById(R.id.assistant_username);
|
||||||
login.addTextChangedListener(this);
|
login.addTextChangedListener(this);
|
||||||
|
userid = (EditText) view.findViewById(R.id.assistant_userid);
|
||||||
|
userid.addTextChangedListener(this);
|
||||||
password = (EditText) view.findViewById(R.id.assistant_password);
|
password = (EditText) view.findViewById(R.id.assistant_password);
|
||||||
password.addTextChangedListener(this);
|
password.addTextChangedListener(this);
|
||||||
domain = (EditText) view.findViewById(R.id.assistant_domain);
|
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 = (Button) view.findViewById(R.id.assistant_apply);
|
||||||
apply.setEnabled(false);
|
apply.setEnabled(false);
|
||||||
apply.setOnClickListener(this);
|
apply.setOnClickListener(this);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
|
||||||
if (id == R.id.assistant_apply) {
|
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) {
|
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();
|
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 {
|
public class WelcomeFragment extends Fragment implements OnClickListener {
|
||||||
private Button createAccount, logLinphoneAccount, logGenericAccount, remoteProvisioning;
|
private Button createAccount, logLinphoneAccount, logGenericAccount, remoteProvisioning;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -47,21 +47,21 @@ public class WelcomeFragment extends Fragment implements OnClickListener {
|
||||||
} else {
|
} else {
|
||||||
logLinphoneAccount.setOnClickListener(this);
|
logLinphoneAccount.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
logGenericAccount = (Button) view.findViewById(R.id.login_generic);
|
logGenericAccount = (Button) view.findViewById(R.id.login_generic);
|
||||||
if (getResources().getBoolean(R.bool.hide_generic_accounts_in_assistant)) {
|
if (getResources().getBoolean(R.bool.hide_generic_accounts_in_assistant)) {
|
||||||
logGenericAccount.setVisibility(View.GONE);
|
logGenericAccount.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
logGenericAccount.setOnClickListener(this);
|
logGenericAccount.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteProvisioning = (Button) view.findViewById(R.id.remote_provisioning);
|
remoteProvisioning = (Button) view.findViewById(R.id.remote_provisioning);
|
||||||
if (getResources().getBoolean(R.bool.hide_remote_provisioning_in_assistant)) {
|
if (getResources().getBoolean(R.bool.hide_remote_provisioning_in_assistant)) {
|
||||||
remoteProvisioning.setVisibility(View.GONE);
|
remoteProvisioning.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
remoteProvisioning.setOnClickListener(this);
|
remoteProvisioning.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class WelcomeFragment extends Fragment implements OnClickListener {
|
||||||
if (id == R.id.login_generic) {
|
if (id == R.id.login_generic) {
|
||||||
AssistantActivity.instance().displayLoginGeneric();
|
AssistantActivity.instance().displayLoginGeneric();
|
||||||
} else if (id == R.id.login_linphone) {
|
} else if (id == R.id.login_linphone) {
|
||||||
AssistantActivity.instance().displayLoginLinphone();
|
AssistantActivity.instance().displayLoginLinphone(null, null);
|
||||||
} else if (id == R.id.create_account) {
|
} else if (id == R.id.create_account) {
|
||||||
AssistantActivity.instance().displayCreateAccount();
|
AssistantActivity.instance().displayCreateAccount();
|
||||||
} else if (id == R.id.remote_provisioning) {
|
} else if (id == R.id.remote_provisioning) {
|
||||||
|
|
Loading…
Reference in a new issue