Commit e76dba0f authored by topjohnwu's avatar topjohnwu

Magisk Version now double, also support custom version names

parent aababe1a
...@@ -33,8 +33,9 @@ import butterknife.ButterKnife; ...@@ -33,8 +33,9 @@ import butterknife.ButterKnife;
public class MagiskFragment extends Fragment { public class MagiskFragment extends Fragment {
public static int magiskVersion, remoteMagiskVersion = -1, remoteAppVersionCode = -1; public static int remoteAppVersionCode = -1;
public static String magiskLink, magiskChangelog, appLink, appChangelog, remoteAppVersion; public static double magiskVersion, remoteMagiskVersion = -1;
public static String magiskVersionString, magiskLink, magiskChangelog, appLink, appChangelog, remoteAppVersion;
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
...@@ -174,10 +175,14 @@ public class MagiskFragment extends Fragment { ...@@ -174,10 +175,14 @@ public class MagiskFragment extends Fragment {
private void updateMagiskVersion() { private void updateMagiskVersion() {
List<String> ret = Shell.sh("getprop magisk.version"); List<String> ret = Shell.sh("getprop magisk.version");
try { if (ret.get(0).length() == 0) {
magiskVersion = Integer.parseInt(ret.get(0));
} catch (NumberFormatException e) {
magiskVersion = -1; 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) { if (magiskVersion == -1) {
...@@ -190,7 +195,7 @@ public class MagiskFragment extends Fragment { ...@@ -190,7 +195,7 @@ public class MagiskFragment extends Fragment {
magiskStatusContainer.setBackgroundColor(colorOK); magiskStatusContainer.setBackgroundColor(colorOK);
magiskStatusIcon.setImageResource(statusOK); magiskStatusIcon.setImageResource(statusOK);
magiskVersionText.setText(getString(R.string.magisk_version, String.valueOf(magiskVersion))); magiskVersionText.setText(getString(R.string.magisk_version, magiskVersionString));
magiskVersionText.setTextColor(colorOK); magiskVersionText.setTextColor(colorOK);
} }
} }
......
...@@ -107,7 +107,7 @@ public class Async { ...@@ -107,7 +107,7 @@ public class Async {
JSONObject magisk = json.getJSONObject("magisk"); JSONObject magisk = json.getJSONObject("magisk");
JSONObject app = json.getJSONObject("app"); JSONObject app = json.getJSONObject("app");
MagiskFragment.remoteMagiskVersion = magisk.getInt("versionCode"); MagiskFragment.remoteMagiskVersion = magisk.getDouble("versionCode");
MagiskFragment.magiskLink = magisk.getString("link"); MagiskFragment.magiskLink = magisk.getString("link");
MagiskFragment.magiskChangelog = magisk.getString("changelog"); MagiskFragment.magiskChangelog = magisk.getString("changelog");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment