Search in sources :

Example 1 with IndeterminateProgressDialog

use of com.owncloud.android.ui.dialog.IndeterminateProgressDialog in project android by nextcloud.

the class AuthenticatorActivity method onGetOAuthAccessTokenFinish.

/**
 * Processes the result of the request for and access token send
 * to an OAuth authorization server.
 *
 * @param result Result of the operation.
 */
private void onGetOAuthAccessTokenFinish(RemoteOperationResult result) {
    mWaitingForOpId = Long.MAX_VALUE;
    dismissDialog(WAIT_DIALOG_TAG);
    if (result.isSuccess()) {
        // / be gentle with the user
        IndeterminateProgressDialog dialog = IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);
        dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);
        // / time to test the retrieved access token on the ownCloud server
        @SuppressWarnings("unchecked") Map<String, String> tokens = (Map<String, String>) (result.getData().get(0));
        mAuthToken = tokens.get(OAuth2Constants.KEY_ACCESS_TOKEN);
        Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken);
        // / validate token accessing to root folder / getting session
        OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBearerCredentials(mAuthToken);
        accessRootFolder(credentials);
    } else {
        updateAuthStatusIconAndText(result);
        showAuthStatus();
        Log_OC.d(TAG, "Access failed: " + result.getLogMessage());
    }
}
Also used : IndeterminateProgressDialog(com.owncloud.android.ui.dialog.IndeterminateProgressDialog) Map(java.util.Map) HashMap(java.util.HashMap) OwnCloudCredentials(com.owncloud.android.lib.common.OwnCloudCredentials)

Example 2 with IndeterminateProgressDialog

use of com.owncloud.android.ui.dialog.IndeterminateProgressDialog in project android by nextcloud.

the class AuthenticatorActivity method getOAuth2AccessTokenFromCapturedRedirection.

/**
 * Parses the redirection with the response to the GET AUTHORIZATION request to the
 * oAuth server and requests for the access token (GET ACCESS TOKEN)
 */
private void getOAuth2AccessTokenFromCapturedRedirection() {
    // / Parse data from OAuth redirection
    String queryParameters = mNewCapturedUriFromOAuth2Redirection.getQuery();
    mNewCapturedUriFromOAuth2Redirection = null;
    // / Showing the dialog with instructions for the user.
    IndeterminateProgressDialog dialog = IndeterminateProgressDialog.newInstance(R.string.auth_getting_authorization, true);
    dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);
    // / GET ACCESS TOKEN to the oAuth server
    Intent getServerInfoIntent = new Intent();
    getServerInfoIntent.setAction(OperationsService.ACTION_OAUTH2_GET_ACCESS_TOKEN);
    getServerInfoIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mOAuthTokenEndpointText.getText().toString().trim());
    getServerInfoIntent.putExtra(OperationsService.EXTRA_OAUTH2_QUERY_PARAMETERS, queryParameters);
    if (mOperationsServiceBinder != null) {
        // Log_OC.e(TAG, "getting access token..." );
        mWaitingForOpId = mOperationsServiceBinder.queueNewOperation(getServerInfoIntent);
    }
}
Also used : Intent(android.content.Intent) IndeterminateProgressDialog(com.owncloud.android.ui.dialog.IndeterminateProgressDialog)

Example 3 with IndeterminateProgressDialog

use of com.owncloud.android.ui.dialog.IndeterminateProgressDialog in project android by nextcloud.

the class AuthenticatorActivity method checkBasicAuthorization.

/**
 * Tests the credentials entered by the user performing a check of existence on the root folder of the ownCloud
 * server.
 */
private void checkBasicAuthorization(@Nullable String webViewUsername, @Nullable String webViewPassword) {
    // be gentle with the user
    IndeterminateProgressDialog dialog = IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.add(dialog, WAIT_DIALOG_TAG);
    ft.commitAllowingStateLoss();
    // validate credentials accessing the root folder
    OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(webViewUsername, webViewPassword);
    accessRootFolder(credentials);
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) IndeterminateProgressDialog(com.owncloud.android.ui.dialog.IndeterminateProgressDialog) OwnCloudCredentials(com.owncloud.android.lib.common.OwnCloudCredentials)

Aggregations

IndeterminateProgressDialog (com.owncloud.android.ui.dialog.IndeterminateProgressDialog)3 OwnCloudCredentials (com.owncloud.android.lib.common.OwnCloudCredentials)2 Intent (android.content.Intent)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1