Skip to content

Commit 5fcaec2

Browse files
committed
Fix 改变语言过程中, 会找不到指定控件
1 parent 6fbdf3c commit 5fcaec2

File tree

3 files changed

+50
-34
lines changed

3 files changed

+50
-34
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.yyxx.wechatfp.util;
2+
3+
import android.content.Context;
4+
import android.content.pm.PackageInfo;
5+
6+
import com.yyxx.wechatfp.util.log.L;
7+
8+
/**
9+
* Created by Jason on 2017/11/1.
10+
*/
11+
12+
public class Tools {
13+
14+
public static void doUnSupportVersionUpload(Context context, String message) {
15+
try {
16+
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
17+
int versionCode = packageInfo.versionCode;
18+
String versionName = packageInfo.versionName;
19+
20+
StringBuffer stringBuffer = new StringBuffer();
21+
stringBuffer.append("UnSupport: versionName:").append(versionName)
22+
.append(" versionCode:").append(versionCode)
23+
.append(" viewInfos:").append(message);
24+
25+
L.e(stringBuffer);
26+
} catch (Exception e) {
27+
L.e(e);
28+
}
29+
}
30+
}

app/src/main/java/com/yyxx/wechatfp/util/ViewUtil.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,12 @@ public static void removeFromSuperView(View v) {
264264
parentLayout.removeView(v);
265265
}
266266
}
267+
268+
public static String viewsDesc(List<View> childView) {
269+
StringBuffer stringBuffer = new StringBuffer();
270+
for (View view: childView) {
271+
stringBuffer.append(ViewUtil.getViewInfo(view)).append("\n");
272+
}
273+
return stringBuffer.toString();
274+
}
267275
}

app/src/main/java/com/yyxx/wechatfp/xposed/plugin/XposedWeChatPlugin.java

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.yyxx.wechatfp.util.ImageUtil;
4141
import com.yyxx.wechatfp.util.StyleUtil;
4242
import com.yyxx.wechatfp.util.Task;
43+
import com.yyxx.wechatfp.util.Tools;
4344
import com.yyxx.wechatfp.util.Umeng;
4445
import com.yyxx.wechatfp.util.ViewUtil;
4546
import com.yyxx.wechatfp.util.log.L;
@@ -441,32 +442,34 @@ public static PayDialog findFrom(ViewGroup rootView) {
441442
}
442443

443444
if (payDialog.passwordLayout == null) {
444-
doUnSupportVersionUpload(rootView.getContext(), "[passwordLayout NOT FOUND] " + viewsDesc(childViews));
445+
Tools.doUnSupportVersionUpload(rootView.getContext(), "[WeChat passwordLayout NOT FOUND] " + ViewUtil.viewsDesc(childViews));
445446
return null;
446447
}
447448

448449
if (payDialog.inputEditText == null) {
449-
doUnSupportVersionUpload(rootView.getContext(), "[inputEditText NOT FOUND] " + viewsDesc(childViews));
450+
Tools.doUnSupportVersionUpload(rootView.getContext(), "[WeChat inputEditText NOT FOUND] " + ViewUtil.viewsDesc(childViews));
450451
return null;
451452
}
452453

453454
if (payDialog.keyboardView == null) {
454-
doUnSupportVersionUpload(rootView.getContext(), "[keyboardView NOT FOUND] " + viewsDesc(childViews));
455+
Tools.doUnSupportVersionUpload(rootView.getContext(), "[WeChat keyboardView NOT FOUND] " + ViewUtil.viewsDesc(childViews));
455456
return null;
456457
}
457458

458459
payDialog.usePasswordText = (TextView)ViewUtil.findViewByText(rootView,
459-
Lang.getString(Lang.WECHAT_PAYVIEW_FINGERPRINT_SWITCH_TEXT),
460-
Lang.getString(Lang.WECHAT_PAYVIEW_PASSWORD_SWITCH_TEXT));
460+
"使用密码", "使用密碼", "Password",
461+
"使用指纹", "使用指紋", "Fingerprint");
462+
L.d("payDialog.usePasswordText", payDialog.usePasswordText); // 6.5.16 app:id/dh0
461463
if (payDialog.usePasswordText == null) {
462-
doUnSupportVersionUpload(rootView.getContext(), "[usePasswordText NOT FOUND] " + viewsDesc(childViews));
464+
Tools.doUnSupportVersionUpload(rootView.getContext(), "[WeChat usePasswordText NOT FOUND] " + ViewUtil.viewsDesc(childViews));
463465
}
464466

465467
payDialog.titleTextView = (TextView)ViewUtil.findViewByText(rootView,
466-
Lang.getString(Lang.WECHAT_PAYVIEW_FINGERPRINT_TITLE),
467-
Lang.getString(Lang.WECHAT_PAYVIEW_PASSWORD_TITLE));
468+
"请验证指纹", "請驗證指紋", "Verify fingerprint",
469+
"请输入支付密码", "請輸入付款密碼", "Enter payment password");
470+
L.d("payDialog.titleTextView", payDialog.titleTextView); // 6.5.16 app:id/dgz
468471
if (payDialog.titleTextView == null) {
469-
doUnSupportVersionUpload(rootView.getContext(), "[titleTextView NOT FOUND] " + viewsDesc(childViews));
472+
Tools.doUnSupportVersionUpload(rootView.getContext(), "[WeChat titleTextView NOT FOUND] " + ViewUtil.viewsDesc(childViews));
470473
}
471474
return payDialog;
472475
} catch (Exception e) {
@@ -487,31 +490,6 @@ public String toString() {
487490
}
488491
}
489492

490-
private static String viewsDesc(List<View> childView) {
491-
StringBuffer stringBuffer = new StringBuffer();
492-
for (View view: childView) {
493-
stringBuffer.append(ViewUtil.getViewInfo(view)).append("\n");
494-
}
495-
return stringBuffer.toString();
496-
}
497-
498-
private static void doUnSupportVersionUpload(Context context, String message) {
499-
try {
500-
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(Constant.PACKAGE_NAME_WECHAT, 0);
501-
int versionCode = packageInfo.versionCode;
502-
String versionName = packageInfo.versionName;
503-
504-
StringBuffer stringBuffer = new StringBuffer();
505-
stringBuffer.append("WeChat un support: versionName:").append(versionName)
506-
.append(" versionCode:").append(versionCode)
507-
.append(" viewInfos:").append(message);
508-
509-
L.e(stringBuffer);
510-
} catch (Exception e) {
511-
L.e(e);
512-
}
513-
}
514-
515493
private static void notifyCurrentVersionUnSupport(final Context context) {
516494
Task.onMain(()->{
517495
try {

0 commit comments

Comments
 (0)