From f9b87e3907a1ea828fa98e69da590e61beedb6a7 Mon Sep 17 00:00:00 2001 From: Andrew Cole Date: Thu, 11 May 2023 14:45:40 -0700 Subject: [PATCH 1/2] Updating isTextClippedVerticallyTest Updating the isTextClippedVertically test to accomodate a different aspect ratio for raven devices Bug: 279464742 Test: isTextClippedVerticallyTest Change-Id: I4a4b740513914f1e76db18a00b65e4f881535d4a --- src/com/android/launcher3/ButtonDropTarget.java | 6 ++++++ .../src/com/android/launcher3/DeleteDropTargetTest.kt | 11 +++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index 1a8600980f..108e557797 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -115,6 +115,12 @@ public abstract class ButtonDropTarget extends TextView setContentDescription(mText); } + protected void updateText(CharSequence text) { + setText(text); + mText = getText(); + setContentDescription(mText); + } + protected void setDrawable(int resId) { // We do not set the drawable in the xml as that inflates two drawables corresponding to // drawableLeft and drawableStart. diff --git a/tests/src/com/android/launcher3/DeleteDropTargetTest.kt b/tests/src/com/android/launcher3/DeleteDropTargetTest.kt index 84c617c30d..bcfb90b4ec 100644 --- a/tests/src/com/android/launcher3/DeleteDropTargetTest.kt +++ b/tests/src/com/android/launcher3/DeleteDropTargetTest.kt @@ -8,7 +8,6 @@ import com.android.launcher3.Utilities.* import com.android.launcher3.util.ActivityContextWrapper import com.google.common.truth.Truth.assertThat import org.junit.Before -import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith @@ -26,19 +25,15 @@ class DeleteDropTargetTest { enableRunningInTestHarnessForTests() } - // Needs mText, mTempRect, getPaddingTop, getPaddingBottom - // availableHeight as a parameter - @Ignore("TODO(b/279464742)") @Test fun isTextClippedVerticallyTest() { - buttonDropTarget.mText = "My Test" + buttonDropTarget.updateText("My Test") + buttonDropTarget.setPadding(0, 0, 0, 0) + buttonDropTarget.setTextMultiLine(false) // No space for text assertThat(buttonDropTarget.isTextClippedVertically(30)).isTrue() - // Some space for text, and just enough that the text should not be clipped - assertThat(buttonDropTarget.isTextClippedVertically(50)).isFalse() - // A lot of space for text so the text should not be clipped assertThat(buttonDropTarget.isTextClippedVertically(100)).isFalse() } From 7a78147ba3852613485f190e2a97230535869248 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Fri, 12 May 2023 10:40:59 -0700 Subject: [PATCH 2/2] Use same calculation for portrait as fake landscape for layout of split thumbnails * Partially revert ag/20330754, not entirely sure why we switched from using dp.isLanscape to splitInfo.appsStackedVertically, since the two represent different states (specifically for fake landscape) Fixes: 280783620 Flag: None Test: Tested on foldable, small + large screen. Fake and real landscape on small screen. Rotated while in overview. Slight sliver of wallpaper shows on large screen, but that issue has been there. Change-Id: I13d834a31417751dd3b757344ec7b4d9a174090e --- .../touch/PortraitPagedViewHandler.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 050e88f5bc..6a972eb0dd 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -589,17 +589,17 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { float scaledDividerHeight = dividerHeight * scale; if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) { - if (splitInfo.appsStackedVertically) { - outRect.bottom = Math.round(outRect.top + scaledTopTaskHeight); - } else { + if (dp.isLandscape) { outRect.right = outRect.left + Math.round(outRect.width() * topLeftTaskPercent); + } else { + outRect.bottom = Math.round(outRect.top + scaledTopTaskHeight); } } else { - if (splitInfo.appsStackedVertically) { - outRect.top += Math.round(scaledTopTaskHeight + scaledDividerHeight); - } else { + if (dp.isLandscape) { outRect.left += Math.round(outRect.width() * (topLeftTaskPercent + dividerBarPercent)); + } else { + outRect.top += Math.round(scaledTopTaskHeight + scaledDividerHeight); } } } @@ -610,9 +610,9 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { DeviceProfile dp, boolean isRtl) { int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx; int totalThumbnailHeight = parentHeight - spaceAboveSnapshot; - int dividerBar = Math.round(splitBoundsConfig.appsStackedVertically - ? splitBoundsConfig.dividerHeightPercent * dp.availableHeightPx - : splitBoundsConfig.dividerWidthPercent * parentWidth); + float dividerScale = splitBoundsConfig.appsStackedVertically + ? splitBoundsConfig.dividerHeightPercent + : splitBoundsConfig.dividerWidthPercent; int primarySnapshotHeight; int primarySnapshotWidth; int secondarySnapshotHeight; @@ -620,12 +620,13 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { float taskPercent = splitBoundsConfig.appsStackedVertically ? splitBoundsConfig.topTaskPercent : splitBoundsConfig.leftTaskPercent; if (dp.isLandscape) { + int scaledDividerBar = Math.round(parentWidth * dividerScale); primarySnapshotHeight = totalThumbnailHeight; primarySnapshotWidth = Math.round(parentWidth * taskPercent); secondarySnapshotHeight = totalThumbnailHeight; - secondarySnapshotWidth = parentWidth - primarySnapshotWidth - dividerBar; - int translationX = primarySnapshotWidth + dividerBar; + secondarySnapshotWidth = parentWidth - primarySnapshotWidth - scaledDividerBar; + int translationX = primarySnapshotWidth + scaledDividerBar; if (isRtl) { primarySnapshot.setTranslationX(-translationX); secondarySnapshot.setTranslationX(0); @@ -640,7 +641,7 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } else { float scale = (float) totalThumbnailHeight / dp.availableHeightPx; float topTaskHeight = dp.availableHeightPx * taskPercent; - float finalDividerHeight = dividerBar * scale; + float finalDividerHeight = Math.round(totalThumbnailHeight * dividerScale); float scaledTopTaskHeight = topTaskHeight * scale; primarySnapshotWidth = parentWidth; primarySnapshotHeight = Math.round(scaledTopTaskHeight);