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);

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#000" />
<padding android:left="10dp" android:top="3dp" android:right="10dp" android:bottom="3dp" />
<corners android:radius="20dp" />
</shape>

View File

@ -13,6 +13,7 @@
android:padding="7dp"
android:orientation="vertical">
<!-- Geofavorite title -->
<TextView
android:id="@+id/bubble_title"
android:layout_width="match_parent"
@ -24,19 +25,35 @@
style="@style/TextAppearance.GeofavoriteInfowindow"
android:text="Lorem"/>
<!-- Geofavorite description -->
<TextView
android:id="@+id/bubble_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Lorem ipsum"/>
<!-- Geofavorite category -->
<TextView
android:id="@+id/bubble_subdescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Lorem ipsum"/>
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:gravity="center_vertical"
android:lines="1"
android:ellipsize="end"
android:text="Lorem ipsum"
app:drawableLeftCompat="@drawable/ic_category_asc"
android:drawablePadding="8sp"
android:drawableTint="@color/white"
android:textColor="@color/white"
android:textStyle="bold"
android:background="@drawable/rounded_label_background"/>
<LinearLayout
android:layout_width="match_parent"