use of android.widget.PopupMenu in project SeriesGuide by UweTrottmann.
the class ExtensionsConfigurationFragment method showAddExtensionPopupMenu.
private void showAddExtensionPopupMenu(View anchorView) {
if (addExtensionPopupMenu != null) {
addExtensionPopupMenu.dismiss();
}
addExtensionPopupMenu = new PopupMenu(getActivity(), anchorView);
Menu menu = addExtensionPopupMenu.getMenu();
// list of installed, but disabled extensions
for (int i = 0; i < availableExtensions.size(); i++) {
ExtensionManager.Extension extension = availableExtensions.get(i);
menu.add(Menu.NONE, i + 1, Menu.NONE, extension.label);
}
// no third-party extensions supported on Amazon app store for now
if (!Utils.isAmazonVersion()) {
// link to get more extensions
menu.add(Menu.NONE, 0, Menu.NONE, R.string.action_extensions_search);
}
addExtensionPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(android.view.MenuItem item) {
if (item.getItemId() == 0) {
// special item: search for more extensions
onGetMoreExtensions();
return true;
}
// add to enabled extensions
ExtensionManager.Extension extension = availableExtensions.get(item.getItemId() - 1);
enabledExtensions.add(extension.componentName);
// re-populate extension list
getLoaderManager().restartLoader(ExtensionsConfigurationActivity.LOADER_ACTIONS_ID, null, mExtensionsLoaderCallbacks);
// scroll to end of list
listView.smoothScrollToPosition(adapter.getCount() - 1);
return true;
}
});
addExtensionPopupMenu.show();
}
use of android.widget.PopupMenu in project SeriesGuide by UweTrottmann.
the class MoviesCollectionFragment method onPopupMenuClick.
@Override
public void onPopupMenuClick(View v, final int movieTmdbId) {
PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
popupMenu.getMenu().add(0, CONTEXT_COLLECTION_REMOVE_ID, 0, R.string.action_collection_remove);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case CONTEXT_COLLECTION_REMOVE_ID:
{
MovieTools.removeFromCollection(SgApp.from(getActivity()), movieTmdbId);
return true;
}
}
return false;
}
});
popupMenu.show();
}
use of android.widget.PopupMenu in project SeriesGuide by UweTrottmann.
the class SeasonsFragment method setWatchedToggleState.
private void setWatchedToggleState(int unwatchedEpisodes) {
watchedAllEpisodes = unwatchedEpisodes == 0;
//noinspection ResourceType
buttonWatchedAll.setImageResource(watchedAllEpisodes ? Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatchedAll) : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatchAll));
buttonWatchedAll.setContentDescription(getString(watchedAllEpisodes ? R.string.unmark_all : R.string.mark_all));
// set onClick listener not before here to avoid unexpected actions
buttonWatchedAll.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
if (!watchedAllEpisodes) {
popupMenu.getMenu().add(0, CONTEXT_WATCHED_SHOW_ALL_ID, 0, R.string.mark_all);
}
popupMenu.getMenu().add(0, CONTEXT_WATCHED_SHOW_NONE_ID, 0, R.string.unmark_all);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case CONTEXT_WATCHED_SHOW_ALL_ID:
{
onFlagShowWatched(true);
Utils.trackAction(getActivity(), TAG, "Flag all watched (inline)");
return true;
}
case CONTEXT_WATCHED_SHOW_NONE_ID:
{
onFlagShowWatched(false);
Utils.trackAction(getActivity(), TAG, "Flag all unwatched (inline)");
return true;
}
}
return false;
}
});
popupMenu.show();
}
});
}
use of android.widget.PopupMenu in project xabber-android by redsolution.
the class ChatViewerFragment method showSecurityMenu.
private void showSecurityMenu() {
PopupMenu popup = new PopupMenu(getActivity(), securityButton);
popup.inflate(R.menu.security);
popup.setOnMenuItemClickListener(this);
Menu menu = popup.getMenu();
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
if (securityLevel == SecurityLevel.plain) {
menu.findItem(R.id.action_start_encryption).setVisible(true).setEnabled(SettingsManager.securityOtrMode() != SettingsManager.SecurityOtrMode.disabled);
} else {
menu.findItem(R.id.action_restart_encryption).setVisible(true);
}
boolean isEncrypted = securityLevel != SecurityLevel.plain;
menu.findItem(R.id.action_stop_encryption).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_fingerprint).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_question).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_shared_secret).setEnabled(isEncrypted);
popup.show();
}
use of android.widget.PopupMenu in project xabber-android by redsolution.
the class ChatViewerFragment method onMessageClick.
@Override
public void onMessageClick(View caller, int position) {
int itemViewType = chatMessageAdapter.getItemViewType(position);
if (itemViewType == ChatMessageAdapter.VIEW_TYPE_INCOMING_MESSAGE || itemViewType == ChatMessageAdapter.VIEW_TYPE_OUTGOING_MESSAGE) {
clickedMessageItem = chatMessageAdapter.getMessageItem(position);
PopupMenu popup = new PopupMenu(getActivity(), caller);
popup.inflate(R.menu.chat_context_menu);
popup.setOnMenuItemClickListener(this);
final Menu menu = popup.getMenu();
if (clickedMessageItem.isError()) {
menu.findItem(R.id.action_message_repeat).setVisible(true);
}
if (clickedMessageItem.isUploadFileMessage()) {
menu.findItem(R.id.action_message_copy).setVisible(false);
menu.findItem(R.id.action_message_quote).setVisible(false);
menu.findItem(R.id.action_message_remove).setVisible(false);
}
final File file = clickedMessageItem.getFile();
if (file != null && file.exists()) {
menu.findItem(R.id.action_message_open_file).setVisible(true);
menu.findItem(R.id.action_message_save_file).setVisible(true);
}
if (clickedMessageItem.isIncoming() && MUCManager.getInstance().hasRoom(account, user)) {
menu.findItem(R.id.action_message_open_muc_private_chat).setVisible(true);
}
popup.show();
}
}
Aggregations