Skip to content

Commit

Permalink
Merge branch 'stable' of github.com:geeeeeeeeek/WeChatLuckyMoney into…
Browse files Browse the repository at this point in the history
… HEAD
  • Loading branch information
Zhongyi Tong committed Feb 12, 2016
2 parents 2ca4b53 + 9dcd925 commit 9867eea
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 28 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 更新日志

**[v2.3 (2016.02.07)](https://github.com/geeeeeeeeek/WeChatLuckyMoney/releases/tag/v2.3)**

- 优化 不打开拜年红包
- 紧急修复了Bugly上几个高优先级的问题,减少Crash出现



**[v2.2 (2016.02.04)](https://github.com/geeeeeeeeek/WeChatLuckyMoney/releases/tag/v2.2)**

- 新增 延时拆开红包的可选项
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 16
targetSdkVersion 22
versionCode 2
versionName "v2.2"
versionName "v2.3"
ndk {
//设置支持的SO库架构
abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.List;

import android.widget.Toast;
import xyz.monkeytong.hongbao.R;
import xyz.monkeytong.hongbao.fragments.GeneralSettingsFragment;
import xyz.monkeytong.hongbao.utils.ConnectivityUtil;
Expand Down Expand Up @@ -89,8 +90,14 @@ protected void onDestroy() {
}

public void onButtonClicked(View view) {
Intent accessibleIntent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivity(accessibleIntent);
try {
Intent accessibleIntent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivity(accessibleIntent);
} catch (Exception e) {
Toast.makeText(this, "遇到一些问题,请手动打开系统设置>辅助服务>微信红包(ฅ´ω`ฅ)", Toast.LENGTH_LONG).show();
e.printStackTrace();
}

}

public void openGithub(View view) {
Expand All @@ -114,12 +121,6 @@ public void openSettings(View view) {
startActivity(settingsIntent);
}

public void openNews(View view) {
Intent webViewIntent = new Intent(this, WebViewActivity.class);
webViewIntent.putExtra("title", "红包攻略");
webViewIntent.putExtra("url", "http://sec-cdn.static.xiaomi.net/secStatic/proj/luckyNewsInfo/0127/index.html?v=1&");
startActivity(webViewIntent);
}

@Override
public void onAccessibilityStateChanged(boolean enabled) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
package xyz.monkeytong.hongbao.services;

import android.accessibilityservice.AccessibilityService;
import android.app.Instrumentation;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import xyz.monkeytong.hongbao.activities.MainActivity;
import xyz.monkeytong.hongbao.utils.HongbaoSignature;
import xyz.monkeytong.hongbao.utils.PowerUtil;

import java.util.List;

import xyz.monkeytong.hongbao.utils.HongbaoSignature;
import xyz.monkeytong.hongbao.utils.PowerUtil;


public class HongbaoService extends AccessibilityService implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String WECHAT_DETAILS_EN = "Details";
Expand All @@ -40,7 +39,7 @@ public class HongbaoService extends AccessibilityService implements SharedPrefer
private AccessibilityNodeInfo rootNodeInfo, mReceiveNode, mUnpackNode;
private boolean mLuckyMoneyPicked, mLuckyMoneyReceived;
private int mUnpackCount = 0;
private boolean mMutex = false;
private boolean mMutex = false, mListMutex = false;
private HongbaoSignature signature = new HongbaoSignature();

private PowerUtil powerUtil;
Expand All @@ -61,6 +60,7 @@ public void onAccessibilityEvent(AccessibilityEvent event) {
if (!mMutex) {
if (sharedPreferences.getBoolean("pref_watch_notification", false) && watchNotifications(event)) return;
if (sharedPreferences.getBoolean("pref_watch_list", false) && watchList(event)) return;
mListMutex = false;
}

if (sharedPreferences.getBoolean("pref_watch_chat", false)) watchChat(event);
Expand Down Expand Up @@ -122,13 +122,17 @@ private void setCurrentActivityName(AccessibilityEvent event) {
}

private boolean watchList(AccessibilityEvent event) {
if (mListMutex) return false;
mListMutex = true;
AccessibilityNodeInfo eventSource = event.getSource();
// Not a message
if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || eventSource == null)
return false;

List<AccessibilityNodeInfo> nodes = eventSource.findAccessibilityNodeInfosByText(WECHAT_NOTIFICATION_TIP);
if (!nodes.isEmpty()) {
//增加条件判断currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY)
//避免当订阅号中出现标题为“[微信红包]拜年红包”(其实并非红包)的信息时误判
if (!nodes.isEmpty() && currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY)) {
AccessibilityNodeInfo nodeToClick = nodes.get(0);
CharSequence contentDescription = nodeToClick.getContentDescription();
if (contentDescription != null && !signature.getContentDescription().equals(contentDescription)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public boolean generateSignature(AccessibilityNodeInfo node, String excludeWords

/* The text in the hongbao. Should mean something. */
String hongbaoContent = hongbaoNode.getChild(0).getText().toString();
if (hongbaoContent == null) return false;
if (hongbaoContent == null || "查看红包".equals(hongbaoContent)) return false;

/* Check the user's exclude words list. */
String[] excludeWordsArray = excludeWords.split(" +");
Expand Down Expand Up @@ -77,10 +77,10 @@ private String[] getSenderContentDescriptionFromNode(AccessibilityNodeInfo node)
String[] result = {"unknownSender", "unknownTime"};
for (int i = 0; i < count; i++) {
AccessibilityNodeInfo thisNode = node.getChild(i);
if ("android.widget.ImageView".equals(thisNode.getClassName())) {
if ("android.widget.ImageView".equals(thisNode.getClassName()) && "unknownSender".equals(result[0])) {
CharSequence contentDescription = thisNode.getContentDescription();
if (contentDescription != null) result[0] = contentDescription.toString().replaceAll("头像$", "");
} else if ("android.widget.TextView".equals(thisNode.getClassName())) {
} else if ("android.widget.TextView".equals(thisNode.getClassName()) && "unknownTime".equals(result[1])) {
CharSequence thisNodeText = thisNode.getText();
if (thisNodeText != null) result[1] = thisNodeText.toString();
}
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
android:id="@+id/textView" android:background="@mipmap/bg_action_bar" android:text="微信红包" android:textColor="#fee1b4"
android:gravity="center_vertical|center_horizontal"
android:textSize="26dp" android:autoText="false"/>
<ImageView
android:layout_width="44dp"
android:layout_height="44dp"
android:id="@+id/imageView3"
android:src="@mipmap/ic_books"
android:padding="10dp"
android:onClick="openNews"
android:layout_below="@+id/main_action_bar_placeholder"
android:layout_alignLeft="@+id/textView" android:layout_marginLeft="6dp" android:layout_marginTop="6dp"/>

<ImageView
android:layout_width="44dp"
Expand Down
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_books.png
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>
<string name="app_name">微信红包</string>
<string name="app_version">稳定版 v2.2</string>
<string name="app_version">稳定版 v2.3</string>
<string name="app_description">∠( ᐛ 」∠)_使用指南∠( ᐛ 」∠)_\n\n ○ 狠戳插件开关\n ○ 回到微信聊天\n ○ 坐等红包进账\n\n 遇到问题, 欢迎通过Github issue反馈~\n https://github.com/geeeeeeeeek/WeChatLuckyMoney</string>
<string name="service_status">当前辅助服务状态:</string>
<string name="service_name">设置抢红包辅助服务</string>
Expand Down

0 comments on commit 9867eea

Please sign in to comment.