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; hasImage = true;
} }
public static GenericItem fromStyle(StyleDocument style, AppController app, Runnable onClick) { public GenericItem(StyleDocument style, AppController app, Runnable onClick) {
if(style == null) return new GenericItem("Unknown"); if (style == null) {
if(style.icon != null) this.name = "Unknown";
return new GenericItem(style.name, FileHelper.getIcon(style.icon, app), onClick); return;
return new GenericItem(style.name, onClick); }
this.name = style.name;
this.image = style.icon != null ? FileHelper.getIcon(style.icon, app) : null;
this.onClick = onClick;
} }
public static GenericItem fromStyle(StyleDocument style, AppController app, Runnable onClick, Runnable onLongClick) {
if(style == null) return new GenericItem("Unknown"); public GenericItem(StyleDocument style, AppController app, Runnable onClick, Runnable onLongClick) {
if(style.icon != null) if (style == null) {
return new GenericItem(style.name, FileHelper.getIcon(style.icon, app), onClick, onLongClick); this.name = "Unknown";
return new GenericItem(style.name, onClick, onLongClick); return;
}
this.name = style.name;
this.image = style.icon != null ? FileHelper.getIcon(style.icon, app) : null;
this.onClick = onClick;
this.onLongClick = onLongClick;
} }
@Override @Override
@@ -58,6 +58,9 @@ public class FragmentMapChangePopup extends Fragment implements Popup {
app, app,
() -> this.setStyle(id), () -> this.setStyle(id),
() -> this.styleDetails(id)).makeView(ui); () -> 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); Bitmap addNewIcon = BitmapFactory.decodeResource(app.getActivity().getResources(), android.R.drawable.ic_menu_add);
stylesLayout.addView(new GenericItem("", 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>
+28 -20
View File
@@ -1,27 +1,35 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:gravity="center" android:gravity="center"
android:padding="8dp"> android:padding="8dp">
<ImageButton <ImageButton
android:id="@+id/image" android:id="@+id/image"
android:layout_width="54dp" android:layout_width="54dp"
android:layout_height="47dp" android:layout_height="46dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="@android:color/transparent"
android:contentDescription="Style Image" android:contentDescription="Image"
android:src="@android:drawable/ic_menu_gallery" /> android:src="@android:drawable/ic_menu_gallery"
android:padding="0dp" />
<TextView <TextView
android:id="@+id/name" android:id="@+id/name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:gravity="center" android:gravity="center"
android:text="Item Name" android:text="Name"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="14sp" /> 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> </LinearLayout>