diff --git a/app/src/main/java/eu/konggdev/strikemaps/ui/element/item/GenericItem.java b/app/src/main/java/eu/konggdev/strikemaps/ui/element/item/GenericItem.java index 4a66cb2..ed8e419 100644 --- a/app/src/main/java/eu/konggdev/strikemaps/ui/element/item/GenericItem.java +++ b/app/src/main/java/eu/konggdev/strikemaps/ui/element/item/GenericItem.java @@ -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; + } + + 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"); - if(style.icon != null) - return new GenericItem(style.name, FileHelper.getIcon(style.icon, app), onClick, onLongClick); - return new GenericItem(style.name, onClick, onLongClick); + + 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 diff --git a/app/src/main/java/eu/konggdev/strikemaps/ui/fragment/popup/FragmentMapChangePopup.java b/app/src/main/java/eu/konggdev/strikemaps/ui/fragment/popup/FragmentMapChangePopup.java index d3d1731..02ff781 100644 --- a/app/src/main/java/eu/konggdev/strikemaps/ui/fragment/popup/FragmentMapChangePopup.java +++ b/app/src/main/java/eu/konggdev/strikemaps/ui/fragment/popup/FragmentMapChangePopup.java @@ -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("", diff --git a/app/src/main/res/drawable/indicator.xml b/app/src/main/res/drawable/indicator.xml new file mode 100644 index 0000000..2f4621a --- /dev/null +++ b/app/src/main/res/drawable/indicator.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_generic.xml b/app/src/main/res/layout/item_generic.xml index 7e9fa2c..7ecf27a 100644 --- a/app/src/main/res/layout/item_generic.xml +++ b/app/src/main/res/layout/item_generic.xml @@ -1,27 +1,35 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + android:gravity="center" + android:padding="8dp"> + android:id="@+id/image" + android:layout_width="54dp" + android:layout_height="46dp" + android:background="@android:color/transparent" + android:contentDescription="Image" + android:src="@android:drawable/ic_menu_gallery" + android:padding="0dp" /> + android:id="@+id/name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="4dp" + android:gravity="center" + android:text="Name" + android:textColor="#FFFFFF" + android:textSize="14sp" /> - + + \ No newline at end of file