use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class SearchPOIActivity method addFilter.
private void addFilter(PopupMenu optionsMenu, final String value) {
UiUtilities iconsCache = getMyApplication().getUIUtilities();
MenuItem item = optionsMenu.getMenu().add(getString(R.string.search_poi_filter) + ": " + value).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_filter_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (searchFilterLayout.getVisibility() == View.GONE) {
searchFilterLayout.setVisibility(View.VISIBLE);
}
searchFilter.setText((searchFilter.getText().toString() + " " + value.replace(' ', '_').toLowerCase()).trim());
return true;
}
});
}
use of net.osmand.plus.utils.UiUtilities 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
UiUtilities iconsCache = getMyApplication().getUIUtilities();
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();
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class SearchHistoryFragment method updateHistoryItem.
public static void updateHistoryItem(@NonNull HistoryEntry historyEntry, @NonNull View row, @Nullable LatLon location, @NonNull OsmandApplication app) {
TextView nameText = row.findViewById(R.id.name);
TextView distanceText = row.findViewById(R.id.distance);
ImageView direction = row.findViewById(R.id.direction);
UiUtilities ic = app.getUIUtilities();
direction.setImageDrawable(ic.getIcon(R.drawable.ic_direction_arrow, R.color.color_distance));
String distance = "";
if (location != null) {
int dist = (int) (MapUtils.getDistance(location, historyEntry.getLat(), historyEntry.getLon()));
distance = OsmAndFormatter.getFormattedDistance(dist, app) + " ";
}
distanceText.setText(distance);
PointDescription pointDescription = historyEntry.getName();
nameText.setText(pointDescription.getSimpleName(app, false), BufferType.SPANNABLE);
ImageView icon = row.findViewById(R.id.icon);
icon.setImageDrawable(ic.getThemedIcon(getItemIcon(pointDescription)));
String typeName = pointDescription.getTypeName();
if (!Algorithms.isEmpty(typeName)) {
ImageView group = row.findViewById(R.id.type_name_icon);
group.setVisibility(View.VISIBLE);
group.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_group_name_16));
((TextView) row.findViewById(R.id.type_name)).setText(typeName);
} else {
row.findViewById(R.id.type_name_icon).setVisibility(View.GONE);
((TextView) row.findViewById(R.id.type_name)).setText("");
}
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class SearchPoiFilterFragment method showOptionsMenu.
private void showOptionsMenu(View v) {
// Show menu with search all, name finder, name finder poi
UiUtilities iconsCache = getMyApplication().getUIUtilities();
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
MenuItem item = optionsMenu.getMenu().add(R.string.poi_filter_custom_filter).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_filter_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
PoiUIFilter filter = getApp().getPoiFilters().getCustomPOIFilter();
filter.clearFilter();
showFilterActivity(filter.getFilterId());
return true;
}
});
optionsMenu.show();
}
use of net.osmand.plus.utils.UiUtilities in project Osmand by osmandapp.
the class MapMarkersActiveAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final MapMarkerItemViewHolder holder, final int pos) {
UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities();
MapMarker marker = markers.get(pos);
ImageView markerImageViewToUpdate;
int drawableResToUpdate;
int markerColor = MapMarker.getColorId(marker.colorIndex);
int actionIconColor = night ? R.color.icon_color_primary_dark : R.color.icon_color_primary_light;
LatLon markerLatLon = new LatLon(marker.getLatitude(), marker.getLongitude());
final boolean displayedInWidget = pos < mapActivity.getMyApplication().getSettings().DISPLAYED_MARKERS_WIDGETS_COUNT.get();
if (showDirectionEnabled && displayedInWidget) {
holder.iconDirection.setVisibility(View.GONE);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_arrow_marker_diretion, markerColor));
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.list_divider_dark : R.color.markers_top_bar_background));
holder.title.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.text_color_primary_dark : R.color.color_white));
holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_divider_color));
holder.optionsBtn.setBackgroundDrawable(AppCompatResources.getDrawable(mapActivity, R.drawable.marker_circle_background_on_map_with_inset));
holder.optionsBtn.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_marker_passed, R.color.color_white));
holder.iconReorder.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_item_move, R.color.icon_color_default_light));
holder.description.setTextColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_color));
drawableResToUpdate = R.drawable.ic_arrow_marker_diretion;
markerImageViewToUpdate = holder.icon;
} else {
holder.iconDirection.setVisibility(View.VISIBLE);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag, markerColor));
holder.mainLayout.setBackgroundColor(ColorUtilities.getListBgColor(mapActivity, night));
holder.title.setTextColor(ColorUtilities.getPrimaryTextColor(mapActivity, night));
holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.app_bar_color_dark : R.color.divider_color_light));
holder.optionsBtn.setBackgroundDrawable(AppCompatResources.getDrawable(mapActivity, night ? R.drawable.marker_circle_background_dark_with_inset : R.drawable.marker_circle_background_light_with_inset));
holder.optionsBtn.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_marker_passed, actionIconColor));
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_item_move));
holder.description.setTextColor(ColorUtilities.getDefaultIconColor(mapActivity, night));
drawableResToUpdate = R.drawable.ic_direction_arrow;
markerImageViewToUpdate = holder.iconDirection;
}
if (pos == getItemCount() - 1) {
holder.bottomShadow.setVisibility(View.VISIBLE);
holder.divider.setVisibility(View.GONE);
} else {
holder.bottomShadow.setVisibility(View.GONE);
holder.divider.setVisibility(View.VISIBLE);
}
holder.point.setVisibility(View.VISIBLE);
holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
listener.onDragStarted(holder);
}
return false;
}
});
holder.title.setText(marker.getName(mapActivity));
String descr;
if ((descr = marker.groupName) != null) {
if (descr.isEmpty()) {
descr = mapActivity.getString(R.string.shared_string_favorites);
}
} else {
descr = OsmAndFormatter.getFormattedDate(mapActivity, marker.creationDate);
}
if (marker.wptPt != null && !Algorithms.isEmpty(marker.wptPt.category)) {
descr = marker.wptPt.category + ", " + descr;
}
holder.description.setText(descr);
holder.optionsBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final int position = holder.getAdapterPosition();
if (position < 0) {
return;
}
final MapMarker marker = markers.get(position);
mapActivity.getMyApplication().getMapMarkersHelper().moveMapMarkerToHistory(marker);
changeMarkers();
notifyDataSetChanged();
snackbar = Snackbar.make(holder.itemView, mapActivity.getString(R.string.marker_moved_to_history), Snackbar.LENGTH_LONG).setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override
public void onClick(View view) {
mapActivity.getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory(marker, position);
changeMarkers();
notifyDataSetChanged();
}
});
UiUtilities.setupSnackbar(snackbar, night);
snackbar.show();
}
});
updateLocationViewCache.arrowResId = drawableResToUpdate;
updateLocationViewCache.arrowColor = showDirectionEnabled && displayedInWidget ? markerColor : 0;
uiUtilities.updateLocationView(updateLocationViewCache, markerImageViewToUpdate, holder.distance, markerLatLon);
}
Aggregations