Search in sources :

Example 21 with AlertDialog

use of android.app.AlertDialog in project SmartAndroidSource by jaychou2012.

the class GoogleHandle method accountDialog.

private void accountDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
    //builder.setTitle("Select a Google account");
    accs = am.getAccountsByType("com.google");
    int size = accs.length;
    if (size == 1) {
        auth(accs[0]);
    } else {
        String[] names = new String[size];
        for (int i = 0; i < size; i++) {
            names[i] = accs[i].name;
        }
        builder.setItems(names, this);
        builder.setOnCancelListener(this);
        //.show();
        AlertDialog dialog = builder.create();
        new AQuery(act).show(dialog);
    }
}
Also used : AlertDialog(android.app.AlertDialog)

Example 22 with AlertDialog

use of android.app.AlertDialog in project materialistic by hidroh.

the class DrawerActivityLoginTest method testNoExistingAccount.

@Test
public void testNoExistingAccount() {
    assertThat(drawerAccount).hasText(R.string.login);
    assertThat(drawerLogout).isNotVisible();
    assertThat(drawerUser).isNotVisible();
    Preferences.setUsername(activity, "username");
    assertThat(drawerAccount).hasText("username");
    assertThat(drawerLogout).isVisible();
    assertThat(drawerUser).isVisible();
    drawerLogout.performClick();
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    assertThat(drawerAccount).hasText(R.string.login);
    assertThat(drawerLogout).isNotVisible();
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Test(org.junit.Test)

Example 23 with AlertDialog

use of android.app.AlertDialog 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();
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Account(android.accounts.Account) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 24 with AlertDialog

use of android.app.AlertDialog 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);
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Account(android.accounts.Account) Test(org.junit.Test)

Example 25 with AlertDialog

use of android.app.AlertDialog 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);
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) ShadowSupportDrawerLayout(io.github.hidroh.materialistic.test.shadow.ShadowSupportDrawerLayout) Account(android.accounts.Account) Test(org.junit.Test)

Aggregations

AlertDialog (android.app.AlertDialog)348 DialogInterface (android.content.DialogInterface)236 View (android.view.View)84 Intent (android.content.Intent)63 TextView (android.widget.TextView)63 EditText (android.widget.EditText)50 OnClickListener (android.content.DialogInterface.OnClickListener)34 Test (org.junit.Test)33 Context (android.content.Context)29 ListView (android.widget.ListView)28 ImageView (android.widget.ImageView)26 AdapterView (android.widget.AdapterView)25 LayoutInflater (android.view.LayoutInflater)24 SuppressLint (android.annotation.SuppressLint)23 Button (android.widget.Button)23 Activity (android.app.Activity)21 Paint (android.graphics.Paint)19 KeyEvent (android.view.KeyEvent)16 OnClickListener (android.view.View.OnClickListener)15 ArrayList (java.util.ArrayList)15