Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit afc73292 authored by George Lin's avatar George Lin
Browse files

Clock floating sheeting

Change the layout of the clock floating sheet

Test: Manually tested. See bug.
Bug: 350718184
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: Ib309ff76c665788ab63b9f549dc3d0090ad2ff15
parent 6c1f7934
Loading
Loading
Loading
Loading
+0 −37
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
     Copyright (C) 2023 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.
-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="invisible"
    android:orientation="vertical">

    <include
        layout="@layout/color_option"
        android:layout_width="@dimen/option_item_size"
        android:layout_height="@dimen/option_item_size" />

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/floating_sheet_list_item_vertical_space"/>

    <include
        layout="@layout/color_option"
        android:layout_width="@dimen/option_item_size"
        android:layout_height="@dimen/option_item_size" />
</LinearLayout>
+0 −37
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
     Copyright (C) 2024 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.
-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="invisible"
    android:orientation="vertical">

    <include
        layout="@layout/clock_style_option"
        android:layout_width="@dimen/floating_sheet_clock_style_option_size"
        android:layout_height="@dimen/floating_sheet_clock_style_option_size" />

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/floating_sheet_list_item_vertical_space"/>

    <include
        layout="@layout/clock_style_option"
        android:layout_width="@dimen/floating_sheet_clock_style_option_size"
        android:layout_height="@dimen/floating_sheet_clock_style_option_size" />
</LinearLayout>
+74 −88
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:paddingHorizontal="@dimen/floating_sheet_horizontal_padding"
    android:orientation="vertical">

@@ -29,13 +31,24 @@
        android:clipToPadding="false"
        android:clipChildren="false">

        <FrameLayout
        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/clock_floating_sheet_style_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipToPadding="false"
            android:clipChildren="false">

            <FrameLayout
                android:id="@+id/clock_style_list_container"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toTopOf="@+id/clock_style_clock_size_title"
                android:clipToPadding="false"
                android:clipChildren="false">

                <!--
                This is 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
@@ -46,9 +59,9 @@
                It's critical for any TextViews inside the included layout to have text.
                -->
                <include
                layout="@layout/clock_style_list_placeholder"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                    layout="@layout/clock_style_option"
                    android:layout_width="@dimen/floating_sheet_clock_style_option_size"
                    android:layout_height="@dimen/floating_sheet_clock_style_option_size"
                    android:visibility="invisible" />

                <androidx.recyclerview.widget.RecyclerView
@@ -59,6 +72,43 @@
                    android:clipToPadding="false"/>
            </FrameLayout>

            <TextView
                android:id="@+id/clock_style_clock_size_title"
                style="@style/CustomizationOptionEntryTitleTextStyle"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="@string/clock_size_large"
                android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
                android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/clock_style_clock_size_switch"
                app:layout_constraintTop_toBottomOf="@+id/clock_style_list_container"
                app:layout_constraintBottom_toTopOf="@+id/clock_style_clock_size_description" />

            <TextView
                android:id="@+id/clock_style_clock_size_description"
                style="@style/CustomizationOptionEntrySubtitleTextStyle"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
                android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
                android:text="@string/clock_size_dynamic_description"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/clock_style_clock_size_switch"
                app:layout_constraintTop_toBottomOf="@+id/clock_style_clock_size_title"
                app:layout_constraintBottom_toBottomOf="parent" />

            <Switch
                android:id="@+id/clock_style_clock_size_switch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/floating_sheet_content_horizontal_padding"
                app:layout_constraintTop_toTopOf="@+id/clock_style_clock_size_title"
                app:layout_constraintBottom_toBottomOf="@+id/clock_style_clock_size_description"
                app:layout_constraintEnd_toEndOf="parent"
                style="@style/Switch.SettingsLib"
                tools:ignore="UseSwitchCompatOrMaterialXml" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <LinearLayout
            android:id="@+id/clock_floating_sheet_color_content"
@@ -85,9 +135,9 @@
                It's critical for any TextViews inside the included layout to have text.
                -->
                <include
                    layout="@layout/clock_color_list_placeholder"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    layout="@layout/color_option"
                    android:layout_width="@dimen/option_item_size"
                    android:layout_height="@dimen/option_item_size"
                    android:visibility="invisible" />

                <androidx.recyclerview.widget.RecyclerView
