mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-09 19:10:51 +00:00
新增:两个常用标签网络状态
({{NET_TYPE}}
)和简单电池信息
({{BATTERY_INFO_SIMPLE}}
) #439
This commit is contained in:
parent
9e1b9abc75
commit
971e262300
@ -15,6 +15,7 @@ import com.idormy.sms.forwarder.utils.SettingUtils.Companion.enableSmsTemplate
|
||||
import com.idormy.sms.forwarder.utils.SettingUtils.Companion.extraDeviceMark
|
||||
import com.idormy.sms.forwarder.utils.SettingUtils.Companion.smsTemplate
|
||||
import com.idormy.sms.forwarder.utils.task.TaskUtils
|
||||
import com.xuexiang.xutil.net.NetworkUtils
|
||||
import com.xuexiang.xutil.resource.ResUtils.getString
|
||||
import java.io.Serializable
|
||||
import java.text.SimpleDateFormat
|
||||
@ -86,17 +87,37 @@ data class MsgInfo(
|
||||
.replaceTag(getString(R.string.tag_card_subid), subId.toString(), needJson)
|
||||
.replaceTag(getString(R.string.tag_title), simInfo, needJson)
|
||||
.replaceTag(getString(R.string.tag_uid), uid.toString(), needJson)
|
||||
.replaceTag(getString(R.string.tag_receive_time), SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date), needJson)
|
||||
.replaceTag(getString(R.string.tag_current_time), SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date()), needJson)
|
||||
.replaceTag(
|
||||
getString(R.string.tag_receive_time),
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date),
|
||||
needJson
|
||||
)
|
||||
.replaceTag(
|
||||
getString(R.string.tag_current_time),
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date()),
|
||||
needJson
|
||||
)
|
||||
.replaceTag(getString(R.string.tag_device_name), extraDeviceMark.trim(), needJson)
|
||||
.replaceTag(getString(R.string.tag_app_version), AppUtils.getAppVersionName(), needJson)
|
||||
.replaceTag(getString(R.string.tag_call_type), CALL_TYPE_MAP[callType.toString()] ?: getString(R.string.unknown_call), needJson)
|
||||
.replaceTag(getString(R.string.tag_call_type),
|
||||
CALL_TYPE_MAP[callType.toString()] ?: getString(R.string.unknown_call), needJson)
|
||||
.replaceTag(getString(R.string.tag_ipv4), TaskUtils.ipv4, needJson)
|
||||
.replaceTag(getString(R.string.tag_ipv6), TaskUtils.ipv6, needJson)
|
||||
.replaceTag(getString(R.string.tag_battery_pct), "%.2f".format(TaskUtils.batteryPct), needJson)
|
||||
.replaceTag(getString(R.string.tag_battery_pct), "%.0f%%".format(TaskUtils.batteryPct), needJson)
|
||||
.replaceTag(getString(R.string.tag_battery_status), BatteryUtils.getStatus(TaskUtils.batteryStatus), needJson)
|
||||
.replaceTag(getString(R.string.tag_battery_plugged), BatteryUtils.getPlugged(TaskUtils.batteryPlugged), needJson)
|
||||
.replaceTag(getString(R.string.tag_battery_info), TaskUtils.batteryInfo, needJson)
|
||||
.replaceTag(getString(R.string.tag_battery_info_simple),
|
||||
"%.0f%%".format(TaskUtils.batteryPct)
|
||||
+ with(BatteryUtils.getPlugged(TaskUtils.batteryPlugged)) {
|
||||
if (this == getString(R.string.battery_unknown)) "" else " - $this"
|
||||
}
|
||||
)
|
||||
.replaceTag(getString(R.string.tag_net_type), with(NetworkUtils.getNetStateType()) {
|
||||
if (this == NetworkUtils.NetState.NET_NO || this == NetworkUtils.NetState.NET_UNKNOWN)
|
||||
this.name
|
||||
this.name.removePrefix("NET_")
|
||||
})
|
||||
.replaceAppNameTag(from, needJson)
|
||||
.replaceLocationTag(needJson)
|
||||
.regexReplace(regexReplace)
|
||||
@ -112,7 +133,9 @@ data class MsgInfo(
|
||||
val lineSplit = line.split("===".toRegex()).toTypedArray()
|
||||
if (lineSplit.isNotEmpty()) {
|
||||
val regex = lineSplit[0]
|
||||
val replacement = if (lineSplit.size >= 2) lineSplit[1].replace("\\\\n".toRegex(), "\n") else ""
|
||||
val replacement =
|
||||
if (lineSplit.size >= 2)
|
||||
lineSplit[1].replace("\\\\n".toRegex(), "\n") else ""
|
||||
newContent = newContent.replace(regex.toRegex(), replacement)
|
||||
}
|
||||
}
|
||||
|
@ -655,6 +655,7 @@
|
||||
<string name="tag_battery_status">{{BATTERY_STATUS}}</string>
|
||||
<string name="tag_battery_plugged">{{BATTERY_PLUGGED}}</string>
|
||||
<string name="tag_battery_info">{{BATTERY_INFO}}</string>
|
||||
<string name="tag_battery_info_simple" translatable="false">{{BATTERY_INFO_SIMPLE}}</string>
|
||||
<string name="tag_uid">{{UID}}</string>
|
||||
<string name="tag_ipv4">{{IPV4}}</string>
|
||||
<string name="tag_ipv6">{{IPV6}}</string>
|
||||
@ -1450,4 +1451,5 @@
|
||||
<string name="bluetooth_not_supported">不支持蓝牙设备</string>
|
||||
<string name="start_discovery">搜索设备</string>
|
||||
<string name="invalid_bluetooth_mac_address">蓝牙设备MAC地址无效,例如:AA:BB:CC:DD:EE:FF</string>
|
||||
<string name="tag_net_type" translatable="false">{{NET_TYPE}}</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user