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 e582652d6f..70a01ae017 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 @@ -95,21 +95,21 @@ public void setViewProfile(View v, String nm, boolean displaySelection) { Drawable cachedIcon = ProfileIconCache.fetchIcon(v.getResources(), nm, minecraftProfile.icon); extendedTextView.setCompoundDrawablesRelative(cachedIcon, null, extendedTextView.getCompoundsDrawables()[2], null); - if(Tools.isValidString(minecraftProfile.name)) - extendedTextView.setText(minecraftProfile.name); - else - extendedTextView.setText(R.string.unnamed); - - if(minecraftProfile.lastVersionId != null){ - if(minecraftProfile.lastVersionId.equalsIgnoreCase("latest-release")){ - extendedTextView.setText( String.format("%s - %s", extendedTextView.getText(), v.getContext().getText(R.string.profiles_latest_release))); - } else if(minecraftProfile.lastVersionId.equalsIgnoreCase("latest-snapshot")){ - extendedTextView.setText( String.format("%s - %s", extendedTextView.getText(), v.getContext().getText(R.string.profiles_latest_snapshot))); - } else { - extendedTextView.setText( String.format("%s - %s", extendedTextView.getText(), minecraftProfile.lastVersionId)); - } - - } else extendedTextView.setText(extendedTextView.getText()); + // Historically, the profile name "New" was hardcoded as the default profile name + // We consider "New" the same as putting no name at all + String profileName = (Tools.isValidString(minecraftProfile.name) && !"New".equalsIgnoreCase(minecraftProfile.name)) ? minecraftProfile.name : null; + String versionName = minecraftProfile.lastVersionId; + + if (MinecraftProfile.LATEST_RELEASE.equalsIgnoreCase(versionName)) + versionName = v.getContext().getString(R.string.profiles_latest_release); + else if (MinecraftProfile.LATEST_SNAPSHOT.equalsIgnoreCase(versionName)) + versionName = v.getContext().getString(R.string.profiles_latest_snapshot); + + if (versionName == null && profileName != null) + extendedTextView.setText(profileName); + else if (versionName != null && profileName == null) + extendedTextView.setText(versionName); + else extendedTextView.setText(String.format("%s - %s", profileName, versionName)); // Set selected background if needed if(displaySelection){ diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/AsyncMinecraftDownloader.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/AsyncMinecraftDownloader.java index d197b4142f..b4d7012b8e 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/AsyncMinecraftDownloader.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/AsyncMinecraftDownloader.java @@ -3,13 +3,14 @@ import net.kdt.pojavlaunch.JMinecraftVersionList; import net.kdt.pojavlaunch.extra.ExtraConstants; import net.kdt.pojavlaunch.extra.ExtraCore; +import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile; public class AsyncMinecraftDownloader { public static String normalizeVersionId(String versionString) { JMinecraftVersionList versionList = (JMinecraftVersionList) ExtraCore.getValue(ExtraConstants.RELEASE_TABLE); if(versionList == null || versionList.versions == null) return versionString; - if("latest-release".equals(versionString)) versionString = versionList.latest.get("release"); - if("latest-snapshot".equals(versionString)) versionString = versionList.latest.get("snapshot"); + if(MinecraftProfile.LATEST_RELEASE.equals(versionString)) versionString = versionList.latest.get("release"); + if(MinecraftProfile.LATEST_SNAPSHOT.equals(versionString)) versionString = versionList.latest.get("snapshot"); return versionString; } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/launcherprofiles/MinecraftProfile.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/launcherprofiles/MinecraftProfile.java index 94545abf62..59fccd7764 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/launcherprofiles/MinecraftProfile.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/launcherprofiles/MinecraftProfile.java @@ -5,6 +5,9 @@ @Keep public class MinecraftProfile { + public static String LATEST_RELEASE = "latest-release"; + public static String LATEST_SNAPSHOT= "latest-snapshot"; + public String name; public String type; public String created; @@ -23,8 +26,8 @@ public class MinecraftProfile { public static MinecraftProfile createTemplate(){ MinecraftProfile TEMPLATE = new MinecraftProfile(); - TEMPLATE.name = "New"; - TEMPLATE.lastVersionId = "latest-release"; + TEMPLATE.name = ""; + TEMPLATE.lastVersionId = LATEST_RELEASE; return TEMPLATE; }