From 89929b5e211f17a70933cdd8b7749eb23ec5e79b Mon Sep 17 00:00:00 2001 From: Mathias-Boulay Date: Wed, 16 Nov 2022 21:06:52 +0100 Subject: [PATCH] Style: add a plus icon to the "create profile" "profile" --- .../kdt/pojavlaunch/profiles/ProfileAdapter.java | 6 +----- .../pojavlaunch/profiles/ProfileIconCache.java | 15 ++++++++++++++- .../src/main/res/drawable/ic_add.xml | 5 +++++ 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 app_pojavlauncher/src/main/res/drawable/ic_add.xml diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileAdapter.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileAdapter.java index eec82a2a5..367baea65 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileAdapter.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileAdapter.java @@ -74,11 +74,7 @@ public class ProfileAdapter extends BaseAdapter { public void fireProfileEdit() { notifyDataSetChanged(); } - /* - * Gets the item ID (crc64 hash of the profile name) for a given index - * @param position index to get the hash for - * @returns ID (crc64 of a profile name string) or -1 if the index is out of bounds - */ + @Override public long getItemId(int position) { return position; diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileIconCache.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileIconCache.java index 4b8bc064e..508fc0cc1 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileIconCache.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileIconCache.java @@ -1,5 +1,7 @@ package net.kdt.pojavlaunch.profiles; +import static net.kdt.pojavlaunch.profiles.ProfileAdapter.CREATE_PROFILE_MAGIC; + import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; @@ -22,6 +24,7 @@ public class ProfileIconCache { private static final Map sIconCache = new HashMap<>(); private static Drawable sDefaultIcon; + public static void initDefault(Context context) { if(sDefaultIcon != null) return; sDefaultIcon = ResourcesCompat.getDrawable(context.getResources(), R.mipmap.ic_launcher_foreground, null); @@ -49,11 +52,21 @@ public class ProfileIconCache { icon = ProfileIconCache.submitIcon(resources, profileName, b64Icon.substring(BASE64_PNG_HEADER.length())); }else{ Log.i("IconParser","Unsupported icon: "+b64Icon); - icon = ProfileIconCache.pushDefaultIcon(profileName); + if(profileName.equals(CREATE_PROFILE_MAGIC)){ + icon = ProfileIconCache.pushAddProfileIcon(ResourcesCompat.getDrawable(resources, R.drawable.ic_add, null)); + }else{ + icon = ProfileIconCache.pushDefaultIcon(profileName); + } + } return icon; } + public static Drawable pushAddProfileIcon(Drawable drawable){ + sIconCache.put(CREATE_PROFILE_MAGIC, drawable); + return drawable; + } + public static Drawable pushDefaultIcon(String key) { sIconCache.put(key, sDefaultIcon); diff --git a/app_pojavlauncher/src/main/res/drawable/ic_add.xml b/app_pojavlauncher/src/main/res/drawable/ic_add.xml new file mode 100644 index 000000000..70046c48f --- /dev/null +++ b/app_pojavlauncher/src/main/res/drawable/ic_add.xml @@ -0,0 +1,5 @@ + + +