Search in sources :

Example 81 with Account

use of android.accounts.Account in project android by owncloud.

the class FileActivity method onCreate.

/**
     * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
     * the {@link FileActivity}.
     *
     * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user
     * is requested to create a new one.
     */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    mFileOperationsHelper = new FileOperationsHelper(this);
    Account account = null;
    if (savedInstanceState != null) {
        mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
        mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
        mFileOperationsHelper.setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE));
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
        }
    } else {
        account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
        mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
        mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false);
    }
    // best place, before any access to AccountManager
    AccountUtils.updateAccountVersion(this);
    // or database
    setAccount(account, savedInstanceState != null);
    mOperationsServiceConnection = new OperationsServiceConnection();
    bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, Context.BIND_AUTO_CREATE);
    mDownloadServiceConnection = newTransferenceServiceConnection();
    if (mDownloadServiceConnection != null) {
        bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection, Context.BIND_AUTO_CREATE);
    }
    mUploadServiceConnection = newTransferenceServiceConnection();
    if (mUploadServiceConnection != null) {
        bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE);
    }
}
Also used : FileOperationsHelper(com.owncloud.android.ui.helpers.FileOperationsHelper) Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) FileUploader(com.owncloud.android.files.services.FileUploader) Handler(android.os.Handler) Intent(android.content.Intent) FileDownloader(com.owncloud.android.files.services.FileDownloader) OperationsService(com.owncloud.android.services.OperationsService)

Example 82 with Account

use of android.accounts.Account in project android by owncloud.

the class BaseActivity method setAccount.

/**
     * Sets and validates the ownCloud {@link Account} associated to the Activity.
     * <p/>
     * If not valid, tries to swap it for other valid and existing ownCloud {@link Account}.
     * <p/>
     * POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}.
     *
     * @param account      New {@link Account} to set.
     * @param savedAccount When 'true', account was retrieved from a saved instance state.
     */
protected void setAccount(Account account, boolean savedAccount) {
    Account oldAccount = mCurrentAccount;
    boolean validAccount = (account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), account.name));
    if (validAccount) {
        mCurrentAccount = account;
        mAccountWasSet = true;
        mAccountWasRestored = (savedAccount || mCurrentAccount.equals(oldAccount));
    } else {
        swapToDefaultAccount();
    }
}
Also used : Account(android.accounts.Account)

Example 83 with Account

use of android.accounts.Account in project android by owncloud.

the class BaseActivity method onNewIntent.

@Override
protected void onNewIntent(Intent intent) {
    Log_OC.v(TAG, "onNewIntent() start");
    Account current = AccountUtils.getCurrentOwnCloudAccount(this);
    if (current != null && mCurrentAccount != null && !mCurrentAccount.name.equals(current.name)) {
        mCurrentAccount = current;
    }
    Log_OC.v(TAG, "onNewIntent() stop");
}
Also used : Account(android.accounts.Account)

Example 84 with Account

use of android.accounts.Account in project Launcher3 by chislon.

the class LauncherTransitionable method skipCustomClingIfNoAccounts.

private boolean skipCustomClingIfNoAccounts() {
    Cling cling = (Cling) findViewById(R.id.workspace_cling);
    boolean customCling = cling.getDrawIdentifier().equals("workspace_custom");
    if (customCling) {
        AccountManager am = AccountManager.get(this);
        if (am == null)
            return false;
        Account[] accounts = am.getAccountsByType("com.google");
        return accounts.length == 0;
    }
    return false;
}
Also used : Account(android.accounts.Account) AccountManager(android.accounts.AccountManager)

Example 85 with Account

use of android.accounts.Account in project philm by chrisbanes.

the class AndroidAccountManager method removeAccount.

@Override
public void removeAccount(PhilmAccount philmAccount) {
    Account account = new Account(philmAccount.getAccountName(), Constants.TRAKT_ACCOUNT_TYPE);
    mAccountManager.removeAccount(account, null, null);
}
Also used : Account(android.accounts.Account) PhilmAccount(app.philm.in.model.PhilmAccount)

Aggregations

Account (android.accounts.Account)550 Bundle (android.os.Bundle)108 AccountManager (android.accounts.AccountManager)79 Test (org.junit.Test)53 ArrayList (java.util.ArrayList)49 Intent (android.content.Intent)40 File (java.io.File)37 Cursor (android.database.Cursor)31 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)29 PersistableBundle (android.os.PersistableBundle)27 UserInfo (android.content.pm.UserInfo)22 MockContentResolver (android.test.mock.MockContentResolver)22 HashMap (java.util.HashMap)20 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)20 RemoteException (android.os.RemoteException)19 FileOutputStream (java.io.FileOutputStream)19 IOException (java.io.IOException)19 SmallTest (android.test.suitebuilder.annotation.SmallTest)18 HashSet (java.util.HashSet)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16