diff --git a/app_dashboard/changelog.md b/app_dashboard/changelog.md index 338b466..8b931e4 100644 --- a/app_dashboard/changelog.md +++ b/app_dashboard/changelog.md @@ -9,6 +9,16 @@ author: 2. $ {VERSION_CODE} (去掉空格),会自动替换实际修订号,比如 1.1.4.$ {VERSION_CODE} --> +### [1.0.5.${VERSION_CODE}] - 2026.3.5 + +#### 文件下载 + +* [dashboardclient_1.0.5.apk](dashboardclient_1.0.5.apk) + +#### 更新记录 +* 仅串口路径为空时才自动检测设备 +* 设置界面可清除串口路径 + ### [1.0.4.23] - 2026.1.5 #### 文件下载 diff --git a/app_dashboard/src/main/java/cn/ykbox/dashboard/activity/BuildingDashboardActivity.java b/app_dashboard/src/main/java/cn/ykbox/dashboard/activity/BuildingDashboardActivity.java index ba04038..98d0a38 100644 --- a/app_dashboard/src/main/java/cn/ykbox/dashboard/activity/BuildingDashboardActivity.java +++ b/app_dashboard/src/main/java/cn/ykbox/dashboard/activity/BuildingDashboardActivity.java @@ -110,22 +110,29 @@ public class BuildingDashboardActivity extends FullscreenActivity { configUrl = urlPrefix + "/data/config.json"; mainUrl = urlEndPoint.isEmpty() ? urlPrefix : urlPrefix + "/" + urlEndPoint; + Log.i(TAG, "Main: " + mainUrl); + Log.i(TAG, "Config: " + configUrl); + configLoadHandler.post(configLoadRunnable); loadUrlWithRetry(); } private void initSerialPort() { String portPath = PreferenceConfiguration.getSerialPortPath(this); - int baudRate = PreferenceConfiguration.getSerialPortBaudRate(this); - // 初始化串口检测器 - detector = new SerialPortDetector(portPath, baudRate); + // 只有 portPath 为空时才进行串口检测 + if (TextUtils.isEmpty(portPath)) { + int baudRate = PreferenceConfiguration.getSerialPortBaudRate(this); + // 初始化串口检测器 + detector = new SerialPortDetector(portPath, baudRate); - // 每次启动都进行串口检测/验证 - // 参数 true 表示确保设备开机(发送两个命令) - // 参数 false 表示仅检测串口(任一命令有响应即可) - Log.i(TAG, "Starting serial port detection/verification..."); - startSerialPortDetection(true); + Log.i(TAG, "Starting serial port detection/verification..."); + // 参数 true 表示确保设备开机(发送两个命令) + // 参数 false 表示仅检测串口(任一命令有响应即可) + startSerialPortDetection(true); + } else { + Log.i(TAG, "Using saved serial port path: " + portPath); + } } /** @@ -276,6 +283,8 @@ public class BuildingDashboardActivity extends FullscreenActivity { WebSettings webSettings = binding.webview.getSettings(); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setJavaScriptEnabled(true); + // 允许媒体自动播放 (Android 8+ 必须) + webSettings.setMediaPlaybackRequiresUserGesture(false); // 禁用缩放相关设置 webSettings.setTextZoom(100); diff --git a/app_dashboard/src/main/java/cn/ykbox/dashboard/activity/SettingsActivity.java b/app_dashboard/src/main/java/cn/ykbox/dashboard/activity/SettingsActivity.java index f5d3726..85c5e26 100644 --- a/app_dashboard/src/main/java/cn/ykbox/dashboard/activity/SettingsActivity.java +++ b/app_dashboard/src/main/java/cn/ykbox/dashboard/activity/SettingsActivity.java @@ -1,12 +1,16 @@ package cn.ykbox.dashboard.activity; +import android.content.SharedPreferences; import android.os.Bundle; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import cn.ykbox.dashboard.R; +import cn.ykbox.dashboard.perferences.PreferenceConfiguration; public class SettingsActivity extends AppCompatActivity { @@ -30,6 +34,21 @@ public class SettingsActivity extends AppCompatActivity { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.root_preferences, rootKey); + + Preference clearDevicePref = findPreference("k_clear_device"); + if (clearDevicePref != null) { + clearDevicePref.setOnPreferenceClickListener(preference -> { + new AlertDialog.Builder(requireContext()) + .setTitle("确认清除") + .setMessage("确定要清除当前串口设备路径吗?") + .setPositiveButton("确定", (dialog, which) -> { + PreferenceConfiguration.setSerialPortPath(requireContext(), ""); + }) + .setNegativeButton("取消", null) + .show(); + return true; + }); + } } } } \ No newline at end of file diff --git a/app_dashboard/src/main/res/xml/root_preferences.xml b/app_dashboard/src/main/res/xml/root_preferences.xml index 4898572..8aa2dd4 100644 --- a/app_dashboard/src/main/res/xml/root_preferences.xml +++ b/app_dashboard/src/main/res/xml/root_preferences.xml @@ -25,5 +25,9 @@ app:title="串口波特率" app:defaultValue="9600" app:useSimpleSummaryProvider="true" /> + \ No newline at end of file