Search in sources :

Example 96 with MenuItem

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);
}
Also used : MenuItem(android.view.MenuItem) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 97 with 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);
}
Also used : MenuItem(android.view.MenuItem) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 98 with 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);
}
Also used : MenuItem(android.view.MenuItem)

Example 99 with MenuItem

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);
}
Also used : StringHolder(com.mikepenz.materialdrawer.holder.StringHolder) SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) ITypeface(com.mikepenz.iconics.typeface.ITypeface) MenuItem(android.view.MenuItem) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 100 with MenuItem

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();
}
Also used : CustomUrlPrimaryDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.CustomUrlPrimaryDrawerItem) CustomPrimaryDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.CustomPrimaryDrawerItem) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) CustomUrlPrimaryDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.CustomUrlPrimaryDrawerItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) MenuItem(android.view.MenuItem) Drawer(com.mikepenz.materialdrawer.Drawer) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) View(android.view.View) SectionDrawerItem(com.mikepenz.materialdrawer.model.SectionDrawerItem) OverflowMenuDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.OverflowMenuDrawerItem) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) CustomPrimaryDrawerItem(com.mikepenz.materialdrawer.app.drawerItems.CustomPrimaryDrawerItem) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

MenuItem (android.view.MenuItem)713 View (android.view.View)125 Intent (android.content.Intent)75 TextView (android.widget.TextView)66 ImageView (android.widget.ImageView)55 PopupMenu (android.widget.PopupMenu)54 Menu (android.view.Menu)47 SmallTest (android.test.suitebuilder.annotation.SmallTest)42 SearchView (android.support.v7.widget.SearchView)41 RecyclerView (android.support.v7.widget.RecyclerView)32 MenuInflater (android.view.MenuInflater)29 AdapterView (android.widget.AdapterView)27 ListView (android.widget.ListView)27 SubMenu (android.view.SubMenu)26 ComponentName (android.content.ComponentName)25 PackageManager (android.content.pm.PackageManager)24 Parcelable (android.os.Parcelable)23 Toolbar (android.support.v7.widget.Toolbar)19 ResolveInfo (android.content.pm.ResolveInfo)18 Bundle (android.os.Bundle)18