@@ -112,70 +162,6 @@
                android:progressDrawable="@drawable/saturation_progress_drawable"
                android:splitTrack="false" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/clock_floating_sheet_size_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:showDividers="middle"
            android:baselineAligned="false"
            android:divider="@drawable/horizontal_divider_16dp"
            android:paddingVertical="@dimen/floating_sheet_content_vertical_padding"
            android:paddingHorizontal="@dimen/floating_sheet_content_horizontal_padding">

            <LinearLayout
                android:id="@+id/clock_size_option_dynamic"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical"
                android:gravity="center_horizontal">
                <ImageView
                    android:layout_width="@dimen/floating_sheet_clock_size_icon_size"
                    android:layout_height="@dimen/floating_sheet_clock_size_icon_size"
                    android:background="#ff00ff"
                    android:layout_marginBottom="@dimen/floating_sheet_clock_size_icon_margin_bottom" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="@style/SectionTitleTextStyle"
                    android:gravity="center"
                    android:text="@string/clock_size_dynamic"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="@style/SectionSubtitleTextStyle"
                    android:gravity="center"
                    android:text="@string/clock_size_dynamic_description"/>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/clock_size_option_small"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical"
                android:gravity="center_horizontal">
                <ImageView
                    android:layout_width="@dimen/floating_sheet_clock_size_icon_size"
                    android:layout_height="@dimen/floating_sheet_clock_size_icon_size"
                    android:background="#ff00ff"
                    android:layout_marginBottom="@dimen/floating_sheet_clock_size_icon_margin_bottom" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="@style/SectionTitleTextStyle"
                    android:gravity="center"
                    android:text="@string/clock_size_small"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="@style/SectionSubtitleTextStyle"
                    android:gravity="center"
                    android:text="@string/clock_size_small_description"/>
            </LinearLayout>
        </LinearLayout>
    </FrameLayout>

    <com.android.wallpaper.picker.customization.ui.view.FloatingToolbar
+1 −2
Original line number Diff line number Diff line
@@ -185,9 +185,8 @@
    <dimen name="floating_sheet_tab_toolbar_vertical_margin">8dp</dimen>
    <dimen name="floating_sheet_list_item_horizontal_space">4dp</dimen>
    <dimen name="floating_sheet_list_item_vertical_space">4dp</dimen>
    <dimen name="floating_sheet_clock_size_icon_size">80dp</dimen>
    <dimen name="floating_sheet_clock_size_icon_margin_bottom">8dp</dimen>
    <dimen name="floating_sheet_clock_style_option_size">82dp</dimen>
    <dimen name="floating_sheet_clock_style_thumbnail_margin">12dp</dimen>
    <dimen name="floating_sheet_clock_style_clock_size_text_margin_end">16dp</dimen>
    <dimen name="customization_option_entry_shortcut_icon_size">20dp</dimen>
</resources>
+23 −48
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.wallpaper.customization.ui.binder

