Styled category label in infowindow
This commit is contained in:
		| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
							
								
								
									
										6
									
								
								app/src/main/res/drawable/rounded_label_background.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								app/src/main/res/drawable/rounded_label_background.xml
									
									
									
									
									
										Normal 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> | ||||
| @@ -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" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user