Skip to content

Commit db13645

Browse files
committed
适配企业微信2.5.8;适配英文系统
1 parent bc92310 commit db13645

File tree

10 files changed

+115
-61
lines changed

10 files changed

+115
-61
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
实现企业微信红包自动点击,自动抢红包
33

44
## 最新版下载地址
5-
[企业微信红包助手_v1.9.0_10_release_2018_09_17_22_11_29.apk](https://github.com/chenyuebo/WeworkRedPacketHelper/raw/master/apk/%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E7%BA%A2%E5%8C%85%E5%8A%A9%E6%89%8B_v1.9.0_10_release_2018_09_17_22_11_29.apk)
5+
[企业微信红包助手_v1.10.0_11_release_2018_09_30_19_06_26.apk](https://github.com/chenyuebo/WeworkRedPacketHelper/raw/master/apk/%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E7%BA%A2%E5%8C%85%E5%8A%A9%E6%89%8B_v1.10.0_11_release_2018_09_30_19_06_26.apk)
66
## 已适配企业微信版本
77
- 2.4.7
88
- 2.4.9
@@ -15,6 +15,7 @@
1515
- 2.4.99
1616
- 2.5.0
1717
- 2.5.2
18+
- 2.5.8
1819

1920
## 屏幕截图
2021

Binary file not shown.

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ android {
66
applicationId "com.cyb.wework"
77
minSdkVersion 16
88
targetSdkVersion 26
9-
versionCode 10
10-
versionName "1.9.0"
9+
versionCode 11
10+
versionName "1.10.0"
1111
// 只打包中文资源
12-
resConfigs "zh"
12+
resConfigs "zh","en"
1313
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1414
}
1515
signingConfigs {

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<activity
4444
android:name=".activity.SettingActivity"
45-
android:label="@string/title_activity_setting"
45+
android:label="@string/preference_setting"
4646
android:theme="@style/AppTheme.NoActionBar"/>
4747
</application>
4848

app/src/main/java/com/cyb/wework/service/RedPacketService.java

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import android.view.accessibility.AccessibilityEvent;
1515
import android.view.accessibility.AccessibilityNodeInfo;
1616

17+
import com.cyb.wework.R;
1718
import com.cyb.wework.utils.AppUtil;
1819
import com.cyb.wework.utils.LogUtil;
1920

@@ -99,7 +100,8 @@ private void onNotificationStateChanged(AccessibilityEvent accessibilityEvent) {
99100
LogUtil.d("notification or toast text=" + text);
100101
String content = text.toString();
101102

102-
String keywords = sharedPreferences.getString("pref_notification_keyword", "拼手气红包");
103+
String defaultKeyword = getResources().getString(R.string.notification_default_keyword); // 拼手气红包
104+
String keywords = sharedPreferences.getString("pref_notification_keyword", defaultKeyword);
103105
String[] keywordArray = keywords.split(";");
104106
for (String keyword : keywordArray) {
105107
if (keyword != null && keyword.length() > 0) {
@@ -150,8 +152,10 @@ private void openPacket() {
150152
LogUtil.d( "拆开红包 openPacket");
151153
final AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
152154
if (nodeInfo != null) {
153-
List<AccessibilityNodeInfo> resultList = nodeInfo.findAccessibilityNodeInfosByText("手慢了,红包派完了");
154-
List<AccessibilityNodeInfo> resultList2 = nodeInfo.findAccessibilityNodeInfosByText("该红包已过期");
155+
String haveBeenOpened = getResources().getString(R.string.red_packet_have_opened); // 手慢了,红包派完了
156+
String redPacketExpired = getResources().getString(R.string.red_packet_expired); // 红包已过期
157+
List<AccessibilityNodeInfo> resultList = nodeInfo.findAccessibilityNodeInfosByText(haveBeenOpened);
158+
List<AccessibilityNodeInfo> resultList2 = nodeInfo.findAccessibilityNodeInfosByText(redPacketExpired);
155159
LogUtil.d( "手慢了,红包派完了 resultList=" + resultList.size());
156160
LogUtil.d( "该红包已过期 resultList2=" + resultList2.size());
157161
// 判断红包是否已抢完,如已经抢完则自动关闭抢红包页面,如没有抢完则自动抢红包
@@ -213,6 +217,8 @@ private String getOpenBtnId() {
213217
return "com.tencent.wework:id/cjj";
214218
} else if ("2.5.2".equals(weworkVersion)) {
215219
return "com.tencent.wework:id/cjj";
220+
} else if ("2.5.8".equals(weworkVersion)) {
221+
return "com.tencent.wework:id/cwf";
216222
}
217223
return null;
218224
}
@@ -225,7 +231,8 @@ private String getOpenBtnId() {
225231
private void queryPacket() {
226232
LogUtil.d( "开始查找红包 queryPacket");
227233
AccessibilityNodeInfo rootNode = getRootInActiveWindow();
228-
AccessibilityNodeInfo node = getLastRedpackageNode(rootNode, "领取红包");
234+
String searchText = getResources().getString(R.string.open_red_packet); // 领取红包
235+
AccessibilityNodeInfo node = getLastRedpackageNode(rootNode, searchText);
229236
LogUtil.d( "最新的红包=" + node);
230237
if (node != null) {
231238
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
@@ -268,36 +275,6 @@ public AccessibilityNodeInfo getLastRedpackageNode(AccessibilityNodeInfo rootNod
268275
return resultNode;
269276
}
270277

271-
// /**
272-
// * 递归查找当前聊天窗口中的红包信息
273-
// *
274-
// * 聊天窗口中的红包都存在"领取红包"一词,因此可根据该词查找红包
275-
// *
276-
// * @param node
277-
// */
278-
// public AccessibilityNodeInfo recycle(AccessibilityNodeInfo node) {
279-
// LogUtil.d( "recycle");
280-
// if (node == null) {
281-
// return null;
282-
// }
283-
// AccessibilityNodeInfo resultNode = null;
284-
// if (node.getChildCount() == 0) {
285-
// if (node.getText() != null) {
286-
// if ("领取红包".equals(node.getText().toString())) {
287-
// resultNode = node;
288-
// }
289-
// }
290-
// } else {
291-
// for (int i = 0; i < node.getChildCount(); i++) {
292-
// if (node.getChild(i) != null) {
293-
// AccessibilityNodeInfo tmpNode = recycle(node.getChild(i));
294-
// resultNode = tmpNode == null ? resultNode : tmpNode;
295-
// }
296-
// }
297-
// }
298-
// return resultNode;
299-
// }
300-
301278
@Override
302279
public void onInterrupt() {
303280
LogUtil.d( "RedPacketService onInterrupt 企业微信红包助手已停止");

app/src/main/res/layout/activity_main.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
android:layout_width="wrap_content"
2020
android:layout_height="wrap_content"
2121
android:layout_centerHorizontal="true"
22+
android:textAlignment="center"
2223
android:layout_marginTop="60dp"
2324
android:text="@string/app_name"
2425
android:textColor="#FFFFFF"
@@ -75,7 +76,8 @@
7576
<TextView
7677
android:layout_width="wrap_content"
7778
android:layout_height="wrap_content"
78-
android:text="开启助手"
79+
android:text="@string/open_assistant"
80+
android:textAlignment="center"
7981
android:textColor="#dfaa6a"
8082
android:textSize="18dp"
8183
android:textStyle="bold" />
@@ -105,7 +107,8 @@
105107
<TextView
106108
android:layout_width="wrap_content"
107109
android:layout_height="wrap_content"
108-
android:text="开启通知监听"
110+
android:text="@string/open_monitor_notification"
111+
android:textAlignment="center"
109112
android:textColor="#dfaa6a"
110113
android:textSize="18dp"
111114
android:textStyle="bold" />
@@ -135,7 +138,8 @@
135138
<TextView
136139
android:layout_width="wrap_content"
137140
android:layout_height="wrap_content"
138-
android:text="设置"
141+
android:text="@string/preference_setting"
142+
android:textAlignment="center"
139143
android:textColor="#dfaa6a"
140144
android:textSize="18dp"
141145
android:textStyle="bold" />

app/src/main/res/layout/activity_setting.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
android:layout_height="?attr/actionBarSize"
1919
android:background="?attr/colorPrimary"
2020
app:popupTheme="@style/AppTheme.PopupOverlay"
21-
app:title="偏好设置" />
21+
app:title="@string/preference_setting" />
2222

2323
</android.support.design.widget.AppBarLayout>
2424

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<resources>
2+
<string name="app_name">WeChat Work Red Packet Assistant</string>
3+
<string name="accessibility_description">企业微信红包助手,帮助你实现在企业微信中,自动抢个人红包和群红包</string>
4+
<string name="preference_setting">Settings</string>
5+
6+
<string name="open_assistant">Open Assistant</string>
7+
<string name="open_monitor_notification">Monitor Notification</string>
8+
9+
<string name="open_red_packet">Open Red Packet</string>
10+
<string name="red_packet_have_opened">All red packets have been opened.</string>
11+
<string name="red_packet_expired">Red Packet expired</string>
12+
<string name="notification_default_keyword">Random Amount Red Packet</string>
13+
14+
<string name="monitor_setting">Monitor Setting</string>
15+
<string name="monitor_notification">Monitor Notification</string>
16+
<string name="monitor_notification_keyword">Motification Keywords</string>
17+
<string name="safty_setting">Safty Setting</string>
18+
<string name="delay_opening_red_packet">Delay Opening Red Packet</string>
19+
<string name="open_red_packet_automatically">Open Red Packet Automatically</string>
20+
<string name="close_red_packet_automatically">Close Red Packet Automatically</string>
21+
<string name="click_msg_automatically">Click Message Automatically</string>
22+
<string name="about">About</string>
23+
<string name="version">Version</string>
24+
<string name="author">Author</string>
25+
<string name="instructions">Instructions</string>
26+
<string name="instructions_detail">Adapted WeChat Work Version:
27+
\n2.4.7,2.4.9,2.4.12,2.4.14,2.4.16,2.4.18,2.4.20,2.4.22,2.4.99,2.5.0,2.5.2,2.5.8</string>
28+
29+
<string-array name="delayTimes">
30+
<item>Delay of 0 ms</item>
31+
<item>Delay of 100 ms</item>
32+
<item>Delay of 200 ms</item>
33+
<item>Delay of 300 ms</item>
34+
<item>Delay of 400 ms</item>
35+
<item>Delay of 500 ms</item>
36+
<item>Delay of 1000 ms</item>
37+
<item>Delay of 2000 ms</item>
38+
</string-array>
39+
40+
<string-array name="delayTimesValue">
41+
<item>0</item>
42+
<item>100</item>
43+
<item>200</item>
44+
<item>300</item>
45+
<item>400</item>
46+
<item>500</item>
47+
<item>1000</item>
48+
<item>2000</item>
49+
</string-array>
50+
</resources>

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
<resources>
22
<string name="app_name">企业微信红包助手</string>
33
<string name="accessibility_description">企业微信红包助手,帮助你实现在企业微信中,自动抢个人红包和群红包</string>
4-
<string name="title_activity_setting">偏好设置</string>
4+
<string name="preference_setting">偏好设置</string>
5+
6+
<string name="open_assistant">开启助手</string>
7+
<string name="open_monitor_notification">开启通知监听</string>
8+
9+
<string name="open_red_packet">领取红包</string>
10+
<string name="red_packet_have_opened">手慢了,红包派完了</string>
11+
<string name="red_packet_expired">该红包已过期</string>
12+
<string name="notification_default_keyword">拼手气红包</string>
13+
14+
<string name="monitor_setting">监视选项</string>
15+
<string name="monitor_notification">监视系统通知</string>
16+
<string name="monitor_notification_keyword">设置监听关键词</string>
17+
<string name="safty_setting">防封号选项</string>
18+
<string name="delay_opening_red_packet">延时拆开红包</string>
19+
<string name="open_red_packet_automatically">自动拆开红包</string>
20+
<string name="close_red_packet_automatically">自动关闭红包</string>
21+
<string name="click_msg_automatically">自动点击红包消息</string>
22+
<string name="about">关于本应用</string>
23+
<string name="version">版本</string>
24+
<string name="author">作者</string>
25+
<string name="instructions">使用说明</string>
26+
<string name="instructions_detail">由于部分功能使用了企业微信部分View的Id,所以升级企业微信客户端可能造成本软件部分功能失效。
27+
\n已适配企业微信版本如下:
28+
\n2.4.7,2.4.9,2.4.12,2.4.14,2.4.16,2.4.18,2.4.20,2.4.22,2.4.99,2.5.0,2.5.2,2.5.8</string>
529

630
<string-array name="delayTimes">
731
<item>延时0毫秒</item>

app/src/main/res/xml/preferences.xml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,57 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
3-
<PreferenceCategory android:title="监视选项">
3+
<PreferenceCategory android:title="@string/monitor_setting">
44

55
<CheckBoxPreference
66
android:defaultValue="true"
77
android:key="pref_watch_notification"
88
android:summary="读取新消息通知中的红包提示并进入聊天页"
9-
android:title="监视系统通知" />
9+
android:title="@string/monitor_notification" />
1010
<EditTextPreference
11-
android:defaultValue="拼手气红包;"
11+
android:defaultValue="拼手气红包;Random Amount Red Packet"
1212
android:key="pref_notification_keyword"
1313
android:summary="当通知中出现设置的关键词时自动点击通知,多个关键词使用英文的分号';'隔开"
14-
android:title="设置监听关键词" />
14+
android:title="@string/monitor_notification_keyword" />
1515
</PreferenceCategory>
1616

17-
<PreferenceCategory android:title="防封号选项">
17+
<PreferenceCategory android:title="@string/safty_setting">
1818
<CheckBoxPreference
1919
android:defaultValue="true"
2020
android:key="pref_auto_click_msg"
2121
android:summary="在聊天页面自动点击屏幕中最下方的红包"
22-
android:title="自动点击红包消息" />
22+
android:title="@string/click_msg_automatically" />
2323
<CheckBoxPreference
2424
android:defaultValue="true"
2525
android:key="pref_auto_open"
2626
android:summary="点开的红包自动点击开按钮"
27-
android:title="自动拆开红包" />
27+
android:title="@string/open_red_packet_automatically" />
2828
<CheckBoxPreference
2929
android:defaultValue="true"
3030
android:key="pref_auto_close"
3131
android:summary="红包已抢完或已过期或者进入红包详情页后自动返回"
32-
android:title="自动关闭红包" />
32+
android:title="@string/close_red_packet_automatically" />
3333
<ListPreference
3434
android:entries="@array/delayTimes"
3535
android:entryValues="@array/delayTimesValue"
3636
android:key="pref_delay_ms"
3737
android:defaultValue="0"
3838
android:summary="延时一段时间点击开按钮"
39-
android:title="延时拆开红包">
39+
android:title="@string/delay_opening_red_packet">
4040

4141
</ListPreference>
4242
</PreferenceCategory>
4343

44-
<PreferenceCategory android:title="关于本应用">
44+
<PreferenceCategory android:title="@string/about">
4545
<Preference
4646
android:key="pref_app_version"
47-
android:summary="v1.9.0"
48-
android:title="版本" />
47+
android:summary="v1.10.0"
48+
android:title="@string/version" />
4949
<Preference
5050
android:key="pref_app_author"
5151
android:summary="CYB"
52-
android:title="作者" />
52+
android:title="@string/author" />
5353
<Preference
54-
android:summary="由于部分功能使用了企业微信部分View的Id,所以升级企业微信客户端可能造成本软件部分功能失效。
55-
\n已测试企业微信版本如下:
56-
\n2.4.7,2.4.9,2.4.12,2.4.14,2.4.16,2.4.18,2.4.20,2.4.22,2.4.99,2.5.0,2.5.2"
57-
android:title="使用说明" />
54+
android:summary="@string/instructions_detail"
55+
android:title="@string/instructions" />
5856
</PreferenceCategory>
5957
</PreferenceScreen>

0 commit comments

Comments
 (0)