From 65fc6f68660636c5801b776b9506154590cad05f Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Wed, 5 Aug 2015 17:31:11 +0200 Subject: [PATCH] Adapt the Firmware installer activity to the new FirmwareHelper --- .../activities/FwAppInstallerActivity.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java index c292fc10..84419855 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java @@ -13,10 +13,13 @@ import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView; +import android.widget.Toast; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; + import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; @@ -24,6 +27,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PBWReader; +import nodomain.freeyourgadget.gadgetbridge.util.GB; public class FwAppInstallerActivity extends Activity { @@ -89,16 +93,21 @@ public class FwAppInstallerActivity extends Activity { } } else { mPBWReader = null; - mFwReader = new MiBandFWHelper(uri, getApplicationContext()); + try { + mFwReader = new MiBandFWHelper(uri, getApplicationContext()); - fwAppInstallTextView.setText(getString(R.string.fw_upgrade_notice, mFwReader.getHumanFirmwareVersion())); + fwAppInstallTextView.setText(getString(R.string.fw_upgrade_notice, mFwReader.getHumanFirmwareVersion())); - if (mFwReader.isFirmwareWhitelisted()) { - fwAppInstallTextView.append(" " + getString(R.string.miband_firmware_known)); - } else { - fwAppInstallTextView.append(" " + getString(R.string.miband_firmware_unknown_warning) + " " + - getString(R.string.miband_firmware_suggest_whitelist, mFwReader.getFirmwareVersion())); + if (mFwReader.isFirmwareWhitelisted()) { + fwAppInstallTextView.append(" " + getString(R.string.miband_firmware_known)); + } else { + fwAppInstallTextView.append(" " + getString(R.string.miband_firmware_unknown_warning) + " " + + getString(R.string.miband_firmware_suggest_whitelist, mFwReader.getFirmwareVersion())); + } + } catch (IOException ex) { + GB.toast(getApplicationContext(), "Firmware cannot be installed: " + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR); } + } installButton.setOnClickListener(new View.OnClickListener() {