Search in sources :

Example 36 with SubMenu

use of android.view.SubMenu in project android_frameworks_base by crdroidandroid.

the class Editor method onCreateContextMenu.

void onCreateContextMenu(ContextMenu menu) {
    if (mIsBeingLongClicked || Float.isNaN(mContextMenuAnchorX) || Float.isNaN(mContextMenuAnchorY)) {
        return;
    }
    final int offset = mTextView.getOffsetForPosition(mContextMenuAnchorX, mContextMenuAnchorY);
    if (offset == -1) {
        return;
    }
    stopTextActionModeWithPreservingSelection();
    final boolean isOnSelection = mTextView.hasSelection() && offset >= mTextView.getSelectionStart() && offset <= mTextView.getSelectionEnd();
    if (!isOnSelection) {
        // Right clicked position is not on the selection. Remove the selection and move the
        // cursor to the right clicked position.
        Selection.setSelection((Spannable) mTextView.getText(), offset);
        stopTextActionMode();
    }
    if (shouldOfferToShowSuggestions()) {
        final SuggestionInfo[] suggestionInfoArray = new SuggestionInfo[SuggestionSpan.SUGGESTIONS_MAX_SIZE];
        for (int i = 0; i < suggestionInfoArray.length; i++) {
            suggestionInfoArray[i] = new SuggestionInfo();
        }
        final SubMenu subMenu = menu.addSubMenu(Menu.NONE, Menu.NONE, MENU_ITEM_ORDER_REPLACE, com.android.internal.R.string.replace);
        final int numItems = mSuggestionHelper.getSuggestionInfo(suggestionInfoArray, null);
        for (int i = 0; i < numItems; i++) {
            final SuggestionInfo info = suggestionInfoArray[i];
            subMenu.add(Menu.NONE, Menu.NONE, i, info.mText).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    replaceWithSuggestion(info);
                    return true;
                }
            });
        }
    }
    menu.add(Menu.NONE, TextView.ID_UNDO, MENU_ITEM_ORDER_UNDO, com.android.internal.R.string.undo).setAlphabeticShortcut('z').setOnMenuItemClickListener(mOnContextMenuItemClickListener).setEnabled(mTextView.canUndo());
    menu.add(Menu.NONE, TextView.ID_REDO, MENU_ITEM_ORDER_REDO, com.android.internal.R.string.redo).setOnMenuItemClickListener(mOnContextMenuItemClickListener).setEnabled(mTextView.canRedo());
    menu.add(Menu.NONE, TextView.ID_CUT, MENU_ITEM_ORDER_CUT, com.android.internal.R.string.cut).setAlphabeticShortcut('x').setOnMenuItemClickListener(mOnContextMenuItemClickListener).setEnabled(mTextView.canCut());
    menu.add(Menu.NONE, TextView.ID_COPY, MENU_ITEM_ORDER_COPY, com.android.internal.R.string.copy).setAlphabeticShortcut('c').setOnMenuItemClickListener(mOnContextMenuItemClickListener).setEnabled(mTextView.canCopy());
    menu.add(Menu.NONE, TextView.ID_PASTE, MENU_ITEM_ORDER_PASTE, com.android.internal.R.string.paste).setAlphabeticShortcut('v').setEnabled(mTextView.canPaste()).setOnMenuItemClickListener(mOnContextMenuItemClickListener);
    menu.add(Menu.NONE, TextView.ID_PASTE, MENU_ITEM_ORDER_PASTE_AS_PLAIN_TEXT, com.android.internal.R.string.paste_as_plain_text).setEnabled(mTextView.canPaste()).setOnMenuItemClickListener(mOnContextMenuItemClickListener);
    menu.add(Menu.NONE, TextView.ID_SHARE, MENU_ITEM_ORDER_SHARE, com.android.internal.R.string.share).setEnabled(mTextView.canShare()).setOnMenuItemClickListener(mOnContextMenuItemClickListener);
    menu.add(Menu.NONE, TextView.ID_SELECT_ALL, MENU_ITEM_ORDER_SELECT_ALL, com.android.internal.R.string.selectAll).setAlphabeticShortcut('a').setEnabled(mTextView.canSelectAllText()).setOnMenuItemClickListener(mOnContextMenuItemClickListener);
    mPreserveSelection = true;
}
Also used : SubMenu(android.view.SubMenu) MenuItem(android.view.MenuItem) Paint(android.graphics.Paint)

Example 37 with SubMenu

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

the class cgeopoint method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // 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, 3, 0, res.getString(R.string.cache_menu_radar));
    // 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, 4, 0, res.getString(R.string.cache_menu_tbt));
    // caches around
    menu.add(0, 5, 0, res.getString(R.string.cache_menu_around)).setIcon(android.R.drawable.ic_menu_rotate);
    return true;
}
Also used : SubMenu(android.view.SubMenu)

Example 38 with SubMenu

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

