Fix crash on rotation and tweak landscape layout
Error and loading views were missing from the landscape
layout causing it to crash, also tweak the landscape layout
for improved UI.
Bug: 134529293
Change-Id: I53d08b6c165b4b3311c98475356f68e7a9a37df0
diff --git a/res/layout-land/fragment_clock_picker.xml b/res/layout-land/fragment_clock_picker.xml
index a292876..b5044b7 100644
--- a/res/layout-land/fragment_clock_picker.xml
+++ b/res/layout-land/fragment_clock_picker.xml
@@ -23,46 +23,75 @@
android:background="?android:colorPrimary">
<include layout="@layout/section_header"/>
- <LinearLayout
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal">
-
- <com.android.customization.widget.PreviewPager
- android:id="@+id/clock_preview_pager"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="@color/secondary_color"
- app:card_style="screen_aspect_ratio"/>
+ android:layout_height="match_parent">
<LinearLayout
- android:id="@+id/options_section"
- android:layout_width="0dp"
+ android:id="@+id/content_section"
+ android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_weight="1"
- android:paddingVertical="10dp"
- android:orientation="vertical">
+ android:orientation="horizontal">
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/options_container"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"/>
+ <com.android.customization.widget.PreviewPager
+ android:id="@+id/clock_preview_pager"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@color/secondary_color"
+ app:card_style="screen_aspect_ratio"/>
- <RelativeLayout
+ <LinearLayout
+ android:id="@+id/options_section"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:paddingVertical="10dp"
+ android:orientation="vertical">
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/options_container"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingHorizontal="10dp">
+ <Button
+ android:id="@+id/apply_button"
+ style="@style/ActionPrimaryButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:text="@string/apply_btn"/>
+ </RelativeLayout>
+
+ </LinearLayout>
+ </LinearLayout>
+ <androidx.core.widget.ContentLoadingProgressBar
+ android:id="@+id/loading_indicator"
+ style="@android:style/Widget.DeviceDefault.ProgressBar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="200dp"
+ android:layout_gravity="center_horizontal|top"
+ android:indeterminate="true"/>
+
+ <FrameLayout
+ android:id="@+id/error_section"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone">
+ <TextView
+ android:id="@+id/error_message"
+ style="@style/HeaderTextAppearance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingHorizontal="10dp">
- <Button
- android:id="@+id/apply_button"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:text="@string/apply_btn"/>
- </RelativeLayout>
-
- </LinearLayout>
- </LinearLayout>
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/something_went_wrong"/>
+ </FrameLayout>
+ </FrameLayout>
</LinearLayout>
diff --git a/res/layout-land/fragment_grid_picker.xml b/res/layout-land/fragment_grid_picker.xml
index 20ee447..6fc5933 100644
--- a/res/layout-land/fragment_grid_picker.xml
+++ b/res/layout-land/fragment_grid_picker.xml
@@ -21,7 +21,13 @@
android:orientation="vertical"
android:background="?android:colorPrimary">
<include layout="@layout/section_header"/>
- <LinearLayout
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:id="@+id/content_section"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
@@ -62,4 +68,28 @@
</LinearLayout>
</LinearLayout>
+ <androidx.core.widget.ContentLoadingProgressBar
+ android:id="@+id/loading_indicator"
+ style="@android:style/Widget.DeviceDefault.ProgressBar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="200dp"
+ android:layout_gravity="center_horizontal|top"
+ android:indeterminate="true"/>
+
+ <FrameLayout
+ android:id="@+id/error_section"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone">
+ <TextView
+ android:id="@+id/error_message"
+ style="@style/HeaderTextAppearance"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/something_went_wrong"/>
+ </FrameLayout>
+ </FrameLayout>
</LinearLayout>
diff --git a/res/layout-land/fragment_theme_picker.xml b/res/layout-land/fragment_theme_picker.xml
index 267ef0d..cd3cdbd 100644
--- a/res/layout-land/fragment_theme_picker.xml
+++ b/res/layout-land/fragment_theme_picker.xml
@@ -22,55 +22,88 @@
android:background="?android:colorPrimary">
<include layout="@layout/section_header"/>
- <LinearLayout
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal">
-
- <com.android.customization.widget.PreviewPager
- android:id="@+id/theme_preview_pager"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:background="@color/secondary_color"/>
-
+ android:layout_height="match_parent">
<LinearLayout
- android:id="@+id/options_section"
- android:layout_width="0dp"
+ android:id="@+id/content_section"
+ android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_weight="1"
- android:paddingVertical="10dp"
- android:orientation="vertical">
+ android:orientation="horizontal">
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/options_container"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"/>
+ <com.android.customization.widget.PreviewPager
+ android:id="@+id/theme_preview_pager"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@color/secondary_color"/>
+ <View
+ android:layout_width="1dp"
+ android:layout_height="match_parent"
+ android:background="@color/divider_color"/>
+ <LinearLayout
+ android:id="@+id/options_section"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:paddingVertical="10dp"
+ android:orientation="vertical">
- <RelativeLayout
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/options_container"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@null"
+ android:paddingHorizontal="10dp">
+ <CheckBox
+ android:id="@+id/use_my_wallpaper"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:layout_toStartOf="@+id/apply_button"
+ android:ellipsize="end"
+ android:paddingLeft="4dp"
+ android:minHeight="@dimen/min_taptarget_height"
+ android:text="@string/keep_my_wallpaper"/>
+ <Button
+ android:id="@+id/apply_button"
+ style="@style/ActionPrimaryButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:text="@string/apply_theme_btn"/>
+ </RelativeLayout>
+ </LinearLayout>
+ </LinearLayout>
+
+ <androidx.core.widget.ContentLoadingProgressBar
+ android:id="@+id/loading_indicator"
+ style="@android:style/Widget.DeviceDefault.ProgressBar"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="200dp"
+ android:layout_gravity="center_horizontal|top"
+ android:indeterminate="true"/>
+
+ <FrameLayout
+ android:id="@+id/error_section"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone">
+ <TextView
+ android:id="@+id/error_message"
+ style="@style/HeaderTextAppearance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingHorizontal="10dp">
- <CheckBox
- android:id="@+id/use_my_wallpaper"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_centerVertical="true"
- android:layout_toStartOf="@+id/apply_button"
- android:ellipsize="end"
- android:paddingLeft="4dp"
- android:minHeight="@dimen/min_taptarget_height"
- android:text="@string/keep_my_wallpaper"/>
- <Button
- android:id="@+id/apply_button"
- style="@style/ActionPrimaryButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:text="@string/apply_theme_btn"/>
- </RelativeLayout>
- </LinearLayout>
- </LinearLayout>
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/something_went_wrong"/>
+ </FrameLayout>
+ </FrameLayout>
</LinearLayout>
diff --git a/res/layout/clock_option.xml b/res/layout/clock_option.xml
index 30aa14f..e65cb65 100644
--- a/res/layout/clock_option.xml
+++ b/res/layout/clock_option.xml
@@ -19,6 +19,8 @@
android:layout_height="wrap_content"
android:paddingRight="2dp"
android:paddingBottom="@dimen/option_bottom_margin"
+ android:clipChildren="false"
+ android:clipToPadding="false"
android:orientation="vertical">
<TextView
diff --git a/res/layout/grid_option.xml b/res/layout/grid_option.xml
index 5edcdc9..286c60b 100644
--- a/res/layout/grid_option.xml
+++ b/res/layout/grid_option.xml
@@ -19,6 +19,8 @@
android:layout_height="wrap_content"
android:paddingRight="2dp"
android:paddingBottom="@dimen/option_bottom_margin"
+ android:clipChildren="false"
+ android:clipToPadding="false"
android:orientation="vertical">
<TextView
diff --git a/res/layout/theme_component_preview.xml b/res/layout/theme_component_preview.xml
index 32d3f20..0d01e05 100644
--- a/res/layout/theme_component_preview.xml
+++ b/res/layout/theme_component_preview.xml
@@ -26,7 +26,7 @@
android:maxHeight="@dimen/preview_theme_max_height"
android:minHeight="@dimen/preview_theme_min_height"
android:paddingHorizontal="@dimen/preview_card_padding"
- android:paddingTop="@dimen/preview_card_padding">
+ android:paddingTop="@dimen/preview_card_top_padding">
<ViewStub
android:id="@+id/theme_preview_top_bar"
@@ -76,7 +76,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/edit_label"
- app:layout_constraintGuide_end="@dimen/min_taptarget_height"
+ app:layout_constraintGuide_end="@dimen/preview_theme_content_bottom"
app:layout_constraintTop_toBottomOf="@+id/theme_preview_card_body_container"/>
<TextView
diff --git a/res/layout/theme_option.xml b/res/layout/theme_option.xml
index 1cb9ffa..e103b69 100644
--- a/res/layout/theme_option.xml
+++ b/res/layout/theme_option.xml
@@ -19,6 +19,8 @@
android:layout_height="wrap_content"
android:paddingRight="2dp"
android:paddingBottom="@dimen/option_bottom_margin"
+ android:clipChildren="false"
+ android:clipToPadding="false"
android:orientation="vertical">
<TextView
diff --git a/res/layout/theme_preview_topbar.xml b/res/layout/theme_preview_topbar.xml
index 5642668..15b665d 100644
--- a/res/layout/theme_preview_topbar.xml
+++ b/res/layout/theme_preview_topbar.xml
@@ -28,6 +28,7 @@
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:textColor="@color/icon_thumbnail_color"
+ android:textSize="@dimen/preview_theme_cover_topbar_clock_size"
tools:text="8:10"/>
<LinearLayout
android:id="@+id/theme_preview_top_bar_icons"
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 4b16b5e..ddf84e8 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -17,22 +17,30 @@
-->
<resources>
<dimen name="card_title_text_size">12sp</dimen>
- <dimen name="card_cover_title_text_size">16sp</dimen>
- <dimen name="card_header_top_margin">8dp</dimen>
+ <dimen name="card_cover_title_text_size">14sp</dimen>
+ <dimen name="card_header_top_margin">6dp</dimen>
<dimen name="preview_card_padding">8dp</dimen>
- <dimen name="preview_page_gap">93dp</dimen>
+ <dimen name="preview_card_top_padding">6dp</dimen>
+ <dimen name="preview_page_gap">60dp</dimen>
<dimen name="preview_page_horizontal_margin">92dp</dimen>
- <dimen name="preview_theme_content_margin">18dp</dimen>
+ <dimen name="preview_theme_content_margin">8dp</dimen>
<dimen name="preview_theme_content_max_height">140dp</dimen>
<dimen name="preview_theme_content_min_height">100dp</dimen>
- <dimen name="preview_theme_cover_topbar_icon_size">14dp</dimen>
- <dimen name="preview_theme_icon_size">28dp</dimen>
+ <dimen name="preview_theme_cover_topbar_clock_size">12sp</dimen>
+ <dimen name="preview_theme_cover_topbar_icon_size">12dp</dimen>
+ <dimen name="preview_theme_icon_size">26dp</dimen>
<dimen name="preview_theme_tile_size">14dp</dimen>
- <dimen name="preview_theme_shape_size">32dp</dimen>
+ <dimen name="preview_theme_shape_size">30dp</dimen>
<dimen name="preview_theme_cover_content_extra_margin">0dp</dimen>
+ <dimen name="preview_theme_content_bottom">8dp</dimen>
+ <dimen name="preview_theme_cover_content_bottom">36dp</dimen>
<dimen name="font_preview_divider_gap">12dp</dimen>
<dimen name="options_container_width">400dp</dimen>
<dimen name="option_bottom_margin">8dp</dimen>
+ <dimen name="option_tile_width">62dp</dimen>
+ <dimen name="option_tile_padding_horizontal">7dp</dimen>
+ <dimen name="option_tile_padding_vertical">8dp</dimen>
+
</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ba7ea6b..51e4a83 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -23,7 +23,7 @@
<dimen name="tip_dot_line_width">2dp</dimen>
<dimen name="check_size">20dp</dimen>
- <dimen name="check_offset">4dp</dimen>
+ <dimen name="check_offset">-4dp</dimen>
<dimen name="preview_indicator_width">16dp</dimen>
<dimen name="preview_indicator_height">8dp</dimen>
@@ -62,6 +62,7 @@
<dimen name="theme_option_label_margin">4dp</dimen>
<dimen name="preview_card_padding">20dp</dimen>
+ <dimen name="preview_card_top_padding">@dimen/preview_card_padding</dimen>
<dimen name="card_title_text_size">16sp</dimen>
<dimen name="card_cover_title_text_size">24sp</dimen>
@@ -77,8 +78,11 @@
<dimen name="preview_theme_icon_size">30dp</dimen>
<dimen name="preview_theme_tile_size">16dp</dimen>
<dimen name="preview_theme_shape_size">36dp</dimen>
+ <dimen name="preview_theme_cover_topbar_clock_size">14sp</dimen>
<dimen name="preview_theme_cover_topbar_icon_size">16dp</dimen>
<dimen name="preview_theme_cover_content_extra_margin">16dp</dimen>
+ <dimen name="preview_theme_content_bottom">@dimen/min_taptarget_height</dimen>
+ <dimen name="preview_theme_cover_content_bottom">@dimen/preview_theme_content_bottom</dimen>
<dimen name="font_preview_body_width">200dp</dimen>
<dimen name="font_preview_divider_gap">30dp</dimen>
@@ -100,4 +104,5 @@
<dimen name="roundCornerThreshold">16dp</dimen>
<dimen name="min_taptarget_height">48dp</dimen>
+
</resources>
diff --git a/src/com/android/customization/picker/theme/ThemePreviewPage.java b/src/com/android/customization/picker/theme/ThemePreviewPage.java
index 79f2e9c..f00cd3f 100644
--- a/src/com/android/customization/picker/theme/ThemePreviewPage.java
+++ b/src/com/android/customization/picker/theme/ThemePreviewPage.java
@@ -20,6 +20,7 @@
import androidx.annotation.DrawableRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.StringRes;
+import androidx.constraintlayout.widget.Guideline;
import com.android.customization.picker.BasePreviewAdapter.PreviewPage;
import com.android.wallpaper.R;
@@ -228,6 +229,12 @@
cornerRadius, cornerRadius, cornerRadius, cornerRadius});
}
}
+
+ Guideline guideline = card.findViewById(R.id.guideline);
+ if (guideline != null) {
+ guideline.setGuidelineEnd(card.getResources().getDimensionPixelOffset(
+ R.dimen.preview_theme_cover_content_bottom));
+ }
}
@Override
diff --git a/src/com/android/customization/widget/OptionSelectorController.java b/src/com/android/customization/widget/OptionSelectorController.java
index e3e2cc5..efd73ea 100644
--- a/src/com/android/customization/widget/OptionSelectorController.java
+++ b/src/com/android/customization/widget/OptionSelectorController.java
@@ -194,7 +194,7 @@
if (mShowCheckmark && option.equals(mAppliedOption)) {
Resources res = mContainer.getContext().getResources();
Drawable checkmark = res.getDrawable(R.drawable.ic_check_circle_filled_24px);
- Drawable frame = holder.itemView.getForeground();
+ Drawable frame = holder.tileView.getForeground();
Drawable[] layers = {frame, checkmark};
if (frame == null) {
layers = new Drawable[]{checkmark};
@@ -204,20 +204,20 @@
// Position at lower right
int idx = layers.length - 1;
int checkSize = (int) res.getDimension(R.dimen.check_size);
- int checkOffset = (int) res.getDimension(R.dimen.check_offset);
+ int checkOffset = (int) res.getDimensionPixelOffset(R.dimen.check_offset);
checkedFrame.setLayerGravity(idx, Gravity.BOTTOM | Gravity.RIGHT);
checkedFrame.setLayerWidth(idx, checkSize);
checkedFrame.setLayerHeight(idx, checkSize);
checkedFrame.setLayerInsetBottom(idx, checkOffset);
- checkedFrame.setLayerInsetLeft(idx, checkOffset);
- holder.itemView.setForeground(checkedFrame);
+ checkedFrame.setLayerInsetRight(idx, checkOffset);
+ holder.tileView.setForeground(checkedFrame);
// Initialize the currently applied option
CharSequence cd = mContainer.getContext().getString(
R.string.option_applied_previewed_description, option.getTitle());
holder.labelView.setContentDescription(cd);
} else if (mShowCheckmark) {
- holder.itemView.setForeground(null);
+ holder.tileView.setForeground(null);
}
}
diff --git a/src/com/android/customization/widget/PageIndicator.java b/src/com/android/customization/widget/PageIndicator.java
index b80f558..dd636ad 100644
--- a/src/com/android/customization/widget/PageIndicator.java
+++ b/src/com/android/customization/widget/PageIndicator.java
@@ -205,7 +205,11 @@
}
private void playAnimation(ImageView imageView, int res) {
- final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getContext().getDrawable(res);
+ Drawable drawable = getContext().getDrawable(res);
+ if (!(drawable instanceof AnimatedVectorDrawable)) {
+ return;
+ }
+ final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) drawable;
imageView.setImageDrawable(avd);
try {
forceAnimationOnUI(avd);