Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97a2dcc2 authored by TChardeur's avatar TChardeur
Browse files

Get credentials from the account to pass them to the...

Get credentials from the account to pass them to the OwnCloudCredentialsFactory in AccountRemoteStoragePreferenceController.java
parent 17c31d89
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
package com.android.settings.accounts;

import android.accounts.Account;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
import android.net.Uri;
import android.view.View;

import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.Credentials;

import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settings.accounts.FollowNSULinkRemoteOperation;

@@ -15,6 +20,8 @@ import com.owncloud.android.lib.common.OwnCloudCredentialsFactory;
public class AccountRemoteStoragePreferenceController extends AbstractPreferenceController {
    private OwnCloudClient mClient;
    private Handler mhandler;
    private Account mAccount;
    private UserHandle mUserHandle;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -25,14 +32,22 @@ public class AccountRemoteStoragePreferenceController extends AbstractPreference

        mHandler = new Handler();
        mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true);

        Credentials cred = mAccount.getState().getCredentials(AuthScope.ANY);

        mClient.setCredentials(
      			OwnCloudCredentialsFactory.newBasicCredentials(
      					"",
      					""
      					cred.getUserName(),
      					cred.getPassword()
  				  )
  		  );
    }

    public void init(Account account, UserHandle userHandle) {
        mAccount = account;
        mUserHandle = userHandle;
    }

    public void onClickHandler(View button) {
        if (button.getId() == R.id.increase_storage_button)
            followNSULink();
+3 −4
Original line number Diff line number Diff line
package com.android.settings.accounts;

import android.net.Uri;

import com.owncloud.android.lib.common.OwnCloudClient;

import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.Cookie;

import android.net.Uri;

import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;