Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/news-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Luhmer <david-dev@live.de>2018-06-12 16:56:02 +0300
committerDavid Luhmer <david-dev@live.de>2018-06-12 16:56:02 +0300
commite48dfe87fd0e11fc561cc38f189108e515555cd0 (patch)
tree7b0dcd4d535ad0cdf00348b353628321c62a8c36 /News-Android-App
parent5e8c8256c8060f101d98b5df41253e2302142e97 (diff)
refactoring / code cleanup
Diffstat (limited to 'News-Android-App')
-rw-r--r--News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogFragment.java84
-rw-r--r--News-Android-App/src/main/res/layout/dialog_signin.xml9
2 files changed, 49 insertions, 44 deletions
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogFragment.java
index f00177bf..c4b08055 100644
--- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogFragment.java
+++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogFragment.java
@@ -118,8 +118,7 @@ public class LoginDialogFragment extends DialogFragment implements IAccountImpor
// UI references.
@BindView(R.id.username) EditText mUsernameView;
@BindView(R.id.password) EditText mPasswordView;
- @BindView(R.id.password_container)
- TextInputLayout mPasswordContainerView;
+ @BindView(R.id.password_container) TextInputLayout mPasswordContainerView;
@BindView(R.id.edt_owncloudRootPath) EditText mOc_root_path_View;
@BindView(R.id.cb_AllowAllSSLCertificates) CheckBox mCbDisableHostnameVerificationView;
@BindView(R.id.imgView_ShowPassword) ImageView mImageViewShowPwd;
@@ -134,10 +133,13 @@ public class LoginDialogFragment extends DialogFragment implements IAccountImpor
try {
SingleSignOnAccount singleAccount = AccountImporter.BlockingGetAuthToken(getActivity(), account);
mUsernameView.setText(singleAccount.username);
+ mPasswordView.setText("");
+ mOc_root_path_View.setText(singleAccount.url);
+
mPasswordContainerView.setVisibility(View.GONE);
- mPasswordView.setText("Dummy");
- mOc_root_path_View.setText(singleAccount.url);
- mCbDisableHostnameVerificationView.setVisibility(View.GONE);
+ mImageViewShowPwd.setVisibility(View.GONE);
+ mCbDisableHostnameVerificationView.setVisibility(View.GONE);
+
this.importedAccount = account;
} catch (Exception e) {
e.printStackTrace();
@@ -249,6 +251,10 @@ public class LoginDialogFragment extends DialogFragment implements IAccountImpor
mOc_root_path_View.setText("");
mCbDisableHostnameVerificationView.setChecked(false);
+ mPasswordContainerView.setVisibility(View.VISIBLE);
+ mImageViewShowPwd.setVisibility(View.VISIBLE);
+ mCbDisableHostnameVerificationView.setVisibility(View.VISIBLE);
+
if(isChecked) {
Intent intent = AccountManager.newChooseAccountIntent(null, null, new String[] {"nextcloud"},
true, null, null, null, null);
@@ -377,36 +383,39 @@ public class LoginDialogFragment extends DialogFragment implements IAccountImpor
boolean cancel = false;
View focusView = null;
- // Check for a valid password.
- if (TextUtils.isEmpty(mPassword)) {
- mPasswordView.setError(getString(R.string.error_field_required));
- focusView = mPasswordView;
- cancel = true;
- }
- // Check for a valid email address.
- if (TextUtils.isEmpty(mUsername)) {
- mUsernameView.setError(getString(R.string.error_field_required));
- focusView = mUsernameView;
- cancel = true;
- }
+ // Only run checks if we don't use sso
+ if(!mSwSingleSignOn.isChecked()) {
+ // Check for a valid password.
+ if (TextUtils.isEmpty(mPassword)) {
+ mPasswordView.setError(getString(R.string.error_field_required));
+ focusView = mPasswordView;
+ cancel = true;
+ }
+ // Check for a valid email address.
+ if (TextUtils.isEmpty(mUsername)) {
+ mUsernameView.setError(getString(R.string.error_field_required));
+ focusView = mUsernameView;
+ cancel = true;
+ }
- if (TextUtils.isEmpty(mOc_root_path)) {
- mOc_root_path_View.setError(getString(R.string.error_field_required));
- focusView = mOc_root_path_View;
- cancel = true;
- } else {
- try {
- URL url = new URL(mOc_root_path);
- if(!url.getProtocol().equals("https"))
- ShowAlertDialog(getString(R.string.login_dialog_title_security_warning),
- getString(R.string.login_dialog_text_security_warning), getActivity());
- } catch (MalformedURLException e) {
- mOc_root_path_View.setError(getString(R.string.error_invalid_url));
- focusView = mOc_root_path_View;
- cancel = true;
- //e.printStackTrace();
- }
- }
+ if (TextUtils.isEmpty(mOc_root_path)) {
+ mOc_root_path_View.setError(getString(R.string.error_field_required));
+ focusView = mOc_root_path_View;
+ cancel = true;
+ } else {
+ try {
+ URL url = new URL(mOc_root_path);
+ if (!url.getProtocol().equals("https"))
+ ShowAlertDialog(getString(R.string.login_dialog_title_security_warning),
+ getString(R.string.login_dialog_text_security_warning), getActivity());
+ } catch (MalformedURLException e) {
+ mOc_root_path_View.setError(getString(R.string.error_invalid_url));
+ focusView = mOc_root_path_View;
+ cancel = true;
+ //e.printStackTrace();
+ }
+ }
+ }
if (cancel) {
// There was an error; don't attempt login and focus the first
@@ -424,9 +433,12 @@ public class LoginDialogFragment extends DialogFragment implements IAccountImpor
final ProgressDialog dialogLogin = BuildPendingDialogWhileLoggingIn();
dialogLogin.show();
- AccountImporter.SetCurrentAccount(getActivity(), importedAccount);
+ if(mSwSingleSignOn.isChecked()) {
+ AccountImporter.SetCurrentAccount(getActivity(), importedAccount);
+ }
+
- mApi.initApi(new NextcloudAPI.ApiConnectedListener() {
+ mApi.initApi(new NextcloudAPI.ApiConnectedListener() {
@Override
public void onConnected() {
Log.d(TAG, "onConnected() called");
diff --git a/News-Android-App/src/main/res/layout/dialog_signin.xml b/News-Android-App/src/main/res/layout/dialog_signin.xml
index ec627fc5..e3d66280 100644
--- a/News-Android-App/src/main/res/layout/dialog_signin.xml
+++ b/News-Android-App/src/main/res/layout/dialog_signin.xml
@@ -1,7 +1,5 @@
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- tools:context=".LoginActivity"
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -44,7 +42,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/username_container"
- android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/password_container">
@@ -66,7 +63,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/password_container"
- android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<EditText
@@ -94,7 +90,6 @@
android:src="@drawable/ic_action_visibility"
android:layout_alignTop="@+id/password_container"
android:layout_alignBottom="@+id/password_container"
- android:layout_alignRight="@+id/password_container"
android:layout_alignEnd="@+id/password_container"
android:contentDescription="@string/content_desc_show_password"/>
@@ -103,9 +98,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pref_title_DisableHostnameVerification"
- android:layout_below="@+id/url_container"
- android:layout_alignRight="@+id/imgView_ShowPassword"
- android:layout_alignEnd="@+id/imgView_ShowPassword" />
+ android:layout_below="@+id/url_container" />
</RelativeLayout>