Search in sources :

Example 81 with PopupMenu

use of android.widget.PopupMenu in project xabber-android by redsolution.

the class ContactListFragment method onAccountMenuClick.

@Override
public void onAccountMenuClick(View view, final String account) {
    PopupMenu popup = new PopupMenu(getActivity(), view);
    popup.inflate(R.menu.account);
    ContextMenuHelper.setUpAccountMenu(getActivity(), adapter, account, popup.getMenu());
    popup.show();
}
Also used : PopupMenu(android.widget.PopupMenu)

Example 82 with PopupMenu

use of android.widget.PopupMenu in project xabber-android by redsolution.

the class AccountInfoEditorFragment method changeAvatar.

private void changeAvatar() {
    PopupMenu menu = new PopupMenu(getActivity(), changeAvatarButton);
    menu.inflate(R.menu.change_avatar);
    menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch(item.getItemId()) {
                case R.id.action_choose_from_gallery:
                    onChooseFromGalleryClick();
                    return true;
                case R.id.action_take_photo:
                    onTakePhotoClick();
                    return true;
                case R.id.action_remove_avatar:
                    removeAvatar();
                    return true;
                default:
                    return false;
            }
        }
    });
    menu.show();
}
Also used : MenuItem(android.view.MenuItem) PopupMenu(android.widget.PopupMenu)

Example 83 with PopupMenu

use of android.widget.PopupMenu in project RxBinding by JakeWharton.

the class RxPopupMenuTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View anchor = new View(this);
    setContentView(anchor);
    popupMenu = new PopupMenu(this, anchor);
}
Also used : View(android.view.View) PopupMenu(android.widget.PopupMenu)

Example 84 with PopupMenu

use of android.widget.PopupMenu in project Gadgetbridge by Freeyourgadget.

the class AbstractAppManagerFragment method openPopupMenu.

public boolean openPopupMenu(View view, int position) {
    PopupMenu popupMenu = new PopupMenu(getContext(), view);
    popupMenu.getMenuInflater().inflate(R.menu.appmanager_context, popupMenu.getMenu());
    Menu menu = popupMenu.getMenu();
    final GBDeviceApp selectedApp = appList.get(position);
    if (!selectedApp.isInCache()) {
        menu.removeItem(R.id.appmanager_app_reinstall);
        menu.removeItem(R.id.appmanager_app_delete_cache);
    }
    if (!PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) {
        menu.removeItem(R.id.appmanager_health_activate);
        menu.removeItem(R.id.appmanager_health_deactivate);
    }
    if (!PebbleProtocol.UUID_WORKOUT.equals(selectedApp.getUUID())) {
        menu.removeItem(R.id.appmanager_hrm_activate);
        menu.removeItem(R.id.appmanager_hrm_deactivate);
    }
    if (!PebbleProtocol.UUID_WEATHER.equals(selectedApp.getUUID())) {
        menu.removeItem(R.id.appmanager_weather_activate);
        menu.removeItem(R.id.appmanager_weather_deactivate);
        menu.removeItem(R.id.appmanager_weather_install_provider);
    }
    if (selectedApp.getType() == GBDeviceApp.Type.APP_SYSTEM || selectedApp.getType() == GBDeviceApp.Type.WATCHFACE_SYSTEM) {
        menu.removeItem(R.id.appmanager_app_delete);
    }
    if (!selectedApp.isConfigurable()) {
        menu.removeItem(R.id.appmanager_app_configure);
    }
    if (PebbleProtocol.UUID_WEATHER.equals(selectedApp.getUUID())) {
        PackageManager pm = getActivity().getPackageManager();
        try {
            pm.getPackageInfo("ru.gelin.android.weather.notification", PackageManager.GET_ACTIVITIES);
            menu.removeItem(R.id.appmanager_weather_install_provider);
        } catch (PackageManager.NameNotFoundException e) {
            menu.removeItem(R.id.appmanager_weather_activate);
            menu.removeItem(R.id.appmanager_weather_deactivate);
        }
    }
    switch(selectedApp.getType()) {
        case WATCHFACE:
        case APP_GENERIC:
        case APP_ACTIVITYTRACKER:
            break;
        default:
            menu.removeItem(R.id.appmanager_app_openinstore);
    }
    //menu.setHeaderTitle(selectedApp.getName());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        public boolean onMenuItemClick(MenuItem item) {
            return onContextItemSelected(item, selectedApp);
        }
    });
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    popupMenu.show();
    return true;
}
Also used : PackageManager(android.content.pm.PackageManager) MenuItem(android.view.MenuItem) PopupMenu(android.widget.PopupMenu) Menu(android.view.Menu) PopupMenu(android.widget.PopupMenu) GBDeviceApp(nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp)

Example 85 with PopupMenu

use of android.widget.PopupMenu in project android_frameworks_base by ParanoidAndroid.

the class BaseStatusBar method getNotificationLongClicker.

protected View.OnLongClickListener getNotificationLongClicker() {
    return new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            NotificationData.Entry entry = (NotificationData.Entry) v.getTag();
            if (entry.notification == null)
                return false;
            StatusBarNotification sbn = entry.notification;
            final String packageNameF = sbn.getPackageName();
            final PendingIntent contentIntent = sbn.getNotification().contentIntent;
            boolean expanded = Settings.System.getInt(mContext.getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0) == 1;
            if (packageNameF == null)
                return false;
            if (v.getWindowToken() == null)
                return false;
            //Long click menu broken on PIE mode...pop up menu is useless (auto-launch on long click)
            if (expanded) {
                launchFloating(contentIntent);
                animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
                return true;
            }
            mNotificationBlamePopup = new PopupMenu(mContext, v);
            mNotificationBlamePopup.getMenuInflater().inflate(R.menu.notification_popup_menu, mNotificationBlamePopup.getMenu());
            mNotificationBlamePopup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                public boolean onMenuItemClick(MenuItem item) {
                    if (item.getItemId() == R.id.notification_inspect_item) {
                        startApplicationDetailsActivity(packageNameF);
                        animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
                    } else if (item.getItemId() == R.id.notification_floating_item) {
                        launchFloating(contentIntent);
                        animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
                    } else {
                        return false;
                    }
                    return true;
                }
            });
            mNotificationBlamePopup.setOnDismissListener(new PopupMenu.OnDismissListener() {

                @Override
                public void onDismiss(PopupMenu popupMenu) {
                    mNotificationBlamePopup = null;
                }
            });
            mNotificationBlamePopup.show();
            return true;
        }
    };
}
Also used : MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) QuickSettingsContainerView(com.android.systemui.statusbar.phone.QuickSettingsContainerView) View(android.view.View) TextView(android.widget.TextView) SearchPanelView(com.android.systemui.SearchPanelView) StatusBarNotification(android.service.notification.StatusBarNotification) PendingIntent(android.app.PendingIntent) 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