Skip to content

Commit

Permalink
pref: 增加hook过滤,不包含金额的数据不转发给自动记账,降低自动记账启动频率
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkioTomas committed Apr 10, 2023
1 parent b6b5fef commit c6ed0af
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/src/main/java/cn/dreamn/qianji_auto/bills/BillTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,10 @@ public static boolean isMoney(String money) {
return money.matches("^-?([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0)$") || money.matches("^(-?[1-9]\\d*)|0$");
}

public static boolean hasMoney(String input) {

return input.matches("[0-9]+(,[0-9]{3})*(\\.[0-9]{2})?");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.hjq.toast.ToastUtils;

import cn.dreamn.qianji_auto.BuildConfig;
import cn.dreamn.qianji_auto.bills.BillTools;
import cn.dreamn.qianji_auto.permission.PermissionUtils;
import cn.dreamn.qianji_auto.setting.AppStatus;
import cn.dreamn.qianji_auto.utils.runUtils.Log;
Expand Down Expand Up @@ -56,7 +57,7 @@ public void onNotificationPosted(StatusBarNotification sbn) {

String s = "title=" + title + ",body=" + text;


if(!BillTools.hasMoney(s))return;
Bundle bundle = new Bundle();
bundle.putString("data", s);
bundle.putString("app_identify", "notice");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import androidx.annotation.NonNull;

import cn.dreamn.qianji_auto.bills.BillInfo;
import cn.dreamn.qianji_auto.bills.BillTools;
import cn.dreamn.qianji_auto.bills.SendDataToApp;
import cn.dreamn.qianji_auto.data.data.RegularCenter;
import cn.dreamn.qianji_auto.data.database.Db;
Expand Down Expand Up @@ -67,6 +68,7 @@ public void onReceive(Context context, Intent intent) {
msg2.append(msg.getDisplayMessageBody());
}
String data = msg2.toString().replace("\r", "").replace("\n", "n");
if(!BillTools.hasMoney(data))return;
String finalUser = user;
TaskThread.onThread(() -> Db.db.AppDataDao().add(data, "sms", finalUser));
Handler mHandler = new Handler(Looper.getMainLooper()) {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/cn/dreamn/qianji_auto/core/hook/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.lang.reflect.Method;

import cn.dreamn.qianji_auto.BuildConfig;
import cn.dreamn.qianji_auto.bills.BillTools;
import cn.dreamn.qianji_auto.utils.runUtils.MultiprocessSharedPreferences;
import de.robv.android.xposed.XposedBridge;

Expand Down Expand Up @@ -110,6 +111,8 @@ public void sendString(String str) {
}

public void sendString(String str, String identify, String packageName) {
//不包含金额信息的数据不转发
if(!BillTools.hasMoney(str))return;
Bundle bundle = new Bundle();
bundle.putString("data", str);
bundle.putString("app_identify", identify);
Expand Down

0 comments on commit c6ed0af

Please sign in to comment.