Skip to content

Commit

Permalink
Fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
xbdcc committed Jan 22, 2020
1 parent 2558e27 commit ff5b901
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ android {
applicationId "com.carlos.grabredenvelope"
minSdkVersion 18
targetSdkVersion 28
versionCode 9
versionName "2.2.0"
flavorDimensions "9" //和versionCode相同
versionCode 10
versionName "3.0.0"
flavorDimensions "10" //和versionCode相同
ndk {
//选择要添加的对应 cpu 类型的 .so 库。
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86'
Expand Down
96 changes: 96 additions & 0 deletions app/src/main/java/com/carlos/grabredenvelope/db/DaoMaster.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.carlos.grabredenvelope.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;

import org.greenrobot.greendao.AbstractDaoMaster;
import org.greenrobot.greendao.database.StandardDatabase;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseOpenHelper;
import org.greenrobot.greendao.identityscope.IdentityScopeType;


// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 1): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 1;

/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
WechatRedEnvelopeDao.createTable(db, ifNotExists);
}

/** Drops underlying database table using DAOs. */
public static void dropAllTables(Database db, boolean ifExists) {
WechatRedEnvelopeDao.dropTable(db, ifExists);
}

/**
* WARNING: Drops all table on Upgrade! Use only during development.
* Convenience method using a {@link DevOpenHelper}.
*/
public static DaoSession newDevSession(Context context, String name) {
Database db = new DevOpenHelper(context, name).getWritableDb();
DaoMaster daoMaster = new DaoMaster(db);
return daoMaster.newSession();
}

public DaoMaster(SQLiteDatabase db) {
this(new StandardDatabase(db));
}

public DaoMaster(Database db) {
super(db, SCHEMA_VERSION);
registerDaoClass(WechatRedEnvelopeDao.class);
}

public DaoSession newSession() {
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
}

public DaoSession newSession(IdentityScopeType type) {
return new DaoSession(db, type, daoConfigMap);
}

/**
* Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
*/
public static abstract class OpenHelper extends DatabaseOpenHelper {
public OpenHelper(Context context, String name) {
super(context, name, SCHEMA_VERSION);
}

public OpenHelper(Context context, String name, CursorFactory factory) {
super(context, name, factory, SCHEMA_VERSION);
}

@Override
public void onCreate(Database db) {
Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
createAllTables(db, false);
}
}

/** WARNING: Drops all table on Upgrade! Use only during development. */
public static class DevOpenHelper extends OpenHelper {
public DevOpenHelper(Context context, String name) {
super(context, name);
}

public DevOpenHelper(Context context, String name, CursorFactory factory) {
super(context, name, factory);
}

@Override
public void onUpgrade(Database db, int oldVersion, int newVersion) {
Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
dropAllTables(db, true);
onCreate(db);
}
}

}
48 changes: 48 additions & 0 deletions app/src/main/java/com/carlos/grabredenvelope/db/DaoSession.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.carlos.grabredenvelope.db;

import java.util.Map;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.AbstractDaoSession;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.identityscope.IdentityScopeType;
import org.greenrobot.greendao.internal.DaoConfig;

import com.carlos.grabredenvelope.db.WechatRedEnvelope;

import com.carlos.grabredenvelope.db.WechatRedEnvelopeDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
* {@inheritDoc}
*
* @see org.greenrobot.greendao.AbstractDaoSession
*/
public class DaoSession extends AbstractDaoSession {

private final DaoConfig wechatRedEnvelopeDaoConfig;

private final WechatRedEnvelopeDao wechatRedEnvelopeDao;

public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
daoConfigMap) {
super(db);

wechatRedEnvelopeDaoConfig = daoConfigMap.get(WechatRedEnvelopeDao.class).clone();
wechatRedEnvelopeDaoConfig.initIdentityScope(type);

wechatRedEnvelopeDao = new WechatRedEnvelopeDao(wechatRedEnvelopeDaoConfig, this);

registerDao(WechatRedEnvelope.class, wechatRedEnvelopeDao);
}

public void clear() {
wechatRedEnvelopeDaoConfig.clearIdentityScope();
}

public WechatRedEnvelopeDao getWechatRedEnvelopeDao() {
return wechatRedEnvelopeDao;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package com.carlos.grabredenvelope.db;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "WECHAT_RED_ENVELOPE".
*/
public class WechatRedEnvelopeDao extends AbstractDao<WechatRedEnvelope, Long> {

public static final String TABLENAME = "WECHAT_RED_ENVELOPE";

/**
* Properties of entity WechatRedEnvelope.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property Time = new Property(1, long.class, "time", false, "TIME");
public final static Property Count = new Property(2, String.class, "count", false, "COUNT");
}


public WechatRedEnvelopeDao(DaoConfig config) {
super(config);
}

public WechatRedEnvelopeDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}

/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"WECHAT_RED_ENVELOPE\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"TIME\" INTEGER NOT NULL ," + // 1: time
"\"COUNT\" TEXT);"); // 2: count
}

/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"WECHAT_RED_ENVELOPE\"";
db.execSQL(sql);
}

@Override
protected final void bindValues(DatabaseStatement stmt, WechatRedEnvelope entity) {
stmt.clearBindings();

Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindLong(2, entity.getTime());

String count = entity.getCount();
if (count != null) {
stmt.bindString(3, count);
}
}

@Override
protected final void bindValues(SQLiteStatement stmt, WechatRedEnvelope entity) {
stmt.clearBindings();

Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindLong(2, entity.getTime());

String count = entity.getCount();
if (count != null) {
stmt.bindString(3, count);
}
}

@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}

@Override
public WechatRedEnvelope readEntity(Cursor cursor, int offset) {
WechatRedEnvelope entity = new WechatRedEnvelope( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.getLong(offset + 1), // time
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2) // count
);
return entity;
}

@Override
public void readEntity(Cursor cursor, WechatRedEnvelope entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setTime(cursor.getLong(offset + 1));
entity.setCount(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
}

@Override
protected final Long updateKeyAfterInsert(WechatRedEnvelope entity, long rowId) {
entity.setId(rowId);
return rowId;
}

@Override
public Long getKey(WechatRedEnvelope entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}

@Override
public boolean hasKey(WechatRedEnvelope entity) {
return entity.getId() != null;
}

@Override
protected final boolean isEntityUpdateable() {
return true;
}

}
11 changes: 7 additions & 4 deletions app/src/main/res/layout/fragment_control.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">


Expand Down Expand Up @@ -167,17 +169,18 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:maxLength="3"
android:maxLength="4"
tools:text = "518"
android:hint="x"/>
<EditText
android:id="@+id/et_pointY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:maxLength="3"
android:maxLength="4"
tools:text = "1447"
android:hint="y"/>
</LinearLayout>

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

<!--old-->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/wechat_service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFeedbackType="feedbackAllMask"
android:notificationTimeout="100"
android:settingsActivity="com.carlos.grabredenvelope.activity.WechatEnvelopeActivity"
android:settingsActivity="com.carlos.grabredenvelope.activity.MainActivity"
android:canRequestEnhancedWebAccessibility = "true"
android:accessibilityFlags="flagDefault"
android:canPerformGestures = "true"
Expand Down
Binary file added images/wechat_point.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ff5b901

Please sign in to comment.