X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/8d38fd331d43f21800843ae4cf340bc33e583a40..1a33e4cf6582c480be3097fcd65fb7ccd876f51a:/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 ee9d9bc1..e0a0ba95 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -43,7 +43,6 @@ import android.support.v4.app.FragmentTransaction; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; -import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -174,7 +173,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// Identifier of operation in progress which result shouldn't be lost - private int mWaitingForOpId = -1; + private long mWaitingForOpId = Long.MAX_VALUE; /** @@ -184,7 +183,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { */ @Override protected void onCreate(Bundle savedInstanceState) { - Log_OC.wtf(TAG, "onCreate init"); + //Log_OC.wtf(TAG, "onCreate init"); super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); @@ -211,7 +210,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { initAuthTokenType(); } else { mAuthTokenType = savedInstanceState.getString(KEY_AUTH_TOKEN_TYPE); - mWaitingForOpId = savedInstanceState.getInt(KEY_WAITING_FOR_OP_ID); + mWaitingForOpId = savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID); } /// load user interface @@ -226,7 +225,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// initialize block to be moved to single Fragment to retrieve and validate credentials initAuthorizationPreFragment(savedInstanceState); - Log_OC.wtf(TAG, "onCreate end"); + //Log_OC.wtf(TAG, "onCreate end"); } private void initAuthTokenType() { @@ -308,7 +307,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState) boolean isUrlInputAllowed = getResources().getBoolean(R.bool.show_server_url_input); - //boolean refreshButtonEnabled = false; if (savedInstanceState == null) { if (mAccount != null) { mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL); @@ -322,7 +320,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); } } else { - //refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); @@ -355,7 +352,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); mRefreshButton = findViewById(R.id.centeredRefreshButton); } - showRefreshButton(mServerIsChecked && !mServerIsValid && mWaitingForOpId == -1); + showRefreshButton(mServerIsChecked && !mServerIsValid && + mWaitingForOpId > Integer.MAX_VALUE); mServerStatusView = (TextView) findViewById(R.id.server_status_text); showServerStatus(); @@ -536,12 +534,12 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { */ @Override protected void onSaveInstanceState(Bundle outState) { - Log.wtf(TAG, "onSaveInstanceState init" ); + //Log_OC.wtf(TAG, "onSaveInstanceState init" ); super.onSaveInstanceState(outState); /// global state outState.putString(KEY_AUTH_TOKEN_TYPE, mAuthTokenType); - outState.putInt(KEY_WAITING_FOR_OP_ID, mWaitingForOpId); + outState.putLong(KEY_WAITING_FOR_OP_ID, mWaitingForOpId); /// Server PRE-fragment state outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText); @@ -561,7 +559,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { outState.putInt(KEY_AUTH_STATUS_TEXT, mAuthStatusText); outState.putString(KEY_AUTH_TOKEN, mAuthToken); - Log.wtf(TAG, "onSaveInstanceState end" ); + //Log_OC.wtf(TAG, "onSaveInstanceState end" ); } @@ -588,7 +586,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { */ @Override protected void onResume() { - Log_OC.wtf(TAG, "onResume init" ); + //Log_OC.wtf(TAG, "onResume init" ); super.onResume(); // bound here to avoid spurious changes triggered by Android on device rotations @@ -603,15 +601,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { doOnResumeAndBound(); } - Log_OC.wtf(TAG, "onResume end" ); + //Log_OC.wtf(TAG, "onResume end" ); } @Override protected void onPause() { - Log.wtf(TAG, "onPause init" ); + //Log_OC.wtf(TAG, "onPause init" ); if (mOperationsServiceBinder != null) { - Log.wtf(TAG, "unregistering to listen for operation callbacks" ); + //Log_OC.wtf(TAG, "unregistering to listen for operation callbacks" ); mOperationsServiceBinder.removeOperationListener(this); } @@ -619,7 +617,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mHostUrlInput.setOnFocusChangeListener(null); super.onPause(); - Log.wtf(TAG, "onPause end" ); + //Log_OC.wtf(TAG, "onPause end" ); } @Override @@ -761,10 +759,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private void showViewPasswordButton() { - //int drawable = android.R.drawable.ic_menu_view; int drawable = R.drawable.ic_view; if (isPasswordVisible()) { - //drawable = android.R.drawable.ic_secure; drawable = R.drawable.ic_hide; } mPasswordInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, drawable, 0); @@ -812,7 +808,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mServerStatusText = R.string.auth_wtf_reenter_URL; showServerStatus(); mOkButton.setEnabled(false); - Log_OC.wtf(TAG, "The user was allowed to click 'connect' to an unchecked server!!"); + //Log_OC.wtf(TAG, "The user was allowed to click 'connect' to an unchecked server!!"); return; } @@ -865,7 +861,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { existenceCheckIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects); if (mOperationsServiceBinder != null) { - Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." ); + //Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." ); mWaitingForOpId = mOperationsServiceBinder.newOperation(existenceCheckIntent); } } @@ -881,14 +877,12 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { showAuthStatus(); // GET AUTHORIZATION request - //Uri uri = Uri.parse(getString(R.string.oauth2_url_endpoint_auth)); Uri uri = Uri.parse(mOAuthAuthEndpointText.getText().toString().trim()); Uri.Builder uriBuilder = uri.buildUpon(); uriBuilder.appendQueryParameter(OAuth2Constants.KEY_RESPONSE_TYPE, getString(R.string.oauth2_response_type)); uriBuilder.appendQueryParameter(OAuth2Constants.KEY_REDIRECT_URI, getString(R.string.oauth2_redirect_uri)); uriBuilder.appendQueryParameter(OAuth2Constants.KEY_CLIENT_ID, getString(R.string.oauth2_client_id)); uriBuilder.appendQueryParameter(OAuth2Constants.KEY_SCOPE, getString(R.string.oauth2_scope)); - //uriBuilder.appendQueryParameter(OAuth2Constants.KEY_STATE, whateverwewant); uri = uriBuilder.build(); Log_OC.d(TAG, "Starting browser to view " + uri.toString()); Intent i = new Intent(Intent.ACTION_VIEW, uri); @@ -938,7 +932,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { onGetOAuthAccessTokenFinish(result); } else if (operation instanceof ExistenceCheckRemoteOperation) { - Log_OC.wtf(TAG, "received detection response through callback" ); + //Log_OC.wtf(TAG, "received detection response through callback" ); if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) { onSamlBasedFederatedSingleSignOnAuthorizationStart(result); @@ -952,7 +946,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } private void onGetUserNameFinish(RemoteOperationResult result) { - mWaitingForOpId = -1; + mWaitingForOpId = Long.MAX_VALUE; if (result.isSuccess()) { boolean success = false; String username = (String) result.getData().get(0); @@ -985,10 +979,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) { - mWaitingForOpId = -1; + mWaitingForOpId = Long.MAX_VALUE; dismissDialog(WAIT_DIALOG_TAG); - //if (result.isTemporalRedirection() && result.isIdPRedirection()) { if (result.isIdPRedirection()) { String url = result.getRedirectedLocation(); String targetUrl = mServerInfo.mBaseUrl @@ -1020,7 +1013,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private void onGetServerInfoFinish(RemoteOperationResult result) { /// update activity state mServerIsChecked = true; - mWaitingForOpId = -1; + mWaitingForOpId = Long.MAX_VALUE; // update server status, but don't show it yet updateServerStatusIconAndText(result); @@ -1287,7 +1280,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { * @param result Result of the operation. */ private void onGetOAuthAccessTokenFinish(RemoteOperationResult result) { - mWaitingForOpId = -1; + mWaitingForOpId = Long.MAX_VALUE; dismissDialog(WAIT_DIALOG_TAG); String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType); @@ -1326,10 +1319,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { * @param result Result of the operation. */ private void onAuthorizationCheckFinish(RemoteOperationResult result) { - mWaitingForOpId = -1; + mWaitingForOpId = Long.MAX_VALUE; dismissDialog(WAIT_DIALOG_TAG); - result = new RemoteOperationResult(new RuntimeException("FAKE")); if (result.isSuccess()) { Log_OC.d(TAG, "Successful access - time to save the account"); @@ -1351,12 +1343,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// the server mServerIsChecked = true; mServerIsValid = false; - /* - mServerInfo.mIsSslConn = false; - mServerInfo.mVersion = null; - mServerInfo.mBaseUrl = - normalizeUrl(mHostUrlInput.getText().toString(), mServerInfo.mIsSslConn); // TODO remove? - */ mServerInfo = new GetServerInfoOperation.ServerInfo(); // update status icon and text @@ -1753,10 +1739,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private void doOnResumeAndBound() { - Log.wtf(TAG, "registering to listen for operation callbacks" ); + //Log_OC.wtf(TAG, "registering to listen for operation callbacks" ); mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler); - if (mWaitingForOpId != -1) { - mOperationsServiceBinder.dispatchResultIfFinished(mWaitingForOpId, this); + if (mWaitingForOpId <= Integer.MAX_VALUE) { + mOperationsServiceBinder.dispatchResultIfFinished((int)mWaitingForOpId, this); } } @@ -1778,7 +1764,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { @Override public void onServiceConnected(ComponentName component, IBinder service) { if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) { - Log_OC.wtf(TAG, "Operations service connected"); + //Log_OC.wtf(TAG, "Operations service connected"); mOperationsServiceBinder = (OperationsServiceBinder) service; doOnResumeAndBound();