Search in sources :

Example 51 with PopupMenu

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

the class ChatFragment 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) CustomMessageMenu(com.xabber.android.ui.widget.CustomMessageMenu) PopupMenu(android.widget.PopupMenu)

Example 52 with PopupMenu

use of android.widget.PopupMenu in project SmartCampus by Vegen.

the class BottomTab method setData.

public void setData(@MenuRes int menuRes, boolean hideSpTab) {
    PopupMenu popupMenu = new PopupMenu(context, null);
    Menu menu = popupMenu.getMenu();
    MenuInflater menuInflater = new MenuInflater(context);
    menuInflater.inflate(menuRes, menu);
    int menuSize = menu.size() - (hideSpTab ? 1 : 0);
    tabs = new Tab[menuSize];
    int index = 0;
    for (int i = 0; i < menu.size(); i++) {
        if (i == 3 && hideSpTab)
            continue;
        MenuItem item = menu.getItem(i);
        Tab tab = new Tab(item.getItemId(), item.getIcon(), item.getTitle().toString());
        tab.position = index++;
        tabs[tab.position] = tab;
    }
    removeAllViews();
    for (int i = 0; i < tabs.length; i++) {
        final Tab tab = tabs[i];
        View view = LayoutInflater.from(context).inflate(R.layout.app_item_tab, this, false);
        LayoutParams params = new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1);
        view.setLayoutParams(params);
        ViewHolder holder = new ViewHolder(view);
        holder.icon.setImageDrawable(tab.drawable);
        holder.title.setText(tab.title);
        holder.redPoint.setVisibility(tab.hasNew ? VISIBLE : INVISIBLE);
        view.setTag(holder);
        view.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (onTabClickListener != null) {
                    onTabClickListener.onTabClick(v, tab.id, tab.position);
                }
                selectTab(tab.position);
            }
        });
        addView(view);
    }
}
Also used : MenuInflater(android.view.MenuInflater) MenuItem(android.view.MenuItem) PopupMenu(android.widget.PopupMenu) Menu(android.view.Menu) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) PopupMenu(android.widget.PopupMenu)

Example 53 with PopupMenu

use of android.widget.PopupMenu in project cloudrail-si-android-sdk by CloudRail.

the class BucketViewer method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_bucket_viewer, container, false);
    this.listView = (ListView) v.findViewById(R.id.bucketListView);
    this.spinner = (ProgressBar) v.findViewById(R.id.spinner);
    switch(mServiceString) {
        case "amazon":
            {
                service = new AmazonS3(context, MainActivity.AMAZON_ACCESS_KEY, MainActivity.AMAZON_SECRET_ACCESS_KEY, MainActivity.AMAZON_REGION);
                break;
            }
        case "backblaze":
            {
                service = new Backblaze(context, MainActivity.BACKBLAZE_ACCOUNT_ID, MainActivity.BACKBLACE_APP_KEY);
                break;
            }
        case "google":
            {
                service = new GoogleCloudPlatform(context, MainActivity.GOOGLE_CLIENT_EMAIL, MainActivity.GOOGLE_PRIVATE_KEY, MainActivity.GOOGLE_PROJECT_ID);
                break;
            }
        case "microsoft":
            {
                service = new MicrosoftAzure(context, MainActivity.AZURE_ACCOUNT_NAME, MainActivity.AZURE_ACCESS_KEY);
                break;
            }
        case "rackspace":
            {
                service = new Rackspace(context, MainActivity.RACKSPACE_USER_NAME, MainActivity.RACKSPACE_API_KEY, MainActivity.RACKSPACE_REGION);
                break;
            }
    }
    refreshList();
    this.listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            selectedItem = view;
            selectedItemPosition = position;
            PopupMenu popupMenu = new PopupMenu(context, view);
            MenuInflater menuInflater = ((Activity) context).getMenuInflater();
            menuInflater.inflate(R.menu.selected_bucket_bar, popupMenu.getMenu());
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.action_delete_bucket:
                            {
                                removeItem();
                                return true;
                            }
                        default:
                            return false;
                    }
                }
            });
            popupMenu.show();
            return true;
        }
    });
    this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectedItem = view;
            selectedItemPosition = position;
            ArrayAdapter<Bucket> adapter = (ArrayAdapter<Bucket>) listView.getAdapter();
            Bucket bucket = adapter.getItem(position);
            mListener.onBucketSelected(mServiceString, bucket.getName(), bucket.getIdentifier());
        }
    });
    ((TextView) v.findViewById(R.id.text2)).setText(mServiceString);
    return v;
}
Also used : AmazonS3(com.cloudrail.si.services.AmazonS3) MenuInflater(android.view.MenuInflater) Rackspace(com.cloudrail.si.services.Rackspace) MenuItem(android.view.MenuItem) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) MicrosoftAzure(com.cloudrail.si.services.MicrosoftAzure) Bucket(com.cloudrail.si.types.Bucket) Backblaze(com.cloudrail.si.services.Backblaze) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) GoogleCloudPlatform(com.cloudrail.si.services.GoogleCloudPlatform) ArrayAdapter(android.widget.ArrayAdapter) PopupMenu(android.widget.PopupMenu)

Example 54 with PopupMenu

use of android.widget.PopupMenu in project cloudrail-si-android-sdk by CloudRail.

