Search in sources :

Example 11 with SubMenu

use of android.view.SubMenu in project c-geo by just-radovan.

the class cgeodetail method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (cache != null && cache.latitude != null && cache.longitude != null) {
        // compass
        menu.add(0, 2, 0, res.getString(R.string.cache_menu_compass)).setIcon(android.R.drawable.ic_menu_compass);
        SubMenu subMenu = menu.addSubMenu(1, 0, 0, res.getString(R.string.cache_menu_navigate)).setIcon(android.R.drawable.ic_menu_more);
        // radar
        subMenu.add(0, 8, 0, res.getString(R.string.cache_menu_radar));
        if (cache != null && cache.reason >= 1 && settings.storeOfflineMaps == 1) {
            // static maps
            subMenu.add(1, 6, 0, res.getString(R.string.cache_menu_map_static));
        }
        // c:geo map
        subMenu.add(0, 1, 0, res.getString(R.string.cache_menu_map));
        if (base.isLocus(activity)) {
            // ext.: locus
            subMenu.add(0, 20, 0, res.getString(R.string.cache_menu_locus));
        }
        if (base.isRmaps(activity)) {
            // ext.: rmaps
            subMenu.add(0, 21, 0, res.getString(R.string.cache_menu_rmaps));
        }
        // ext.: other
        subMenu.add(0, 23, 0, res.getString(R.string.cache_menu_map_ext));
        // turn-by-turn
        subMenu.add(0, 9, 0, res.getString(R.string.cache_menu_tbt));
    }
    if (cache != null && cache.hidden != null && (cache.type.equalsIgnoreCase("event") == true || cache.type.equalsIgnoreCase("mega") == true || cache.type.equalsIgnoreCase("cito") == true)) {
        // add event to calendar
        menu.add(1, 11, 0, res.getString(R.string.cache_menu_event)).setIcon(android.R.drawable.ic_menu_agenda);
    }
    if (settings.isLogin() == true) {
        // log visit
        menu.add(1, 3, 0, res.getString(R.string.cache_menu_visit)).setIcon(android.R.drawable.ic_menu_agenda);
    }
    if (cache != null && cache.spoilers != null && cache.spoilers.size() > 0) {
        // spoiler images
        menu.add(1, 5, 0, res.getString(R.string.cache_menu_spoilers)).setIcon(android.R.drawable.ic_menu_gallery);
    }
    if (cache != null && cache.latitude != null && cache.longitude != null) {
        // caches around
        menu.add(0, 10, 0, res.getString(R.string.cache_menu_around)).setIcon(android.R.drawable.ic_menu_rotate);
    }
    // browser
    menu.add(1, 7, 0, res.getString(R.string.cache_menu_browser)).setIcon(android.R.drawable.ic_menu_info_details);
    // share cache
    menu.add(0, 12, 0, res.getString(R.string.cache_menu_share)).setIcon(android.R.drawable.ic_menu_share);
    return true;
}
Also used : SubMenu(android.view.SubMenu)

Example 12 with SubMenu

use of android.view.SubMenu in project FileExplorer by MiCode.

the class FileViewInteractionHub method onCreateOptionsMenu.

