From ecd053898dd447999143b65cff88c36e45c5dd9e Mon Sep 17 00:00:00 2001 From: XuXiangJun Date: Mon, 1 Jul 2019 15:18:52 +0800 Subject: [PATCH] update --- app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 1 + .../espblufi/task/BlufiAppReleaseTask.java | 136 ++++++++++++++++++ .../espblufi/ui/SettingsActivity.java | 78 ++++++++++ app/src/main/res/values-zh-rCN/strings.xml | 19 ++- app/src/main/res/values/strings.xml | 19 ++- app/src/main/res/xml/blufi_settings.xml | 5 +- log/updatelog-en.md | 5 +- log/updatelog-zh-rCN.md | 5 +- 9 files changed, 257 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/com/espressif/espblufi/task/BlufiAppReleaseTask.java diff --git a/app/build.gradle b/app/build.gradle index f92e800..22f9b39 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.espressif.espblufi" minSdkVersion 18 targetSdkVersion 28 - versionCode 18 - versionName "1.4.1" + versionCode 19 + versionName "1.4.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 76ba13c..b30566d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ + new AtomicReference<>(task.requestLatestRelease())) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(reference -> { + mVersionCheckPref.setEnabled(true); + + mAppLatestRelease = null; + BlufiAppReleaseTask.ReleaseInfo latestRelease = reference.get(); + if (latestRelease == null) { + mVersionCheckPref.setSummary(R.string.settings_upgrade_check_failed); + return; + } else if (latestRelease.getVersionCode() < 0) { + mVersionCheckPref.setSummary(R.string.settings_upgrade_check_not_found); + return; + } + + int currentVersion = AppUtil.getVersionCode(getActivity()); + int latestVersion = latestRelease.getVersionCode(); + if (latestVersion > currentVersion) { + mVersionCheckPref.setSummary(R.string.settings_upgrade_check_disciver_new); + mAppLatestRelease = latestRelease; + + new AlertDialog.Builder(getActivity()) + .setTitle(R.string.settings_upgrade_dialog_title) + .setMessage(R.string.settings_upgrade_dialog_message) + .setNegativeButton(android.R.string.cancel, null) + .setPositiveButton(R.string.settings_upgrade_dialog_upgrade, + (dialog, which) -> downloadLatestRelease()) + .show(); + } else { + mVersionCheckPref.setSummary(R.string.settings_upgrade_check_current_latest); + } + }) + .subscribe(); + + } + + private void downloadLatestRelease() { + Intent intent = new Intent(Intent.ACTION_VIEW); + Uri uri = Uri.parse(mAppLatestRelease.getDownloadUrl()); + intent.setData(uri); + startActivity(intent); + } } // Fragment end } // Activity end diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 954fd4a..4879d2b 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -1,10 +1,10 @@ - EspBlufi + EspBluFi 未知 - EspBlufi + EspBluFi 蓝牙不可用 位置信息(GPS)不可用 设置 @@ -50,7 +50,7 @@ 设置 setting_category_blufi - Blufi + BluFi settings_key_mtu_length 设置 mtu 长度 设置一个大于 %1$d 的数 @@ -61,5 +61,14 @@ settings_key_version APP 版本 settings_key_blufi_version - Blufi 库版本 - \ No newline at end of file + BluFi 库版本 + settings_upgrade_check + 检查更新 + 获取最新版本信息失败 + 没有找到更新版本 + 当前APP已经是最新版本 + 发现新版本APP, 点击开始下载 + 发现新版本 + 点击[升级]下载APK + 升级 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 62cfd03..3a688e9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,9 +1,9 @@ - EspBlufi + EspBluFi Unknown - EspBlufi + EspBluFi Bluetooth is disable Location is disable Settings @@ -15,7 +15,7 @@ Security Negotiate security with device Version - Get the device blufi version + Get the device BluFi version Status Get the device status Configure @@ -49,7 +49,7 @@ Settings setting_category_blufi - Blufi + BluFi settings_key_mtu_length Set mtu length Enter a number great than %1$d @@ -60,5 +60,14 @@ settings_key_version APP Version settings_key_blufi_version - Blufi lib version + BluFi lib version + settings_upgrade_check + Check APP latest version + Get latest release information failed + Not found new release + Current APP is latest + Discover new version APP, Click to download + Discover new version + Click [Upgrade] to download APK + Upgrade diff --git a/app/src/main/res/xml/blufi_settings.xml b/app/src/main/res/xml/blufi_settings.xml index bd62533..eaceb6c 100644 --- a/app/src/main/res/xml/blufi_settings.xml +++ b/app/src/main/res/xml/blufi_settings.xml @@ -20,5 +20,8 @@ + - \ No newline at end of file + diff --git a/log/updatelog-en.md b/log/updatelog-en.md index 43ed2d1..5576ec7 100644 --- a/log/updatelog-en.md +++ b/log/updatelog-en.md @@ -2,7 +2,10 @@ # Update Log -# v1.4.1 +## v1.4.2 +- Add app upgrade option in Settings + +## v1.4.1 - Add error code in BluFi callback function,see class BlufiCallback ## v1.4.0 diff --git a/log/updatelog-zh-rCN.md b/log/updatelog-zh-rCN.md index 494d8bd..b2c6cae 100644 --- a/log/updatelog-zh-rCN.md +++ b/log/updatelog-zh-rCN.md @@ -2,7 +2,10 @@ # 更新日志 -# v1.4.1 +# v1.4.2 +- 设置界面内增加 APP 检查更新功能 + +## v1.4.1 - BluFi 回调方法中返回具体的错误码,可参考类 BlufiCallback ## v1.4.0