feat: add indicator to currently active style in map change ui

This commit is contained in:
2026-09-13 16:25:36 +02:00
parent 19d0a768fd
commit 85734fa98d
4 changed files with 59 additions and 31 deletions
@@ -55,17 +55,27 @@ public class GenericItem implements UIItem {
hasImage = true;
}
public static GenericItem fromStyle(StyleDocument style, AppController app, Runnable onClick) {
if(style == null) return new GenericItem("Unknown");
if(style.icon != null)
return new GenericItem(style.name, FileHelper.getIcon(style.icon, app), onClick);
return new GenericItem(style.name, onClick);
public GenericItem(StyleDocument style, AppController app, Runnable onClick) {
if (style == null) {
this.name = "Unknown";
return;
}
public static GenericItem fromStyle(StyleDocument style, AppController app, Runnable onClick, Runnable onLongClick) {
if(style == null) return new GenericItem("Unknown");
if(style.icon != null)
return new GenericItem(style.name, FileHelper.getIcon(style.icon, app), onClick, onLongClick);
return new GenericItem(style.name, onClick, onLongClick);
this.name = style.name;
this.image = style.icon != null ? FileHelper.getIcon(style.icon, app) : null;
this.onClick = onClick;
}
public GenericItem(StyleDocument style, AppController app, Runnable onClick, Runnable onLongClick) {
if (style == null) {
this.name = "Unknown";
return;
}
this.name = style.name;
this.image = style.icon != null ? FileHelper.getIcon(style.icon, app) : null;
this.onClick = onClick;
this.onLongClick = onLongClick;
}
@Override
@@ -58,6 +58,9 @@ public class FragmentMapChangePopup extends Fragment implements Popup {
app,
() -> this.setStyle(id),
() -> this.styleDetails(id)).makeView(ui);
if (Objects.equals(map.styleId, id)) item.findViewById(R.id.indicator)
.setVisibility(View.VISIBLE);
stylesLayout.addView(item);
});
Bitmap addNewIcon = BitmapFactory.decodeResource(app.getActivity().getResources(), android.R.drawable.ic_menu_add);
stylesLayout.addView(new GenericItem("",
+7
View File
@@ -0,0 +1,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#FFFFFF" />
</shape>
+13 -5
View File
@@ -9,10 +9,11 @@
<ImageButton
android:id="@+id/image"
android:layout_width="54dp"
android:layout_height="47dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Style Image"
android:src="@android:drawable/ic_menu_gallery" />
android:layout_height="46dp"
android:background="@android:color/transparent"
android:contentDescription="Image"
android:src="@android:drawable/ic_menu_gallery"
android:padding="0dp" />
<TextView
android:id="@+id/name"
@@ -20,8 +21,15 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center"
android:text="Item Name"
android:text="Name"
android:textColor="#FFFFFF"
android:textSize="14sp" />
<View
android:id="@+id/indicator"
android:layout_width="24dp"
android:layout_height="3dp"
android:layout_marginTop="5dp"
android:visibility="gone"
android:background="@drawable/indicator"/>
</LinearLayout>