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;
|
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);
|
|
||||||
}
|
}
|
||||||
public static GenericItem fromStyle(StyleDocument style, AppController app, Runnable onClick, Runnable onLongClick) {
|
|
||||||
if(style == null) return new GenericItem("Unknown");
|
this.name = style.name;
|
||||||
if(style.icon != null)
|
this.image = style.icon != null ? FileHelper.getIcon(style.icon, app) : null;
|
||||||
return new GenericItem(style.name, FileHelper.getIcon(style.icon, app), onClick, onLongClick);
|
this.onClick = onClick;
|
||||||
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
|
@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("",
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -9,10 +9,11 @@
|
|||||||
<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"
|
||||||
@@ -20,8 +21,15 @@
|
|||||||
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>
|
||||||
Reference in New Issue
Block a user