import android.animation.ValueAnimator
import android.annotation.DrawableRes
import android.content.Context
import android.content.res.Configuration
import android.graphics.drawable.Drawable
@@ -25,25 +24,24 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.SeekBar
import androidx.core.content.res.ResourcesCompat
import android.widget.Switch
import androidx.core.view.doOnLayout
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.color.ui.binder.ColorOptionIconBinder
import com.android.customization.picker.color.ui.view.ColorOptionIconView
import com.android.customization.picker.color.ui.viewmodel.ColorOptionIconViewModel
import com.android.customization.picker.common.ui.view.DoubleRowListItemSpacing
import com.android.customization.picker.common.ui.view.SingleRowListItemSpacing
import com.android.themepicker.R
import com.android.wallpaper.customization.ui.util.ThemePickerCustomizationOptionUtil.ThemePickerLockCustomizationOption.CLOCK
import com.android.wallpaper.customization.ui.viewmodel.ClockFloatingSheetHeightsViewModel
import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel.Tab.COLOR
import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel.Tab.SIZE
import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel.Tab.STYLE
import com.android.wallpaper.customization.ui.viewmodel.ThemePickerCustomizationOptionsViewModel
import com.android.wallpaper.picker.customization.ui.view.FloatingToolbar
@@ -119,10 +117,8 @@ object ClockFloatingSheetBinder {
            }
        )

        // Clock size
        val clockSizeContent = view.requireViewById<View>(R.id.clock_floating_sheet_size_content)
        val clockSizeOptionDynamic = view.requireViewById<View>(R.id.clock_size_option_dynamic)
        val clockSizeOptionSmall = view.requireViewById<View>(R.id.clock_size_option_small)
        // Clock size switch
        val clockSizeSwitch = view.requireViewById<Switch>(R.id.clock_style_clock_size_switch)

        view.doOnLayout {
            if (_clockFloatingSheetHeights.value == null) {
@@ -130,7 +126,6 @@ object ClockFloatingSheetBinder {
                    ClockFloatingSheetHeightsViewModel(
                        clockStyleContentHeight = clockStyleContent.height,
                        clockColorContentHeight = clockColorContent.height,
                        clockSizeContentHeight = clockSizeContent.height,
                    )
            }
        }
@@ -150,7 +145,6 @@ object ClockFloatingSheetBinder {
                                when (selectedTab) {
                                    STYLE -> heights.clockStyleContentHeight
                                    COLOR -> heights.clockColorContentHeight
                                    SIZE -> heights.clockSizeContentHeight
                                } +
                                    view.resources.getDimensionPixelSize(
                                        R.dimen.floating_sheet_content_vertical_padding
@@ -168,7 +162,6 @@ object ClockFloatingSheetBinder {

                            clockStyleContent.isVisible = selectedTab == STYLE
                            clockColorContent.isVisible = selectedTab == COLOR
                            clockSizeContent.isVisible = selectedTab == SIZE
                        }
                }

@@ -177,7 +170,7 @@ object ClockFloatingSheetBinder {
                        clockStyleAdapter.setItems(styleOptions) {
                            var indexToFocus = styleOptions.indexOfFirst { it.isSelected.value }
                            indexToFocus = if (indexToFocus < 0) 0 else indexToFocus
                            (clockStyleList.layoutManager as GridLayoutManager)
                            (clockStyleList.layoutManager as LinearLayoutManager)
                                .scrollToPositionWithOffset(indexToFocus, 0)
                        }
                    }
@@ -188,7 +181,7 @@ object ClockFloatingSheetBinder {
                        clockColorAdapter.setItems(colorOptions) {
                            var indexToFocus = colorOptions.indexOfFirst { it.isSelected.value }
                            indexToFocus = if (indexToFocus < 0) 0 else indexToFocus
                            (clockColorList.layoutManager as GridLayoutManager)
                            (clockColorList.layoutManager as LinearLayoutManager)
                                .scrollToPositionWithOffset(indexToFocus, 0)
                        }
                    }
@@ -209,26 +202,18 @@ object ClockFloatingSheetBinder {
                }

                launch {
                    viewModel.sizeOptions.collect { sizeOptions ->
                        sizeOptions.forEach { option ->
                            lifecycleOwner.lifecycleScope.launch {
                                lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
                                    launch {
                                        option.onClicked.collect { onClicked ->
                                            when (option.size) {
                                                ClockSize.DYNAMIC ->
                                                    clockSizeOptionDynamic.setOnClickListener {
                                                        onClicked?.invoke()
                                                    }
                                                ClockSize.SMALL ->
                                                    clockSizeOptionSmall.setOnClickListener {
                                                        onClicked?.invoke()
                                                    }
                                            }
                                        }
                    viewModel.previewingClockSize.collect { size ->
                        when (size) {
                            ClockSize.DYNAMIC -> clockSizeSwitch.isChecked = true
                            ClockSize.SMALL -> clockSizeSwitch.isChecked = false
                        }
                    }
                }

                launch {
                    viewModel.onClockSizeSwitchCheckedChange.collect { onCheckedChange ->
                        clockSizeSwitch.setOnCheckedChangeListener { _, _ ->
                            onCheckedChange.invoke()
                        }
                    }
                }
@@ -250,18 +235,15 @@ object ClockFloatingSheetBinder {
    private fun RecyclerView.initStyleList(context: Context, adapter: OptionItemAdapter<Drawable>) {
        apply {
            this.adapter = adapter
            layoutManager = GridLayoutManager(context, 2, GridLayoutManager.HORIZONTAL, false)
            layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
            addItemDecoration(
                DoubleRowListItemSpacing(
                SingleRowListItemSpacing(
                    context.resources.getDimensionPixelSize(
                        R.dimen.floating_sheet_content_horizontal_padding
                    ),
                    context.resources.getDimensionPixelSize(
                        R.dimen.floating_sheet_list_item_horizontal_space
                    ),
                    context.resources.getDimensionPixelSize(
                        R.dimen.floating_sheet_list_item_vertical_space
                    ),
                )
            )
        }
@@ -288,24 +270,17 @@ object ClockFloatingSheetBinder {
    ) {
        apply {
            this.adapter = adapter
            layoutManager = GridLayoutManager(context, 2, GridLayoutManager.HORIZONTAL, false)
            layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
            addItemDecoration(
                DoubleRowListItemSpacing(
                SingleRowListItemSpacing(
                    context.resources.getDimensionPixelSize(
                        R.dimen.floating_sheet_content_horizontal_padding
                    ),
                    context.resources.getDimensionPixelSize(
                        R.dimen.floating_sheet_list_item_horizontal_space
                    ),
                    context.resources.getDimensionPixelSize(
                        R.dimen.floating_sheet_list_item_vertical_space
                    ),
                )
            )
        }
    }

    private fun getDrawable(context: Context, @DrawableRes res: Int): Drawable? {
        return ResourcesCompat.getDrawable(context.resources, res, null)
    }
}
Loading