use of android.view.MenuItem in project standup-timer by jwood.
the class ConfigureStandupTimerTest method test_about_box_displayed_successfully.
@MediumTest
public void test_about_box_displayed_successfully() {
MenuItem menuItem = EasyMock.createMock(MenuItem.class);
EasyMock.expect(menuItem.getItemId()).andReturn(R.id.about);
EasyMock.replay(menuItem);
a.onOptionsItemSelected(menuItem);
assertTrue(a.displayAboutBoxCalled());
assertFalse(a.displayHelpDialogCalled());
assertFalse(a.displaySettingsCalled());
assertFalse(isFinishCalled());
EasyMock.verify(menuItem);
}
use of android.view.MenuItem in project standup-timer by jwood.
the class ConfigureStandupTimerTest method test_settings_displayed_successfully.
@MediumTest
public void test_settings_displayed_successfully() {
MenuItem menuItem = EasyMock.createMock(MenuItem.class);
EasyMock.expect(menuItem.getItemId()).andReturn(R.id.settings);
EasyMock.replay(menuItem);
a.onOptionsItemSelected(menuItem);
assertFalse(a.displayAboutBoxCalled());
assertFalse(a.displayHelpDialogCalled());
assertTrue(a.displaySettingsCalled());
assertFalse(isFinishCalled());
assertFalse(a.displayTeamConfigurationCalled());
EasyMock.verify(menuItem);
}
use of android.view.MenuItem in project Android by hmkcode.
the class MainActivity method onPrepareOptionsMenu.
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (canAddItem) {
menu.getItem(0).setIcon(R.drawable.ic_content_remove);
MenuItem mi = menu.add("New Item");
mi.setIcon(R.drawable.ic_location_web_site);
mi.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
canAddItem = false;
} else {
menu.getItem(0).setIcon(R.drawable.ic_content_new);
canAddItem = true;
}
return super.onPrepareOptionsMenu(menu);
}
use of android.view.MenuItem in project Android-Iconics by mikepenz.
the class MainActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
//
menu.findItem(R.id.search).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_search).color(Color.WHITE).sizeDp(24).respectFontBounds(true));
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
search(s);
return true;
}
@Override
public boolean onQueryTextChange(String s) {
search(s);
return true;
}
private void search(String s) {
mCurrentSearch = s;
if (mDrawer != null) {
int count = 0;
for (ITypeface font : mFonts) {
int foundCount = 0;
if (font.getIcons() != null) {
for (String icon : font.getIcons()) {
if (icon.toLowerCase().contains(s.toLowerCase())) {
foundCount++;
}
}
}
mDrawer.updateBadge(count, new StringHolder(foundCount + ""));
count++;
}
}
//filter out the current fragment
if (mIconsFragment != null)
mIconsFragment.onSearch(s);
}
});
} else {
menu.findItem(R.id.search).setVisible(false);
}
MenuItem menuItem = menu.findItem(R.id.action_opensource);
menuItem.setIcon(new IconicsDrawable(this, FontAwesome.Icon.faw_github).actionBar().color(Color.WHITE));
return super.onCreateOptionsMenu(menu);
}
use of android.view.MenuItem in project MaterialDrawer by mikepenz.
the class AdvancedActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.drawer_item_advanced_drawer);
// Create a few sample profile
profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile));
profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile2)).withIdentifier(2);
profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile3));
profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile4)).withIdentifier(4);
profile5 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5));
// Create the AccountHeader
buildHeader(false, savedInstanceState);
//Create the drawer
result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(//set the AccountHeader we created earlier for the header
headerResult).addDrawerItems(new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home), //this custom DrawerItem extends the PrimaryDrawerItem so it just overwrites some methods
new OverflowMenuDrawerItem().withName(R.string.drawer_item_menu_drawer_item).withDescription(R.string.drawer_item_menu_drawer_item_desc).withMenu(R.menu.fragment_menu).withOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(AdvancedActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
return false;
}
}).withIcon(GoogleMaterial.Icon.gmd_filter_center_focus), new CustomPrimaryDrawerItem().withBackgroundRes(R.color.accent).withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad), new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withDescription("This is a description").withIcon(FontAwesome.Icon.faw_eye), new CustomUrlPrimaryDrawerItem().withName(R.string.drawer_item_fragment_drawer).withDescription(R.string.drawer_item_fragment_drawer_desc).withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460"), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cart_plus), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_database).withEnabled(false), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withSelectedIconColor(Color.RED).withIconTintingEnabled(true).withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus).actionBar().paddingDp(5).colorRes(R.color.material_drawer_dark_primary_text)).withTag("Bullhorn"), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false)).withOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() {
@Override
public boolean onNavigationClickListener(View clickedView) {
//this method is only called if the Arrow icon is shown. The hamburger is automatically managed by the MaterialDrawer
//if the back arrow is shown. close the activity
AdvancedActivity.this.finish();
//return true if we have consumed the event
return true;
}
}).addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog).withIdentifier(10), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github)).withSavedInstance(savedInstanceState).build();
}
Aggregations