use of android.accounts.Account in project philm by chrisbanes.
the class AndroidAccountManager method getAccounts.
@Override
public List<PhilmAccount> getAccounts() {
final Account[] accounts = mAccountManager.getAccountsByType(Constants.TRAKT_ACCOUNT_TYPE);
ArrayList<PhilmAccount> philmAccounts = new ArrayList<>(accounts.length);
for (int i = 0; i < accounts.length; i++) {
final Account account = accounts[i];
String password = mAccountManager.getPassword(account);
philmAccounts.add(new PhilmAccount(account.name, password));
}
return philmAccounts;
}
use of android.accounts.Account in project materialistic by hidroh.
the class DrawerActivityLoginTest method testRemoveAccount.
@Config(sdk = 21)
@Test
public void testRemoveAccount() {
ShadowAccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null);
Preferences.setUsername(activity, "existing");
drawerAccount.performClick();
AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
assertNotNull(alertDialog);
assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).performClick();
assertThat(alertDialog).isNotShowing();
assertThat(ShadowAccountManager.get(activity).getAccounts()).isEmpty();
}
use of android.accounts.Account in project materialistic by hidroh.
the class DrawerActivityLoginTest method testExistingAccount.
@Test
public void testExistingAccount() {
ShadowAccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null);
drawerAccount.performClick();
AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
assertNotNull(alertDialog);
assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
shadowOf(alertDialog).clickOnItem(0);
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
assertThat(alertDialog).isNotShowing();
assertThat(drawerAccount).hasText("existing");
assertThat(drawerLogout).isVisible();
drawerAccount.performClick();
alertDialog = ShadowAlertDialog.getLatestAlertDialog();
assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
}
use of android.accounts.Account in project materialistic by hidroh.
the class DrawerActivityLoginTest method testAddAccount.
@Test
public void testAddAccount() {
ShadowAccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null);
drawerAccount.performClick();
AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
assertNotNull(alertDialog);
assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
assertThat(alertDialog).isNotShowing();
((ShadowSupportDrawerLayout) ShadowExtractor.extract(activity.findViewById(R.id.drawer_layout))).getDrawerListeners().get(0).onDrawerClosed(activity.findViewById(R.id.drawer));
assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, LoginActivity.class);
}
use of android.accounts.Account in project QuantumFlux by himanshu-soni.
the class SyncUtils method createSyncAccount.
/**
* Create a new dummy account for the sync adapter
*
* @param context The application context
*/
public static Account createSyncAccount(Context context, String name) {
// Create the account type and default account
Account newAccount = new Account(name, ACCOUNT_TYPE);
// Get an instance of the Android account manager
AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
/*
* Add the account and account type, no password or user data
* If successful, return the Account object, otherwise report an error.
*/
if (accountManager.addAccountExplicitly(newAccount, null, null)) {
/*
* If you don't set android:syncable="true" in
* in your <provider> element in the manifest,
* then call context.setIsSyncable(account, CONTENT_AUTHORITY, 1)
* here.
*/
// Turn on automatic syncing for the default account and authority
// mResolver.setSyncAutomatically(newAccount, SyncConstants.AUTHORITY, true);
} else {
/*
* The account exists or some other error occurred. Log this, report it,
* or handle it internally.
*/
}
return newAccount;
}
Aggregations