mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-08 01:10:23 +00:00
优化:主动控制·客户端
的历史列表
增加设备名称
、远程发短信
增加卡槽备注
#201
This commit is contained in:
parent
432bbeaa16
commit
91b3cd11dc
@ -137,12 +137,18 @@ class ClientFragment : BaseFragment<FragmentClientBinding?>(),
|
||||
}
|
||||
Log.d(TAG, "serverHistory = $serverHistory")
|
||||
|
||||
MaterialDialog.Builder(context!!)
|
||||
MaterialDialog.Builder(requireContext())
|
||||
.title(R.string.server_history)
|
||||
.items(serverHistory.keys)
|
||||
.itemsCallbackSingleChoice(0) { _: MaterialDialog?, _: View?, _: Int, text: CharSequence ->
|
||||
//XToastUtils.info("$which: $text")
|
||||
binding!!.etServerAddress.setText(text)
|
||||
val matches = Regex("【(.*)】(.*)", RegexOption.IGNORE_CASE).findAll(text).toList().flatMap(MatchResult::groupValues)
|
||||
Log.i(TAG, "matches = $matches")
|
||||
if (matches.isNotEmpty()) {
|
||||
binding!!.etServerAddress.setText(matches[2])
|
||||
} else {
|
||||
binding!!.etServerAddress.setText(text)
|
||||
}
|
||||
binding!!.etSignKey.setText(serverHistory[text])
|
||||
true // allow selection
|
||||
}
|
||||
@ -241,9 +247,13 @@ class ClientFragment : BaseFragment<FragmentClientBinding?>(),
|
||||
if (resp.code == 200) {
|
||||
serverConfig = resp.data!!
|
||||
if (needToast) XToastUtils.success(ResUtils.getString(R.string.request_succeeded))
|
||||
//删除3.0.8之前保存的记录
|
||||
serverHistory.remove(HttpServerUtils.serverAddress.toString())
|
||||
//添加到历史记录
|
||||
serverHistory[HttpServerUtils.serverAddress.toString()] = HttpServerUtils.clientSignKey ?: ""
|
||||
val key = "【${serverConfig?.extraDeviceMark}】${HttpServerUtils.serverAddress.toString()}"
|
||||
serverHistory[key] = HttpServerUtils.clientSignKey ?: ""
|
||||
HttpServerUtils.serverHistory = Gson().toJson(serverHistory)
|
||||
HttpServerUtils.serverConfig = Gson().toJson(serverConfig)
|
||||
} else {
|
||||
if (needToast) XToastUtils.error(ResUtils.getString(R.string.request_failed) + resp.msg)
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.idormy.sms.forwarder.R
|
||||
import com.idormy.sms.forwarder.core.BaseFragment
|
||||
import com.idormy.sms.forwarder.databinding.FragmentClientSmsSendBinding
|
||||
import com.idormy.sms.forwarder.server.model.BaseResponse
|
||||
import com.idormy.sms.forwarder.server.model.ConfigData
|
||||
import com.idormy.sms.forwarder.utils.*
|
||||
import com.jeremyliao.liveeventbus.LiveEventBus
|
||||
import com.xuexiang.xaop.annotation.SingleClick
|
||||
@ -56,6 +57,14 @@ class SmsSendFragment : BaseFragment<FragmentClientSmsSendBinding?>(), View.OnCl
|
||||
binding!!.btnSubmit.text = getString(R.string.send)
|
||||
}
|
||||
})
|
||||
|
||||
//卡槽信息
|
||||
val serverConfigStr = HttpServerUtils.serverConfig
|
||||
if (!TextUtils.isEmpty(serverConfigStr)) {
|
||||
val serverConfig: ConfigData = Gson().fromJson(serverConfigStr, object : TypeToken<ConfigData>() {}.type)
|
||||
binding!!.rbSimSlot1.text = "SIM1:" + serverConfig.extraSim1
|
||||
binding!!.rbSimSlot2.text = "SIM2:" + serverConfig.extraSim2
|
||||
}
|
||||
}
|
||||
|
||||
override fun initListeners() {
|
||||
|
@ -245,6 +245,7 @@ const val SP_ENABLE_API_WOL = "enable_api_wol"
|
||||
const val SP_WOL_HISTORY = "wol_history"
|
||||
const val SP_SERVER_ADDRESS = "server_address"
|
||||
const val SP_SERVER_HISTORY = "server_history"
|
||||
const val SP_SERVER_CONFIG = "server_config"
|
||||
const val SP_CLIENT_SIGN_KEY = "client_sign_key"
|
||||
var CLIENT_FRAGMENT_LIST = listOf(
|
||||
PageInfo(getString(R.string.api_clone), "com.idormy.sms.forwarder.fragment.client.CloneFragment", "{\"\":\"\"}", CoreAnim.slide, R.drawable.icon_api_clone),
|
||||
|
@ -56,6 +56,14 @@ class HttpServerUtils private constructor() {
|
||||
MMKVUtils.put(SP_SERVER_HISTORY, serverHistory)
|
||||
}
|
||||
|
||||
//服务端配置
|
||||
@JvmStatic
|
||||
var serverConfig: String?
|
||||
get() = MMKVUtils.getString(SP_SERVER_CONFIG, "")
|
||||
set(serverConfig) {
|
||||
MMKVUtils.put(SP_SERVER_CONFIG, serverConfig)
|
||||
}
|
||||
|
||||
//客户端签名密钥
|
||||
@JvmStatic
|
||||
var clientSignKey: String?
|
||||
|
@ -41,17 +41,17 @@
|
||||
<RadioGroup
|
||||
android:id="@+id/rg_sim_slot"
|
||||
style="@style/rg_style"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_sim_slot_1"
|
||||
style="@style/rg_rb_style"
|
||||
style="@style/rg_rb_style_match"
|
||||
android:checked="true"
|
||||
android:text="@string/sim1" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rb_sim_slot_2"
|
||||
style="@style/rg_rb_style"
|
||||
style="@style/rg_rb_style_match"
|
||||
android:text="@string/sim2" />
|
||||
|
||||
</RadioGroup>
|
||||
|
@ -191,4 +191,11 @@
|
||||
<item name="android:textSize">13sp</item>
|
||||
</style>
|
||||
|
||||
<style name="rg_rb_style_match">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:textSize">13sp</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user