the class cgeopopup method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // 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, 3, 0, res.getString(R.string.cache_menu_radar));
    // 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, 4, 0, res.getString(R.string.cache_menu_tbt));
    // log visit
    menu.add(0, 6, 0, res.getString(R.string.cache_menu_visit)).setIcon(android.R.drawable.ic_menu_agenda);
    // caches around
    menu.add(0, 5, 0, res.getString(R.string.cache_menu_around)).setIcon(android.R.drawable.ic_menu_rotate);
    // browser
    menu.add(0, 7, 0, res.getString(R.string.cache_menu_browser)).setIcon(android.R.drawable.ic_menu_info_details);
    return true;
}
Also used : SubMenu(android.view.SubMenu)

Example 39 with SubMenu

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

the class cgeocaches method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    SubMenu subMenuFilter = menu.addSubMenu(0, 105, 0, res.getString(R.string.caches_filter)).setIcon(android.R.drawable.ic_menu_search);
    subMenuFilter.setHeaderTitle(res.getString(R.string.caches_filter_title));
    subMenuFilter.add(0, 21, 0, res.getString(R.string.caches_filter_type));
    subMenuFilter.add(0, 22, 0, res.getString(R.string.caches_filter_size));
    subMenuFilter.add(0, 23, 0, res.getString(R.string.caches_filter_track));
    subMenuFilter.add(0, 24, 0, res.getString(R.string.caches_filter_clear));
    SubMenu subMenuSort = menu.addSubMenu(0, 104, 0, res.getString(R.string.caches_sort)).setIcon(android.R.drawable.ic_menu_sort_alphabetically);
    subMenuSort.setHeaderTitle(res.getString(R.string.caches_sort_title));
    // sort the context menu labels alphabetically for easier reading
    HashMap<String, Integer> comparators = new HashMap<String, Integer>();
    comparators.put(res.getString(R.string.caches_sort_distance), 10);
    comparators.put(res.getString(R.string.caches_sort_difficulty), 11);
    comparators.put(res.getString(R.string.caches_sort_terrain), 12);
    comparators.put(res.getString(R.string.caches_sort_size), 13);
    comparators.put(res.getString(R.string.caches_sort_favorites), 14);
    comparators.put(res.getString(R.string.caches_sort_name), 15);
    comparators.put(res.getString(R.string.caches_sort_gccode), 16);
    comparators.put(res.getString(R.string.caches_sort_rating), 18);
    comparators.put(res.getString(R.string.caches_sort_vote), 19);
    comparators.put(res.getString(R.string.caches_sort_inventory), 20);
    ArrayList<String> sortedLabels = new ArrayList<String>(comparators.keySet());
    Collections.sort(sortedLabels);
    for (String label : sortedLabels) {
        Integer id = comparators.get(label);
        subMenuSort.add(1, id, 0, label).setCheckable(true).setChecked(id == 10);
    }
    subMenuSort.setGroupCheckable(1, true, true);
    menu.add(0, 0, 0, res.getString(R.string.caches_select_mode)).setIcon(android.R.drawable.ic_menu_agenda);
    menu.add(0, 9, 0, res.getString(R.string.caches_select_invert)).setIcon(android.R.drawable.ic_menu_agenda);
    if (type.equals("offline") == true) {
        SubMenu subMenu = menu.addSubMenu(0, 103, 0, res.getString(R.string.caches_manage)).setIcon(android.R.drawable.ic_menu_save);
        // delete saved caches
        subMenu.add(0, 5, 0, res.getString(R.string.caches_drop_all));
        // download details for all caches
        subMenu.add(0, 1, 0, res.getString(R.string.cache_offline_refresh));
        // import gpx file
        menu.add(0, 6, 0, res.getString(R.string.gpx_import_title)).setIcon(android.R.drawable.ic_menu_upload);
    } else {
        // download details for all caches
        menu.add(0, 1, 0, res.getString(R.string.caches_store_offline)).setIcon(android.R.drawable.ic_menu_set_as);
    }
    final Intent intentTest = new Intent(Intent.ACTION_VIEW);
    intentTest.setData(Uri.parse("menion.points:x"));
    if (cgBase.isIntentAvailable(activity, intentTest) == true) {
        SubMenu subMenu = menu.addSubMenu(0, 101, 0, res.getString(R.string.caches_on_map)).setIcon(android.R.drawable.ic_menu_mapmode);
        // show all caches on map using c:geo
        subMenu.add(0, 2, 0, res.getString(R.string.caches_map_cgeo));
        // show all caches on map using Locus
        subMenu.add(0, 3, 0, res.getString(R.string.caches_map_locus));
    } else {
        // show all caches on map
        menu.add(0, 2, 0, res.getString(R.string.caches_on_map)).setIcon(android.R.drawable.ic_menu_mapmode);
    }
    if (type.equals("offline") == true) {
        SubMenu subMenu = menu.addSubMenu(0, 102, 0, res.getString(R.string.list_menu)).setIcon(android.R.drawable.ic_menu_more);
        subMenu.add(0, 7, 0, res.getString(R.string.list_menu_create));
        subMenu.add(0, 8, 0, res.getString(R.string.list_menu_drop));
        subMenu.add(0, 17, 0, res.getString(R.string.list_menu_change));
    }
    return true;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SubMenu(android.view.SubMenu) Intent(android.content.Intent)

