feat: add indicator to currently active style in map change ui
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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("",
|
||||
|
||||
@@ -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>
|
||||
@@ -1,27 +1,35 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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">
|
||||
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">
|
||||
|
||||
<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: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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:gravity="center"
|
||||
android:text="Item Name"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp" />
|
||||
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" />
|
||||
|
||||
<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>
|
||||
Reference in New Issue
Block a user