From 5d830c2d163d916376bd815bb159f05c690b5610 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 14 Jun 2019 09:33:39 +0200 Subject: [PATCH] Cleanup, extra checks --- .../java/eu/faircode/email/ActivityView.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index ca25078f8d..5fb312514c 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -699,7 +699,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB private class UpdateInfo { String tag_name; // version - boolean prerelease; String html_url; } @@ -752,27 +751,26 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB JSONObject jroot = new JSONObject(response.toString()); - if (!jroot.has("tag_name")) + if (!jroot.has("tag_name") || jroot.isNull("tag_name")) throw new IOException("tag_name field missing"); - if (!jroot.has("html_url")) + if (!jroot.has("html_url") || jroot.isNull("html_url")) throw new IOException("html_url field missing"); - if (!jroot.has("assets")) + if (!jroot.has("assets") || jroot.isNull("assets")) throw new IOException("assets section missing"); // Get update info UpdateInfo info = new UpdateInfo(); info.tag_name = jroot.getString("tag_name"); - info.prerelease = jroot.getBoolean("prerelease"); info.html_url = jroot.getString("html_url"); // Check if new release JSONArray jassets = jroot.getJSONArray("assets"); for (int i = 0; i < jassets.length(); i++) { JSONObject jasset = jassets.getJSONObject(i); - if (jasset.has("name")) { + if (jasset.has("name") && !jasset.isNull("name")) { String name = jasset.getString("name"); - if (name != null && name.endsWith(".apk")) { - Log.i("Latest version=" + info.tag_name + " prerelease=" + info.prerelease); + if (name.endsWith(".apk")) { + Log.i("Latest version=" + info.tag_name); if (BuildConfig.VERSION_NAME.equals(info.tag_name)) return null; else @@ -800,9 +798,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB return; } - if (!always && info.prerelease) - return; - final Intent update = new Intent(Intent.ACTION_VIEW, Uri.parse(info.html_url)); if (update.resolveActivity(getPackageManager()) != null) new DialogBuilderLifecycle(ActivityView.this, ActivityView.this)