From d626fe651effb096e0198b2e9cf26ed16178ea5f Mon Sep 17 00:00:00 2001 From: twwang Date: Sat, 29 Aug 2020 17:07:44 +0800 Subject: [PATCH] DecorCaption show error for tonghuashun app app compatibility: DecorCaption show error due to this app adds status_background --- core/java/android/view/View.java | 26 ++++++++++++++++++++++ core/java/android/widget/LinearLayout.java | 10 +++++++++ core/java/android/widget/TextView.java | 4 ++++ 3 files changed, 40 insertions(+) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 97220836..33e20326 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -4826,6 +4826,32 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mAttributes = trimmed; } + /** + * return view id name by resource id + *@hide + */ + public String entryName(int id) { + String name = ""; + final Resources r = mResources; + if (id > 0 && Resources.resourceHasPackage(id) && r != null) { + name = r.getResourceEntryName(id); + } + return name; + } + + /** + *return view package name by resource id + * @hide + */ + public String pkgName(int id) { + String name = ""; + final Resources r = mResources; + if (id > 0 && Resources.resourceHasPackage(id) && r != null) { + name = r.getResourcePackageName(id); + } + return name; + } + public String toString() { StringBuilder out = new StringBuilder(128); out.append(getClass().getName()); diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index f897372c..94df776e 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -714,6 +714,11 @@ public class LinearLayout extends ViewGroup { // See how tall everyone is. Also remember max width. for (int i = 0; i < count; ++i) { final View child = getVirtualChildAt(i); + // don't show tonghuashun status background + if (entryName(this.getId()).equals("status_background") && + pkgName(this.getId()).equals("com.hexin.plat.android")) { + this.setVisibility(View.GONE); + } if (child == null) { mTotalLength += measureNullChild(i); continue; @@ -1054,6 +1059,11 @@ public class LinearLayout extends ViewGroup { // See how wide everyone is. Also remember max height. for (int i = 0; i < count; ++i) { final View child = getVirtualChildAt(i); + // don't show tonghuashun status background + if (entryName(this.getId()).equals("status_background") && + pkgName(this.getId()).equals("com.hexin.plat.android")) { + this.setVisibility(View.GONE); + } if (child == null) { mTotalLength += measureNullChild(i); continue; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index f8daa882..847b8f2a 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -7213,6 +7213,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener scrollTo(0, 0); } + if (entryName(this.getId()).equals("hexin_status_bar") && + pkgName(this.getId()).equals("com.hexin.plat.android")) { + height = 15; + } setMeasuredDimension(width, height); } -- Gitee