From c9359dc2c5effc0e96b746c56ad8578448d23b9d Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Mon, 1 Mar 2021 15:50:56 +0700 Subject: [PATCH] =?UTF-8?q?Use=20MCHeads=20for=20avatar=20head=20with=20la?= =?UTF-8?q?yers=20Idea=20suggested=20by=20@Syjalo=201=20month=20ago=20?= =?UTF-8?q?=F0=9F=98=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/assets/about_en.txt | 9 +++-- .../src/main/assets/ic_steve.png | Bin 308 -> 0 bytes .../kdt/pojavlaunch/PojavLoginActivity.java | 21 +++--------- .../pojavlaunch/value/MinecraftAccount.java | 31 ++++++++---------- 4 files changed, 24 insertions(+), 37 deletions(-) delete mode 100644 app_pojavlauncher/src/main/assets/ic_steve.png diff --git a/app_pojavlauncher/src/main/assets/about_en.txt b/app_pojavlauncher/src/main/assets/about_en.txt index 7dcdcd9ab..37e1f7767 100644 --- a/app_pojavlauncher/src/main/assets/about_en.txt +++ b/app_pojavlauncher/src/main/assets/about_en.txt @@ -1,9 +1,9 @@ %s (Minecraft Java Launcher for Android), version %s by Tran Khanh Duy (based on "Boardwalk" app)
* License:
- • This application is licensed under GNU GPLv3.
+ • This application is licensed under GNU GPLv3.
-* Third party components and their licenses:
+* Credits / Third party components and their licenses:
• Apache Commons Compress (unknown or Apache License 2.0).
• exp4j: Apache License 2.0.
• GL4ES: MIT License.
@@ -11,9 +11,12 @@ • OpenJDK: GNU GPLv2 License.
• LWJGL: LWJGL 2's License.

• pro-gradle: Apache License 2.0.
+ • More (check at GitHub). + • Privacy policy. + • Thanks to MCHeads for providing Minecraft avatars. * Notes:
- - This app is under development and will not be stable.
+ - This app is under development and might not be stable.
- This app is not affiliated with Minecraft, Mojang or Microsoft.

* Translators can be found at Crowdin diff --git a/app_pojavlauncher/src/main/assets/ic_steve.png b/app_pojavlauncher/src/main/assets/ic_steve.png deleted file mode 100644 index cbc47f01a58b8d1cfcb21b503a7050c69b20f3c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 308 zcmV-40n7f0P)YE0Knm2E|*+VX{%70B83V*fG^-If@^n&f{TwJ?t+_x zE@Pi`+}XVx;GAFAkfxej711RBtyIhX&e9;?^sJ> znsI<7WL{{jw@85V<3m&wlO_#T%LRmj{P&x)y9a{X(<5I~ia)IhLq)#G>1AyuAFlw2 zno=B`TyXQeO;VNgvNl)u8H39qjn*c?^{Y1%0000= 23 && !isStorageAllowed()){ @@ -655,22 +654,12 @@ public class PojavLoginActivity extends BaseActivity String accNameStr = s.substring(0, s.length() - 5); String skinFaceBase64 = MinecraftAccount.load(accNameStr).skinFaceBase64; - Bitmap bitmap = Bitmap.createBitmap(8, 8, Bitmap.Config.ARGB_8888); - if (skinFaceBase64 != null) { - byte[] faceIconBytes = Base64.decode(skinFaceBase64, Base64.DEFAULT); - bitmap = BitmapFactory.decodeByteArray(faceIconBytes, 0, faceIconBytes.length); - } else { - try { - bitmap = BitmapFactory.decodeStream(getAssets().open("ic_steve.png")); - } catch (IOException e) { - // Should never happen - e.printStackTrace(); - } - } - accountName.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(getResources(), - Bitmap.createScaledBitmap(bitmap, 80, 80, false)), - null, null, null); + byte[] faceIconBytes = Base64.decode(skinFaceBase64, Base64.DEFAULT); + Bitmap bitmap = BitmapFactory.decodeByteArray(faceIconBytes, 0, faceIconBytes.length); + accountName.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(getResources(), + bitmap), + null, null, null); accountName.setText(accNameStr); accountListLayout.addView(child); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/MinecraftAccount.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/MinecraftAccount.java index 7469c5b4b..422afe521 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/MinecraftAccount.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/value/MinecraftAccount.java @@ -6,36 +6,24 @@ import java.io.*; import com.google.gson.*; import android.graphics.Bitmap; import android.util.Base64; +import org.apache.commons.io.IOUtils; public class MinecraftAccount { public String accessToken = "0"; // access token public String clientToken = "0"; // clientID: refresh and invalidate - public String profileId = "0"; // authenticate UUID + public String profileId = "0"; // profile UUID, for obtaining skin public String username = "Steve"; public String selectedVersion = "1.7.10"; public boolean isMicrosoft = false; public String msaRefreshToken = "0"; public String skinFaceBase64; - public void updateSkinFace() { + void updateSkinFace(String uuid) { try { - Bitmap bSkin = AccountSkin.getSkin(profileId); - if (bSkin.getWidth() != 64 || bSkin.getHeight() != 64) { - Log.w("SkinLoader", "Only skin size 64x64 is currently supported, this skin is " + bSkin.getWidth() + "x" + bSkin.getHeight()); - return; - } - - int[] pixels = new int[8 * 8]; - bSkin.getPixels(pixels, 0, 8, 8, 8, 8, 8); - bSkin.recycle(); - - ByteArrayOutputStream outByteArr = new ByteArrayOutputStream(); - Bitmap bFace = Bitmap.createBitmap(pixels, 8, 8, Bitmap.Config.ARGB_8888); - bFace.compress(Bitmap.CompressFormat.PNG, 100, outByteArr); - bFace.recycle(); - skinFaceBase64 = Base64.encodeToString(outByteArr.toByteArray(), Base64.DEFAULT); - outByteArr.close(); + File skinFile = File.createTempFile("skin", ".png", new File(Tools.DIR_DATA, "cache")); + Tools.downloadFile("https://mc-heads.net/head/" + uuid + "/100", skinFile.getAbsolutePath()); + skinFaceBase64 = Base64.encodeToString(IOUtils.toByteArray(new FileInputStream(skinFile)), Base64.DEFAULT); Log.i("SkinLoader", "Update skin face success"); } catch (IOException e) { @@ -45,6 +33,10 @@ public class MinecraftAccount } } + public void updateSkinFace() { + updateSkinFace(profileId); + } + public String save(String outPath) throws IOException { Tools.write(outPath, Tools.GLOBAL_GSON.toJson(this)); return username; @@ -79,6 +71,9 @@ public class MinecraftAccount if (acc.msaRefreshToken == null) { acc.msaRefreshToken = "0"; } + if (acc.skinFaceBase64 == null) { + acc.updateSkinFace("MHF_Steve"); + } return acc; } catch(IOException e) { Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the profile",e);