Skip to content

Commit

Permalink
[bot] AutoMerging: merge all upstream's changes:
Browse files Browse the repository at this point in the history
* 'main' of https://github.com/pppscn/SmsForwarder:
  新增:`手机短信` 发送通道的 `接收手机` 允许插入 `{{来源号码}}` 标签来实现短信自动回复(短信/来电场景) pppscn#211
  优化:`Telegram`发送通道仅`POST`请求时转义原始短信内容中的`<``>``&``"`字符(正则替换不影响) pppscn#210
  • Loading branch information
github-actions[bot] committed Aug 26, 2022
2 parents fa18d19 + 657eb41 commit 939748c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class SmsFragment : BaseFragment<FragmentSendersSmsBinding?>(), View.OnClickList
}

override fun initListeners() {
binding!!.btInsertSender.setOnClickListener(this)
binding!!.btnTest.setOnClickListener(this)
binding!!.btnDel.setOnClickListener(this)
binding!!.btnSave.setOnClickListener(this)
Expand All @@ -165,6 +166,10 @@ class SmsFragment : BaseFragment<FragmentSendersSmsBinding?>(), View.OnClickList
override fun onClick(v: View) {
try {
when (v.id) {
R.id.bt_insert_sender -> {
CommonUtils.insertOrReplaceText2Cursor(binding!!.etMobiles, getString(R.string.tag_from))
return
}
R.id.btn_test -> {
mCountDownHelper?.start()
Thread {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ class SmsUtils {
}
Log.d(TAG, App.SimInfoList.toString())

//替换 {{来源号码}} 标签
val mobiles = setting.mobiles.replace(ResUtils.getString(R.string.tag_from), msgInfo.from)

//TODO:取不到卡槽信息时,采用默认卡槽发送
val mSubscriptionId: Int = App.SimInfoList[simSlotIndex]?.mSubscriptionId ?: -1
val res: String? = PhoneUtils.sendSms(mSubscriptionId, setting.mobiles, content)
val res: String? = PhoneUtils.sendSms(mSubscriptionId, mobiles, content)
if (res == null) {
SendUtils.updateLogs(logId, 2, ResUtils.getString(R.string.request_succeeded))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class TelegramUtils private constructor() {
rule: Rule?,
logId: Long?,
) {
if (setting.method == null || setting.method == "POST") {
msgInfo.content = htmlEncode(msgInfo.content)
msgInfo.simInfo = htmlEncode(msgInfo.simInfo)
}

val content: String = if (rule != null) {
msgInfo.getContentForSend(rule.smsTemplate, rule.regexReplace)
} else {
Expand All @@ -52,7 +57,7 @@ class TelegramUtils private constructor() {
} else {
val bodyMap: MutableMap<String, Any> = mutableMapOf()
bodyMap["chat_id"] = setting.chatId
bodyMap["text"] = htmlEncode(content)
bodyMap["text"] = content
bodyMap["parse_mode"] = "HTML"
bodyMap["disable_web_page_preview"] = "true"
val requestMsg: String = Gson().toJson(bodyMap)
Expand Down Expand Up @@ -100,7 +105,7 @@ class TelegramUtils private constructor() {
}

request.keepJson(true)
.ignoreHttpsCert()
//.ignoreHttpsCert()
.timeOut((SettingUtils.requestTimeout * 1000).toLong()) //超时时间10s
.cacheMode(CacheMode.NO_CACHE)
.retryCount(SettingUtils.requestRetryTimes) //超时重试的次数
Expand Down
30 changes: 25 additions & 5 deletions app/src/main/res/layout/fragment_senders_sms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,33 @@
android:text="@string/SmsMobiles"
android:textStyle="bold" />

<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
android:id="@+id/et_mobiles"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/SmsMobilesTips"
android:singleLine="true"
app:met_clearButton="true" />
android:orientation="horizontal">

<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
android:id="@+id/et_mobiles"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:singleLine="true"
app:met_clearButton="true" />

<com.xuexiang.xui.widget.button.shadowbutton.RippleShadowShadowButton
android:id="@+id/bt_insert_sender"
style="@style/insertButtonStyle"
android:layout_marginStart="5dp"
android:text="@string/insert_sender" />

</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/SmsMobilesTips"
android:textSize="10sp"
tools:ignore="SmallSp" />

</LinearLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
<string name="SmsSimSlot">SIM Slot</string>
<string name="same_source">Same source</string>
<string name="SmsMobiles">Receive Mobile Phone Numbers</string>
<string name="SmsMobilesTips">Separated by ; , e.g. 15888888888;19999999999</string>
<string name="SmsMobilesTips">Tips:\n1.Separated by ; , e.g. 15888888888;19999999999\n2.Allow to insert `{{FROM}}` tag to realize SMS auto-reply (SMS/Call scenario)</string>
<string name="OnlyNoNetwork">Enable only when no network</string>
<!--SettingActivity-->
<string name="notify_content">Notify Content</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
<string name="SmsSimSlot">发送卡槽</string>
<string name="same_source">原进原出</string>
<string name="SmsMobiles">接收手机</string>
<string name="SmsMobilesTips">多个号码以半角分号分隔,例如:15888888888;19999999999</string>
<string name="SmsMobilesTips">Tips:\n1.多个号码以半角分号分隔,例如:15888888888;19999999999\n2.允许插入`{{来源号码}}`标签来实现短信自动回复(短信/来电场景)</string>
<string name="OnlyNoNetwork">仅当无网络时启用</string>
<!--SettingActivity-->
<string name="notify_content">通知文案</string>
Expand Down

0 comments on commit 939748c

Please sign in to comment.