diff --git a/CHANGELOG.md b/CHANGELOG.md index ee27d9f1..87b9a8d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)** - 新增 延时拆开红包的可选项 diff --git a/app/build.gradle b/app/build.gradle index 44e233b9..850ef703 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/java/xyz/monkeytong/hongbao/activities/MainActivity.java b/app/src/main/java/xyz/monkeytong/hongbao/activities/MainActivity.java index 107f4a67..105f9a47 100644 --- a/app/src/main/java/xyz/monkeytong/hongbao/activities/MainActivity.java +++ b/app/src/main/java/xyz/monkeytong/hongbao/activities/MainActivity.java @@ -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; @@ -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) { @@ -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) { diff --git a/app/src/main/java/xyz/monkeytong/hongbao/services/HongbaoService.java b/app/src/main/java/xyz/monkeytong/hongbao/services/HongbaoService.java index 814759c6..f58b6bec 100644 --- a/app/src/main/java/xyz/monkeytong/hongbao/services/HongbaoService.java +++ b/app/src/main/java/xyz/monkeytong/hongbao/services/HongbaoService.java @@ -1,7 +1,6 @@ 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; @@ -9,19 +8,19 @@ 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"; @@ -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; @@ -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); @@ -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 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)) { diff --git a/app/src/main/java/xyz/monkeytong/hongbao/utils/HongbaoSignature.java b/app/src/main/java/xyz/monkeytong/hongbao/utils/HongbaoSignature.java index 4d7e1889..f8b03119 100644 --- a/app/src/main/java/xyz/monkeytong/hongbao/utils/HongbaoSignature.java +++ b/app/src/main/java/xyz/monkeytong/hongbao/utils/HongbaoSignature.java @@ -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(" +"); @@ -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(); } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ea3c9511..46646bb0 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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"/> - 微信红包 - 稳定版 v2.2 + 稳定版 v2.3 ∠( ᐛ 」∠)_使用指南∠( ᐛ 」∠)_\n\n ○ 狠戳插件开关\n ○ 回到微信聊天\n ○ 坐等红包进账\n\n 遇到问题, 欢迎通过Github issue反馈~\n https://github.com/geeeeeeeeek/WeChatLuckyMoney 当前辅助服务状态: 设置抢红包辅助服务