diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2021-11-08 11:29:10 +0800 |
---|---|---|
committer | Pasty Chang <pastychang@google.com> | 2021-11-09 01:20:10 +0000 |
commit | 860cce2416fb7f1cd44256790c8ccc56ea9b4945 (patch) | |
tree | 6bf30857ce7d5742e563bfcf7bb655d974bf905c | |
parent | 341b27d037e36a2408025d97dc2a382955386933 (diff) | |
download | setupdesign-860cce2416fb7f1cd44256790c8ccc56ea9b4945.tar.gz |
Import updated Android Setupdesign Library 408233292
Copied from google3/third_party/java_src/android_libs/setupdesign
Bug: 205134345
Test: mm
Included changes:
- 408233292 Automated g4 rollback of changelist 407821022.
- 407821022 [SetupDesign] Follow SUW OEM guideline update the default...
- 407758043 [SetupDesign] Fix the GlifLoadingLayout content area trun...
- 407292165 Fix the content show in card layout be truncated in two p...
- 406832607 Automated g4 rollback of changelist 405880437.
PiperOrigin-RevId: 408233292
Change-Id: Id71919a5a133b040e7e30f2b511a94ed763de13f
3 files changed, 51 insertions, 28 deletions
diff --git a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java index 8b26e70..7874b75 100644 --- a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java +++ b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java @@ -61,6 +61,7 @@ import com.google.android.setupcompat.template.FooterBarMixin; import com.google.android.setupcompat.util.BuildCompatUtils; import com.google.android.setupdesign.lottieloadinglayout.R; import com.google.android.setupdesign.view.IllustrationVideoView; +import com.google.android.setupdesign.util.LayoutStyler; import java.io.InputStream; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -148,6 +149,9 @@ public class GlifLoadingLayout extends GlifLayout { View view = findManagedViewById(R.id.sud_layout_loading_content); if (view != null) { + if (shouldApplyPartnerResource()) { + LayoutStyler.applyPartnerCustomizationExtraPaddingStyle(view); + } tryApplyPartnerCustomizationContentPaddingTopStyle(view); } diff --git a/main/res/values-sw600dp-v31/diments.xml b/main/res/values-sw600dp-v31/diments.xml deleted file mode 100644 index 899fa39..0000000 --- a/main/res/values-sw600dp-v31/diments.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Copyright (C) 2021 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<resources> - - <!-- GLIF card layout for tablets. Set 0dp to enable fullscreen layout --> - <dimen name="sud_glif_card_width">0dp</dimen> - <dimen name="sud_glif_card_height">0dp</dimen> - -</resources> diff --git a/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java b/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java index 3eaf580..4094f3a 100644 --- a/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java +++ b/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java @@ -16,15 +16,21 @@ package com.google.android.setupdesign.view; +import static java.lang.Math.min; + import android.annotation.TargetApi; import android.content.Context; import android.content.res.TypedArray; +import android.graphics.Rect; import android.os.Build; import android.os.Build.VERSION_CODES; import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.view.Display; import android.view.ViewGroup; import android.view.WindowInsets; import android.widget.FrameLayout; +import androidx.annotation.VisibleForTesting; import com.google.android.setupcompat.partnerconfig.PartnerConfig; import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper; import com.google.android.setupcompat.util.BuildCompatUtils; @@ -44,6 +50,9 @@ public class IntrinsicSizeFrameLayout extends FrameLayout { private int intrinsicWidth = 0; private Object lastInsets; // Use generic Object type for compatibility + // Define here to avoid allocating resource during layout/draw operation. + private final Rect windowVisibleDisplayRect = new Rect(); + public IntrinsicSizeFrameLayout(Context context) { super(context); init(context, null, 0); @@ -108,9 +117,43 @@ public class IntrinsicSizeFrameLayout extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure( - getIntrinsicMeasureSpec(widthMeasureSpec, intrinsicWidth), - getIntrinsicMeasureSpec(heightMeasureSpec, intrinsicHeight)); + int measureWidth; + + // The the content may be truncated if the layout show in multi-window mode or two pane mode, + // because the given width is fixed size which based on the display to compute. So the width + // the content may be truncated. Make the layout width align window while window width smaller + // than display size. + if (isWindowSizeSmallerThanDisplaySize()) { + getWindowVisibleDisplayFrame(windowVisibleDisplayRect); + + measureWidth = + MeasureSpec.makeMeasureSpec(windowVisibleDisplayRect.width(), MeasureSpec.EXACTLY); + } else { + measureWidth = getIntrinsicMeasureSpec(widthMeasureSpec, intrinsicWidth); + } + + super.onMeasure(measureWidth, getIntrinsicMeasureSpec(heightMeasureSpec, intrinsicHeight)); + } + + @VisibleForTesting + boolean isWindowSizeSmallerThanDisplaySize() { + boolean result = false; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + getWindowVisibleDisplayFrame(windowVisibleDisplayRect); + + Display display = getDisplay(); + if (display != null) { + DisplayMetrics displayMetrics = new DisplayMetrics(); + display.getRealMetrics(displayMetrics); + + if (windowVisibleDisplayRect.width() > 0 + && windowVisibleDisplayRect.width() < displayMetrics.widthPixels) { + result = true; + } + } + } + + return result; } private int getIntrinsicMeasureSpec(int measureSpec, int intrinsicSize) { @@ -126,7 +169,7 @@ public class IntrinsicSizeFrameLayout extends FrameLayout { } else if (mode == MeasureSpec.AT_MOST) { // If intrinsic size is within parents constraint, take the intrinsic size. // Otherwise take the parents size because that's closest to the intrinsic size. - return MeasureSpec.makeMeasureSpec(Math.min(size, intrinsicHeight), MeasureSpec.EXACTLY); + return MeasureSpec.makeMeasureSpec(min(size, intrinsicHeight), MeasureSpec.EXACTLY); } // Parent specified EXACTLY, or in all other cases, just return the original spec return measureSpec; |