Java Code Examples for android.view.ContextMenu#setHeaderTitle()

The following examples show how to use android.view.ContextMenu#setHeaderTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserContextMenuListener.java    From YiBo with Apache License 2.0 7 votes vote down vote up
private void analyzeUserMenu(final Adapter adapter, final User user, ContextMenu menu, final Context context) {
	menu.setHeaderTitle(R.string.menu_title_blog);
    int order = 0;

    MenuItem commentMenu = menu.add(0, 1, order++, R.string.menu_group_member_user_profile);
    Intent commentIntent = new Intent(context, ProfileActivity.class);
    commentIntent.putExtra("USER", user);
    commentMenu.setIntent(commentIntent);

    MenuItem unfollowMenu = menu.add(0, 2, order++, R.string.menu_group_member_unfollow);
    unfollowMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			CacheAdapter<User> cacheAdapter = (CacheAdapter<User>)AdapterUtil.getCacheAdapter(adapter);
			GroupMemberUnfollowTask task = new GroupMemberUnfollowTask(cacheAdapter, user);
			task.execute();
			return false;
		}
    });
    
    MenuItem messageMenu = menu.add(0, 2, order++, R.string.menu_group_member_message);
    Intent messageIntent = new Intent(context, EditDirectMessageActivity.class);
    messageIntent.putExtra("DISPLAY_NAME", user.getDisplayName());
	messageMenu.setIntent(messageIntent);
}
 
Example 2
Source File: AuthenticatorActivity.java    From google-authenticator-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
  super.onCreateContextMenu(menu, v, menuInfo);
  AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
  PinInfo selectedUser = users[(int) info.id];
  getMenuInflater().inflate(R.menu.account_list_context, menu);
  menu.setHeaderTitle(selectedUser.getIndex().getStrippedName());

  if (!isRenameAccountAvailableSupported(selectedUser)) {
    menu.removeItem(R.id.rename);
  }

  if (!isCheckAccountKeyValueSupported(selectedUser)) {
    menu.removeItem(R.id.check_code);
  }

  mostRecentContextMenu = menu;
}
 
Example 3
Source File: EnterTreatment.java    From HAPP with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterView.AdapterContextMenuInfo aInfo = (AdapterView.AdapterContextMenuInfo) menuInfo;

    // We know that each row in the adapter is a Map
    HashMap map =  (HashMap) adapter.getItem(aInfo.position);

    selectedListItemDB_ID   = map.get("id").toString();
    selectedListItemID      = (HashMap) adapter.getItem(aInfo.position);
    if (map.get(Constants.treatments.TYPE).equals(Constants.treatments.CORRECTION) || map.get(Constants.treatments.TYPE).equals(Constants.treatments.BOLUS)){
        selectedListType = Constants.treatments.BOLUS;
        menu.setHeaderTitle(tools.formatDisplayInsulin(Double.parseDouble(map.get("value").toString()),2) + " " + map.get(Constants.treatments.TYPE));
    } else {
        selectedListType = Constants.treatments.CARBS;
        menu.setHeaderTitle(tools.formatDisplayCarbs(Double.parseDouble(map.get("value").toString())) + " " + map.get(Constants.treatments.TYPE));
    }

    menu.add(1, 1, 1, "Edit");
    menu.add(1, 2, 2, "Delete");
    menu.add(1, 3, 3, "Integration Details");
}
 
Example 4
Source File: MainActivity.java    From example with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
		ContextMenuInfo menuInfo) {
	try {
		// Criação do popup menu com as opções que termos sobre
		// nossos Contatos

		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
		if (!blnShort) {
			posicao = info.position;
		}
		blnShort = false;

		menu.setHeaderTitle("Selecione:");
		// a origem dos dados do menu está definido no arquivo arrays.xml
		String[] menuItems = getResources().getStringArray(R.array.menu);
		for (int i = 0; i < menuItems.length; i++) {
			menu.add(Menu.NONE, i, i, menuItems[i]);
		}
	} catch (Exception e) {
		trace("Erro : " + e.getMessage());
	}
}
 