Example 40 with SubMenu

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

the class cgeocaches method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo info) {
    super.onCreateContextMenu(menu, view, info);
    if (adapter == null) {
        return;
    }
    AdapterContextMenuInfo adapterInfo = null;
    try {
        adapterInfo = (AdapterContextMenuInfo) info;
    } catch (Exception e) {
        Log.w(cgSettings.tag, "cgeocaches.onCreateContextMenu: " + e.toString());
    }
    if ((adapterInfo == null || adapterInfo.position < 0) && selectedFilter != null) {
        if (selectedFilter.equals(res.getString(R.string.caches_filter_size))) {
            menu.setHeaderTitle(res.getString(R.string.caches_filter_size_title));
            menu.add(0, 8, 0, res.getString(R.string.caches_filter_size_micro));
            menu.add(0, 9, 0, res.getString(R.string.caches_filter_size_small));
            menu.add(0, 10, 0, res.getString(R.string.caches_filter_size_regular));
            menu.add(0, 11, 0, res.getString(R.string.caches_filter_size_large));
            menu.add(0, 12, 0, res.getString(R.string.caches_filter_size_other));
            menu.add(0, 13, 0, res.getString(R.string.caches_filter_size_virtual));
            menu.add(0, 14, 0, res.getString(R.string.caches_filter_size_notchosen));
        } else if (selectedFilter.equals(res.getString(R.string.caches_filter_type))) {
            menu.setHeaderTitle(res.getString(R.string.caches_filter_type_title));
            menu.add(0, 15, 0, res.getString(R.string.caches_filter_type_traditional));
            menu.add(0, 16, 0, res.getString(R.string.caches_filter_type_multi));
            menu.add(0, 17, 0, res.getString(R.string.caches_filter_type_mystery));
            menu.add(0, 18, 0, res.getString(R.string.caches_filter_type_letterbox));
            menu.add(0, 19, 0, res.getString(R.string.caches_filter_type_event));
            menu.add(0, 20, 0, res.getString(R.string.caches_filter_type_mega));
            menu.add(0, 21, 0, res.getString(R.string.caches_filter_type_earth));
            menu.add(0, 22, 0, res.getString(R.string.caches_filter_type_cito));
            menu.add(0, 23, 0, res.getString(R.string.caches_filter_type_webcam));
            menu.add(0, 24, 0, res.getString(R.string.caches_filter_type_virtual));
            menu.add(0, 25, 0, res.getString(R.string.caches_filter_type_wherigo));
            menu.add(0, 26, 0, res.getString(R.string.caches_filter_type_lostfound));
            menu.add(0, 27, 0, res.getString(R.string.caches_filter_type_ape));
            menu.add(0, 28, 0, res.getString(R.string.caches_filter_type_gchq));
            menu.add(0, 29, 0, res.getString(R.string.caches_filter_type_gps));
        }
    } else {
        final cgCache cache = adapter.getItem(adapterInfo.position);
        if (cache.name != null && cache.name.length() > 0) {
            menu.setHeaderTitle(cache.name);
        } else {
            menu.setHeaderTitle(cache.geocode);
        }
        if (cache.latitude != null && cache.longitude != null) {
            menu.add(0, 1, 0, res.getString(R.string.cache_menu_compass));
            menu.add(0, 2, 0, res.getString(R.string.cache_menu_radar));
            menu.add(0, 3, 0, res.getString(R.string.cache_menu_map));
            menu.add(0, 4, 0, res.getString(R.string.cache_menu_map_ext));
            menu.add(0, 5, 0, res.getString(R.string.cache_menu_tbt));
            menu.add(0, 6, 0, res.getString(R.string.cache_menu_visit));
            menu.add(0, 7, 0, res.getString(R.string.cache_menu_details));
        }
    }
    ArrayList<cgList> cacheLists = app.getLists();
    int listCount = cacheLists.size();
    if (listCount > 1) {
        SubMenu submenu = menu.addSubMenu(0, 8, 0, res.getString(R.string.cache_menu_move_list));
        for (int i = 0; i < listCount; i++) {
            cgList list = cacheLists.get(i);
            submenu.add(Menu.NONE, 100 + list.id, Menu.NONE, list.title);
        }
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) SubMenu(android.view.SubMenu)

Aggregations

SubMenu (android.view.SubMenu)64 MenuItem (android.view.MenuItem)25 PackageManager (android.content.pm.PackageManager)9 ResolveInfo (android.content.pm.ResolveInfo)8 TextView (android.widget.TextView)8 AdapterView (android.widget.AdapterView)7 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 Paint (android.graphics.Paint)5 ArrayList (java.util.ArrayList)5 Cursor (android.database.Cursor)3 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 PopupMenu (android.support.v7.widget.PopupMenu)2 RecyclerView (android.support.v7.widget.RecyclerView)2 MenuInflater (android.view.MenuInflater)2 View (android.view.View)2 Playlist (com.simplecity.amp_library.model.Playlist)2 TargetApi (android.annotation.TargetApi)1 ProgressDialog (android.app.ProgressDialog)1