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

Commit 0cd4076e authored by Catherine Liang's avatar Catherine Liang
Browse files

Color Picker Fragment Dark Mode Toggle (1/2)

Move dark mode toggle from the customization hub landing page into the
color picker page, gated by revamped UI flag. Currently the dark mode
section controller is kept and used in the color picker page, but this
can be refactored in the future.

Bug: 269449457
Test: Manual
Change-Id: I2669cee07fa81fcd8c436a30c511bae66aa50a29
parent 46892c51
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -60,8 +60,7 @@
        android:layout_marginHorizontal="24dp"
        android:layout_marginBottom="28dp"
        android:background="@drawable/picker_fragment_background"
        android:paddingTop="22dp"
        android:paddingBottom="62dp">
        android:paddingTop="22dp">

        <FrameLayout
            android:layout_width="match_parent"
@@ -124,6 +123,11 @@

        </FrameLayout>

        <FrameLayout
            android:id="@+id/dark_mode_toggle_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

</LinearLayout>
+0 −6
Original line number Diff line number Diff line
@@ -174,12 +174,6 @@ public final class DefaultCustomizationSections implements CustomizationSections
                break;

            case HOME_SCREEN:
                // Dark/Light theme section.
                sectionControllers.add(new DarkModeSectionController(
                        activity,
                        lifecycleOwner.getLifecycle(),
                        mDarkModeSnapshotRestorer));

                // Themed app icon section.
                sectionControllers.add(
                        new ThemedIconSectionController(
+1 −1
Original line number Diff line number Diff line
@@ -374,7 +374,7 @@ open class ThemePickerInjector : WallpaperPicker2Injector(), CustomizationInject
                .also { colorPickerViewModelFactory = it }
    }

    protected fun getDarkModeSnapshotRestorer(
    fun getDarkModeSnapshotRestorer(
        context: Context,
    ): DarkModeSnapshotRestorer {
        return darkModeSnapshotRestorer
+13 −0
Original line number Diff line number Diff line
@@ -19,9 +19,11 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.cardview.widget.CardView
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.get
import com.android.customization.model.mode.DarkModeSectionController
import com.android.customization.module.ThemePickerInjector
import com.android.customization.picker.color.ui.binder.ColorPickerBinder
import com.android.wallpaper.R
@@ -137,6 +139,17 @@ class ColorPickerFragment : AppbarFragment() {
            lifecycleOwner = this,
            offsetToStart = displayUtils.isOnWallpaperDisplay(requireActivity()),
        )
        val darkModeToggleContainerView: FrameLayout =
            view.requireViewById(R.id.dark_mode_toggle_container)
        val darkModeSectionView =
            DarkModeSectionController(
                    context,
                    lifecycle,
                    injector.getDarkModeSnapshotRestorer(requireContext())
                )
                .createView(requireContext())
        darkModeSectionView.background = null
        darkModeToggleContainerView.addView(darkModeSectionView)
        return view
    }