Styled category label in infowindow

This commit is contained in:
Daniele Verducci (Slimpenguin)
2024-02-22 08:10:26 +01:00
parent b6ce246a74
commit 053f7401b8
4 changed files with 41 additions and 6 deletions

View File

@ -159,7 +159,7 @@ public class GeofavoriteMapFragment extends GeofavoritesFragment implements Main
// Set icon and color
Drawable icon = DrawableCompat.wrap(AppCompatResources.getDrawable(requireContext(), R.drawable.ic_list_pin));
DrawableCompat.setTint(icon, geofavorite.categoryColor());
DrawableCompat.setTint(icon, geofavorite.categoryColor() == 0 ? requireContext().getColor(R.color.defaultBrand) : geofavorite.categoryColor());
// Set infowindow (popup opened on marker click) and its listeners
GeofavMarkerInfoWindow iw = new GeofavMarkerInfoWindow(map, geofavorite);

View File

@ -1,7 +1,12 @@
package it.danieleverducci.nextcloudmaps.views;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.graphics.drawable.DrawableCompat;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.infowindow.InfoWindow;
import org.osmdroid.views.overlay.infowindow.MarkerInfoWindow;
@ -14,7 +19,14 @@ public class GeofavMarkerInfoWindow extends MarkerInfoWindow implements View.OnC
public GeofavMarkerInfoWindow(MapView mapView, Geofavorite geofavorite) {
super(R.layout.infowindow_geofav, mapView);
Context context = getView().getContext();
// Set category color
View category = getView().findViewById(R.id.bubble_subdescription);
Drawable backgroundDrawable = category.getBackground();
DrawableCompat.setTint(backgroundDrawable, geofavorite.categoryColor() == 0 ? context.getColor(R.color.defaultBrand) : geofavorite.categoryColor());
// Set listeners
getView().findViewById(R.id.action_icon_share).setOnClickListener(this);
getView().findViewById(R.id.action_icon_nav).setOnClickListener(this);
getView().findViewById(R.id.action_icon_delete).setOnClickListener(this);