Skip to content

Commit ff5b901

Browse files
committed
Fix bug.
1 parent 2558e27 commit ff5b901

8 files changed

Lines changed: 292 additions & 12 deletions

File tree

app/build.gradle

Lines changed: 3 additions & 3 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 9
36-
versionName "2.2.0"
37-
flavorDimensions "9" //和versionCode相同
35+
versionCode 10
36+
versionName "3.0.0"
37+
flavorDimensions "10" //和versionCode相同
3838
ndk {
3939
//选择要添加的对应 cpu 类型的 .so 库。
4040
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86'
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package com.carlos.grabredenvelope.db;
2+
3+
import android.content.Context;
4+
import android.database.sqlite.SQLiteDatabase;
5+
import android.database.sqlite.SQLiteDatabase.CursorFactory;
6+
import android.util.Log;
7+
8+
import org.greenrobot.greendao.AbstractDaoMaster;
9+
import org.greenrobot.greendao.database.StandardDatabase;
10+
import org.greenrobot.greendao.database.Database;
11+
import org.greenrobot.greendao.database.DatabaseOpenHelper;
12+
import org.greenrobot.greendao.identityscope.IdentityScopeType;
13+
14+
15+
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
16+
/**
17+
* Master of DAO (schema version 1): knows all DAOs.
18+
*/
19+
public class DaoMaster extends AbstractDaoMaster {
20+
public static final int SCHEMA_VERSION = 1;
21+
22+
/** Creates underlying database table using DAOs. */
23+
public static void createAllTables(Database db, boolean ifNotExists) {
24+
WechatRedEnvelopeDao.createTable(db, ifNotExists);
25+
}
26+
27+
/** Drops underlying database table using DAOs. */
28+
public static void dropAllTables(Database db, boolean ifExists) {
29+
WechatRedEnvelopeDao.dropTable(db, ifExists);
30+
}
31+
32+
/**
33+
* WARNING: Drops all table on Upgrade! Use only during development.
34+
* Convenience method using a {@link DevOpenHelper}.
35+
*/
36+
public static DaoSession newDevSession(Context context, String name) {
37+
Database db = new DevOpenHelper(context, name).getWritableDb();
38+
DaoMaster daoMaster = new DaoMaster(db);
39+
return daoMaster.newSession();
40+
}
41+
42+
public DaoMaster(SQLiteDatabase db) {
43+
this(new StandardDatabase(db));
44+
}
45+
46+
public DaoMaster(Database db) {
47+
super(db, SCHEMA_VERSION);
48+
registerDaoClass(WechatRedEnvelopeDao.class);
49+
}
50+
51+
public DaoSession newSession() {
52+
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
53+
}
54+
55+
public DaoSession newSession(IdentityScopeType type) {
56+
return new DaoSession(db, type, daoConfigMap);
57+
}
58+
59+
/**
60+
* Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
61+
*/
62+
public static abstract class OpenHelper extends DatabaseOpenHelper {
63+
public OpenHelper(Context context, String name) {
64+
super(context, name, SCHEMA_VERSION);
65+
}
66+
67+
public OpenHelper(Context context, String name, CursorFactory factory) {
68+
super(context, name, factory, SCHEMA_VERSION);
69+
}
70+
71+
@Override
72+
public void onCreate(Database db) {
73+
Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
74+
createAllTables(db, false);
75+
}
76+
}
77+
78+
/** WARNING: Drops all table on Upgrade! Use only during development. */
79+
public static class DevOpenHelper extends OpenHelper {
80+
public DevOpenHelper(Context context, String name) {
81+
super(context, name);
82+
}
83+
84+
public DevOpenHelper(Context context, String name, CursorFactory factory) {
85+
super(context, name, factory);
86+
}
87+
88+
@Override
89+
public void onUpgrade(Database db, int oldVersion, int newVersion) {
90+
Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
91+
dropAllTables(db, true);
92+
onCreate(db);
93+
}
94+
}
95+
96+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.carlos.grabredenvelope.db;
2+
3+
import java.util.Map;
4+
5+
import org.greenrobot.greendao.AbstractDao;
6+
import org.greenrobot.greendao.AbstractDaoSession;
7+
import org.greenrobot.greendao.database.Database;
8+
import org.greenrobot.greendao.identityscope.IdentityScopeType;
9+
import org.greenrobot.greendao.internal.DaoConfig;
10+
11+
import com.carlos.grabredenvelope.db.WechatRedEnvelope;
12+
13+
import com.carlos.grabredenvelope.db.WechatRedEnvelopeDao;
14+
15+
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
16+
17+
/**
18+
* {@inheritDoc}
19+
*
20+
* @see org.greenrobot.greendao.AbstractDaoSession
21+
*/
22+
public class DaoSession extends AbstractDaoSession {
23+
24+
private final DaoConfig wechatRedEnvelopeDaoConfig;
25+
26+
private final WechatRedEnvelopeDao wechatRedEnvelopeDao;
27+
28+
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
29+
daoConfigMap) {
30+
super(db);
31+
32+
wechatRedEnvelopeDaoConfig = daoConfigMap.get(WechatRedEnvelopeDao.class).clone();
33+
wechatRedEnvelopeDaoConfig.initIdentityScope(type);
34+
35+
wechatRedEnvelopeDao = new WechatRedEnvelopeDao(wechatRedEnvelopeDaoConfig, this);
36+
37+
registerDao(WechatRedEnvelope.class, wechatRedEnvelopeDao);
38+
}
39+
40+
public void clear() {
41+
wechatRedEnvelopeDaoConfig.clearIdentityScope();
42+
}
43+
44+
public WechatRedEnvelopeDao getWechatRedEnvelopeDao() {
45+
return wechatRedEnvelopeDao;
46+
}
47+
48+
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
package com.carlos.grabredenvelope.db;
2+
3+
import android.database.Cursor;
4+
import android.database.sqlite.SQLiteStatement;
5+
6+
import org.greenrobot.greendao.AbstractDao;
7+
import org.greenrobot.greendao.Property;
8+
import org.greenrobot.greendao.internal.DaoConfig;
9+
import org.greenrobot.greendao.database.Database;
10+
import org.greenrobot.greendao.database.DatabaseStatement;
11+
12+
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
13+
/**
14+
* DAO for table "WECHAT_RED_ENVELOPE".
15+
*/
16+
public class WechatRedEnvelopeDao extends AbstractDao<WechatRedEnvelope, Long> {
17+
18+
public static final String TABLENAME = "WECHAT_RED_ENVELOPE";
19+
20+
/**
21+
* Properties of entity WechatRedEnvelope.<br/>
22+
* Can be used for QueryBuilder and for referencing column names.
23+
*/
24+
public static class Properties {
25+
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
26+
public final static Property Time = new Property(1, long.class, "time", false, "TIME");
27+
public final static Property Count = new Property(2, String.class, "count", false, "COUNT");
28+
}
29+
30+
31+
public WechatRedEnvelopeDao(DaoConfig config) {
32+
super(config);
33+
}
34+
35+
public WechatRedEnvelopeDao(DaoConfig config, DaoSession daoSession) {
36+
super(config, daoSession);
37+
}
38+
39+
/** Creates the underlying database table. */
40+
public static void createTable(Database db, boolean ifNotExists) {
41+
String constraint = ifNotExists? "IF NOT EXISTS ": "";
42+
db.execSQL("CREATE TABLE " + constraint + "\"WECHAT_RED_ENVELOPE\" (" + //
43+
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
44+
"\"TIME\" INTEGER NOT NULL ," + // 1: time
45+
"\"COUNT\" TEXT);"); // 2: count
46+
}
47+
48+
/** Drops the underlying database table. */
49+
public static void dropTable(Database db, boolean ifExists) {
50+
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"WECHAT_RED_ENVELOPE\"";
51+
db.execSQL(sql);
52+
}
53+
54+
@Override
55+
protected final void bindValues(DatabaseStatement stmt, WechatRedEnvelope entity) {
56+
stmt.clearBindings();
57+
58+
Long id = entity.getId();
59+
if (id != null) {
60+
stmt.bindLong(1, id);
61+
}
62+
stmt.bindLong(2, entity.getTime());
63+
64+
String count = entity.getCount();
65+
if (count != null) {
66+
stmt.bindString(3, count);
67+
}
68+
}
69+
70+
@Override
71+
protected final void bindValues(SQLiteStatement stmt, WechatRedEnvelope entity) {
72+
stmt.clearBindings();
73+
74+
Long id = entity.getId();
75+
if (id != null) {
76+
stmt.bindLong(1, id);
77+
}
78+
stmt.bindLong(2, entity.getTime());
79+
80+
String count = entity.getCount();
81+
if (count != null) {
82+
stmt.bindString(3, count);
83+
}
84+
}
85+
86+
@Override
87+
public Long readKey(Cursor cursor, int offset) {
88+
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
89+
}
90+
91+
@Override
92+
public WechatRedEnvelope readEntity(Cursor cursor, int offset) {
93+
WechatRedEnvelope entity = new WechatRedEnvelope( //
94+
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
95+
cursor.getLong(offset + 1), // time
96+
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2) // count
97+
);
98+
return entity;
99+
}
100+
101+
@Override
102+
public void readEntity(Cursor cursor, WechatRedEnvelope entity, int offset) {
103+
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
104+
entity.setTime(cursor.getLong(offset + 1));
105+
entity.setCount(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
106+
}
107+
108+
@Override
109+
protected final Long updateKeyAfterInsert(WechatRedEnvelope entity, long rowId) {
110+
entity.setId(rowId);
111+
return rowId;
112+
}
113+
114+
@Override
115+
public Long getKey(WechatRedEnvelope entity) {
116+
if(entity != null) {
117+
return entity.getId();
118+
} else {
119+
return null;
120+
}
121+
}
122+
123+
@Override
124+
public boolean hasKey(WechatRedEnvelope entity) {
125+
return entity.getId() != null;
126+
}
127+
128+
@Override
129+
protected final boolean isEntityUpdateable() {
130+
return true;
131+
}
132+
133+
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:orientation="vertical" android:layout_width="match_parent"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:orientation="vertical"
5+
android:layout_width="match_parent"
46
android:layout_height="match_parent">
57

68

@@ -167,17 +169,18 @@
167169
android:layout_width="wrap_content"
168170
android:layout_height="wrap_content"
169171
android:inputType="numberDecimal"
170-
android:maxLength="3"
172+
android:maxLength="4"
173+
tools:text = "518"
171174
android:hint="x"/>
172175
<EditText
173176
android:id="@+id/et_pointY"
174177
android:layout_width="wrap_content"
175178
android:layout_height="wrap_content"
176179
android:inputType="numberDecimal"
177-
android:maxLength="3"
180+
android:maxLength="4"
181+
tools:text = "1447"
178182
android:hint="y"/>
179183
</LinearLayout>
180-
181184
</LinearLayout>
182185
</ScrollView>
183186
</LinearLayout>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
<string name="grab_dingding_envelope">抢钉钉红包</string>
77

88
<string name="how_to_use">
9-
该版本适配微信7.0.3,7.0.4,7.0.5,7.0.8,7.0.97.0.10,其他版本下可能无效,最好在已适配的微信版本下使用。
9+
该版本适配微信7.0.3,7.0.4,7.0.5,7.0.8,7.0.9,7.0.10,其他版本下可能无效,最好在已适配的微信版本下使用,长时间后台可能被杀,如果失效请重新开启无障碍服务
1010
\n\n控制说明:
11-
\n1.微信红包监控开关:点击进入设置找到辅助功能开启【抢微信红包】,开启后下面操作才有效;
11+
\n1.微信红包监控开关:点击进入设置找到无障碍服务辅助功能开启【抢微信红包】,开启后下面操作才有效;
1212
\n2.通知监控开关:开启后通知收到微信红包则会自动点击该通知,若开启后无效请确认通知权限是否开启;
1313
\n3.聊天列表页监控开关:开启后停留在首页聊天列表页时会监听,若收到红包会自动点击;
1414
\n4.领红包延迟时间:设置时间后拆红包会停留设置的时间后点击;
1515
\n5.红包领取页关闭时间:设置后在红包领取详情页面会停留设置的时间后关闭;
1616
\n6.自定义拆红包按钮坐标:该功能针对Android7.0以上设备开放,为了解决之前版本出现的部分机型会自动点击红包但不会自动拆的问题,开启后才有效。
1717
关于如何找红包坐标点的方法有很多种,简书上之前分享的文章《Android通过辅助功能实现抢微信红包原理简单介绍》,图3其实就可以看到坐标范围,
18-
这里介绍手机上查看的两个方法,设置里开发者选项中的显示指针位置或显示布局边界,使用比较简单详情可百度。
18+
这里介绍手机上查看的两个方法,设置里开发者选项中的显示指针位置或显示布局边界,然后在红包弹窗手指触摸顶部可以看到x坐标和y坐标,使用比较简单详情可百度。
1919
\n
2020
\n\n已知的bug有:
2121
\n若出现文字与红包文字相同则也会点击
@@ -32,7 +32,7 @@
3232
<string name="wechat_description">
3333
使用指南:使用前仔细看APP使用说明。辅助功能开启【抢微信红包】,APP 抢微信红包设置是否监控通知和聊天列表页面,同时可设置延迟时间。代码开源仅供学习使用,请勿用作商业用途。
3434
\n\n如果有遇到说明里除已知bug外的问题, 欢迎通过 GitHub Issue 反馈:https://github.com/xbdcc/GrabRedEnvelope
35-
\n\n主要基于自己手上的OPPO R9测试,因Android机型众多,有些机型可能会有不同未知Bug还未适配,待后续完善。
35+
\n\n主要基于自己手上的Android机测试,因Android机型众多,可能有些机型没设备适配,待后续完善。
3636
\n\n ——made by 小不点</string>
3737

3838
<!--old-->

app/src/main/res/xml/wechat_service.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
android:accessibilityEventTypes="typeAllMask"
66
android:accessibilityFeedbackType="feedbackAllMask"
77
android:notificationTimeout="100"
8-
android:settingsActivity="com.carlos.grabredenvelope.activity.WechatEnvelopeActivity"
8+
android:settingsActivity="com.carlos.grabredenvelope.activity.MainActivity"
99
android:canRequestEnhancedWebAccessibility = "true"
1010
android:accessibilityFlags="flagDefault"
1111
android:canPerformGestures = "true"

images/wechat_point.jpg

89.5 KB
Loading

0 commit comments

Comments
 (0)