use of nodomain.freeyourgadget.gadgetbridge.model.GenericItem in project Gadgetbridge by Freeyourgadget.
the class FwAppInstallerActivity method addMessage.
private void addMessage(String message, int severity) {
mDetails.add(new GenericItem(message));
mDetailsItemAdapter.notifyDataSetChanged();
}
use of nodomain.freeyourgadget.gadgetbridge.model.GenericItem in project Gadgetbridge by Freeyourgadget.
the class AbstractMiBandFWInstallHandler method validateInstallation.
@Override
public void validateInstallation(InstallActivity installActivity, GBDevice device) {
if (device.isBusy()) {
installActivity.setInfoText(device.getBusyTask());
installActivity.setInstallEnabled(false);
return;
}
if (!isSupportedDeviceType(device) || !device.isInitialized()) {
installActivity.setInfoText(mContext.getString(R.string.fwapp_install_device_not_ready));
installActivity.setInstallEnabled(false);
return;
}
try {
helper.checkValid();
} catch (IllegalArgumentException ex) {
installActivity.setInfoText(ex.getLocalizedMessage());
installActivity.setInstallEnabled(false);
return;
}
GenericItem fwItem = new GenericItem(mContext.getString(R.string.miband_installhandler_miband_firmware, helper.getHumanFirmwareVersion()));
fwItem.setIcon(R.drawable.ic_device_miband);
if (!helper.isFirmwareGenerallyCompatibleWith(device)) {
fwItem.setDetails(mContext.getString(R.string.miband_fwinstaller_incompatible_version));
installActivity.setInfoText(mContext.getString(R.string.fwinstaller_firmware_not_compatible_to_device));
installActivity.setInstallEnabled(false);
return;
}
StringBuilder builder = new StringBuilder();
if (helper.isSingleFirmware()) {
builder.append(mContext.getString(R.string.fw_upgrade_notice, helper.getHumanFirmwareVersion()));
} else {
builder.append(mContext.getString(R.string.fw_multi_upgrade_notice, helper.getHumanFirmwareVersion(), helper.getHumanFirmwareVersion2()));
}
if (helper.isFirmwareWhitelisted()) {
builder.append(" ").append(mContext.getString(R.string.miband_firmware_known));
fwItem.setDetails(mContext.getString(R.string.miband_fwinstaller_compatible_version));
// TODO: set a CHECK (OKAY) button
} else {
builder.append(" ").append(mContext.getString(R.string.miband_firmware_unknown_warning)).append(" \n\n").append(mContext.getString(R.string.miband_firmware_suggest_whitelist, helper.getFirmwareVersion()));
fwItem.setDetails(mContext.getString(R.string.miband_fwinstaller_untested_version));
// TODO: set a UNKNOWN (question mark) button
}
installActivity.setInfoText(builder.toString());
installActivity.setInstallItem(fwItem);
installActivity.setInstallEnabled(true);
}
use of nodomain.freeyourgadget.gadgetbridge.model.GenericItem in project Gadgetbridge by Freeyourgadget.
the class PBWInstallHandler method validateInstallation.
@Override
public void validateInstallation(InstallActivity installActivity, GBDevice device) {
if (device.isBusy()) {
installActivity.setInfoText(device.getBusyTask());
installActivity.setInstallEnabled(false);
return;
}
if (device.getType() != DeviceType.PEBBLE || !device.isConnected()) {
installActivity.setInfoText("Element cannot be installed");
installActivity.setInstallEnabled(false);
return;
}
String platformName = PebbleUtils.getPlatformName(device.getModel());
try {
mPBWReader = new PBWReader(mUri, mContext, platformName);
} catch (FileNotFoundException e) {
installActivity.setInfoText("file not found");
installActivity.setInstallEnabled(false);
return;
} catch (IOException e) {
installActivity.setInfoText("error reading file");
installActivity.setInstallEnabled(false);
return;
}
if (!mPBWReader.isValid()) {
installActivity.setInfoText("pbw/pbz is broken or incompatible with your Hardware or Firmware.");
installActivity.setInstallEnabled(false);
return;
}
GenericItem installItem = new GenericItem();
// FIXME: do not set twice
installItem.setIcon(R.drawable.ic_watchapp);
if (mPBWReader.isFirmware()) {
installItem.setIcon(R.drawable.ic_firmware);
String hwRevision = mPBWReader.getHWRevision();
if (hwRevision != null && hwRevision.equals(device.getModel())) {
installItem.setName(mContext.getString(R.string.pbw_installhandler_pebble_firmware, ""));
installItem.setDetails(mContext.getString(R.string.pbwinstallhandler_correct_hw_revision));
installActivity.setInfoText(mContext.getString(R.string.firmware_install_warning, hwRevision));
installActivity.setInstallEnabled(true);
} else {
if (hwRevision != null) {
installItem.setName(mContext.getString(R.string.pbw_installhandler_pebble_firmware, hwRevision));
installItem.setDetails(mContext.getString(R.string.pbwinstallhandler_incorrect_hw_revision));
}
installActivity.setInfoText(mContext.getString(R.string.pbw_install_handler_hw_revision_mismatch));
installActivity.setInstallEnabled(false);
}
} else {
GBDeviceApp app = mPBWReader.getGBDeviceApp();
if (app != null) {
installItem.setName(app.getName());
installItem.setDetails(mContext.getString(R.string.pbwinstallhandler_app_item, app.getCreator(), app.getVersion()));
int drawable;
if (mPBWReader.isLanguage()) {
drawable = R.drawable.ic_languagepack;
} else {
switch(app.getType()) {
case WATCHFACE:
drawable = R.drawable.ic_watchface;
break;
case APP_ACTIVITYTRACKER:
drawable = R.drawable.ic_activitytracker;
break;
default:
drawable = R.drawable.ic_watchapp;
}
}
installItem.setIcon(drawable);
installActivity.setInfoText(mContext.getString(R.string.app_install_info, app.getName(), app.getVersion(), app.getCreator()));
installActivity.setInstallEnabled(true);
} else {
installActivity.setInfoText(mContext.getString(R.string.pbw_install_handler_unable_to_install, mUri.getPath()));
installActivity.setInstallEnabled(false);
}
}
if (installItem.getName() != null) {
installActivity.setInstallItem(installItem);
}
}
use of nodomain.freeyourgadget.gadgetbridge.model.GenericItem in project Gadgetbridge by Freeyourgadget.
the class GBDevice method getDeviceInfos.
public List<ItemWithDetails> getDeviceInfos() {
List<ItemWithDetails> result = new ArrayList<>();
if (mDeviceInfos != null) {
result.addAll(mDeviceInfos);
}
if (mModel != null) {
result.add(new GenericItem(DEVINFO_HW_VER, mModel));
}
if (mFirmwareVersion != null) {
result.add(new GenericItem(DEVINFO_FW_VER, mFirmwareVersion));
}
if (mFirmwareVersion2 != null) {
result.add(new GenericItem(DEVINFO_HR_VER, mFirmwareVersion2));
}
if (mAddress != null) {
result.add(new GenericItem(DEVINFO_ADDR, mAddress));
}
if (mVolatileAddress != null) {
result.add(new GenericItem(DEVINFO_ADDR2, mVolatileAddress));
}
Collections.sort(result);
return result;
}
Aggregations