mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-25 15:32:52 +00:00
Cleanup, extra checks
This commit is contained in:
parent
1f3e4a20f1
commit
5d830c2d16
1 changed files with 6 additions and 11 deletions
|
@ -699,7 +699,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
|
|
||||||
private class UpdateInfo {
|
private class UpdateInfo {
|
||||||
String tag_name; // version
|
String tag_name; // version
|
||||||
boolean prerelease;
|
|
||||||
String html_url;
|
String html_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,27 +751,26 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
|
|
||||||
JSONObject jroot = new JSONObject(response.toString());
|
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");
|
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");
|
throw new IOException("html_url field missing");
|
||||||
if (!jroot.has("assets"))
|
if (!jroot.has("assets") || jroot.isNull("assets"))
|
||||||
throw new IOException("assets section missing");
|
throw new IOException("assets section missing");
|
||||||
|
|
||||||
// Get update info
|
// Get update info
|
||||||
UpdateInfo info = new UpdateInfo();
|
UpdateInfo info = new UpdateInfo();
|
||||||
info.tag_name = jroot.getString("tag_name");
|
info.tag_name = jroot.getString("tag_name");
|
||||||
info.prerelease = jroot.getBoolean("prerelease");
|
|
||||||
info.html_url = jroot.getString("html_url");
|
info.html_url = jroot.getString("html_url");
|
||||||
|
|
||||||
// Check if new release
|
// Check if new release
|
||||||
JSONArray jassets = jroot.getJSONArray("assets");
|
JSONArray jassets = jroot.getJSONArray("assets");
|
||||||
for (int i = 0; i < jassets.length(); i++) {
|
for (int i = 0; i < jassets.length(); i++) {
|
||||||
JSONObject jasset = jassets.getJSONObject(i);
|
JSONObject jasset = jassets.getJSONObject(i);
|
||||||
if (jasset.has("name")) {
|
if (jasset.has("name") && !jasset.isNull("name")) {
|
||||||
String name = jasset.getString("name");
|
String name = jasset.getString("name");
|
||||||
if (name != null && name.endsWith(".apk")) {
|
if (name.endsWith(".apk")) {
|
||||||
Log.i("Latest version=" + info.tag_name + " prerelease=" + info.prerelease);
|
Log.i("Latest version=" + info.tag_name);
|
||||||
if (BuildConfig.VERSION_NAME.equals(info.tag_name))
|
if (BuildConfig.VERSION_NAME.equals(info.tag_name))
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
|
@ -800,9 +798,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!always && info.prerelease)
|
|
||||||
return;
|
|
||||||
|
|
||||||
final Intent update = new Intent(Intent.ACTION_VIEW, Uri.parse(info.html_url));
|
final Intent update = new Intent(Intent.ACTION_VIEW, Uri.parse(info.html_url));
|
||||||
if (update.resolveActivity(getPackageManager()) != null)
|
if (update.resolveActivity(getPackageManager()) != null)
|
||||||
new DialogBuilderLifecycle(ActivityView.this, ActivityView.this)
|
new DialogBuilderLifecycle(ActivityView.this, ActivityView.this)
|
||||||
|
|
Loading…
Reference in a new issue