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);
}
}
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();
}
}
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");
}
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;
}
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);
}
Aggregations