Example 5
Source File: AllTasksListFragment.java    From ActivityLauncher with ISC License 6 votes vote down vote up
@Override
public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v,
                                ContextMenuInfo menuInfo) {
    menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut);
    menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch);

    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    ExpandableListView list = getView().findViewById(R.id.expandableListView1);

    switch (ExpandableListView.getPackedPositionType(info.packedPosition)) {
        case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
            MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
            menu.setHeaderIcon(activity.icon);
            menu.setHeaderTitle(activity.name);
            menu.add(Menu.NONE, 2, Menu.NONE, R.string.context_action_edit);
            break;
        case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
            MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
            menu.setHeaderIcon(pack.icon);
            menu.setHeaderTitle(pack.name);
            break;
    }

    super.onCreateContextMenu(menu, v, menuInfo);
}
 
Example 6
Source File: ManageAccountActivity.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ManageAccountActivity.this.getMenuInflater().inflate(
            R.menu.manageaccounts_context, menu);
    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
    this.selectedAccount = accountList.get(acmi.position);
    if (this.selectedAccount.isEnabled()) {
        menu.findItem(R.id.mgmt_account_enable).setVisible(false);
        menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(Config.supportOpenPgp());
    } else {
        menu.findItem(R.id.mgmt_account_disable).setVisible(false);
        menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(false);
        menu.findItem(R.id.mgmt_account_publish_avatar).setVisible(false);
    }
    menu.setHeaderTitle(this.selectedAccount.getJid().asBareJid().toEscapedString());
}
 
Example 7
Source File: SudokuListActivity.java    From opensudoku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {
        info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuInfo", e);
        return;
    }

    Cursor cursor = (Cursor) mListView.getAdapter().getItem(info.position);
    if (cursor == null) {
        // For some reason the requested item isn't available, do nothing
        return;
    }

    menu.setHeaderTitle("Puzzle");

    // Add a menu item to delete the note
    menu.add(0, MENU_ITEM_PLAY, 0, R.string.play_puzzle);
    menu.add(0, MENU_ITEM_EDIT_NOTE, 1, R.string.edit_note);
    menu.add(0, MENU_ITEM_RESET, 2, R.string.reset_puzzle);
    menu.add(0, MENU_ITEM_EDIT, 3, R.string.edit_puzzle);
    menu.add(0, MENU_ITEM_DELETE, 4, R.string.delete_puzzle);
}
 
Example 8
Source File: ChooseSyncGroupedContextMenuHelper.java    From PADListener with GNU General Public License v2.0 6 votes vote down vote up
private void createContextMenuForGroup(ContextMenu menu, ContextMenu.ContextMenuInfo menuInfo) {
	MyLog.entry("menuInfo = " + menuInfo);

	final MonsterInfoModel monsterInfo = getGroupMonsterItem(menuInfo);

	menu.setHeaderTitle(getContext().getString(R.string.choose_sync_context_menu_all_title, monsterInfo.getName()));
	menu.add(getGroupId(), MENU_ID_DESELECT_ALL, 0, R.string.choose_sync_context_menu_all_deselect);
	menu.add(getGroupId(), MENU_ID_SELECT_ALL, 0, R.string.choose_sync_context_menu_all_select);

	if (getMode() != SyncMode.DELETED) {
		menu.add(getGroupId(), MENU_ID_CHANGE_PRIORITY_ALL, 0, R.string.choose_sync_context_menu_all_change_priority);
		menu.add(getGroupId(), MENU_ID_CHANGE_NOTE_ALL, 0, R.string.choose_sync_context_menu_all_change_note);
	}

	if (new DefaultSharedPreferencesHelper(getContext()).isChooseSyncUseIgnoreListForMonsters(getMode())) {
		menu.add(getGroupId(), MENU_ID_ADD_TO_IGNORE_LIST, 0, R.string.choose_sync_context_menu_all_add_to_ignore_list);
	}

	MyLog.exit();
}
 
