Search in sources :

Example 76 with PopupMenu

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();
}
Also used : PopupMenu(android.widget.PopupMenu) Menu(android.view.Menu) Point(android.graphics.Point) PopupMenu(android.widget.PopupMenu) MenuItem(android.view.MenuItem)

Example 77 with PopupMenu

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();
}
Also used : MenuItem(android.view.MenuItem) PopupMenu(android.widget.PopupMenu)

Example 78 with PopupMenu

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();
        }
    });
}
Also used : OnClickListener(android.view.View.OnClickListener) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) PopupMenu(android.widget.PopupMenu)

Example 79 with PopupMenu

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();
}
Also used : SecurityLevel(com.xabber.android.data.extension.otr.SecurityLevel) PopupMenu(android.widget.PopupMenu) Menu(android.view.Menu) PopupMenu(android.widget.PopupMenu)

Example 80 with PopupMenu

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();
    }
}
Also used : PopupMenu(android.widget.PopupMenu) Menu(android.view.Menu) File(java.io.File) PopupMenu(android.widget.PopupMenu)

Aggregations

PopupMenu (android.widget.PopupMenu)99 MenuItem (android.view.MenuItem)60 View (android.view.View)44 TextView (android.widget.TextView)41 ImageView (android.widget.ImageView)30 RecyclerView (android.support.v7.widget.RecyclerView)22 TargetApi (android.annotation.TargetApi)20 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)19 Test (org.junit.Test)19 ShadowPopupMenu (org.robolectric.shadows.ShadowPopupMenu)19 RoboMenuItem (org.robolectric.fakes.RoboMenuItem)18 Intent (android.content.Intent)14 Context (android.content.Context)12 DialogAction (com.afollestad.materialdialogs.DialogAction)12 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)12 MenuInflater (android.view.MenuInflater)10 AdapterView (android.widget.AdapterView)10 ListView (android.widget.ListView)10 Menu (android.view.Menu)9 NonNull (android.support.annotation.NonNull)8