Skip to content

Commit

Permalink
refactor(history):refactor welcome code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCShou committed Oct 15, 2022
1 parent e0b684e commit 8ac1e95
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/com/zcshou/gogogo/HistoryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
.setPositiveButton("确定",
(dialog, which) -> {
if (deleteRecord(-1)) {
GoUtils.DisplayToast(this,"删除成功!");
GoUtils.DisplayToast(this, getResources().getString(R.string.history_delete_ok));
updateRecordList();
}
})
Expand Down Expand Up @@ -164,7 +164,7 @@ private List<Map<String, Object>> fetchAllRecord() {
}

private void recordArchive() {
final double limits = Double.parseDouble(sharedPreferences.getString("setting_pos_history", getResources().getString(R.string.setting_pos_history_default)));
final double limits = Double.parseDouble(sharedPreferences.getString("setting_pos_history", getResources().getString(R.string.history_expiration)));
final long weekSecond = (long) (limits * 24 * 60 * 60);

try {
Expand Down Expand Up @@ -233,7 +233,7 @@ public boolean onQueryTextChange(String newText) {// 当搜索内容改变时触
new int[]{R.id.LocationID, R.id.LocationText, R.id.TimeText, R.id.WGSLatLngText, R.id.BDLatLngText});
mRecordListView.setAdapter(simAdapt);
} else {
GoUtils.DisplayToast(HistoryActivity.this,"未搜索到指定内容");
GoUtils.DisplayToast(HistoryActivity.this, getResources().getString(R.string.history_error_search));
SimpleAdapter simAdapt = new SimpleAdapter(
HistoryActivity.this.getBaseContext(),
mAllRecord,
Expand Down Expand Up @@ -272,7 +272,7 @@ private void initRecordListView() {
wgs84Latitude = latLngStr2[1].substring(latLngStr2[1].indexOf(':') + 1);

if (!MainActivity.showLocation(bd09Longitude, bd09Latitude, wgs84Longitude, wgs84Latitude)) {
GoUtils.DisplayToast(this, "定位失败,请手动选取定位点");
GoUtils.DisplayToast(this, getResources().getString(R.string.history_error_location));
}
this.finish();
});
Expand All @@ -287,7 +287,7 @@ private void initRecordListView() {
boolean deleteRet = deleteRecord(Integer.parseInt(locID));

if (deleteRet) {
GoUtils.DisplayToast(this,"删除成功!");
GoUtils.DisplayToast(this, getResources().getString(R.string.history_delete_ok));
updateRecordList();
}
})
Expand Down
25 changes: 14 additions & 11 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@
<string name="setting_group_log">记录</string>
<string name="setting_log_off">关闭日志</string>
<string name="setting_pos_history">历史记录有效期(天)</string>
<string name="setting_pos_history_default">7</string>
<string name="setting_group_about">关于</string>
<string name="setting_version">版本号</string>
<string name="setting_author">开发者</string>
<string name="setting_group_sys">系统</string>

<!-- 历史记录页面 -->
<string name="history_idle">暂无历史记录</string>
<string name="history_delete_ok">删除成功!</string>
<string name="history_expiration">7</string>
<string name="history_error_location">定位失败,请手动选取定位点</string>
<string name="history_error_search">未搜索到指定内容</string>

<!-- 通知栏 -->
<string name="note_show">显示摇杆</string>
<string name="note_hide">隐藏摇杆</string>
Expand All @@ -61,16 +67,6 @@
<string name="error_gps">位置检索失败,请检查 GPS 是否开启</string>
<string name="error_network">搜索失败,请检查网络连接</string>

<!-- 更新 -->
<string name="update_title">新版本可用</string>
<string name="update_download">立即下载</string>
<string name="update_ignore">忽略一次</string>
<string name="update_time">更新时间:</string>
<string name="update_commit">提交信息:</string>

<!-- 历史记录页面 -->
<string name="history_idle">暂无历史记录</string>

<!-- 导航页 -->
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
Expand All @@ -90,6 +86,13 @@
<string name="safecode">32:2F:E6:05:6C:2F:11:6D:CD:ED:AC:FF:23:02:5A:29:68:FD:45:D2;com.zcshou.gogogo</string>
<string name="ak">fb7YwlKY3ntx8hBDGMGLqX2FhlPkDMvv</string>

<!-- 更新 -->
<string name="update_title">新版本可用</string>
<string name="update_download">立即下载</string>
<string name="update_ignore">忽略一次</string>
<string name="update_time">更新时间:</string>
<string name="update_commit">提交信息:</string>

<!-- 摇杆 -->
<string name="joystick_map_tips">搜索或点击地图位置</string>
<string name="joystick_history_tips">搜索或点击历史位置</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/preferences_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<EditTextPreference
app:key="setting_pos_history"
app:title="@string/setting_pos_history"
app:defaultValue="@string/setting_pos_history_default"
app:summary="@string/setting_pos_history_default"
app:defaultValue="@string/history_expiration"
app:summary="@string/history_expiration"
app:iconSpaceReserved="false"/>
</PreferenceCategory>

Expand Down

0 comments on commit 8ac1e95

Please sign in to comment.