Example 9
Source File: MainMenu.java    From MifareClassicTool with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Add the menu with the tools.
 * It will be shown if the user clicks on "Tools".
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
            ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    menu.setHeaderTitle(R.string.dialog_tools_menu_title);
    menu.setHeaderIcon(android.R.drawable.ic_menu_preferences);
    inflater.inflate(R.menu.tools, menu);
    // Enable/Disable tag info tool depending on NFC availability.
    menu.findItem(R.id.menuMainTagInfo).setEnabled(
            !Common.useAsEditorOnly());
    // Enable/Disable UID clone info tool depending on NFC availability.
    menu.findItem(R.id.menuMainCloneUidTool).setEnabled(
            !Common.useAsEditorOnly());
    // Enable/Disable diff tool depending on write permissions.
    menu.findItem(R.id.menuMainDiffTool).setEnabled(
            Common.hasWritePermissionToExternalStorage(this));
}
 
Example 10
Source File: PlaylistsFragment.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterContextMenuInfo mi = (AdapterContextMenuInfo)menuInfo;
    menu.add(mFragmentGroupId, PLAY_SELECTION, 0, getResources().getString(R.string.play_all));
    if (mi.id >= 0) {
        menu.add(mFragmentGroupId, RENAME_PLAYLIST, 0, getResources().getString(R.string.rename_playlist));
        menu.add(mFragmentGroupId, DELETE_PLAYLIST, 0, getResources().getString(R.string.delete_playlist));
    }
    mCurrentId = mCursor.getString(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
    String title = mCursor.getString(mCursor.getColumnIndexOrThrow(PlaylistsColumns.NAME));
    menu.setHeaderTitle(title);
}
 
Example 11
Source File: SearchActivity.java    From HayaiLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (menuInfo instanceof AdapterContextMenuInfo) {
        AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo) menuInfo;
        menu.setHeaderTitle(
                ((LaunchableActivity) adapterMenuInfo.targetView
                        .findViewById(R.id.appIcon).getTag()).getActivityLabel());
    }
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.app, menu);
}
 
Example 12
Source File: AppAdapter.java    From NanoIconPack with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
    contextMenu.setHeaderTitle(dataList.get(contextMenuActiveItemPos).getLabel());
    contextMenu.add(Menu.NONE, 0, Menu.NONE, R.string.menu_request_icon);
    contextMenu.add(Menu.NONE, 1, Menu.NONE, R.string.menu_copy_code);
    contextMenu.add(Menu.NONE, 2, Menu.NONE, R.string.menu_save_icon);
    contextMenu.getItem(0).setOnMenuItemClickListener(this);
    contextMenu.getItem(1).setOnMenuItemClickListener(this);
    contextMenu.getItem(2).setOnMenuItemClickListener(this);

    contextMenu.getItem(0).setVisible(enableStatsModule);
}
 
Example 13
Source File: OPDSActivity.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
protected void onCreateLinkContextMenu(final ContextMenu menu, final Book book, final Link link) {
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.opds_bookmenu, menu);

    menu.setHeaderTitle(book.title);
    ActionMenuHelper.setMenuParameters(getController(), menu, new Constant("book", book),
            new Constant("link", link));
}
 
Example 14
Source File: FragmentWalletsAbstract.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    menu.setHeaderTitle(R.string.wallet_menu_title);
    menu.add(0, 200, 0, R.string.wallet_menu_changename);
    menu.add(0, 201, 0, R.string.wallet_menu_copyadd);
    menu.add(0, 202, 0, R.string.wallet_menu_share);
    menu.add(0, 203, 0, R.string.wallet_menu_export);
    menu.add(0, 204, 0, R.string.wallet_menu_private_key);
    menu.add(0, 205, 0, R.string.wallet_menu_delete);
}
 
Example 15
Source File: SavedTextsList.java    From Document-Scanner with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    int id = v.getId();
    if (id == R.id.listText) {
        menu.setHeaderTitle("Manage Saved Texts");
        String[] menuItems = getResources().getStringArray(R.array.manage_text);
        for (int i = 0; i < menuItems.length; i++) {
            menu.add(Menu.NONE, i, i, menuItems[i]);
        }
    }
}
 
