新增:转发规则测试弹窗自动填充上次填写的内容 #711

This commit is contained in:
pppscn
2026-07-19 23:16:20 +08:00
parent e5db93b06e
commit e816885df9
2 changed files with 38 additions and 0 deletions

View File

@@ -62,10 +62,16 @@ import cn.ppps.forwarder.utils.PhoneUtils
import cn.ppps.forwarder.utils.SENDER_LOGIC_ALL
import cn.ppps.forwarder.utils.SENDER_LOGIC_UNTIL_FAIL
import cn.ppps.forwarder.utils.SENDER_LOGIC_UNTIL_SUCCESS
import cn.ppps.forwarder.utils.SP_RULE_TEST_CALL_TYPE
import cn.ppps.forwarder.utils.SP_RULE_TEST_CONTENT
import cn.ppps.forwarder.utils.SP_RULE_TEST_FROM
import cn.ppps.forwarder.utils.SP_RULE_TEST_SIM_SLOT
import cn.ppps.forwarder.utils.SP_RULE_TEST_TITLE
import cn.ppps.forwarder.utils.STATUS_OFF
import cn.ppps.forwarder.utils.STATUS_ON
import cn.ppps.forwarder.utils.SendUtils
import cn.ppps.forwarder.utils.SettingUtils
import cn.ppps.forwarder.utils.SharedPreference
import cn.ppps.forwarder.utils.XToastUtils
import cn.ppps.forwarder.workers.LoadAppListWorker
import com.jeremyliao.liveeventbus.LiveEventBus
@@ -761,6 +767,24 @@ class RulesEditFragment : BaseFragment<FragmentRulesEditBinding?>(), View.OnClic
var callTypeTest = callType
var callTypeIndexTest = callTypeIndex
//测试弹窗填写内容缓存按ruleType区分
var cacheSimSlot: Int by SharedPreference(SP_RULE_TEST_SIM_SLOT + ruleType, 0)
var cacheFrom: String by SharedPreference(SP_RULE_TEST_FROM + ruleType, "")
var cacheTitle: String by SharedPreference(SP_RULE_TEST_TITLE + ruleType, "")
var cacheContent: String by SharedPreference(SP_RULE_TEST_CONTENT + ruleType, "")
var cacheCallType: Int by SharedPreference(SP_RULE_TEST_CALL_TYPE + ruleType, callType)
//自动填充上次填写的内容
rgSimSlot.check(if (cacheSimSlot == 1) R.id.rb_sim_slot_2 else R.id.rb_sim_slot_1)
etFrom.setText(cacheFrom)
etTitle.setText(cacheTitle)
etContent.setText(cacheContent)
val cacheCallTypeIndex = CALL_TYPE_MAP.keys.toList().indexOf(cacheCallType.toString())
if (cacheCallTypeIndex != -1) {
callTypeTest = cacheCallType
callTypeIndexTest = cacheCallTypeIndex
}
if ("app" == ruleType) {
tvSimSlot.visibility = View.GONE
rgSimSlot.visibility = View.GONE
@@ -799,6 +823,13 @@ class RulesEditFragment : BaseFragment<FragmentRulesEditBinding?>(), View.OnClic
else -> -1
}
//缓存本次填写的内容
cacheSimSlot = if (simSlot == 1) 1 else 0
cacheFrom = etFrom.text.toString()
cacheTitle = etTitle.text.toString()
cacheContent = etContent.text.toString()
cacheCallType = callTypeTest
val testSim = "SIM" + (simSlot + 1)
val ruleSim: String = rule.simSlot
if (ruleSim != "ALL" && ruleSim != testSim) {

View File

@@ -185,6 +185,13 @@ const val KEY_RULE_TYPE = "key_rule_type"
const val KEY_RULE_CLONE = "key_rule_clone"
const val KEY_DEFAULT_SELECTION = "key_default_selection"
//转发规则测试弹窗填写内容缓存key需拼接ruleType后缀区分
const val SP_RULE_TEST_SIM_SLOT = "rule_test_sim_slot_"
const val SP_RULE_TEST_FROM = "rule_test_from_"
const val SP_RULE_TEST_TITLE = "rule_test_title_"
const val SP_RULE_TEST_CONTENT = "rule_test_content_"
const val SP_RULE_TEST_CALL_TYPE = "rule_test_call_type_"
const val KEY_TASK_ID = "key_task_id"
const val KEY_TASK_TYPE = "key_task_type"
const val KEY_TASK_CLONE = "key_task_clone"