diff --git a/CHANGELOG.md b/CHANGELOG.md index 0216a5ec1..fade77367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ### Changelog +#### Version 0.23.0 +* Initial support for LineageOS/CyanogenMod weather provider +* Amazfit Bip/Cor: Support for current weather temperature +* Amazfit Bip/Cor: Display firmware version and type also for non-whitelisted firmware files + #### Version 0.22.5 * Unlock Teclast H10 support using the same code as H30 * Amazfit Bip: Fix installation of 0.1.0.11 Firmware diff --git a/README.md b/README.md index c705d0530..21823bcf4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ vendor's servers. * Pebble 2 (add the device from within Gadgetbridge!) [Wiki section about pebble](https://github.com/Freeyourgadget/Gadgetbridge/wiki/Pebble), most parts apply to Pebble 2 as well * Mi Band, Mi Band 1A, Mi Band 1S [Wiki section about this device](https://github.com/Freeyourgadget/Gadgetbridge/wiki/Mi-Band) * Mi Band 2 [Wiki section about mi band](https://github.com/Freeyourgadget/Gadgetbridge/wiki/Mi-Band), some parts apply to mi band 2 as well -* Amazfit Bip (WIP) [Wiki section about the Amazfit Bip](https://github.com/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip) +* Amazfit Bip [Wiki section about the Amazfit Bip](https://github.com/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip) +* Amazfit Cor (no maintainer) [Wiki section about the Amazfit Cor](https://github.com/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cor) * HPlus Devices (e.g. ZeBand) [Wiki section about this device](https://github.com/Freeyourgadget/Gadgetbridge/wiki/HPlus) * Teclast H30 (WIP) * NO.1 F1 (WIP) diff --git a/app/build.gradle b/app/build.gradle index b02e76497..8534d1abe 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,8 +26,8 @@ android { targetSdkVersion 25 // note: always bump BOTH versionCode and versionName! - versionName "0.22.5" - versionCode 113 + versionName "0.23.0" + versionCode 114 vectorDrawables.useSupportLibrary = true } buildTypes { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java index cc8a5144f..da63c3c73 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java @@ -43,11 +43,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import nodomain.freeyourgadget.gadgetbridge.BuildConfig; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceManager; import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandPreferencesActivity; -import nodomain.freeyourgadget.gadgetbridge.externalevents.CMWeatherReceiver; import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; import nodomain.freeyourgadget.gadgetbridge.util.GB; @@ -268,7 +268,7 @@ public class SettingsActivity extends AbstractSettingsActivity { GBApplication.getPrefs().getPreferences().edit().putString("weather_cityid",null).apply(); preference.setSummary(newVal.toString()); Intent intent = new Intent("GB_UPDATE_WEATHER"); - intent.setPackage(CMWeatherReceiver.class.getCanonicalName()); + intent.setPackage(BuildConfig.APPLICATION_ID); sendBroadcast(intent); return true; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiFWHelper.java index 0cd16f984..50c54bc53 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiFWHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiFWHelper.java @@ -18,12 +18,16 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami; import android.content.Context; import android.net.Uri; +import android.support.annotation.NonNull; import java.io.IOException; +import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareInfo; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType; public abstract class HuamiFWHelper extends AbstractMiBandFWHelper { protected HuamiFirmwareInfo firmwareInfo; @@ -37,6 +41,41 @@ public abstract class HuamiFWHelper extends AbstractMiBandFWHelper { return firmwareInfo.toVersion(version); } + @NonNull + @Override + public String getFirmwareKind() { + int resId = R.string.kind_invalid; + switch (getFirmwareInfo().getFirmwareType()) { + case FONT: + resId = R.string.kind_font; + break; + case GPS: + resId = R.string.kind_gps; + break; + case GPS_ALMANAC: + resId = R.string.kind_gps_almanac; + break; + case GPS_CEP: + resId = R.string.kind_gps_cep; + break; + case RES: + resId = R.string.kind_resources; + break; + case RES_NEW: + resId = R.string.kind_resources; + break; + case FIRMWARE: + resId = R.string.kind_firmware; + break; + case WATCHFACE: + resId = R.string.kind_watchface; + break; + case INVALID: + // fall through + } + return GBApplication.getContext().getString(resId); + } + @Override public int getFirmwareVersion() { return firmwareInfo.getFirmwareVersion(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipFWInstallHandler.java index 981cba76b..77438bc9c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipFWInstallHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipFWInstallHandler.java @@ -26,18 +26,12 @@ import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelpe import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.model.GenericItem; class AmazfitBipFWInstallHandler extends AbstractMiBandFWInstallHandler { AmazfitBipFWInstallHandler(Uri uri, Context context) { super(uri, context); } - @Override - protected GenericItem createInstallItem() { - return new GenericItem(mContext.getString(R.string.amazfitbip_firmware, helper.getHumanFirmwareVersion())); - } - @Override protected String getFwUpgradeNotice() { return mContext.getString(R.string.fw_upgrade_notice_amazfitbip, helper.getHumanFirmwareVersion()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorFWInstallHandler.java index 2316e12e3..a13800f3d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorFWInstallHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcor/AmazfitCorFWInstallHandler.java @@ -22,23 +22,16 @@ import android.net.Uri; import java.io.IOException; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.model.GenericItem; class AmazfitCorFWInstallHandler extends AbstractMiBandFWInstallHandler { AmazfitCorFWInstallHandler(Uri uri, Context context) { super(uri, context); } - @Override - protected GenericItem createInstallItem() { - return new GenericItem(mContext.getString(R.string.amazfitcor_firmware, helper.getHumanFirmwareVersion())); - } - @Override protected String getFwUpgradeNotice() { return mContext.getString(R.string.fw_upgrade_notice_amazfitcor, helper.getHumanFirmwareVersion()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/AbstractMiBandFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/AbstractMiBandFWHelper.java index 628c3907b..e22c22f59 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/AbstractMiBandFWHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/AbstractMiBandFWHelper.java @@ -61,6 +61,12 @@ public abstract class AbstractMiBandFWHelper { } } + /** + * Returns a localized, user-visible representation of the kind of firmware to be installed. + */ + @NonNull + public abstract String getFirmwareKind(); + public abstract int getFirmwareVersion(); public abstract int getFirmware2Version(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/AbstractMiBandFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/AbstractMiBandFWInstallHandler.java index f677ab442..27a0a860c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/AbstractMiBandFWInstallHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/AbstractMiBandFWInstallHandler.java @@ -58,8 +58,8 @@ public abstract class AbstractMiBandFWInstallHandler implements InstallHandler { protected abstract AbstractMiBandFWHelper createHelper(Uri uri, Context context) throws IOException; - protected GenericItem createInstallItem() { - return new GenericItem(mContext.getString(R.string.miband_installhandler_miband_firmware, helper.getHumanFirmwareVersion())); + protected GenericItem createInstallItem(GBDevice device) { + return new GenericItem(mContext.getString(R.string.installhandler_firmware_name, mContext.getString(device.getType().getName()), helper.getFirmwareKind(), helper.getHumanFirmwareVersion())); } protected String getFwUpgradeNotice() { @@ -88,7 +88,7 @@ public abstract class AbstractMiBandFWInstallHandler implements InstallHandler { return; } - GenericItem fwItem = createInstallItem(); + GenericItem fwItem = createInstallItem(device); fwItem.setIcon(device.getType().getIcon()); if (!helper.isFirmwareGenerallyCompatibleWith(device)) { @@ -112,7 +112,7 @@ public abstract class AbstractMiBandFWInstallHandler implements InstallHandler { // 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())); + .append(mContext.getString(R.string.miband_firmware_suggest_whitelist, String.valueOf(helper.getFirmwareVersion()))); fwItem.setDetails(mContext.getString(R.string.miband_fwinstaller_untested_version)); // TODO: set a UNKNOWN (question mark) button } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWHelper.java index 450a7a2a5..5e16ea4c4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWHelper.java @@ -26,6 +26,8 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.AbstractMiFirmwareInfo; @@ -67,6 +69,12 @@ public class MiBandFWHelper extends AbstractMiBandFWHelper { super(uri, context); } + @NonNull + @Override + public String getFirmwareKind() { + return GBApplication.getContext().getString(R.string.kind_firmware); + } + @Override public int getFirmwareVersion() { // FIXME: UnsupportedOperationException! diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/AlarmReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/AlarmReceiver.java index 6a5823beb..b4e815822 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/AlarmReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/AlarmReceiver.java @@ -51,7 +51,7 @@ public class AlarmReceiver extends BroadcastReceiver { Context context = GBApplication.getContext(); Intent intent = new Intent("DAILY_ALARM"); intent.setPackage(BuildConfig.APPLICATION_ID); - PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, new Intent("DAILY_ALARM"), 0); + PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); AlarmManager am = (AlarmManager) (context.getSystemService(Context.ALARM_SERVICE)); if (am != null) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CMWeatherReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CMWeatherReceiver.java index 2513956af..d061372d0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CMWeatherReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/CMWeatherReceiver.java @@ -18,6 +18,7 @@ import cyanogenmod.weather.CMWeatherManager; import cyanogenmod.weather.WeatherInfo; import cyanogenmod.weather.WeatherLocation; import cyanogenmod.weather.util.WeatherUtils; +import nodomain.freeyourgadget.gadgetbridge.BuildConfig; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.model.Weather; import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; @@ -83,7 +84,9 @@ public class CMWeatherReceiver extends BroadcastReceiver implements CMWeatherMan } if (enable) { - mPendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent("GB_UPDATE_WEATHER"), 0); + Intent intent = new Intent("GB_UPDATE_WEATHER"); + intent.setPackage(BuildConfig.APPLICATION_ID); + mPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); am.setInexactRepeating(AlarmManager.RTC_WAKEUP, Calendar.getInstance().getTimeInMillis() + 10000, AlarmManager.INTERVAL_HOUR, mPendingIntent); } else { am.cancel(mPendingIntent); @@ -129,9 +132,9 @@ public class CMWeatherReceiver extends BroadcastReceiver implements CMWeatherMan weatherSpec.todayMaxTemp = (int) weatherInfo.getTodaysHigh() + 273; weatherSpec.todayMinTemp = (int) weatherInfo.getTodaysLow() + 273; } - weatherSpec.currentConditionCode = Weather.mapToOpenWeatherMapCondition(CMtoYahooCondintion(weatherInfo.getConditionCode())); weatherSpec.currentCondition = Weather.getConditionString(weatherSpec.currentConditionCode); + weatherSpec.currentHumidity = (int) weatherInfo.getHumidity(); weatherSpec.forecasts = new ArrayList<>(); List forecasts = weatherInfo.getForecasts(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/WeatherNotificationReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/WeatherNotificationReceiver.java index 102bd22a5..f016b61e5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/WeatherNotificationReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/WeatherNotificationReceiver.java @@ -48,7 +48,6 @@ public class WeatherNotificationReceiver extends BroadcastReceiver { if (parcelableWeather2 != null) { Weather weather = Weather.getInstance(); - weather.setReconstructedOWMWeather(parcelableWeather2.reconstructedOWMWeather); weather.setReconstructedOWMForecast(parcelableWeather2.reconstructedOWMForecast); WeatherSpec weatherSpec = parcelableWeather2.weatherSpec; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java index ff9f90072..b56551193 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.model; import android.support.annotation.DrawableRes; +import android.support.annotation.StringRes; import nodomain.freeyourgadget.gadgetbridge.R; @@ -28,31 +29,34 @@ import nodomain.freeyourgadget.gadgetbridge.R; * and may not be changed. */ public enum DeviceType { - UNKNOWN(-1, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled), - PEBBLE(1, R.drawable.ic_device_pebble, R.drawable.ic_device_pebble_disabled), - MIBAND(10, R.drawable.ic_device_miband, R.drawable.ic_device_miband_disabled), - MIBAND2(11, R.drawable.ic_device_miband, R.drawable.ic_device_miband_disabled), - AMAZFITBIP(12, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled), - AMAZFITCOR(13, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled), - VIBRATISSIMO(20, R.drawable.ic_device_lovetoy, R.drawable.ic_device_lovetoy_disabled), - LIVEVIEW(30, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled), - HPLUS(40, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled), - MAKIBESF68(41, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled), - EXRIZUK8(42, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled), - NO1F1(50, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled), - TECLASTH30(60, R.drawable.ic_device_h30_h10, R.drawable.ic_device_h30_h10_disabled), - TEST(1000, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled); + UNKNOWN(-1, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_unknown), + PEBBLE(1, R.drawable.ic_device_pebble, R.drawable.ic_device_pebble_disabled, R.string.devicetype_pebble), + MIBAND(10, R.drawable.ic_device_miband, R.drawable.ic_device_miband_disabled, R.string.devicetype_miband), + MIBAND2(11, R.drawable.ic_device_miband, R.drawable.ic_device_miband_disabled, R.string.devicetype_miband2), + AMAZFITBIP(12, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_amazfit_bip), + AMAZFITCOR(13, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_amazfit_cor), + VIBRATISSIMO(20, R.drawable.ic_device_lovetoy, R.drawable.ic_device_lovetoy_disabled, R.string.devicetype_vibratissimo), + LIVEVIEW(30, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_liveview), + HPLUS(40, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_hplus), + MAKIBESF68(41, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_makibes_f68), + EXRIZUK8(42, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_exrizu_k8), + NO1F1(50, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_no1_f1), + TECLASTH30(60, R.drawable.ic_device_h30_h10, R.drawable.ic_device_h30_h10_disabled, R.string.devicetype_teclast_h30), + TEST(1000, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_test); private final int key; @DrawableRes private final int defaultIcon; @DrawableRes private final int disabledIcon; + @StringRes + private final int name; - DeviceType(int key, int defaultIcon, int disabledIcon) { + DeviceType(int key, int defaultIcon, int disabledIcon, int name) { this.key = key; this.defaultIcon = defaultIcon; this.disabledIcon = disabledIcon; + this.name = name; } public int getKey() { @@ -72,6 +76,11 @@ public enum DeviceType { return DeviceType.UNKNOWN; } + @StringRes + public int getName() { + return name; + } + @DrawableRes public int getIcon() { return defaultIcon; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/Weather.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/Weather.java index fd758aa86..410804503 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/Weather.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/Weather.java @@ -16,12 +16,17 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.model; +import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Weather { + private static final Logger LOG = LoggerFactory.getLogger(Weather.class); + private WeatherSpec weatherSpec = null; - private JSONObject reconstructedOWMWeather = null; private JSONObject reconstructedOWMForecast = null; public WeatherSpec getWeatherSpec() { @@ -32,12 +37,36 @@ public class Weather { this.weatherSpec = weatherSpec; } - public JSONObject getReconstructedOWMWeather() { - return reconstructedOWMWeather; - } + public JSONObject createReconstructedOWMWeatherReply() { + if (weatherSpec == null) { + return null; + } + JSONObject reconstructedOWMWeather = new JSONObject(); + JSONArray weather = new JSONArray(); + JSONObject condition = new JSONObject(); + JSONObject main = new JSONObject(); - public void setReconstructedOWMWeather(JSONObject reconstructedOWMWeather) { - this.reconstructedOWMWeather = reconstructedOWMWeather; + try { + condition.put("id", weatherSpec.currentConditionCode); + condition.put("main", weatherSpec.currentCondition); + condition.put("icon", Weather.mapToOpenWeatherMapIcon(weatherSpec.currentConditionCode)); + weather.put(condition); + + main.put("temp", weatherSpec.currentTemp); + main.put("humidity", weatherSpec.currentHumidity); + main.put("temp_min", weatherSpec.todayMinTemp); + main.put("temp_max", weatherSpec.todayMaxTemp); + main.put("name", weatherSpec.location); + + reconstructedOWMWeather.put("weather", weather); + reconstructedOWMWeather.put("main", main); + + } catch (JSONException e) { + LOG.error("Error while reconstructing OWM weather reply"); + return null; + } + LOG.debug("Weather JSON for WEBVIEW: " + reconstructedOWMWeather.toString()); + return reconstructedOWMWeather; } public JSONObject getReconstructedOWMForecast() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/WeatherSpec.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/WeatherSpec.java index 8ea43c05d..5f84eb423 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/WeatherSpec.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/WeatherSpec.java @@ -39,6 +39,7 @@ public class WeatherSpec implements Parcelable { public int currentTemp; public int currentConditionCode = 3200; public String currentCondition; + public int currentHumidity; public int todayMaxTemp; public int todayMinTemp; public ArrayList forecasts = new ArrayList<>(); @@ -53,6 +54,7 @@ public class WeatherSpec implements Parcelable { currentTemp = in.readInt(); currentConditionCode = in.readInt(); currentCondition = in.readString(); + currentHumidity = in.readInt(); todayMaxTemp = in.readInt(); todayMinTemp = in.readInt(); in.readList(forecasts, Forecast.class.getClassLoader()); @@ -70,6 +72,7 @@ public class WeatherSpec implements Parcelable { dest.writeInt(currentTemp); dest.writeInt(currentConditionCode); dest.writeString(currentCondition); + dest.writeInt(currentHumidity); dest.writeInt(todayMaxTemp); dest.writeInt(todayMinTemp); dest.writeList(forecasts); @@ -90,20 +93,23 @@ public class WeatherSpec implements Parcelable { public int minTemp; public int maxTemp; public int conditionCode; + public int humidity; public Forecast() { } - public Forecast(int minTemp, int maxTemp, int conditionCode) { + public Forecast(int minTemp, int maxTemp, int conditionCode, int humidity) { this.minTemp = minTemp; this.maxTemp = maxTemp; this.conditionCode = conditionCode; + this.humidity = humidity; } Forecast(Parcel in) { minTemp = in.readInt(); maxTemp = in.readInt(); conditionCode = in.readInt(); + humidity = in.readInt(); } @Override @@ -116,6 +122,7 @@ public class WeatherSpec implements Parcelable { dest.writeInt(minTemp); dest.writeInt(maxTemp); dest.writeInt(conditionCode); + dest.writeInt(humidity); } } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipFirmwareInfo.java index 1f90a9de9..cfc50290c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipFirmwareInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipFirmwareInfo.java @@ -66,25 +66,30 @@ public class AmazfitBipFirmwareInfo extends HuamiFirmwareInfo { crcToVersion.put(57724, "0.0.8.88"); crcToVersion.put(27668, "0.0.8.96"); crcToVersion.put(60173, "0.0.8.97"); - crcToVersion.put(3462, "0.0.8.98"); + crcToVersion.put(3462, "0.0.8.98"); crcToVersion.put(55420, "0.0.9.14"); crcToVersion.put(39465, "0.0.9.26"); crcToVersion.put(27394, "0.0.9.40"); crcToVersion.put(24736, "0.0.9.49"); crcToVersion.put(49555, "0.0.9.59"); + crcToVersion.put(28586, "0.1.0.08"); crcToVersion.put(26714, "0.1.0.11"); + crcToVersion.put(64160, "0.1.0.17"); + crcToVersion.put(43028, "0.1.0.27"); // resources - crcToVersion.put(12586, "RES 0.0.8.74"); - crcToVersion.put(34068, "RES 0.0.8.88"); - crcToVersion.put(59839, "RES 0.0.8.96-98"); - crcToVersion.put(50401, "RES 0.0.9.14-26"); - crcToVersion.put(22051, "RES 0.0.9.40"); - crcToVersion.put(46233, "RES 0.0.9.49-0.1.0.11"); + crcToVersion.put(12586, "0.0.8.74"); + crcToVersion.put(34068, "0.0.8.88"); + crcToVersion.put(59839, "0.0.8.96-98"); + crcToVersion.put(50401, "0.0.9.14-26"); + crcToVersion.put(22051, "0.0.9.40"); + crcToVersion.put(46233, "0.0.9.49-0.1.0.11"); + crcToVersion.put(12098, "0.1.0.17"); + crcToVersion.put(28696, "0.1.0.27"); // gps - crcToVersion.put(61520, "GPS 9367,8f79a91,0,0,"); - crcToVersion.put(8784, "GPS 9565,dfbd8fa,0,0,"); + crcToVersion.put(61520, "9367,8f79a91,0,0,"); + crcToVersion.put(8784, "9565,dfbd8fa,0,0,"); } public AmazfitBipFirmwareInfo(byte[] bytes) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java index 47a6e8fb2..850d4764f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java @@ -170,7 +170,7 @@ public class AmazfitBipSupport extends MiBand2Support { TransactionBuilder builder; builder = performInitialized("Sending air quality index"); int length = 8; - String aqiString = "(fake)"; + String aqiString = "(n/a)"; if (supportsConditionString) { length += aqiString.getBytes().length + 1; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/GBWebClient.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/GBWebClient.java index 311c33dca..ca0ecaf44 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/GBWebClient.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/webview/GBWebClient.java @@ -140,11 +140,8 @@ public class GBWebClient extends WebViewClient { CurrentPosition currentPosition = new CurrentPosition(); try { - JSONObject resp; - - if ("/data/2.5/weather".equals(type) && Weather.getInstance().getReconstructedOWMWeather() != null) { - resp = new JSONObject(Weather.getInstance().getReconstructedOWMWeather().toString()); - + JSONObject resp = Weather.getInstance().createReconstructedOWMWeatherReply(); + if ("/data/2.5/weather".equals(type) && resp != null) { JSONObject main = resp.getJSONObject("main"); convertTemps(main, units); //caller might want different units diff --git a/app/src/main/java/ru/gelin/android/weather/notification/ParcelableWeather2.java b/app/src/main/java/ru/gelin/android/weather/notification/ParcelableWeather2.java index 6707939f5..d30a2707a 100644 --- a/app/src/main/java/ru/gelin/android/weather/notification/ParcelableWeather2.java +++ b/app/src/main/java/ru/gelin/android/weather/notification/ParcelableWeather2.java @@ -35,7 +35,6 @@ public class ParcelableWeather2 implements Parcelable { // getters and setters suck ;) public WeatherSpec weatherSpec = new WeatherSpec(); - public JSONObject reconstructedOWMWeather = null; public JSONObject reconstructedOWMForecast = null; private ParcelableWeather2(Parcel in) { @@ -53,11 +52,6 @@ public class ParcelableWeather2 implements Parcelable { int conditions = bundle.getInt("weather_conditions"); if (conditions > 0) { Bundle conditionBundle = in.readBundle(getClass().getClassLoader()); - reconstructedOWMWeather = new JSONObject(); - JSONArray weather = new JSONArray(); - JSONObject condition = new JSONObject(); - JSONObject main = new JSONObject(); - weatherSpec.currentCondition = conditionBundle.getString("weather_condition_text"); conditionBundle.getStringArray("weather_condition_types"); weatherSpec.currentTemp = conditionBundle.getInt("weather_current_temp"); @@ -68,25 +62,8 @@ public class ParcelableWeather2 implements Parcelable { } weatherSpec.todayMinTemp = conditionBundle.getInt("weather_low_temp"); weatherSpec.todayMaxTemp = conditionBundle.getInt("weather_high_temp"); - try { - condition.put("id", weatherSpec.currentConditionCode); - condition.put("main", weatherSpec.currentCondition); - condition.put("icon", Weather.mapToOpenWeatherMapIcon(weatherSpec.currentConditionCode)); - weather.put(condition); + weatherSpec.currentHumidity = conditionBundle.getInt("weather_humidity_value"); - main.put("temp", weatherSpec.currentTemp); - main.put("humidity", conditionBundle.getInt("weather_humidity_value")); - main.put("temp_min", weatherSpec.todayMinTemp); - main.put("temp_max", weatherSpec.todayMaxTemp); - main.put("name", weatherSpec.location); - - reconstructedOWMWeather.put("weather", weather); - reconstructedOWMWeather.put("main", main); - - } catch (JSONException e) { - e.printStackTrace(); - } - LOG.debug("Weather JSON for WEBVIEW: " + reconstructedOWMWeather.toString()); //fetch forecasts int timeOffset = 0; @@ -95,9 +72,9 @@ public class ParcelableWeather2 implements Parcelable { while (--conditions > 0) { timeOffset += 86400000; //manually determined JSONObject item = new JSONObject(); - condition = new JSONObject(); - main = new JSONObject(); - weather = new JSONArray(); + JSONObject condition = new JSONObject(); + JSONObject main = new JSONObject(); + JSONArray weather = new JSONArray(); Bundle forecastBundle = in.readBundle(getClass().getClassLoader()); String[] forecastConditionType = forecastBundle.getStringArray("weather_condition_types"); int forecastConditionCode = 0; @@ -106,7 +83,8 @@ public class ParcelableWeather2 implements Parcelable { } int forecastLowTemp = forecastBundle.getInt("weather_low_temp"); int forecastHighTemp = forecastBundle.getInt("weather_high_temp"); - weatherSpec.forecasts.add(new WeatherSpec.Forecast(forecastLowTemp, forecastHighTemp, forecastConditionCode)); + int forecastHumidity = forecastBundle.getInt("weather_humidity_value"); + weatherSpec.forecasts.add(new WeatherSpec.Forecast(forecastLowTemp, forecastHighTemp, forecastConditionCode, forecastHumidity)); try { condition.put("id", forecastConditionCode); condition.put("main", forecastBundle.getString("weather_condition_text")); @@ -114,7 +92,7 @@ public class ParcelableWeather2 implements Parcelable { weather.put(condition); main.put("temp", forecastBundle.getInt("weather_current_temp")); - main.put("humidity", forecastBundle.getInt("weather_humidity_value")); + main.put("humidity", forecastHumidity); main.put("temp_min", forecastLowTemp); main.put("temp_max", forecastHighTemp); diff --git a/app/src/main/res/layout/activity_appinstaller.xml b/app/src/main/res/layout/activity_appinstaller.xml index 3dc4aa3e1..59a91a97d 100644 --- a/app/src/main/res/layout/activity_appinstaller.xml +++ b/app/src/main/res/layout/activity_appinstaller.xml @@ -1,77 +1,85 @@ - + android:layout_width="fill_parent" + android:layout_height="fill_parent"> - - - + android:layout_height="fill_parent" + android:animateLayoutChanges="true" + android:orientation="vertical" + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + tools:context="nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity" + tools:ignore="ScrollViewSize"> - + - + -