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

Commit 1dbb7723 authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

Add wallpaper support to theme bundles

Show wallpaper preview if available, show a checkbox to keep the
current wallpaper and apply the theme's wallpaper if needed.

Bug: 120559294

Change-Id: I229ab6e3372ace8218356d965e8d38f074e95061
parent a48e47fe
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -45,6 +45,13 @@
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <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:text="@string/keep_my_wallpaper"/>
            <Button
                android:id="@+id/apply_button"
                style="@style/ActionPrimaryButton"
+31 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2019 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.
-->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/preview_static_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    tools:showIn="@layout/theme_preview_card">
    <TextView
        style="@style/CardTitleTextAppearance"
        android:id="@+id/wallpaper_description"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal|bottom"/>
</FrameLayout>
 No newline at end of file
+24 −17
Original line number Diff line number Diff line
@@ -16,13 +16,20 @@
-->
<androidx.cardview.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    style="@style/PreviewCard"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    android:layout_height="match_parent"
    app:contentPadding="0dp">

    <FrameLayout
        android:id="@+id/theme_preview_card_background"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="@dimen/preview_card_padding"
            android:orientation="vertical">
            <TextView
                android:id="@+id/theme_preview_card_header"
@@ -38,5 +45,5 @@
                android:layout_height="match_parent"
                android:layout_marginHorizontal="8dp"/>
        </LinearLayout>

    </FrameLayout>
</androidx.cardview.widget.CardView>
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -38,6 +38,10 @@
        [CHAR LIMIT=20] -->
    <string name="apply_theme_btn">Apply</string>

    <!-- Label for a checkbox to allow the user to use their currently set wallpaper instead of
        the one bundled with selected Theme [CHAR LIMIT=35]-->
    <string name="keep_my_wallpaper">Keep current wallpaper</string>

    <!-- Label for a button that allows the user to apply the currently selected customization option.
        [CHAR LIMIT=20] -->
    <string name="apply_btn">Apply</string>
@@ -81,4 +85,8 @@

    <!-- Message shown when a theme has been applied successfully in the system [CHAR LIMIT=NONE] -->
    <string name="applied_theme_msg">Style applied</string>

    <!-- Message shown when a theme couldn't be applied in the system because of an error
        [CHAR LIMIT=NONE] -->
    <string name="apply_theme_error_msg">There was a problem applying the style</string>
</resources>
+19 −1
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.customization.model;

import androidx.annotation.Nullable;

import java.util.List;

/**
@@ -23,6 +25,22 @@ import java.util.List;
 */
public interface CustomizationManager<T extends CustomizationOption> {

    /**
     * Callback for applying a customization option.
     */
    interface Callback {
        /**
         * Called after an option was applied successfully.
         */
        void onSuccess();

        /**
         * Called if there was an error applying the customization
         * @param throwable Exception thrown if available.
         */
        void onError(@Nullable Throwable throwable);
    }

    /**
     * Listener interface for fetching CustomizationOptions
     */
@@ -41,7 +59,7 @@ public interface CustomizationManager<T extends CustomizationOption> {
    /**
     * Applies the given option into the system.
     */
    void apply(T option);
    void apply(T option, Callback callback);

    /**
     * Loads the available options for the type of Customization managed by this class, calling the
Loading