diff --git a/app/src/main/java/com/idormy/sms/forwarder/entity/MsgInfo.kt b/app/src/main/java/com/idormy/sms/forwarder/entity/MsgInfo.kt index f5e1b059..0eb446e7 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/entity/MsgInfo.kt +++ b/app/src/main/java/com/idormy/sms/forwarder/entity/MsgInfo.kt @@ -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) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 61114004..49431ad9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -655,6 +655,7 @@ {{BATTERY_STATUS}} {{BATTERY_PLUGGED}} {{BATTERY_INFO}} + {{BATTERY_INFO_SIMPLE}} {{UID}} {{IPV4}} {{IPV6}} @@ -1450,4 +1451,5 @@ 不支持蓝牙设备 搜索设备 蓝牙设备MAC地址无效,例如:AA:BB:CC:DD:EE:FF + {{NET_TYPE}}