public boolean onCreateOptionsMenu(Menu menu) {
    clearSelection();
    showDropdownNavigation(false);
    // menu.add(0, MENU_SEARCH, 0,
    // R.string.menu_item_search).setOnMenuItemClickListener(
    // menuItemClick);
    addMenuItem(menu, MENU_SELECTALL, 0, R.string.operation_selectall, R.drawable.ic_menu_select_all);
    SubMenu sortMenu = menu.addSubMenu(0, MENU_SORT, 1, R.string.menu_item_sort).setIcon(R.drawable.ic_menu_sort);
    addMenuItem(sortMenu, MENU_SORT_NAME, 0, R.string.menu_item_sort_name);
    addMenuItem(sortMenu, MENU_SORT_SIZE, 1, R.string.menu_item_sort_size);
    addMenuItem(sortMenu, MENU_SORT_DATE, 2, R.string.menu_item_sort_date);
    addMenuItem(sortMenu, MENU_SORT_TYPE, 3, R.string.menu_item_sort_type);
    sortMenu.setGroupCheckable(0, true, true);
    sortMenu.getItem(0).setChecked(true);
    // addMenuItem(menu, GlobalConsts.MENU_PASTE, 2,
    // R.string.operation_paste);
    addMenuItem(menu, GlobalConsts.MENU_NEW_FOLDER, 3, R.string.operation_create_folder, R.drawable.ic_menu_new_folder);
    addMenuItem(menu, GlobalConsts.MENU_FAVORITE, 4, R.string.operation_favorite, R.drawable.ic_menu_delete_favorite);
    addMenuItem(menu, GlobalConsts.MENU_SHOWHIDE, 5, R.string.operation_show_sys, R.drawable.ic_menu_show_sys);
    addMenuItem(menu, MENU_REFRESH, 6, R.string.operation_refresh, R.drawable.ic_menu_refresh);
    addMenuItem(menu, MENU_SETTING, 7, R.string.menu_setting, drawable.ic_menu_preferences);
    addMenuItem(menu, MENU_EXIT, 8, R.string.menu_exit, drawable.ic_menu_close_clear_cancel);
    return true;
}
Also used : SubMenu(android.view.SubMenu)

Example 13 with SubMenu

use of android.view.SubMenu in project HoloEverywhere by Prototik.

the class SupportMenuInflater method parseMenu.

/**
     * Called internally to fill the given menu. If a sub menu is seen, it will
     * call this recursively.
     */
private void parseMenu(XmlPullParser parser, AttributeSet attrs, Menu menu) throws XmlPullParserException, IOException {
    MenuState menuState = new MenuState(menu);
    int eventType = parser.getEventType();
    String tagName;
    boolean lookingForEndOfUnknownTag = false;
    String unknownTagName = null;
    // This loop will skip to the menu start tag
    do {
        if (eventType == XmlPullParser.START_TAG) {
            tagName = parser.getName();
            if (tagName.equals(XML_MENU)) {
                // Go to next tag
                eventType = parser.next();
                break;
            }
            throw new RuntimeException("Expecting menu, got " + tagName);
        }
        eventType = parser.next();
    } while (eventType != XmlPullParser.END_DOCUMENT);
    boolean reachedEndOfMenu = false;
    while (!reachedEndOfMenu) {
        switch(eventType) {
            case XmlPullParser.START_TAG:
                if (lookingForEndOfUnknownTag) {
                    break;
                }
                tagName = parser.getName();
                if (tagName.equals(XML_GROUP)) {
                    menuState.readGroup(attrs);
                } else if (tagName.equals(XML_ITEM)) {
                    menuState.readItem(attrs);
                } else if (tagName.equals(XML_MENU)) {
                    // A menu start tag denotes a submenu for an item
                    SubMenu subMenu = menuState.addSubMenuItem();
                    // Parse the submenu into returned SubMenu
                    parseMenu(parser, attrs, subMenu);
                } else {
                    lookingForEndOfUnknownTag = true;
                    unknownTagName = tagName;
                }
                break;
            case XmlPullParser.END_TAG:
                tagName = parser.getName();
                if (lookingForEndOfUnknownTag && tagName.equals(unknownTagName)) {
                    lookingForEndOfUnknownTag = false;
                    unknownTagName = null;
                } else if (tagName.equals(XML_GROUP)) {
                    menuState.resetGroup();
                } else if (tagName.equals(XML_ITEM)) {
                    // a submenu, it would have been added already)
                    if (!menuState.hasAddedItem()) {
                        if (menuState.itemActionProvider != null && menuState.itemActionProvider.hasSubMenu()) {
                            menuState.addSubMenuItem();
                        } else {
                            menuState.addItem();
                        }
                    }
                } else if (tagName.equals(XML_MENU)) {
                    reachedEndOfMenu = true;
                }
                break;
            case XmlPullParser.END_DOCUMENT:
                throw new RuntimeException("Unexpected end of document");
        }
        eventType = parser.next();
    }
}
Also used : SubMenu(android.view.SubMenu)

