update 增加防卡顿模式;增加发送消息重试

This commit is contained in:
gallonyin
2023-06-25 18:13:56 +08:00
parent 92effe3c6f
commit d61931aa99
5 changed files with 91 additions and 10 deletions

View File

@@ -7,9 +7,12 @@ object Constant {
val AVAILABLE_VERSION = arrayListOf("4.0.2", "4.0.6", "4.0.8", "4.0.10", "4.0.12", "4.0.16", "4.0.18", "4.0.19", "4.0.20", "4.1.0", "4.1.2", "4.1.3", "4.1.6")
const val PACKAGE_NAMES = "com.tencent.wework"
const val WEWORK_NOTIFY = "wework_notify"
const val LONG_INTERVAL = 5000L
const val CHANGE_PAGE_INTERVAL = 1000L
const val POP_WINDOW_INTERVAL = 500L
const val BASE_LONG_INTERVAL = 5000L
const val BASE_CHANGE_PAGE_INTERVAL = 1000L
const val BASE_POP_WINDOW_INTERVAL = 500L
var LONG_INTERVAL = BASE_LONG_INTERVAL
var CHANGE_PAGE_INTERVAL = BASE_CHANGE_PAGE_INTERVAL
var POP_WINDOW_INTERVAL = BASE_POP_WINDOW_INTERVAL
private const val DEFAULT_HOST = "wss://worktool.asrtts.cn"
var myName = ""
@@ -91,6 +94,9 @@ object Constant {
set(value) {
SPUtils.getInstance().put("host", value)
}
var oldDevice: Boolean
get() = SPUtils.getInstance().getBoolean("oldDevice", false)
set(value) = SPUtils.getInstance().put("oldDevice", value)
fun getWsUrl() = "$host/webserver/wework/$robotId"

View File

@@ -64,6 +64,12 @@ class SettingsAdvanceActivity : AppCompatActivity() {
LogUtils.i("sw_auto_publish onCheckedChanged: $isChecked")
Constant.autoPublishComment = isChecked
})
sw_old_device.isChecked = Constant.oldDevice
sw_old_device.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { buttonView, isChecked ->
LogUtils.i("sw_old_device onCheckedChanged: $isChecked")
Constant.oldDevice = isChecked
updateOldDeviceConfig()
})
ll_corp_param.visibility = if (Constant.customLink) View.VISIBLE else View.GONE
rl_username.visibility = if (Constant.customMP) View.VISIBLE else View.GONE
rl_qa_url.setOnClickListener { showQaUrlDialog() }
@@ -226,4 +232,18 @@ class SettingsAdvanceActivity : AppCompatActivity() {
.create(R.style.QMUI_Dialog).show()
}
private fun updateOldDeviceConfig() {
if (Constant.oldDevice) {
Constant.LONG_INTERVAL = (Constant.BASE_LONG_INTERVAL * 1.5).toLong()
Constant.CHANGE_PAGE_INTERVAL = (Constant.BASE_CHANGE_PAGE_INTERVAL * 1.5).toLong()
Constant.POP_WINDOW_INTERVAL = (Constant.BASE_POP_WINDOW_INTERVAL * 1.5).toLong()
ToastUtils.showLong("防卡顿模式开启")
} else {
Constant.LONG_INTERVAL = Constant.BASE_LONG_INTERVAL
Constant.CHANGE_PAGE_INTERVAL = Constant.BASE_CHANGE_PAGE_INTERVAL
Constant.POP_WINDOW_INTERVAL = Constant.BASE_POP_WINDOW_INTERVAL
ToastUtils.showLong("防卡顿模式关闭")
}
}
}

View File

@@ -552,7 +552,7 @@ object WeworkLoopImpl {
if (tvList.size == 3) {
//只查看最近一周内的消息
if (tvList[1].isBlank() || tvList[1].contains("(刚刚)|(分钟前)|(上午)|(下午)|(昨天)|(星期)|(日程)|(会议)|(:)".toRegex())) {
if (tvList[2].contains("(移出了群聊)|(邀请你加入了)|(修改群名为)|(此群为外部群)|(加入了外部群)".toRegex())) {
if (tvList[2].contains("(退出了外部群)|(移出了群聊)|(邀请你加入了)|(修改群名为)|(此群为外部群)|(加入了外部群)".toRegex())) {
val interval = System.currentTimeMillis() / 1000 - SPUtils.getInstance("noTipMessage").getLong(tvList[0], 0)
if (interval > 3600) {
LogUtils.i("发现无提示消息: $tvList")

View File

@@ -44,19 +44,32 @@ object WeworkOperationImpl {
val successList = arrayListOf<String>()
val failList = arrayListOf<String>()
for (title in titleList) {
var successFlag = true
if (WeworkRoomUtil.intoRoom(title)) {
if (sendChatMessage(receivedContent, at = at, atList = atList)) {
successList.add(title)
LogUtils.d("$title: 发送成功")
} else {
LogUtils.d("$title: 发送失败")
failList.add(title)
error("$title: 发送失败 $receivedContent")
successFlag = false
}
} else {
failList.add(title)
LogUtils.d("$title: 发送失败 进入房间失败")
error("$title: 发送失败 进入房间失败 $receivedContent")
successFlag = false
}
if (!successFlag) {
if (WeworkRoomUtil.intoRoom(title)) {
if (sendChatMessage(receivedContent, at = at, atList = atList)) {
successList.add(title)
LogUtils.d("$title: 发送成功")
} else {
LogUtils.d("$title: 发送失败")
failList.add(title)
error("$title: 发送失败 $receivedContent")
}
} else {
LogUtils.d("$title: 发送失败 进入房间失败")
failList.add(title)
error("$title: 发送失败 进入房间失败 $receivedContent")
}
}
}
if (failList.isNotEmpty()) {

View File

@@ -188,6 +188,48 @@
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_old_device"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/setting_start_padding"
android:paddingTop="@dimen/setting_vertical_padding"
android:paddingEnd="@dimen/setting_end_padding"
android:paddingBottom="@dimen/setting_vertical_padding">
<Switch
android:id="@+id/sw_old_device"
android:layout_width="@dimen/setting_end_font_width"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/setting_end_start_padding" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/setting_start_padding"
android:layout_toStartOf="@id/sw_old_device"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="防卡顿模式"
android:textColor="@color/color_333333"
android:textSize="@dimen/setting_start_font_size" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="开启此功能以提高稳定性(性能降低)"
android:textColor="@color/color_999999"
android:textSize="@dimen/setting_end_font_size" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_qa_url"
android:layout_width="match_parent"