Search in sources :

Example 1 with CustomEditText

use of com.owncloud.android.ui.components.CustomEditText in project android by nextcloud.

the class AuthenticatorActivity method onAuthenticatorTaskCallback.

/**
 * Processes the result of the access check performed to try the user credentials.
 *
 * Creates a new account through the AccountManager.
 *
 * @param result Result of the operation.
 */
@Override
public void onAuthenticatorTaskCallback(RemoteOperationResult result) {
    mWaitingForOpId = Long.MAX_VALUE;
    dismissDialog(WAIT_DIALOG_TAG);
    mAsyncTask = null;
    if (result.isSuccess()) {
        Log_OC.d(TAG, "Successful access - time to save the account");
        boolean success = false;
        if (mAction == ACTION_CREATE) {
            success = createAccount(result);
        } else {
            try {
                updateAccountAuthentication();
                success = true;
            } catch (AccountNotFoundException e) {
                Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);
                Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();
                finish();
            }
        }
        // Reset webView
        webViewPassword = null;
        webViewUser = null;
        forceOldLoginMethod = false;
        deleteCookies();
        if (success) {
            finish();
        } else {
            // init webView again
            if (mLoginWebView != null) {
                mLoginWebView.setVisibility(View.GONE);
            }
            setContentView(R.layout.account_setup);
            initOverallUi();
            CustomEditText serverAddressField = findViewById(R.id.hostUrlInput);
            serverAddressField.setText(mServerInfo.mBaseUrl);
            findViewById(R.id.oauth_onOff_check).setVisibility(View.GONE);
            findViewById(R.id.server_status_text).setVisibility(View.GONE);
            mAuthStatusView = findViewById(R.id.auth_status_text);
            showAuthStatus();
        }
    } else if (result.isServerFail() || result.isException()) {
        // / server errors or exceptions in authorization take to requiring a new check of
        // / the server
        mServerIsChecked = true;
        mServerIsValid = false;
        mServerInfo = new GetServerInfoOperation.ServerInfo();
        // update status icon and text
        updateServerStatusIconAndText(result);
        showServerStatus();
        mAuthStatusIcon = 0;
        mAuthStatusText = "";
        if (!webViewLoginMethod) {
            showAuthStatus();
            // update input controls state
            showRefreshButton(true);
            mOkButton.setEnabled(false);
        }
        // very special case (TODO: move to a common place for all the remote operations)
        if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {
            showUntrustedCertDialog(result);
        }
    } else {
        // authorization fail due to client side - probably wrong credentials
        if (webViewLoginMethod) {
            mLoginWebView = findViewById(R.id.login_webview);
            initWebViewLogin(mServerInfo.mBaseUrl);
            Snackbar.make(mLoginWebView, getString(R.string.auth_access_failed) + ": " + result.getLogMessage(), Snackbar.LENGTH_LONG).show();
        } else {
            updateAuthStatusIconAndText(result);
            showAuthStatus();
        }
        // reset webview
        webViewPassword = null;
        webViewUser = null;
        deleteCookies();
        Log_OC.d(TAG, "Access failed: " + result.getLogMessage());
    }
}
Also used : CustomEditText(com.owncloud.android.ui.components.CustomEditText) AccountNotFoundException(com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException)

Aggregations

AccountNotFoundException (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException)1 CustomEditText (com.owncloud.android.ui.components.CustomEditText)1