From 35a480bb2f6302b06ca6e20557fadb3d8a1a7d20 Mon Sep 17 00:00:00 2001 From: Andrey Prygunkov Date: Tue, 28 Jul 2015 23:15:24 +0200 Subject: [PATCH] added version check for 16.0 Avoiding download of stable 15.0 which cannot be installed anyway. --- .../net/nzbget/nzbget/InstallActivity.java | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/net/nzbget/nzbget/InstallActivity.java b/app/src/main/java/net/nzbget/nzbget/InstallActivity.java index a5d9e89..041d63d 100644 --- a/app/src/main/java/net/nzbget/nzbget/InstallActivity.java +++ b/app/src/main/java/net/nzbget/nzbget/InstallActivity.java @@ -64,6 +64,12 @@ private void enableButtons(boolean enabled) { findViewById(R.id.customButton).setEnabled(enabled); } + private void finished() { + setStatusText(null); + enableButtons(true); + downloading = false; + } + public void installDaemon(View view) { setStatusText("Downloading installer package..."); @@ -98,9 +104,9 @@ public void installCustom(View view) { if (downloadName != null) { installFile(downloadName); } else { - MessageActivity.showErrorMessage(this, "NZBGet daemon installer", "Could not find NZBGet daemon installer in Download-directory.", null); - enableButtons(true); - setStatusText(null); + MessageActivity.showErrorMessage(this, "NZBGet daemon installer", + "Could not find NZBGet daemon installer in Download-directory.", null); + finished(); } } @@ -177,12 +183,23 @@ private void infoCompleted(long aLong) { file.delete(); } catch (IOException e) { - MessageActivity.showErrorMessage(this, "NZBGet daemon installer", "Could not read version info:" + e.getMessage(), null); + MessageActivity.showErrorMessage(this, "NZBGet daemon installer", + "Could not read version info:" + e.getMessage(), null); + finished(); + return; + } + + if (downloadUrl.indexOf("nzbget-15.") > -1) { + MessageActivity.showErrorMessage(this, "NZBGet daemon installer", + "This installer requires version 16.0, which seems to be not released yet. Please install the testing version instead.", null); + finished(); return; } if (downloadUrl == null) { - MessageActivity.showErrorMessage(this, "NZBGet daemon installer", "Could not read version info: file format error.", null); + MessageActivity.showErrorMessage(this, "NZBGet daemon installer", + "Could not read version info: file format error.", null); + finished(); return; } @@ -246,9 +263,7 @@ private void cancelDownload() { //Patch for bug: http://code.google.com/p/android/issues/detail?id=6191 } - setStatusText(null); - enableButtons(true); - downloading = false; + finished(); } protected void downloadCompleted(long downloadId) { @@ -264,8 +279,7 @@ protected void downloadCompleted(long downloadId) { if (!validDownload(downloadId)) { MessageActivity.showErrorMessage(this, "NZBGet daemon installer", "Download failed.", null); - setStatusText(null); - enableButtons(true); + finished(); return; } @@ -325,8 +339,7 @@ public void onClick() { MessageActivity.showLogMessage(activity, "NZBGet daemon installation failed."); } - enableButtons(true); - setStatusText(null); + finished(); } }); }