X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/90428ec4c79e78cc62bad1cec325c28b6f89614f..b52f0484b4a2815f2373422bfc61beea2a985854:/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 e4839707..b6ead824 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -54,6 +54,7 @@ import android.text.TextWatcher; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.View.OnClickListener; import android.view.View.OnFocusChangeListener; import android.view.View.OnTouchListener; import android.view.Window; @@ -131,6 +132,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList private byte mAction; private Account mAccount; + private Button mCheckServerButton; private EditText mHostUrlInput; private EditText mUsernameInput; private EditText mPasswordInput; @@ -143,6 +145,8 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList private TextView mOAuthTokenEndpointText; private boolean mRefreshButtonEnabled; + + private boolean mHostUrlInputEnabled; /** @@ -157,6 +161,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList /// set view and get references to view elements setContentView(R.layout.account_setup); + mCheckServerButton = (Button) findViewById(R.id.checkServerButton); mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); mUsernameInput = (EditText) findViewById(R.id.account_username); mPasswordInput = (EditText) findViewById(R.id.account_password); @@ -165,6 +170,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); @@ -178,6 +187,25 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); mAccount = null; mHostBaseUrl = ""; + + // URL Branding + if (!mHostUrlInputEnabled) + { + mHostUrlInput.setText(getString(R.string.server_url)); + mHostUrlInput.setVisibility(View.GONE); + + mCheckServerButton.setVisibility(View.VISIBLE); + mCheckServerButton.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + checkOcServer(); + + } + }); + + checkOcServer(); + } if (savedInstanceState == null) { /// connection state and info @@ -451,6 +479,11 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList 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); @@ -935,7 +968,33 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList finish(); - } else { + } else if (result.isServerFail() || result.isException()) { + /// if server fail or exception in authorization, the UI is updated as when a server check failed + mServerIsChecked = true; + mServerIsValid = false; + mIsSslConn = false; + mOcServerChkOperation = null; + mDiscoveredVersion = null; + mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString()); + + // update status icon and text + updateServerStatusIconAndText(result); + showServerStatus(); + mAuthStatusIcon = 0; + mAuthStatusText = 0; + showAuthStatus(); + + // update input controls state + showRefreshButton(); + mOkButton.setEnabled(false); + + // very special case (TODO: move to a common place for all the remote operations) (dangerous here?) + if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) { + mLastSslUntrustedServerResult = result; + showDialog(DIALOG_SSL_VALIDATOR); + } + + } else { // authorization fail due to client side - probably wrong credentials updateAuthStatusIconAndText(result); showAuthStatus(); Log_OC.d(TAG, "Access failed: " + result.getLogMessage()); @@ -1170,11 +1229,19 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList private void showRefreshButton() { mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0); mRefreshButtonEnabled = true; + + if (!mHostUrlInputEnabled){ + mCheckServerButton.setVisibility(View.VISIBLE); + } } private void hideRefreshButton() { mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); mRefreshButtonEnabled = false; + + if (!mHostUrlInputEnabled){ + mCheckServerButton.setVisibility(View.INVISIBLE); + } } /**