use of android.support.v7.widget.PopupMenu in project RoMote by wseemann.
the class AltMainActivity method showMenu.
private void showMenu(final View v) {
PopupMenu popup = new PopupMenu(this, v);
// This activity implements OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Device device = (Device) v.getTag();
switch(item.getItemId()) {
case R.id.action_info:
Intent intent = new Intent(AltMainActivity.this, DeviceInfoActivity.class);
intent.putExtra("serial_number", device.getSerialNumber());
intent.putExtra("host", device.getHost());
startActivity(intent);
return true;
case R.id.action_unpair:
PreferenceUtils.setConnectedDevice(AltMainActivity.this, "");
DBUtils.removeDevice(AltMainActivity.this, device.getSerialNumber());
refreshList(false);
return true;
default:
return false;
}
}
});
popup.inflate(R.menu.device_menu);
Device device = (Device) v.getTag();
if (DBUtils.getDevice(this, device.getSerialNumber()) == null) {
popup.getMenu().removeItem(R.id.action_unpair);
}
popup.show();
}
use of android.support.v7.widget.PopupMenu in project edx-app-android by edx.
the class EditUserProfileFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewHolder = new ViewHolder(view);
viewHolder.profileImageProgress.setVisibility(View.GONE);
viewHolder.username.setText(username);
viewHolder.username.setContentDescription(ResourceUtil.getFormattedString(getResources(), R.string.profile_username_description, "username", username));
final IconDrawable icon = new IconDrawable(getActivity(), FontAwesomeIcons.fa_camera).colorRes(getActivity(), R.color.disableable_button_text).sizeRes(getActivity(), R.dimen.fa_x_small).tint(// IconDrawable is tinted by default, but we don't want it to be tinted here
null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(viewHolder.changePhoto, icon, null, null, null);
viewHolder.changePhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu popup = new PopupMenu(getActivity(), v);
popup.getMenuInflater().inflate(R.menu.change_photo, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.take_photo:
{
startActivityForResult(helper.createCaptureIntent(getActivity()), CAPTURE_PHOTO_REQUEST);
break;
}
case R.id.choose_photo:
{
final Intent galleryIntent = new Intent().setType("image/*").setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(galleryIntent, CHOOSE_PHOTO_REQUEST);
break;
}
case R.id.remove_photo:
{
final Task task = new DeleteAccountImageTask(getActivity(), username);
task.setProgressDialog(viewHolder.profileImageProgress);
executePhotoTask(task);
break;
}
}
return true;
}
});
popup.show();
}
});
setData(account, formDescription);
}
use of android.support.v7.widget.PopupMenu in project Osmand by osmandapp.
the class ItemViewHolder method contextMenu.
protected void contextMenu(View v, final IndexItem indexItem, final DownloadResourceGroup parentOptional) {
final PopupMenu optionsMenu = new PopupMenu(context, v);
MenuItem item;
final File fl = indexItem.getTargetFile(context.getMyApplication());
if (fl.exists()) {
item = optionsMenu.getMenu().add(R.string.shared_string_remove).setIcon(context.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
LocalIndexType tp = LocalIndexType.MAP_DATA;
if (indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) {
tp = LocalIndexType.TILES_DATA;
} else if (indexItem.getType() == DownloadActivityType.ROADS_FILE) {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
tp = LocalIndexType.SRTM_DATA;
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.FONT_FILE) {
tp = LocalIndexType.FONT_DATA;
} else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
tp = indexItem.getBasename().contains("tts") ? LocalIndexType.TTS_VOICE_DATA : LocalIndexType.VOICE_DATA;
}
final LocalIndexInfo info = new LocalIndexInfo(tp, fl, false, context.getMyApplication());
AlertDialog.Builder confirm = new AlertDialog.Builder(context);
confirm.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new LocalIndexOperationTask(context, null, LocalIndexOperationTask.DELETE_OPERATION).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, info);
}
});
confirm.setNegativeButton(R.string.shared_string_no, null);
String fn = FileNameTranslationHelper.getFileName(context, context.getMyApplication().getRegions(), indexItem.getVisibleName(context, context.getMyApplication().getRegions()));
confirm.setMessage(context.getString(R.string.delete_confirmation_msg, fn));
confirm.show();
return true;
}
});
}
item = optionsMenu.getMenu().add(R.string.shared_string_download).setIcon(context.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_import));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
download(indexItem, parentOptional);
return true;
}
});
optionsMenu.show();
}
use of android.support.v7.widget.PopupMenu in project Osmand by osmandapp.
the class DashWaypointsFragment method selectTargetModel.
private void selectTargetModel(final TargetPoint point, final View view) {
final PopupMenu optionsMenu = new PopupMenu(getActivity(), view);
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
MenuItem item;
// item = optionsMenu.getMenu().add(
// R.string.shared_string_add_to_favorites).setIcon(getMyApplication().getIconsCache().
// getIcon(R.drawable.ic_action_fav_dark));
// item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// Bundle args = new Bundle();
// Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), args);
// dlg.show();
// FavoriteDialogs.prepareAddFavouriteDialog(getActivity(), dlg, args, model.getLatitude(), model.getLongitude(),
// model.getOriginalPointDescription());
// return true;
// }
// });
final boolean target = point == getMyApplication().getTargetPointsHelper().getPointToNavigate();
if (SHOW_ALL && getMyApplication().getTargetPointsHelper().getIntermediatePoints().size() > 0) {
final List<TargetPoint> allTargets = getMyApplication().getTargetPointsHelper().getIntermediatePointsWithTarget();
if (point.index > 0 || target) {
final int ind = target ? allTargets.size() - 1 : point.index;
item = optionsMenu.getMenu().add(R.string.waypoint_visit_before).setIcon(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_up_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
TargetPoint remove = allTargets.remove(ind - 1);
allTargets.add(ind, remove);
getMyApplication().getTargetPointsHelper().reorderAllTargetPoints(allTargets, true);
setupView();
return true;
}
});
}
if (!target) {
item = optionsMenu.getMenu().add(R.string.waypoint_visit_after).setIcon(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_down_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
TargetPoint remove = allTargets.remove(point.index + 1);
allTargets.add(point.index, remove);
getMyApplication().getTargetPointsHelper().reorderAllTargetPoints(allTargets, true);
setupView();
return true;
}
});
}
}
item = optionsMenu.getMenu().add(R.string.shared_string_remove).setIcon(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
deletePointConfirm(point, view);
return true;
}
});
optionsMenu.show();
}
use of android.support.v7.widget.PopupMenu in project Osmand by osmandapp.
the class SearchPOIActivity method showOptionsMenu.
private void showOptionsMenu(View v) {
// Show menu with search all, name finder, name finder poi
IconsCache iconsCache = getMyApplication().getIconsCache();
final PopupMenu optionsMenu = new PopupMenu(this, v);
final PoiUIFilter f = this.filter;
MenuItem item = optionsMenu.getMenu().add(R.string.shared_string_edit).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
PoiUIFilter custom = getMyApplication().getPoiFilters().getCustomPOIFilter();
custom.replaceWithPoiFilter(f);
showEditActivity(custom);
return true;
}
});
addFilter(optionsMenu, getString(R.string.shared_string_is_open));
addFilter(optionsMenu, getString(R.string.shared_string_is_open_24_7));
Map<String, PoiType> poiAdditionals = f.getPoiAdditionals();
if (poiAdditionals != null) {
TreeMap<String, PoiType> adds = new TreeMap<String, PoiType>();
for (PoiType vtype : poiAdditionals.values()) {
if (vtype.isTopVisible()) {
adds.put(vtype.getTranslation().replace(' ', ':').toLowerCase(), vtype);
}
}
for (String vtype : adds.keySet()) {
addFilter(optionsMenu, vtype);
}
}
optionsMenu.show();
}
Aggregations