Example 14 with SubMenu

use of android.view.SubMenu in project HoloEverywhere by Prototik.

the class BaseMenuWrapper method getSubMenuWrapper.

final SubMenu getSubMenuWrapper(android.view.SubMenu frameworkSubMenu) {
    if (frameworkSubMenu != null) {
        // Instantiate HashMap if null
        if (mSubMenus == null) {
            mSubMenus = new HashMap<android.view.SubMenu, SubMenu>();
        }
        SubMenu compatSubMenu = mSubMenus.get(frameworkSubMenu);
        if (null == compatSubMenu) {
            compatSubMenu = MenuWrapperFactory.createSupportSubMenuWrapper(frameworkSubMenu);
            mSubMenus.put(frameworkSubMenu, compatSubMenu);
        }
        return compatSubMenu;
    }
    return null;
}
Also used : SubMenu(android.view.SubMenu)

Example 15 with SubMenu

use of android.view.SubMenu in project Anki-Android by Ramblurr.

the class Reviewer method onCreateOptionsMenu.

//    @Override
//    public void onConfigurationChanged(Configuration newConfig) {
//        super.onConfigurationChanged(newConfig);
//        setLanguage(mLocale);
//        Log.i(AnkiDroidApp.TAG, "onConfigurationChanged");
//
//        mConfigurationChanged = true;
//
//        long savedTimer = mCardTimer.getBase();
//        CharSequence savedAnswerField = mAnswerField.getText();
//        boolean cardVisible = mCardContainer.getVisibility() == View.VISIBLE;
//        int lookupButtonVis = mLookUpIcon.getVisibility();
//
//        // Reload layout
//        initLayout(R.layout.flashcard);
//
//        if (mRelativeButtonSize != 100) {
//            mFlipCard.setHeight(mButtonHeight);
//            mEase1.setHeight(mButtonHeight);
//            mEase2.setHeight(mButtonHeight);
//            mEase3.setHeight(mButtonHeight);
//            mEase4.setHeight(mButtonHeight);
//        }
//
//        // Modify the card template to indicate the new available width and refresh card
//        mCardTemplate = mCardTemplate.replaceFirst("var availableWidth = \\d*;", "var availableWidth = "
//                + getAvailableWidthInCard() + ";");
//
//        if (typeAnswer()) {
//            mAnswerField.setText(savedAnswerField);
//        }
//        if (mPrefWhiteboard) {
//            mWhiteboard.rotate();
//        }
//        if (mInvertedColors) {
//            invertColors(true);
//        }
//
//        // If the card hasn't loaded yet, don't refresh it
//        // Also skipping the counts (because we don't know which one to underline)
//        // They will be updated when the card loads anyway
//        if (mCurrentCard != null) {
//            if (cardVisible) {
//                fillFlashcard(false);
//                if (mPrefTimer) {
//                    mCardTimer.setBase(savedTimer);
//                    mCardTimer.start();
//                }
//                if (sDisplayAnswer) {
//                    updateForNewCard();
//                }
//            } else {
//                mCardContainer.setVisibility(View.INVISIBLE);
//                switchVisibility(mProgressBars, View.INVISIBLE);
//                switchVisibility(mCardTimer, View.INVISIBLE);
//            }
//            if (sDisplayAnswer) {
//                showEaseButtons();
//            }
//        }
//        mLookUpIcon.setVisibility(lookupButtonVis);
//        mConfigurationChanged = false;
//    }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Resources res = getResources();
    UIUtils.addMenuItemInActionBar(menu, Menu.NONE, MENU_MARK, Menu.NONE, R.string.menu_mark_card, R.drawable.ic_menu_mark);
    UIUtils.addMenuItemInActionBar(menu, Menu.NONE, MENU_UNDO, Menu.NONE, R.string.undo, R.drawable.ic_menu_revert_disabled);
    UIUtils.addMenuItem(menu, Menu.NONE, MENU_EDIT, Menu.NONE, R.string.menu_edit_card, R.drawable.ic_menu_edit);
    if (mPrefWhiteboard) {
        if (mShowWhiteboard) {
            UIUtils.addMenuItemInActionBar(menu, Menu.NONE, MENU_WHITEBOARD, Menu.NONE, R.string.hide_whiteboard, R.drawable.ic_menu_compose);
        } else {
            UIUtils.addMenuItemInActionBar(menu, Menu.NONE, MENU_WHITEBOARD, Menu.NONE, R.string.show_whiteboard, R.drawable.ic_menu_compose);
        }
        UIUtils.addMenuItemInActionBar(menu, Menu.NONE, MENU_CLEAR_WHITEBOARD, Menu.NONE, R.string.clear_whiteboard, R.drawable.ic_menu_clear_playlist);
    }
    SubMenu removeDeckSubMenu = menu.addSubMenu(Menu.NONE, MENU_REMOVE, Menu.NONE, R.string.menu_dismiss_note);
    removeDeckSubMenu.setIcon(R.drawable.ic_menu_stop);
    removeDeckSubMenu.add(Menu.NONE, MENU_REMOVE_BURY_CARD, Menu.NONE, R.string.menu_bury_card);
    removeDeckSubMenu.add(Menu.NONE, MENU_REMOVE_BURY_NOTE, Menu.NONE, R.string.menu_bury_note);
    removeDeckSubMenu.add(Menu.NONE, MENU_REMOVE_SUSPEND_CARD, Menu.NONE, R.string.menu_suspend_card);
    removeDeckSubMenu.add(Menu.NONE, MENU_REMOVE_SUSPEND_NOTE, Menu.NONE, R.string.menu_suspend_note);
    removeDeckSubMenu.add(Menu.NONE, MENU_REMOVE_DELETE, Menu.NONE, R.string.menu_delete_note);
    if (mPrefTextSelection) {
        MenuItem item = menu.add(Menu.NONE, MENU_SEARCH, Menu.NONE, res.getString(R.string.menu_select));
        item.setIcon(R.drawable.ic_menu_search);
        item.setEnabled(Lookup.isAvailable());
    }
    return true;
}
Also used : SubMenu(android.view.SubMenu) MenuItem(android.view.MenuItem) Resources(android.content.res.Resources)

