当选择自动跳转时,直接访问 URL 前缀,这样网址自由设置

This commit is contained in:
Zhanghu
2025-11-01 10:03:36 +08:00
parent cb151b989e
commit 80341f540f
6 changed files with 34 additions and 27 deletions

View File

@@ -9,6 +9,15 @@ author:
2. $ {VERSION_CODE} (去掉空格),会自动替换实际修订号,比如 1.1.4.$ {VERSION_CODE} 2. $ {VERSION_CODE} (去掉空格),会自动替换实际修订号,比如 1.1.4.$ {VERSION_CODE}
--> -->
### [1.0.3.${VERSION_CODE}] - 2025.11.1
#### 文件下载
* [dashboardclient_1.0.3.apk](dashboardclient_1.0.3.apk)
#### 更新记录
* 当选择自动跳转时,直接访问 URL 前缀,这样网址自由设置
### [1.0.2.19] - 2025.10.11 ### [1.0.2.19] - 2025.10.11
#### 文件下载 #### 文件下载

View File

@@ -96,21 +96,19 @@ public class BuildingDashboardActivity extends FullscreenActivity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
// 当用户选择了自动跳转时,直接访问 urlPrefix这样 url 可以自由设置
SharedPreferences pre = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences pre = PreferenceManager.getDefaultSharedPreferences(this);
String url = pre.getString("k_url", "http://172.18.22.211:8002/Dashboard"); String urlPrefix = pre.getString("k_url_prefix", "http://172.18.22.211:8002/Dashboard");
String type = pre.getString("k_dashboard_type", "0"); String urlEndPoint = pre.getString("k_url_end_point", "/").replaceFirst("^/", "");
configUrl = url + "/data/config.json"; configUrl = urlPrefix + "/data/config.json";
mainUrl = urlEndPoint.isEmpty() ? urlPrefix : urlPrefix + "/" + urlEndPoint;
if(!type.equals("0"))
mainUrl = url + "/dashboards/" + type + "/index.html";
else
mainUrl = url + "/index.html";
configLoadHandler.post(configLoadRunnable); configLoadHandler.post(configLoadRunnable);
loadUrlWithRetry(); loadUrlWithRetry();
} }
private void loadUrlWithRetry() { private void loadUrlWithRetry() {
Log.i("WebView", "Loading " + mainUrl);
binding.webview.loadUrl(mainUrl); binding.webview.loadUrl(mainUrl);
} }

View File

@@ -1,7 +1,7 @@
<resources> <resources>
<string-array name="dashboard_type_entries"> <string-array name="url_end_point_entries">
<item>0 (根据服务器配置跳转)</item> <item>自动跳转</item>
<item>1 (按楼层)</item> <item>按楼层</item>
<item>2 (网格+统计)</item> <item>网格+统计</item>
</string-array> </string-array>
</resources> </resources>

View File

@@ -10,15 +10,15 @@
<item>reply_all</item> <item>reply_all</item>
</string-array> </string-array>
<string-array name="dashboard_type_entries"> <string-array name="url_end_point_entries">
<item>0 (Auto Redirect)</item> <item>Auto Redirect</item>
<item>1 (Floor)</item> <item>Floor</item>
<item>2 (Grid+Statics)</item> <item>Grid+Statics</item>
</string-array> </string-array>
<string-array name="dashboard_type_values"> <string-array name="url_end_point_values">
<item>0</item> <item>/</item>
<item>1</item> <item>/dashboards/1</item>
<item>2</item> <item>/dashboards/2</item>
</string-array> </string-array>
</resources> </resources>

View File

@@ -2,5 +2,5 @@
<string name="app_name">Dashboard</string> <string name="app_name">Dashboard</string>
<string name="title_activity_building_dashboard">Building Dashboard</string> <string name="title_activity_building_dashboard">Building Dashboard</string>
<string name="title_activity_settings">Settings</string> <string name="title_activity_settings">Settings</string>
<string name="dashboard_type_default_value" translatable="false">0</string> <string name="url_end_point_default_value" translatable="false">/</string>
</resources> </resources>

View File

@@ -1,16 +1,16 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"> <PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:title="网页地址"> <PreferenceCategory app:title="网页地址">
<EditTextPreference <EditTextPreference
app:key="k_url" app:key="k_url_prefix"
app:title="URL 前缀" app:title="URL 前缀"
app:defaultValue="http://172.18.22.211:8002/Dashboard" app:defaultValue="http://172.18.22.211:8002/Dashboard"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
<ListPreference <ListPreference
app:title="仪表盘类型" app:title="仪表盘风格"
app:key="k_dashboard_type" app:key="k_url_end_point"
app:useSimpleSummaryProvider="true" app:useSimpleSummaryProvider="true"
app:entries="@array/dashboard_type_entries" app:entries="@array/url_end_point_entries"
app:entryValues="@array/dashboard_type_values" app:entryValues="@array/url_end_point_values"
app:defaultValue="@string/dashboard_type_default_value" /> app:defaultValue="@string/url_end_point_default_value" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>