From 971e2623004889457d387f46d118f9a8ea4f6592 Mon Sep 17 00:00:00 2001 From: alphime <109449075+alphime@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:16:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E5=B8=B8=E7=94=A8=E6=A0=87=E7=AD=BE`=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E7=8A=B6=E6=80=81`(`{{NET=5FTYPE}}`)=E5=92=8C`=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E7=94=B5=E6=B1=A0=E4=BF=A1=E6=81=AF`(`{{BATTERY=5FINF?= =?UTF-8?q?O=5FSIMPLE}}`)=20#439?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idormy/sms/forwarder/entity/MsgInfo.kt | 33 ++++++++++++++++--- app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 30 insertions(+), 5 deletions(-) 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}}