Skip to content

Commit 49d1fe5

Browse files
committed
Update auto send emoji funtion.
1 parent 4ea68e6 commit 49d1fe5

File tree

9 files changed

+266
-12
lines changed

9 files changed

+266
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ https://github.com/xbdcc/CUtils
2929
- 延迟时间说明:为防止秒抢拉仇恨加了延迟功能,延迟可以选择0-9秒。
3030
- 自定义拆红包坐标点说明:自定义红包拆按钮的横纵坐标,解决部分Android7.0以上机型无法自动拆红包的问题。
3131

32-
最新版适配微信7.0.3,7.0.4,7.0.5,7.0.8,7.0.9,7.0.10,7.0.11,7.0.12,7.0.16版本,代码开源仅供学习使用,请勿用作商业用途。
32+
最新版适配微信7.0.3,7.0.4,7.0.5,7.0.8,7.0.9,7.0.10,7.0.11,7.0.12,7.0.16,8.0.0,8.0.1版本,代码开源仅供学习使用,请勿用作商业用途。
3333

3434

3535

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ android {
3232
applicationId "com.carlos.grabredenvelope"
3333
minSdkVersion 18
3434
targetSdkVersion 28
35-
versionCode 13
35+
versionCode 330
3636
versionName "3.3.0"
37-
flavorDimensions "13" //和versionCode相同
37+
flavorDimensions "330" //和versionCode相同
3838
ndk {
3939
//选择要添加的对应 cpu 类型的 .so 库。
4040
abiFilters 'armeabi-v7a', 'x86'

app/src/main/java/com/carlos/grabredenvelope/activity/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ open class MainActivity : BaseActivity() {
5353
private val WECHAT_SERVICE_NAME = "com.carlos.grabredenvelope/.services.WechatService"
5454

5555
var fragments = mutableListOf<Fragment>(ControlFragment(), GuideFragment(), AboutFragment(),
56-
CodeFragment(), RewardFragment(), RecordFragment(), RecordDingDIngFragment()
56+
CodeFragment(), RewardFragment(), RecordFragment(), EmojiFragment()
5757
)
58-
var titles = mutableListOf("控制", "教程", "说明", "源码", "打赏", "微信", "钉钉")
58+
var titles = mutableListOf("控制", "教程", "说明", "源码", "打赏", "微信", "表情")
5959

6060
override fun onCreate(savedInstanceState: Bundle?) {
6161
super.onCreate(savedInstanceState)

app/src/main/java/com/carlos/grabredenvelope/data/RedEnvelopePreferences.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ object RedEnvelopePreferences :
4747

4848
private const val WECHAT_CONTROL = "wechat_control"
4949
private const val USE_STATUS = "use_status"
50+
private const val EMOJI_TEXT = "emoji_text"
51+
private const val EMOJI_TIMES = "emoji_times"
52+
private const val EMOJI_INTERVAL = "emoji_interval"
5053

5154
var wechatControl: WechatControlVO
5255
get() {
@@ -72,6 +75,24 @@ object RedEnvelopePreferences :
7275
set(value) {
7376
setBoolean(USE_STATUS, value)
7477
}
78+
79+
var autoText: String
80+
get() = getString(EMOJI_TEXT, "[烟花]")
81+
set(value) {
82+
setString(EMOJI_TEXT, value)
83+
}
84+
85+
var emojiTimes: Int
86+
get() = getInt(EMOJI_TIMES, 0)
87+
set(value) {
88+
setInt(EMOJI_TIMES, value)
89+
}
90+
91+
var emojiInterval: Int
92+
get() = getInt(EMOJI_INTERVAL, 0)
93+
set(value) {
94+
setInt(EMOJI_INTERVAL, value)
95+
}
7596
}
7697

7798

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.carlos.grabredenvelope.fragment
2+
3+
import android.content.Intent
4+
import android.os.Bundle
5+
import android.provider.Settings
6+
import android.view.View
7+
import android.widget.Toast
8+
import androidx.core.widget.doAfterTextChanged
9+
import com.carlos.grabredenvelope.R
10+
import com.carlos.grabredenvelope.data.RedEnvelopePreferences
11+
import kotlinx.android.synthetic.main.fragment_emoji.*
12+
13+
/**
14+
* _ooOoo_
15+
* o8888888o
16+
* 88" . "88
17+
* (| -_- |)
18+
* O\ = /O
19+
* ____/`---'\____
20+
* .' \\| |// `.
21+
* / \\||| : |||// \
22+
* / _||||| -:- |||||- \
23+
* | | \\\ - /// | |
24+
* | \_| ''\---/'' | |
25+
* \ .-\__ `-` ___/-. /
26+
* ___`. .' /--.--\ `. . __
27+
* ."" '< `.___\_<|>_/___.' >'"".
28+
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
29+
* \ \ `-. \_ __\ /__ _/ .-` / /
30+
* ======`-.____`-.___\_____/___.-`____.-'======
31+
* `=---='
32+
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
* 佛祖保佑 永无BUG
34+
* 佛曰:
35+
* 写字楼里写字间,写字间里程序员;
36+
* 程序人员写程序,又拿程序换酒钱。
37+
* 酒醒只在网上坐,酒醉还来网下眠;
38+
* 酒醉酒醒日复日,网上网下年复年。
39+
* 但愿老死电脑间,不愿鞠躬老板前;
40+
* 奔驰宝马贵者趣,公交自行程序员。
41+
* 别人笑我忒疯癫,我笑自己命太贱;
42+
* 不见满街漂亮妹,哪个归得程序员?
43+
*/
44+
45+
/**
46+
* Created by Carlos on 2021/2/8.
47+
*/
48+
class EmojiFragment : BaseFragment(R.layout.fragment_emoji) {
49+
50+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
51+
super.onViewCreated(view, savedInstanceState)
52+
init()
53+
}
54+
55+
private fun init() {
56+
tv_control.setOnClickListener {
57+
startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
58+
Toast.makeText(view?.context, "辅助功能找到(抢微信红包)开启或关闭。", Toast.LENGTH_SHORT)
59+
.show()
60+
}
61+
62+
et_emoji.setText(RedEnvelopePreferences.autoText)
63+
et_emoji.doAfterTextChanged {
64+
RedEnvelopePreferences.autoText = et_emoji.text.toString()
65+
}
66+
67+
np_times.minValue = 0
68+
np_times.maxValue = 100
69+
np_times.value = RedEnvelopePreferences.emojiTimes
70+
np_times.setOnValueChangedListener { picker, oldVal, newVal ->
71+
RedEnvelopePreferences.emojiTimes = newVal
72+
}
73+
74+
np_interval.minValue = 0
75+
np_interval.maxValue = 3000
76+
np_interval.value = RedEnvelopePreferences.emojiInterval
77+
np_interval.setOnValueChangedListener { picker, oldVal, newVal ->
78+
RedEnvelopePreferences.emojiInterval = newVal
79+
}
80+
}
81+
82+
}

app/src/main/java/com/carlos/grabredenvelope/services/EmojiService.kt

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,43 @@ import android.os.Bundle
44
import android.view.accessibility.AccessibilityEvent
55
import android.view.accessibility.AccessibilityNodeInfo
66
import android.widget.EditText
7+
import com.carlos.cutils.util.LogUtils
8+
import com.carlos.grabredenvelope.data.RedEnvelopePreferences
9+
import kotlinx.coroutines.GlobalScope
10+
import kotlinx.coroutines.delay
11+
import kotlinx.coroutines.launch
12+
13+
/**
14+
* _ooOoo_
15+
* o8888888o
16+
* 88" . "88
17+
* (| -_- |)
18+
* O\ = /O
19+
* ____/`---'\____
20+
* .' \\| |// `.
21+
* / \\||| : |||// \
22+
* / _||||| -:- |||||- \
23+
* | | \\\ - /// | |
24+
* | \_| ''\---/'' | |
25+
* \ .-\__ `-` ___/-. /
26+
* ___`. .' /--.--\ `. . __
27+
* ."" '< `.___\_<|>_/___.' >'"".
28+
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
29+
* \ \ `-. \_ __\ /__ _/ .-` / /
30+
* ======`-.____`-.___\_____/___.-`____.-'======
31+
* `=---='
32+
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
* 佛祖保佑 永无BUG
34+
* 佛曰:
35+
* 写字楼里写字间,写字间里程序员;
36+
* 程序人员写程序,又拿程序换酒钱。
37+
* 酒醒只在网上坐,酒醉还来网下眠;
38+
* 酒醉酒醒日复日,网上网下年复年。
39+
* 但愿老死电脑间,不愿鞠躬老板前;
40+
* 奔驰宝马贵者趣,公交自行程序员。
41+
* 别人笑我忒疯癫,我笑自己命太贱;
42+
* 不见满街漂亮妹,哪个归得程序员?
43+
*/
744

845
/**
946
* Created by Carlos on 2021/2/9.
@@ -12,19 +49,41 @@ class EmojiService : BaseAccessibilityService() {
1249

1350
private var windowClassName = ""
1451
private val CHAT_ACTIVITY = "com.tencent.mm.ui.LauncherUI" //微信红包弹框
52+
private var text = ""
53+
private var times = 0
54+
private var interval = 0
55+
private var count = 0
56+
1557
override fun monitorContentChanged(event: AccessibilityEvent) {
1658
}
1759

1860
override fun monitorWindowChanged(event: AccessibilityEvent) {
1961
windowClassName = event.className.toString()
62+
loadConfig()
2063
sendMessage()
2164
}
2265

66+
private fun loadConfig() {
67+
text = RedEnvelopePreferences.autoText
68+
times = RedEnvelopePreferences.emojiTimes
69+
interval = RedEnvelopePreferences.emojiInterval
70+
count = 0
71+
LogUtils.d("text:$text")
72+
LogUtils.d("times:$times")
73+
LogUtils.d("interval:$interval")
74+
LogUtils.d("count:$count")
75+
}
76+
2377
/**
2478
* 找到文本框输入表情,找到发送按钮点击循环执行
2579
*/
2680
private fun sendMessage() {
2781
if (windowClassName != CHAT_ACTIVITY) return
82+
if (count >= times && times != 0) {
83+
return
84+
}
85+
LogUtils.d("count:$count")
86+
2887
val accessibilityNodeInfo =
2988
rootInActiveWindow?.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/auj")
3089
?: return
@@ -34,7 +93,7 @@ class EmojiService : BaseAccessibilityService() {
3493
val arguments = Bundle()
3594
arguments.putCharSequence(
3695
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,
37-
"[烟花]"
96+
text
3897
)
3998
editText.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments)
4099

@@ -45,7 +104,11 @@ class EmojiService : BaseAccessibilityService() {
45104

46105
}
47106

48-
sendMessage()
107+
count++
108+
GlobalScope.launch {
109+
delay(interval.toLong())
110+
sendMessage()
111+
}
49112

50113
}
51114

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:orientation="vertical"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
>
9+
<LinearLayout
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
android:orientation="vertical"
13+
android:gravity="center_horizontal">
14+
15+
<TextView
16+
android:id="@+id/tv_control"
17+
android:layout_width="match_parent"
18+
android:layout_height="wrap_content"
19+
android:layout_marginTop="5dp"
20+
android:textSize="@dimen/text_size_small"
21+
android:text="自动发表情插件(点击跳转开启)"
22+
android:textColor="@color/blue_light"
23+
android:gravity="center"
24+
/>
25+
26+
<TextView
27+
android:layout_width="match_parent"
28+
android:layout_height="wrap_content"
29+
android:layout_marginTop="5dp"
30+
android:textSize="@dimen/text_size_small"
31+
android:text="可快速自动发送烟花制造聊天对话页连续放烟花的效果,过年庆祝下,平时也可以快速丢炸弹玩。需先找到辅助功能【自动发送表情】开启才有效"
32+
/>
33+
34+
<View
35+
android:layout_marginTop="10dp"
36+
android:layout_marginBottom="10dp"
37+
style="@style/view_line"/>
38+
39+
<TextView
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:text="设置发送文本,如表情[烟花]:"/>
43+
<EditText
44+
android:id="@+id/et_emoji"
45+
android:layout_width="match_parent"
46+
android:layout_height="wrap_content"
47+
tools:text="[炸弹]"
48+
android:text="[烟花]"
49+
android:singleLine="true"
50+
/>
51+
52+
<View
53+
android:layout_marginTop="10dp"
54+
android:layout_marginBottom="10dp"
55+
style="@style/view_line"/>
56+
57+
<TextView
58+
android:layout_width="wrap_content"
59+
android:layout_height="wrap_content"
60+
android:text="设置进入一次聊天页自动发送次数(0为无限):"/>
61+
<NumberPicker
62+
android:id="@+id/np_times"
63+
android:layout_width="wrap_content"
64+
android:layout_height="wrap_content"
65+
/>
66+
67+
<View
68+
android:layout_marginTop="10dp"
69+
android:layout_marginBottom="10dp"
70+
style="@style/view_line"/>
71+
72+
<TextView
73+
android:layout_width="wrap_content"
74+
android:layout_height="wrap_content"
75+
android:text="设置每次发送间隔时间(ms):"/>
76+
<NumberPicker
77+
android:id="@+id/np_interval"
78+
android:layout_width="wrap_content"
79+
android:layout_height="wrap_content"
80+
/>
81+
82+
</LinearLayout>
83+
84+
</ScrollView>

app/src/main/res/values/strings.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88
<string name="auto_send_emoji">自动发送表情</string>
99

1010
<string name="how_to_use">
11-
该版本适配微信7.0.3,7.0.4,7.0.5,7.0.8,7.0.9,7.0.10,7.0.11,7.0.12,7.0.16,其他版本未适配可能无效。长时间服务后台可能被杀,如果服务被杀需要关闭重新开启无障碍服务。
11+
该版本适配微信7.0.3,7.0.4,7.0.5,7.0.8,7.0.9,7.0.10,7.0.11,7.0.12,7.0.16,8.0.0,8.0.1,其他版本未适配可能无效。长时间服务后台可能被杀,如果服务被杀需要关闭重新开启无障碍服务。
1212
\n\n控制说明:
1313
\n1.微信红包监控开关:点击进入设置找到无障碍服务辅助功能开启【抢微信红包】,开启后下面操作才有效;
1414
\n2.通知监控开关:开启后通知收到微信红包则会自动点击该通知,若开启后无效请确认通知权限是否开启;
1515
\n3.聊天列表页监控开关:开启后停留在首页聊天列表页时会监听,若收到红包会自动点击;
1616
\n4.是否抢自己发的红包:开启则自己发的也会抢;
1717
\n5.领红包延迟时间:设置时间后拆红包会停留设置的时间后点击;
1818
\n6.红包领取页关闭时间:设置后在红包领取详情页面会停留设置的时间后关闭;
19-
\n7.自定义拆红包按钮坐标:该功能针对Android7.0以上设备开放,为了解决之前版本出现的部分机型会自动点击红包但不会自动拆的问题,开启后才有效。
20-
关于如何找红包坐标点的方法有很多种,简书上之前分享的文章《Android通过辅助功能实现抢微信红包原理简单介绍》,图3其实就可以看到坐标范围,
21-
这里介绍手机上查看的两个方法,设置里开发者选项中的显示指针位置或显示布局边界,然后在红包弹窗手指触摸顶部可以看到x坐标和y坐标,使用比较简单详情可百度。
19+
\n7.自定义拆红包按钮坐标:该功能针对Android7.0以上设备开放,为了解决之前版本出现的部分机型会自动点击红包但不会自动拆的问题,当能自动点击红包但不会自动点击拆按钮时可开启使用自定义拆按钮坐标点。
2220
\n\n
2321
\n代码开源仅供学习使用,请勿用作商业用途
2422
<!-- \nAPP说明:http://xbdcc.cn/GrabRedEnvelope/index.html-->
@@ -33,6 +31,12 @@
3331
\n\n如果有遇到说明里除已知bug外的问题, 欢迎通过 GitHub Issue 反馈:https://github.com/xbdcc/GrabRedEnvelope。
3432
\n\n有问题也可联系偶尔会使用的微信:xbdcc1。
3533
\n\n ——made by 小不点</string>
34+
<string name="emoji_description">
35+
使用指南:使用前仔细看APP使用说明。辅助功能开启【自动发送表情】,支持设置自动输入文本、发送次数、发送间隔时间。代码开源仅供学习使用,请勿用作商业用途。
36+
\n\n如果有遇到说明里除已知bug外的问题, 欢迎通过 GitHub Issue 反馈:https://github.com/xbdcc/GrabRedEnvelope。
37+
\n\n有问题也可联系偶尔会使用的微信:xbdcc1。
38+
\n\n ——made by 小不点</string>
39+
3640
<string name="dingding_description">基于钉钉5.0.5版本开发,不做版本适配,只监听当前对话页面红包</string>
3741

3842

app/src/main/res/xml/emoji_service.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- android:packageNames="com.tencent.mm"在9.0中会无法监听通知内容,这里去掉在代码里判断。links:https://stackoverflow.com/questions/55472464/type-notification-state-changed-event-is-not-getting-received-by-accessibility-s -->
22
<accessibility-service
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
android:description="@string/wechat_description"
4+
android:description="@string/emoji_description"
55
android:accessibilityEventTypes="typeAllMask"
66
android:accessibilityFeedbackType="feedbackAllMask"
77
android:notificationTimeout="100"

0 commit comments

Comments
 (0)