Skip to content

Commit

Permalink
Add function to monitor the redenvelope sent by myself.
Browse files Browse the repository at this point in the history
  • Loading branch information
xbdcc committed Jul 27, 2020
1 parent 0d52154 commit 07a6286
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 18 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ https://github.com/xbdcc/CUtils
- 辅助功能开启【抢微信红包】,若使用默认参数则通知或聊天列表页面或群聊发现有红包,则会自动点击红包并拆开跳转到详情页自动关闭。
- 通知监控开关说明:需要微信通知权限开启,此时若开启此功能收到通知有红包消息会自动跳转点击。
- 聊天列表页监控开关说明:若打开则在微信首页列表也发现红包消息则会跳转到详情页点击。
- 是否抢自己发的红包说明:若打开则自己发的红包也会去抢。
- 延迟时间说明:为防止秒抢拉仇恨加了延迟功能,延迟可以选择0-9秒。
- 自定义拆红包坐标点说明:自定义红包拆按钮的横纵坐标,解决部分Android7.0以上机型无法自动拆红包的问题。

最新版适配微信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.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版本,代码开源仅供学习使用,请勿用作商业用途。



Expand All @@ -55,6 +55,8 @@ https://github.com/xbdcc/CUtils


## 版本说明
### v3.2.0(2020.07.27)
适配微信7.0.16,增加是否抢自己发的红包开关。
### v3.1.0(2020.03.14)
适配微信7.0.11,7.0.12。
### v3.0.0(2020.01.22)
Expand Down
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
targetSdkVersion 28
versionCode 12
versionName "3.2.0"
flavorDimensions "11" //和versionCode相同
flavorDimensions "12" //和versionCode相同
ndk {
//选择要添加的对应 cpu 类型的 .so 库。
abiFilters 'armeabi-v7a', 'x86'
Expand Down Expand Up @@ -149,7 +149,6 @@ dependencies {

// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'


}
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ data class WechatControlVO(
@Transient
var isMonitorNotification: Boolean = true, //是否监控通知
var isMonitorChat: Boolean = true, //是否监控聊天列表页面
var ifGrabSelf: Boolean = true, //是否抢自己发的红包
@Transient
var delayOpenTime: Int = 0,
@Transient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ class ControlFragment : BaseFragment(R.layout.fragment_control), SeekBar.OnSeekB
}
cb_wechat_chat_control.setOnCheckedChangeListener { buttonView, isChecked ->
wechatControlVO.isMonitorChat = isChecked
LogUtils.d("ismotior:" + isChecked)
// LogUtils.d("ismotior:" + isChecked)
RedEnvelopePreferences.wechatControl = wechatControlVO
}
cb_if_grab_self.setOnCheckedChangeListener { buttonView, isChecked ->
wechatControlVO.ifGrabSelf = isChecked
// LogUtils.d("ifGrabSelf:" + isChecked)
RedEnvelopePreferences.wechatControl = wechatControlVO
}

Expand Down Expand Up @@ -123,6 +128,7 @@ class ControlFragment : BaseFragment(R.layout.fragment_control), SeekBar.OnSeekB
cb_wechat_notification_control.isChecked =
RedEnvelopePreferences.wechatControl.isMonitorNotification
cb_wechat_chat_control.isChecked = RedEnvelopePreferences.wechatControl.isMonitorChat
cb_if_grab_self.isChecked = RedEnvelopePreferences.wechatControl.ifGrabSelf
LogUtils.d("wechatControl:" + RedEnvelopePreferences.wechatControl.toString())

wechatControlVO = RedEnvelopePreferences.wechatControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ class WechatService : BaseAccessibilityService() {
private fun grabRedEnvelope() {
// LogUtils.d("grabRedEnvelope")
/* 发现红包点击进入领取红包页面 */

val ifGrabSelf = RedEnvelopePreferences.wechatControl.ifGrabSelf
if (findAndClickFirstNodeInfoByViewId(
RED_ENVELOPE_ID, RED_ENVELOPE_FLAG_ID, RED_ENVELOPE_BEEN_GRAB_ID, true
RED_ENVELOPE_ID, RED_ENVELOPE_FLAG_ID, RED_ENVELOPE_BEEN_GRAB_ID, !ifGrabSelf, true
)
) {
status = HAS_CLICKED
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/res/layout/fragment_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,29 @@
android:checked="true"
android:button="@drawable/switch_course_control"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_small"
android:text="是否抢自己发的红包:"
android:layout_centerHorizontal="true"/>
<CheckBox
android:id="@+id/cb_if_grab_self"
android:layout_width="60dp"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:checked="true"
android:button="@drawable/switch_course_control"/>
</LinearLayout>

<View
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
Expand Down
19 changes: 8 additions & 11 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,22 @@
<string name="grab_dingding_envelope">抢钉钉红包</string>

<string name="how_to_use">
该版本适配微信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.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,其他版本未适配可能无效。长时间服务后台可能被杀,如果服务被杀需要关闭重新开启无障碍服务
\n\n控制说明:
\n1.微信红包监控开关:点击进入设置找到无障碍服务辅助功能开启【抢微信红包】,开启后下面操作才有效;
\n2.通知监控开关:开启后通知收到微信红包则会自动点击该通知,若开启后无效请确认通知权限是否开启;
\n3.聊天列表页监控开关:开启后停留在首页聊天列表页时会监听,若收到红包会自动点击;
\n4.领红包延迟时间:设置时间后拆红包会停留设置的时间后点击;
\n5.红包领取页关闭时间:设置后在红包领取详情页面会停留设置的时间后关闭;
\n6.自定义拆红包按钮坐标:该功能针对Android7.0以上设备开放,为了解决之前版本出现的部分机型会自动点击红包但不会自动拆的问题,开启后才有效。
\n4.是否抢自己发的红包:开启则自己发的也会抢;
\n5.领红包延迟时间:设置时间后拆红包会停留设置的时间后点击;
\n6.红包领取页关闭时间:设置后在红包领取详情页面会停留设置的时间后关闭;
\n7.自定义拆红包按钮坐标:该功能针对Android7.0以上设备开放,为了解决之前版本出现的部分机型会自动点击红包但不会自动拆的问题,开启后才有效。
关于如何找红包坐标点的方法有很多种,简书上之前分享的文章《Android通过辅助功能实现抢微信红包原理简单介绍》,图3其实就可以看到坐标范围,
这里介绍手机上查看的两个方法,设置里开发者选项中的显示指针位置或显示布局边界,然后在红包弹窗手指触摸顶部可以看到x坐标和y坐标,使用比较简单详情可百度。
\n
\n\n已知的bug有:
\n若出现文字与红包文字相同则也会点击
\n若红包没领完则还会继续点击
\n\n
\n代码开源仅供学习使用,请勿用作商业用途
\nAPP说明:http://xbdcc.cn/GrabRedEnvelope/index.html
\n代码地址:https://github.com/xbdcc/GrabRedEnvelope
\n\简单教程:https://github.com/xbdcc/GrabRedEnvelope/blob/master/demo/README.md
<!-- \nAPP说明:http://xbdcc.cn/GrabRedEnvelope/index.html-->
<!-- \n代码地址:https://github.com/xbdcc/GrabRedEnvelope-->
<!-- \n\简单教程:https://github.com/xbdcc/GrabRedEnvelope/blob/master/demo/README.md-->
\n
</string>

Expand Down

0 comments on commit 07a6286

Please sign in to comment.