Connected sections for wallpaper and colors (2/3).
This is a side-by-side layout for the color and wallpaper quick switcher sections on the main/landing screen of wallpaper picker.
Bug: 265837104
Test: manually verified layout on large screens in landscape and
portrait mode, hand-helds in portrait mode - both with left-to-right
(English) and right-to-left (Hebrew) setups
Change-Id: I5e03344ba8a365803e4df3a031ce0ec1f2f1b862
diff --git a/res/drawable/color_section_background.xml b/res/drawable/top_connected_section_background.xml
similarity index 100%
rename from res/drawable/color_section_background.xml
rename to res/drawable/top_connected_section_background.xml
diff --git a/res/layout/color_section_view2.xml b/res/layout/color_section_view2.xml
index 9ad140b..1811641 100644
--- a/res/layout/color_section_view2.xml
+++ b/res/layout/color_section_view2.xml
@@ -16,36 +16,30 @@
-->
<com.android.customization.picker.color.ColorSectionView2
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/color_section_option_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingBottom="@dimen/section_bottom_padding"
- android:paddingHorizontal="@dimen/section_horizontal_padding"
- android:orientation="vertical">
+ android:layout_marginBottom="@dimen/section_bottom_padding"
+ android:layout_marginHorizontal="@dimen/section_horizontal_padding"
+ android:orientation="horizontal"
+ android:background="@drawable/top_connected_section_background"
+ android:paddingVertical="24dp"
+ android:paddingHorizontal="24dp"
+ android:weightSum="@integer/color_section_num_columns">
- <LinearLayout
- android:id="@+id/color_section_option_container"
- android:layout_width="match_parent"
+ <!--
+ This is just an invisible placeholder put in place so that the parent keeps its height
+ stable as the RecyclerView updates from 0 items to N items. Keeping it stable allows the
+ layout logic to keep the size of the preview container stable as well, which bodes well
+ for setting up the SurfaceView for remote rendering without changing its size after the
+ content is loaded into the RecyclerView.
+
+ It's critical for any TextViews inside the included layout to have text.
+ -->
+ <include
+ android:layout_width="0dp"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:background="@drawable/color_section_background"
- android:paddingVertical="24dp"
- android:paddingHorizontal="24dp"
- android:weightSum="@integer/color_section_num_columns">
-
- <!--
- This is just an invisible placeholder put in place so that the parent keeps its height
- stable as the RecyclerView updates from 0 items to N items. Keeping it stable allows the
- layout logic to keep the size of the preview container stable as well, which bodes well
- for setting up the SurfaceView for remote rendering without changing its size after the
- content is loaded into the RecyclerView.
-
- It's critical for any TextViews inside the included layout to have text.
- -->
- <include
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- layout="@layout/color_option_section_overflow"
- android:visibility="invisible"
- android:layout_weight="1"/>
- </LinearLayout>
+ layout="@layout/color_option_section_overflow"
+ android:visibility="invisible"
+ android:layout_weight="1"/>
</com.android.customization.picker.color.ColorSectionView2>
diff --git a/src/com/android/customization/module/DefaultCustomizationSections.java b/src/com/android/customization/module/DefaultCustomizationSections.java
index c7fa255..2b29312 100644
--- a/src/com/android/customization/module/DefaultCustomizationSections.java
+++ b/src/com/android/customization/module/DefaultCustomizationSections.java
@@ -29,6 +29,7 @@
import com.android.wallpaper.model.WorkspaceViewModel;
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
import com.android.wallpaper.module.CustomizationSections;
+import com.android.wallpaper.picker.customization.ui.section.ConnectedSectionController;
import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewSectionController;
import com.android.wallpaper.picker.customization.ui.section.WallpaperQuickSwitchSectionController;
import com.android.wallpaper.picker.customization.ui.viewmodel.WallpaperQuickSwitchViewModel;
@@ -82,17 +83,21 @@
wallpaperColorsViewModel,
displayUtils));
- // Theme color section.
- sectionControllers.add(new ColorSectionController2(
- activity, wallpaperColorsViewModel, lifecycleOwner, sectionNavigationController));
-
- // Wallpaper quick switch section.
sectionControllers.add(
- new WallpaperQuickSwitchSectionController(
- screen,
- wallpaperQuickSwitchViewModel,
- lifecycleOwner,
- sectionNavigationController));
+ new ConnectedSectionController(
+ // Theme color section.
+ new ColorSectionController2(
+ activity,
+ wallpaperColorsViewModel,
+ lifecycleOwner,
+ sectionNavigationController),
+ // Wallpaper quick switch section.
+ new WallpaperQuickSwitchSectionController(
+ screen,
+ wallpaperQuickSwitchViewModel,
+ lifecycleOwner,
+ sectionNavigationController),
+ /* reverseOrderWhenHorizontal= */ true));
switch (screen) {
case LOCK_SCREEN:
diff --git a/src/com/android/customization/picker/clock/ui/section/ClockSectionController.kt b/src/com/android/customization/picker/clock/ui/section/ClockSectionController.kt
index 052d0f5..bd81719 100644
--- a/src/com/android/customization/picker/clock/ui/section/ClockSectionController.kt
+++ b/src/com/android/customization/picker/clock/ui/section/ClockSectionController.kt
@@ -39,9 +39,9 @@
private val lifecycleOwner: LifecycleOwner,
private val flag: BaseFlags,
private val clockRegistryProvider: ClockRegistryProvider,
-) : CustomizationSectionController<ClockSectionView?> {
+) : CustomizationSectionController<ClockSectionView> {
- override fun isAvailable(context: Context?): Boolean {
+ override fun isAvailable(context: Context): Boolean {
return flag.isCustomClocksEnabled(context!!)
}
diff --git a/src/com/android/customization/picker/notifications/ui/section/NotificationSectionController.kt b/src/com/android/customization/picker/notifications/ui/section/NotificationSectionController.kt
index 6e30c6b..d35c382 100644
--- a/src/com/android/customization/picker/notifications/ui/section/NotificationSectionController.kt
+++ b/src/com/android/customization/picker/notifications/ui/section/NotificationSectionController.kt
@@ -33,12 +33,12 @@
private val lifecycleOwner: LifecycleOwner,
) : CustomizationSectionController<NotificationSectionView> {
- override fun isAvailable(context: Context?): Boolean {
+ override fun isAvailable(context: Context): Boolean {
return true
}
@SuppressLint("InflateParams") // We don't care that the parent is null.
- override fun createView(context: Context?): NotificationSectionView {
+ override fun createView(context: Context): NotificationSectionView {
val view =
LayoutInflater.from(context)
.inflate(
diff --git a/src/com/android/customization/picker/quickaffordance/ui/section/KeyguardQuickAffordanceSectionController.kt b/src/com/android/customization/picker/quickaffordance/ui/section/KeyguardQuickAffordanceSectionController.kt
index 6b35d7c..e0beeff 100644
--- a/src/com/android/customization/picker/quickaffordance/ui/section/KeyguardQuickAffordanceSectionController.kt
+++ b/src/com/android/customization/picker/quickaffordance/ui/section/KeyguardQuickAffordanceSectionController.kt
@@ -39,11 +39,11 @@
private val isFeatureEnabled: Boolean = runBlocking { interactor.isFeatureEnabled() }
- override fun isAvailable(context: Context?): Boolean {
+ override fun isAvailable(context: Context): Boolean {
return isFeatureEnabled
}
- override fun createView(context: Context?): KeyguardQuickAffordanceSectionView {
+ override fun createView(context: Context): KeyguardQuickAffordanceSectionView {
val view =
LayoutInflater.from(context)
.inflate(
diff --git a/src/com/android/customization/picker/settings/ui/section/MoreSettingsSectionController.kt b/src/com/android/customization/picker/settings/ui/section/MoreSettingsSectionController.kt
index 146aca1..5e890cd 100644
--- a/src/com/android/customization/picker/settings/ui/section/MoreSettingsSectionController.kt
+++ b/src/com/android/customization/picker/settings/ui/section/MoreSettingsSectionController.kt
@@ -28,17 +28,17 @@
class MoreSettingsSectionController : CustomizationSectionController<MoreSettingsSectionView> {
- override fun isAvailable(context: Context?): Boolean {
+ override fun isAvailable(context: Context): Boolean {
return true
}
@SuppressLint("InflateParams") // We're okay not providing a parent view.
- override fun createView(context: Context?): MoreSettingsSectionView {
+ override fun createView(context: Context): MoreSettingsSectionView {
return LayoutInflater.from(context)
.inflate(R.layout.more_settings_section_view, null)
.apply {
setOnClickListener {
- context?.startActivity(Intent(Settings.ACTION_LOCKSCREEN_SETTINGS))
+ context.startActivity(Intent(Settings.ACTION_LOCKSCREEN_SETTINGS))
}
} as MoreSettingsSectionView
}