the class Files method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_files, container, false);
    TextView tv = (TextView) v.findViewById(R.id.service_name);
    switch(this.currentService) {
        case 1:
            {
                tv.setText("My Dropbox:");
                break;
            }
        case 2:
            {
                tv.setText("My Box:");
                break;
            }
        case 3:
            {
                tv.setText("My GoogleDrive:");
                break;
            }
        case 4:
            {
                tv.setText("My OneDrive:");
                break;
            }
        case 5:
            {
                tv.setText("My Egnyte:");
                break;
            }
        case 6:
            {
                tv.setText("My OneDrive Business:");
                break;
            }
    }
    final TextView tv2 = (TextView) v.findViewById(R.id.allocation);
    new Thread(new Runnable() {

        @Override
        public void run() {
            final SpaceAllocation alloc = getService().getAllocation();
            getOwnActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    String used = getSizeString(alloc.getUsed());
                    String total = getSizeString(alloc.getTotal());
                    tv2.setText(used + " used of " + total);
                }
            });
        }
    }).start();
    this.list = (ListView) v.findViewById(R.id.listView);
    this.list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startSpinner();
            LinearLayout ll = (LinearLayout) view;
            TextView tv = (TextView) ll.findViewById(R.id.list_item);
            final String name = (String) tv.getText();
            new Thread(new Runnable() {

                @Override
                public void run() {
                    String next = currentPath;
                    if (!currentPath.equals("/")) {
                        next += "/";
                    }
                    next += name;
                    CloudMetaData info = getService().getMetadata(next);
                    if (info.getFolder()) {
                        setNewPath(next);
                    } else {
                        File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
                        InputStream data = getService().download(next);
                        File file = new File(path, name);
                        try {
                            FileOutputStream stream = new FileOutputStream(file, true);
                            pipe(data, stream);
                            data.close();
                            stream.close();
                        } catch (Exception e) {
                            stopSpinner();
                            e.printStackTrace();
                        }
                        Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                        intent.setData(Uri.fromFile(file));
                        getOwnActivity().sendBroadcast(intent);
                        String ext = getMimeType(name);
                        String mime = null;
                        stopSpinner();
                        if (ext != null && isDisplayable(ext)) {
                            mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
                            intent = new Intent(Intent.ACTION_VIEW);
                            intent.setDataAndType(Uri.fromFile(file), mime);
                            startActivity(intent);
                        } else {
                            getOwnActivity().runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    Toast.makeText(context, "Download complete! Stored to download folder.", Toast.LENGTH_SHORT).show();
                                }
                            });
                        }
                    }
                }
            }).start();
        }
    });
    this.list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            selectedItem = view;
            PopupMenu popupMenu = new PopupMenu(getOwnActivity(), view);
            MenuInflater menuInflater = getOwnActivity().getMenuInflater();
            menuInflater.inflate(R.menu.selected_item_bar, popupMenu.getMenu());
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.action_delete:
                            {
                                removeItem();
                                return true;
                            }
                        case R.id.action_copy:
                            {
                                copyItem();
                                return true;
                            }
                        case R.id.action_create_share_link:
                            {
                                createShareLink();
                                return true;
                            }
                        case R.id.action_cut:
                            {
                                cutItem();
                                return true;
                            }
                        default:
                            return false;
                    }
                }
            });
            popupMenu.show();
            return true;
        }
    });
    this.spinner = (ProgressBar) v.findViewById(R.id.spinner);
    this.spinner.setVisibility(View.GONE);
    this.currentPath = "/";
    this.updateList();
    return v;
}
Also used : MenuInflater(android.view.MenuInflater) InputStream(java.io.InputStream) Intent(android.content.Intent) MenuItem(android.view.MenuItem) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) IOException(java.io.IOException) CloudMetaData(com.cloudrail.si.types.CloudMetaData) SpaceAllocation(com.cloudrail.si.types.SpaceAllocation) FileOutputStream(java.io.FileOutputStream) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) File(java.io.File) LinearLayout(android.widget.LinearLayout) PopupMenu(android.widget.PopupMenu)

Example 55 with PopupMenu

use of android.widget.PopupMenu in project bugzy by cpunq.

the class MyCasesFragment method setupSortingView.

public void setupSortingView() {
    mAppliedSortingsAdapter = new AppliedSortAdapter(3);
    mAppliedSortingsAdapter.setItemClickListener((position, view) -> {
        PopupMenu popupMenu = new PopupMenu(getActivity(), view);
        popupMenu.setOnMenuItemClickListener(item -> {
            if (item.getTitle().equals("Remove")) {
                mViewModel.removeSortClicked(position);
            } else {
                showSortOrderSelectionMenu(view, position);
            }
            return true;
        });
        popupMenu.getMenu().add("Replace");
        popupMenu.getMenu().add("Remove");
        popupMenu.show();
    });
    FlowLayoutManager manager = new FlowLayoutManager();
    manager.setAutoMeasureEnabled(true);
    mSortingRecyclerView.setLayoutManager(manager);
    mSortingRecyclerView.addItemDecoration(new ItemOffsetDecoration((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f, getResources().getDisplayMetrics())));
    mSortingRecyclerView.setAdapter(mAppliedSortingsAdapter);
    mAppliedSortingsAdapter.setOnAddClickListener(v -> {
        showSortOrderSelectionMenu(v, -1);
    });
}
Also used : AppliedSortAdapter(com.bluestacks.bugzy.ui.common.AppliedSortAdapter) FlowLayoutManager(com.xiaofeng.flowlayoutmanager.FlowLayoutManager) ItemOffsetDecoration(com.bluestacks.bugzy.ui.common.ItemOffsetDecoration) 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