From e76dba0f84b4281f471667d6dcc66bd9a5bdca13 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 9 Nov 2016 01:28:05 +0800 Subject: [PATCH] Magisk Version now double, also support custom version names --- .../com/topjohnwu/magisk/MagiskFragment.java | 17 +++++++++++------ .../java/com/topjohnwu/magisk/utils/Async.java | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java index ffd61a7b0..d3ffb18b7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java @@ -33,8 +33,9 @@ import butterknife.ButterKnife; public class MagiskFragment extends Fragment { - public static int magiskVersion, remoteMagiskVersion = -1, remoteAppVersionCode = -1; - public static String magiskLink, magiskChangelog, appLink, appChangelog, remoteAppVersion; + public static int remoteAppVersionCode = -1; + public static double magiskVersion, remoteMagiskVersion = -1; + public static String magiskVersionString, magiskLink, magiskChangelog, appLink, appChangelog, remoteAppVersion; @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; @@ -174,10 +175,14 @@ public class MagiskFragment extends Fragment { private void updateMagiskVersion() { List ret = Shell.sh("getprop magisk.version"); - try { - magiskVersion = Integer.parseInt(ret.get(0)); - } catch (NumberFormatException e) { + if (ret.get(0).length() == 0) { magiskVersion = -1; + } else try { + magiskVersionString = ret.get(0); + magiskVersion = Double.parseDouble(ret.get(0)); + } catch (NumberFormatException e) { + // Custom version don't need to receive updates + magiskVersion = Double.POSITIVE_INFINITY; } if (magiskVersion == -1) { @@ -190,7 +195,7 @@ public class MagiskFragment extends Fragment { magiskStatusContainer.setBackgroundColor(colorOK); magiskStatusIcon.setImageResource(statusOK); - magiskVersionText.setText(getString(R.string.magisk_version, String.valueOf(magiskVersion))); + magiskVersionText.setText(getString(R.string.magisk_version, magiskVersionString)); magiskVersionText.setTextColor(colorOK); } } diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java index 7cc7ffc27..9f93944c2 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java @@ -107,7 +107,7 @@ public class Async { JSONObject magisk = json.getJSONObject("magisk"); JSONObject app = json.getJSONObject("app"); - MagiskFragment.remoteMagiskVersion = magisk.getInt("versionCode"); + MagiskFragment.remoteMagiskVersion = magisk.getDouble("versionCode"); MagiskFragment.magiskLink = magisk.getString("link"); MagiskFragment.magiskChangelog = magisk.getString("changelog");