X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/8f1566a21c1dfdc562d701c5514ee616509fcb65..1eed6a6812f41d17c44a3c0d8d87a265165fb2cb:/src/com/owncloud/android/authentication/AuthenticatorActivity.java diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 015be51d..05789059 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -18,7 +18,6 @@ package com.owncloud.android.authentication; -import com.owncloud.android.AccountUtils; import com.owncloud.android.Log_OC; import com.owncloud.android.ui.dialog.SslValidatorDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener; @@ -133,6 +132,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList private Account mAccount; private EditText mHostUrlInput; + private View mRefreshButton; private EditText mUsernameInput; private EditText mPasswordInput; private CheckBox mOAuth2Check; @@ -144,6 +144,8 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList private TextView mOAuthTokenEndpointText; private boolean mRefreshButtonEnabled; + + private boolean mHostUrlInputEnabled; /** @@ -166,6 +168,10 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check); mOkButton = findViewById(R.id.buttonOK); mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); + + /// set Host Url Input Enabled + mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input); + /// complete label for 'register account' button Button b = (Button) findViewById(R.id.account_register); @@ -179,6 +185,19 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); mAccount = null; mHostBaseUrl = ""; + boolean refreshButtonEnabled = false; + + // URL input configuration applied + if (!mHostUrlInputEnabled) + { + mHostUrlInput.setText(getString(R.string.server_url)); + findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); + + mRefreshButton = findViewById(R.id.centeredRefreshButton); + + } else { + mRefreshButton = findViewById(R.id.embeddedRefreshButton); + } if (savedInstanceState == null) { /// connection state and info @@ -207,6 +226,10 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList mOAuth2Check.setChecked(oAuthRequired); changeViewByOAuth2Check(oAuthRequired); mJustCreated = true; + + if (mAction == ACTION_UPDATE_TOKEN || !mHostUrlInputEnabled) { + checkOcServer(); + } } else { /// connection state and info @@ -237,42 +260,35 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } // refresh button enabled - mRefreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); + refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); + } showServerStatus(); showAuthStatus(); - if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton(); - mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes - - if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) { - mOAuth2Check.setVisibility(View.GONE); - } if (mAction == ACTION_UPDATE_TOKEN) { /// lock things that should not change mHostUrlInput.setEnabled(false); + mHostUrlInput.setFocusable(false); mUsernameInput.setEnabled(false); + mUsernameInput.setFocusable(false); + mOAuth2Check.setVisibility(View.GONE); + } + + //if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton(); + if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton(); + mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes + + if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) { mOAuth2Check.setVisibility(View.GONE); - if (!mServerIsValid && mOcServerChkOperation == null) { - checkOcServer(); - } } mPasswordInput.setText(""); // clean password to avoid social hacking (disadvantage: password in removed if the device is turned aside) /// bind view elements to listeners mHostUrlInput.setOnFocusChangeListener(this); - mHostUrlInput.setOnTouchListener(new RightDrawableOnTouchListener() { - @Override - public boolean onDrawableTouch(final MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_UP) { - AuthenticatorActivity.this.onRefreshClick(); - } - return true; - } - }); mHostUrlInput.addTextChangedListener(new TextWatcher() { @Override @@ -338,7 +354,8 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList } // refresh button enabled - outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled); + //outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled); + outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE)); } @@ -415,9 +432,6 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList if (view.getId() == R.id.hostUrlInput) { if (!hasFocus) { onUrlInputFocusLost((TextView) view); - if (!mServerIsValid) { - showRefreshButton(); - } } else { hideRefreshButton(); @@ -445,12 +459,20 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList checkOcServer(); } else { mOkButton.setEnabled(mServerIsValid); + if (!mServerIsValid) { + showRefreshButton(); + } } } private void checkOcServer() { String uri = trimUrlWebdav(mHostUrlInput.getText().toString().trim()); + + if (!mHostUrlInputEnabled){ + uri = getString(R.string.server_url); + } + mServerIsValid = false; mServerIsChecked = false; mOkButton.setEnabled(false); @@ -1194,13 +1216,11 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList private void showRefreshButton() { - mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0); - mRefreshButtonEnabled = true; + mRefreshButton.setVisibility(View.VISIBLE); } private void hideRefreshButton() { - mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); - mRefreshButtonEnabled = false; + mRefreshButton.setVisibility(View.GONE); } /** @@ -1210,7 +1230,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList * * @param view Refresh 'button' */ - public void onRefreshClick() { + public void onRefreshClick(View view) { checkOcServer(); } @@ -1271,7 +1291,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList * Called from SslValidatorDialog when a new server certificate was correctly saved. */ public void onSavedCertificate() { - mOperationThread = mOcServerChkOperation.retry(this, mHandler); + checkOcServer(); } /**