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();
}
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);
}
}
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;
}
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;
}
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);
});
}
Aggregations