Adapt the Firmware installer activity to the new FirmwareHelper

This commit is contained in:
Daniele Gobbetti 2015-08-05 17:31:11 +02:00
parent e92c9dbbb5
commit 65fc6f6866
1 changed files with 16 additions and 7 deletions

View File

@ -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() {