From bcb9957e0cc201937ed5d692de3b3547097760d4 Mon Sep 17 00:00:00 2001 From: SerpentSpirale Date: Wed, 11 Aug 2021 16:25:55 +0200 Subject: [PATCH] - Clean FontChanger - Put fonts in the res folder - Progressive transition towards a clean architecture detection system --- .../main/java/com/kdt/mcgui/MineButton.java | 2 +- .../net/kdt/pojavlaunch/Architecture.java | 6 +-- .../java/net/kdt/pojavlaunch/FontChanger.java | 33 -------------- .../java/net/kdt/pojavlaunch/JVersion.java | 43 ------------------ .../net/kdt/pojavlaunch/PojavApplication.java | 28 +++++------- .../kdt/pojavlaunch/PojavLoginActivity.java | 2 +- .../main/java/net/kdt/pojavlaunch/Tools.java | 4 +- .../font/minecraft_ten.ttf} | Bin .../font/noto_sans_bold.ttf} | Bin .../src/main/res/layout/start_screen.xml | 2 + 10 files changed, 20 insertions(+), 100 deletions(-) delete mode 100644 app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/FontChanger.java delete mode 100644 app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JVersion.java rename app_pojavlauncher/src/main/{assets/font/minecraft-ten.ttf => res/font/minecraft_ten.ttf} (100%) rename app_pojavlauncher/src/main/{assets/font/NotoSans-Bold.ttf => res/font/noto_sans_bold.ttf} (100%) diff --git a/app_pojavlauncher/src/main/java/com/kdt/mcgui/MineButton.java b/app_pojavlauncher/src/main/java/com/kdt/mcgui/MineButton.java index 6efdcfcda..9d1ff8c88 100644 --- a/app_pojavlauncher/src/main/java/com/kdt/mcgui/MineButton.java +++ b/app_pojavlauncher/src/main/java/com/kdt/mcgui/MineButton.java @@ -17,7 +17,7 @@ public class MineButton extends androidx.appcompat.widget.AppCompatButton } public void init() { - setTypeface(Typeface.createFromAsset(getContext().getAssets(), "font/NotoSans-Bold.ttf")); + setTypeface(Typeface.createFromAsset(getContext().getAssets(), "font/noto_sans_bold.ttf")); } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Architecture.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Architecture.java index bc14657fd..3f62d9f1a 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Architecture.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Architecture.java @@ -78,9 +78,9 @@ public class Architecture * @return The architecture as an int. */ public static int archAsInt(String arch){ - arch = arch.toLowerCase(); - if(arch.equals("arm64-v8a") || arch.equals("aarch64")) return ARCH_ARM64; - if(arch.contains("armeabi") ||arch.contains("armv7")) return ARCH_ARM; + arch = arch.toLowerCase().trim().replace(" ", ""); + if(arch.contains("arm64") || arch.equals("aarch64") || arch.equals("adm64")) return ARCH_ARM64; + if(arch.contains("arm")) return ARCH_ARM; if(arch.equals("x86_64")) return ARCH_X86_64; if(arch.equals("x86") || (arch.startsWith("i") && arch.endsWith("86"))) return ARCH_X86; //Shouldn't happen diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/FontChanger.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/FontChanger.java deleted file mode 100644 index 354adab61..000000000 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/FontChanger.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.kdt.pojavlaunch; - -import android.graphics.*; -import android.view.*; -import android.widget.*; -import android.content.*; -import com.kdt.mcgui.*; - -public class FontChanger -{ - private static Typeface fNotoSans, fMinecraftTen; - - public static void initFonts(Context ctx) { - fNotoSans = Typeface.createFromAsset(ctx.getAssets(), "font/NotoSans-Bold.ttf"); - fMinecraftTen = Typeface.createFromAsset(ctx.getAssets(), "font/minecraft-ten.ttf"); - } - - public static void changeFonts(ViewGroup viewTree) { - View child; - for(int i = 0; i < viewTree.getChildCount(); ++i) { - child = viewTree.getChildAt(i); - if (child instanceof ViewGroup) { - changeFonts((ViewGroup) child); - } else if (child instanceof TextView) { - changeFont((TextView) child); - } - } - } - - public static void changeFont(TextView view) { - view.setTypeface(view instanceof MineButton ? fMinecraftTen : fNotoSans); - } -} diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JVersion.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JVersion.java deleted file mode 100644 index 2b03b0cea..000000000 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JVersion.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.kdt.pojavlaunch; - -public class JVersion extends Object -{ - private String version; - private JVersion(String version) - { - this.version = version; - } - public static JVersion from(String version) - { - return new JVersion(version); - } - public boolean isVersionCode() - { - return !version.contains("."); - } - public JVersion toVersionCode() - { - if(!isVersionCode()){ - version = version.replace(".", ""); - return this; - } else throw new RuntimeException("Can't convert version code to itself"); - } - public JVersion toVersionName() - { - if(isVersionCode()){ - StringBuilder charList = new StringBuilder(); - for(int i=0; i