Aggregations

SubMenu (android.view.SubMenu)80 MenuItem (android.view.MenuItem)38 View (android.view.View)11 LayoutInflater (android.view.LayoutInflater)10 PackageManager (android.content.pm.PackageManager)9 Bundle (android.os.Bundle)9 Nullable (android.support.annotation.Nullable)9 ViewGroup (android.view.ViewGroup)9 R (com.simplecity.amp_library.R)9 UpgradeDialog (com.simplecity.amp_library.ui.dialog.UpgradeDialog)9 SelectableViewModel (com.simplecity.amp_library.ui.modelviews.SelectableViewModel)9 ContextualToolbar (com.simplecity.amp_library.ui.views.ContextualToolbar)9 ContextualToolbarHelper (com.simplecity.amp_library.utils.ContextualToolbarHelper)9 MenuUtils (com.simplecity.amp_library.utils.MenuUtils)9 PlaylistUtils (com.simplecity.amp_library.utils.PlaylistUtils)9 ViewModel (com.simplecityapps.recycler_adapter.model.ViewModel)9 Disposable (io.reactivex.disposables.Disposable)9 ResolveInfo (android.content.pm.ResolveInfo)8 MusicUtils (com.simplecity.amp_library.utils.MusicUtils)8 RecyclerListener (com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener)8