Example 16
Source File: OPDSActivity.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
protected void onCreateBookContextMenu(final ContextMenu menu, final Book book) {
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.opds_bookmenu, menu);

    menu.setHeaderTitle(book.title);
    ActionMenuHelper.setMenuParameters(getController(), menu, new Constant("book", book));
}
 
Example 17
Source File: OOM.java    From Kernel-Tuner with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
		ContextMenuInfo menuInfo) {
	super.onCreateContextMenu(menu, v, menuInfo);

	menu.setHeaderTitle(getResources().getString(R.string.oom_preset));
	menu.setHeaderIcon(R.drawable.swap);
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.oom_context_menu, menu);
}
 
Example 18
Source File: ForecastDetailsActivity.java    From PressureNet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
  if (v.getId()==R.id.listForecastAlerts) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
    menu.setHeaderTitle("Alert Options");
    String[] menuItems = {"Delete", "Close"};
    for (int i = 0; i<menuItems.length; i++) {
      menu.add(Menu.NONE, i, i, menuItems[i]);
    }
  }
}
 
Example 19
Source File: FilterRulesFragment.java    From NekoSMS with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.context_filter_rules, menu);
    menu.setHeaderTitle(R.string.filter_actions);
}
 
Example 20
Source File: AppListFragment.java    From Shelter with Do What The F*ck You Want To Public License 4 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (mSelectedApp == null) return;

    if (mIsRemote) {
        if (!mSelectedApp.isSystem())
            menu.add(Menu.NONE, MENU_ITEM_CLONE, Menu.NONE, R.string.clone_to_main_profile);
        // Freezing / Unfreezing is only available in profiles that we can control
        if (mSelectedApp.isHidden()) {
            menu.add(Menu.NONE, MENU_ITEM_UNFREEZE, Menu.NONE, R.string.unfreeze_app);
            menu.add(Menu.NONE, MENU_ITEM_LAUNCH, Menu.NONE, R.string.unfreeze_and_launch);
        } else {
            menu.add(Menu.NONE, MENU_ITEM_FREEZE, Menu.NONE, R.string.freeze_app);
            menu.add(Menu.NONE, MENU_ITEM_LAUNCH, Menu.NONE, R.string.launch);
        }
        // Cross-profile widget settings is also limited to work profile
        MenuItem crossProfileWdiegt =
                menu.add(Menu.NONE, MENU_ITEM_ALLOW_CROSS_PROFILE_WIDGET, Menu.NONE,
                        R.string.allow_cross_profile_widgets);
        crossProfileWdiegt.setCheckable(true);
        crossProfileWdiegt.setChecked(
                mCrossProfileWidgetProviders.contains(mSelectedApp.getPackageName()));

        // TODO: If we implement God Mode (i.e. Shelter as device owner), we should
        // TODO: use two different lists to store auto freeze apps because we'll be
        // TODO: able to freeze apps in main profile.
        MenuItem autoFreeze = menu.add(Menu.NONE, MENU_ITEM_AUTO_FREEZE, Menu.NONE, R.string.auto_freeze);
        autoFreeze.setCheckable(true);
        autoFreeze.setChecked(
                LocalStorageManager.getInstance().stringListContains(
                        LocalStorageManager.PREF_AUTO_FREEZE_LIST_WORK_PROFILE, mSelectedApp.getPackageName()));
        menu.add(Menu.NONE, MENU_ITEM_CREATE_UNFREEZE_SHORTCUT, Menu.NONE, R.string.create_unfreeze_shortcut);
    } else {
        menu.add(Menu.NONE, MENU_ITEM_CLONE, Menu.NONE, R.string.clone_to_work_profile);
    }

    if (!mSelectedApp.isSystem()) {
        // We can't uninstall system apps in both cases
        // but we'll be able to "freeze" them
        menu.add(Menu.NONE, MENU_ITEM_UNINSTALL, Menu.NONE, R.string.uninstall_app);
    }

    if (menu.size() > 0) {
        // Only set title when the menu is not empty
        // this ensures that no menu will be shown
        // if no operation available
        menu.setHeaderTitle(
                getString(R.string.app_context_menu_title, mSelectedApp.getLabel()));
    }
}