From 54aafb683b9a2cc4b1292d9b6d8a450f401feff9 Mon Sep 17 00:00:00 2001 From: zhanghaidong Date: Mon, 31 Aug 2020 15:57:32 +0800 Subject: [PATCH] app: fix app view size bug. Do white list for some views. --- core/java/android/view/View.java | 40 +++++++++++++++++++++++ core/java/android/widget/FrameLayout.java | 5 --- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 97220836..64b54d7f 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -19818,6 +19818,46 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see #onMeasure(int, int) */ public final void measure(int widthMeasureSpec, int heightMeasureSpec) { + /* *********************** -App View WhiteList- *********************** */ + // Log.d(VIEW_LOG_TAG, "view=" + this.getClass().getName() + " (" + + // MeasureSpec.toString(widthMeasureSpec) + "," + MeasureSpec.toString(heightMeasureSpec) + ")"); + + final int widthSize = MeasureSpec.getSize(widthMeasureSpec); + final int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + if (this.getClass().getName().startsWith("com.zhihu.android.base.widget.ZHFrameLayout")) { + if (heightSize > 960) { + heightMeasureSpec = MeasureSpec.makeMeasureSpec(960, MeasureSpec.EXACTLY); + } + } + + if (this.getClass().getName().startsWith("com.ss.android.ugc.aweme.homepage.ui.view.MainScrollableViewPager")) { + if (heightSize > 960) { + heightMeasureSpec = MeasureSpec.makeMeasureSpec(960, MeasureSpec.EXACTLY); + } + } + + if (this.getClass().getName().startsWith("com.ss.android.ugc.playerkit.videoview.KeepSurfaceTextureView")) { + if (widthSize > 540) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(540, MeasureSpec.EXACTLY); + heightMeasureSpec = MeasureSpec.makeMeasureSpec(540 * heightSize / widthSize, MeasureSpec.EXACTLY); + } + } + + if (this.getClass().getName().startsWith("com.ss.android.videoshop.mediaview.SimpleMediaView")) { + if (widthSize > 540) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec(540, MeasureSpec.EXACTLY); + heightMeasureSpec = MeasureSpec.makeMeasureSpec(303, MeasureSpec.EXACTLY); + } + } + + if (this.getClass().getName().startsWith("com.ixigua.commonui.view.RoundRelativeLayout")) { + if (widthSize == 508) { + heightMeasureSpec = MeasureSpec.makeMeasureSpec(303, MeasureSpec.EXACTLY); + } + } + /* ******************************************************************** */ + boolean optical = isLayoutModeOptical(this); if (optical != isLayoutModeOptical(mParent)) { Insets insets = getOpticalInsets(); diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index da737f01..b8c74d88 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -170,11 +170,6 @@ public class FrameLayout extends ViewGroup { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int count = getChildCount(); - if ((this.getClass().getName().startsWith("com.zhihu.android.base.widget.ZHFrameLayout")) && - (this.mParent.getClass().getName().startsWith("androidx.appcompat.widget.ContentFrameLayout"))) { - heightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec) - 42, MeasureSpec.EXACTLY); - } - final boolean measureMatchParentChildren = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY || MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY; -- Gitee