Merge "Fixed width to resolve preview rendering issue on different screens" into udc-dev
diff --git a/res/layout/clock_carousel.xml b/res/layout/clock_carousel.xml
index 290bfa4..e253f1a 100644
--- a/res/layout/clock_carousel.xml
+++ b/res/layout/clock_carousel.xml
@@ -24,8 +24,8 @@
<FrameLayout
android:id="@+id/item_view_0"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/clock_carousel_item_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_view_1"
@@ -38,27 +38,28 @@
android:layout_gravity="center"
android:background="@drawable/carousel_item_card_background"/>
- <com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
+ <com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
android:id="@+id/clock_scale_view_0"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
<FrameLayout
android:id="@+id/clock_host_view_0"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clipChildren="false" />
- </com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
+ </com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/item_view_1"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/clock_carousel_item_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_view_2"
- app:layout_constraintTop_toTopOf="parent" >
+ app:layout_constraintTop_toTopOf="parent">
<View
android:id="@+id/item_card_1"
@@ -67,23 +68,24 @@
android:layout_gravity="center"
android:background="@drawable/carousel_item_card_background"/>
- <com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
+ <com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
android:id="@+id/clock_scale_view_1"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
<FrameLayout
android:id="@+id/clock_host_view_1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clipChildren="false"/>
- </com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
+ </com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/item_view_2"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
@@ -98,23 +100,24 @@
android:layout_gravity="center"
android:background="@drawable/carousel_item_card_background"/>
- <com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
+ <com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
android:id="@+id/clock_scale_view_2"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
<FrameLayout
android:id="@+id/clock_host_view_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clipChildren="false"/>
- </com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
+ </com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/item_view_3"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
android:layout_marginStart="@dimen/clock_carousel_item_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_view_2"
@@ -127,23 +130,24 @@
android:layout_gravity="center"
android:background="@drawable/carousel_item_card_background"/>
- <com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
+ <com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
android:id="@+id/clock_scale_view_3"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
<FrameLayout
android:id="@+id/clock_host_view_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clipChildren="false"/>
- </com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
+ </com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/item_view_4"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
android:layout_marginStart="@dimen/clock_carousel_item_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_view_3"
@@ -156,17 +160,18 @@
android:layout_gravity="center"
android:background="@drawable/carousel_item_card_background"/>
- <com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
+ <com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
android:id="@+id/clock_scale_view_4"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
<FrameLayout
android:id="@+id/clock_host_view_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clipChildren="false" />
- </com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
+ </com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout>
</FrameLayout>
<androidx.constraintlayout.helper.widget.Carousel
diff --git a/res/layout/single_clock_view.xml b/res/layout/single_clock_view.xml
index 3ba673b..ca408d7 100644
--- a/res/layout/single_clock_view.xml
+++ b/res/layout/single_clock_view.xml
@@ -13,13 +13,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<com.android.wallpaper.picker.DisplayAspectRatioFrameLayout
+<com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="@dimen/screen_preview_height">
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
<FrameLayout
android:id="@+id/single_clock_host_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
-</com.android.wallpaper.picker.DisplayAspectRatioFrameLayout>
\ No newline at end of file
+</com.android.wallpaper.picker.FixedWidthDisplayRatioFrameLayout>
\ No newline at end of file
diff --git a/res/values-h960dp-port/dimens.xml b/res/values-w400dp/dimens.xml
similarity index 73%
rename from res/values-h960dp-port/dimens.xml
rename to res/values-w400dp/dimens.xml
index 9ab1757..e546787 100644
--- a/res/values-h960dp-port/dimens.xml
+++ b/res/values-w400dp/dimens.xml
@@ -15,8 +15,8 @@
~ limitations under the License
-->
<resources>
- <dimen name="clock_carousel_item_width">300dp</dimen>
- <dimen name="clock_carousel_guideline_margin">190dp</dimen>
- <dimen name="clock_carousel_item_card_width">120dp</dimen>
- <dimen name="clock_carousel_item_card_height">129dp</dimen>
-</resources>
\ No newline at end of file
+ <!-- Clock carousel dimens -->
+ <dimen name="clock_carousel_item_card_width">114dp</dimen>
+ <dimen name="clock_carousel_item_card_height">124dp</dimen>
+ <dimen name="clock_carousel_guideline_margin">130dp</dimen>
+</resources>
diff --git a/res/values-h960dp-port/dimens.xml b/res/values-w500dp/dimens.xml
similarity index 73%
copy from res/values-h960dp-port/dimens.xml
copy to res/values-w500dp/dimens.xml
index 9ab1757..6d9476a 100644
--- a/res/values-h960dp-port/dimens.xml
+++ b/res/values-w500dp/dimens.xml
@@ -15,8 +15,8 @@
~ limitations under the License
-->
<resources>
- <dimen name="clock_carousel_item_width">300dp</dimen>
- <dimen name="clock_carousel_guideline_margin">190dp</dimen>
- <dimen name="clock_carousel_item_card_width">120dp</dimen>
- <dimen name="clock_carousel_item_card_height">129dp</dimen>
-</resources>
\ No newline at end of file
+ <!-- Clock carousel dimens -->
+ <dimen name="clock_carousel_item_card_width">114dp</dimen>
+ <dimen name="clock_carousel_item_card_height">124dp</dimen>
+ <dimen name="clock_carousel_guideline_margin">180dp</dimen>
+</resources>
diff --git a/res/values-w600dp/dimens.xml b/res/values-w600dp/dimens.xml
index 0f6c43f..f9ed41b 100644
--- a/res/values-w600dp/dimens.xml
+++ b/res/values-w600dp/dimens.xml
@@ -16,7 +16,9 @@
-->
<resources>
<dimen name="clock_carousel_item_width">607dp</dimen>
- <dimen name="clock_carousel_guideline_margin">290dp</dimen>
- <dimen name="clock_carousel_item_card_width">175dp</dimen>
- <dimen name="clock_carousel_item_card_height">190dp</dimen>
+
+ <!-- Clock carousel dimens -->
+ <dimen name="clock_carousel_item_card_width">114dp</dimen>
+ <dimen name="clock_carousel_item_card_height">124dp</dimen>
+ <dimen name="clock_carousel_guideline_margin">220dp</dimen>
</resources>
diff --git a/res/values-h960dp-port/dimens.xml b/res/values-w700dp/dimens.xml
similarity index 73%
copy from res/values-h960dp-port/dimens.xml
copy to res/values-w700dp/dimens.xml
index 9ab1757..3e3fa01 100644
--- a/res/values-h960dp-port/dimens.xml
+++ b/res/values-w700dp/dimens.xml
@@ -15,8 +15,8 @@
~ limitations under the License
-->
<resources>
- <dimen name="clock_carousel_item_width">300dp</dimen>
- <dimen name="clock_carousel_guideline_margin">190dp</dimen>
- <dimen name="clock_carousel_item_card_width">120dp</dimen>
- <dimen name="clock_carousel_item_card_height">129dp</dimen>
+ <!-- Clock carousel dimens -->
+ <dimen name="clock_carousel_item_card_width">114dp</dimen>
+ <dimen name="clock_carousel_item_card_height">124dp</dimen>
+ <dimen name="clock_carousel_guideline_margin">240dp</dimen>
</resources>
\ No newline at end of file
diff --git a/res/values-w800dp/dimens.xml b/res/values-w800dp/dimens.xml
index 6ba900e..d5032b6 100644
--- a/res/values-w800dp/dimens.xml
+++ b/res/values-w800dp/dimens.xml
@@ -18,4 +18,9 @@
<!-- Dimensions for the customization option tiles -->
<dimen name="option_tile_width">87dp</dimen>
<dimen name="option_tile_linear_padding_horizontal">8dp</dimen>
+
+ <!-- Clock carousel dimens -->
+ <dimen name="clock_carousel_item_card_width">114dp</dimen>
+ <dimen name="clock_carousel_item_card_height">124dp</dimen>
+ <dimen name="clock_carousel_guideline_margin">320dp</dimen>
</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index bbebbcb..9f5d736 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -158,7 +158,7 @@
<dimen name="clock_carousel_item_width">190dp</dimen>
<dimen name="clock_carousel_item_margin">16dp</dimen>
- <dimen name="clock_carousel_guideline_margin">140dp</dimen>
+ <dimen name="clock_carousel_guideline_margin">100dp</dimen>
<dimen name="clock_carousel_item_card_width">100dp</dimen>
<dimen name="clock_carousel_item_card_height">108dp</dimen>
diff --git a/res/xml/carousel_scene.xml b/res/xml/carousel_scene.xml
index d728dd8..140d0f2 100644
--- a/res/xml/carousel_scene.xml
+++ b/res/xml/carousel_scene.xml
@@ -40,17 +40,17 @@
<ConstraintSet android:id="@+id/previous">
<Constraint
android:id="@+id/item_view_0"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintEnd_toStartOf="@id/guideline_start"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
<Constraint
android:id="@+id/item_view_1"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
- motion:layout_constraintWidth_max="@dimen/clock_carousel_item_width"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ motion:layout_constraintWidth_max="@dimen/screen_preview_width"
motion:layout_constraintHorizontal_bias="0.5"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
@@ -59,16 +59,16 @@
<Constraint
android:id="@+id/item_view_2"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintStart_toStartOf="@id/guideline_end"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
<Constraint
android:id="@+id/item_view_3"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintStart_toEndOf="@+id/item_view_2"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
@@ -77,25 +77,25 @@
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/item_view_0"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintEnd_toStartOf="@+id/item_view_1"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
<Constraint
android:id="@+id/item_view_1"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintEnd_toStartOf="@id/guideline_start"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
<Constraint
android:id="@+id/item_view_2"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
- motion:layout_constraintWidth_max="@dimen/clock_carousel_item_width"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ motion:layout_constraintWidth_max="@dimen/screen_preview_width"
motion:layout_constraintHorizontal_bias="0.5"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
@@ -104,16 +104,16 @@
<Constraint
android:id="@+id/item_view_3"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintStart_toStartOf="@id/guideline_end"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
<Constraint
android:id="@+id/item_view_4"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintStart_toEndOf="@+id/item_view_3"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
@@ -122,25 +122,25 @@
<ConstraintSet android:id="@+id/next">
<Constraint
android:id="@+id/item_view_1"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintEnd_toStartOf="@+id/item_view_2"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
<Constraint
android:id="@+id/item_view_2"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintEnd_toStartOf="@id/guideline_start"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
<Constraint
android:id="@+id/item_view_3"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
- motion:layout_constraintWidth_max="@dimen/clock_carousel_item_width"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
+ motion:layout_constraintWidth_max="@dimen/screen_preview_width"
motion:layout_constraintHorizontal_bias="0.5"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
@@ -149,8 +149,8 @@
<Constraint
android:id="@+id/item_view_4"
- android:layout_width="@dimen/clock_carousel_item_width"
- android:layout_height="@dimen/screen_preview_height"
+ android:layout_width="@dimen/screen_preview_width"
+ android:layout_height="wrap_content"
motion:layout_constraintStart_toStartOf="@id/guideline_end"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintBottom_toBottomOf="parent" />
diff --git a/src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt b/src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt
index 3c7bab1..782d69e 100644
--- a/src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt
+++ b/src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt
@@ -38,8 +38,8 @@
fun getRatio(): Float {
val screenSizeCalculator = ScreenSizeCalculator.getInstance()
val screenSize = screenSizeCalculator.getScreenSize(activity.windowManager.defaultDisplay)
- return activity.resources.getDimensionPixelSize(R.dimen.screen_preview_height).toFloat() /
- screenSize.y.toFloat()
+ return activity.resources.getDimensionPixelSize(R.dimen.screen_preview_width).toFloat() /
+ screenSize.x.toFloat()
}
fun getController(clockId: String): ClockController {