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

Commit 115b0de0 authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

Implement "Apply theme" for default theme.

Default theme requires disabling current overlays so it needs
a different implementation.

Bug: 120559294
Change-Id: I287d285a74c5b123f807b6589a2e81572abc30d0
parent d24c4986
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */
package com.android.customization.model;

import android.content.Context;
import android.view.View;

import androidx.annotation.LayoutRes;
@@ -26,7 +25,7 @@ import com.android.wallpaper.R;
/**
 * Represents an option of customization (eg, a ThemeBundle, a Clock face, a Grid size)
 */
public interface CustomizationOption {
public interface CustomizationOption <T extends CustomizationOption> {

    /**
     * Optional name or label for this option
@@ -44,7 +43,7 @@ public interface CustomizationOption {
    /**
     * Returns whether this option is the one currently set in the System.
     */
    boolean isActive(Context context);
    boolean isActive(CustomizationManager<T> manager);

    /**
     * Return the id of the layout used to show this option in the UI. It must contain a view with
+5 −0
Original line number Diff line number Diff line
@@ -25,6 +25,11 @@ public interface ResourceConstants {
     */
    String ANDROID_PACKAGE = "android";

    /**
     * Package name for android settings resources.
     */
    String SETTINGS_PACKAGE = "com.android.settings";

    /**
     * Package name for android sysui resources.
     */
+8 −1
Original line number Diff line number Diff line
@@ -17,11 +17,14 @@ package com.android.customization.model.clock;

import android.content.Context;
import android.provider.Settings;
import android.provider.Settings.Secure;

import com.android.customization.model.CustomizationManager;

public class ClockManager implements CustomizationManager<Clockface> {

    // TODO: use constant from Settings.Secure
    private static final String CLOCK_FACE_SETTING = "lock_screen_custom_clock_face";
    private final ClockProvider mClockProvider;
    private final Context mContext;

@@ -38,11 +41,15 @@ public class ClockManager implements CustomizationManager<Clockface> {
    @Override
    public void apply(Clockface option) {
        Settings.Secure.putString(mContext.getContentResolver(),
                Clockface.CLOCK_FACE_SETTING, option.getId());
                CLOCK_FACE_SETTING, option.getId());
    }

    @Override
    public void fetchOptions(OptionsFetchedListener<Clockface> callback) {
        mClockProvider.fetch(callback, false);
    }

    public String getCurrentClock() {
        return Secure.getString(mContext.getContentResolver(), CLOCK_FACE_SETTING);
    }
}
+4 −8
Original line number Diff line number Diff line
@@ -15,20 +15,17 @@
 */
package com.android.customization.model.clock;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.provider.Settings.Secure;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.android.customization.model.CustomizationManager;
import com.android.customization.model.CustomizationOption;
import com.android.wallpaper.R;

public class Clockface implements CustomizationOption {
public class Clockface implements CustomizationOption<Clockface> {

    // TODO: use constant from Settings.Secure
    static final String CLOCK_FACE_SETTING = "lock_screen_custom_clock_face";
    private final String mTitle;
    private final String mId;
    private final Drawable mPreview;
@@ -52,9 +49,8 @@ public class Clockface implements CustomizationOption {
    }

    @Override
    public boolean isActive(Context context) {
        String currentClock = Secure.getString(context.getContentResolver(),
                Clockface.CLOCK_FACE_SETTING);
    public boolean isActive(CustomizationManager<Clockface> manager) {
        String currentClock = ((ClockManager) manager).getCurrentClock();
        // Empty clock Id is the default system clock
        return (TextUtils.isEmpty(currentClock) && TextUtils.isEmpty(mId))
                || (mId != null && mId.equals(currentClock));
+3 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.net.Uri;
import android.view.View;
import android.widget.ImageView;

import com.android.customization.model.CustomizationManager;
import com.android.customization.model.CustomizationOption;
import com.android.customization.widget.GridTileDrawable;
import com.android.wallpaper.R;
@@ -28,7 +29,7 @@ import com.android.wallpaper.R;
/**
 * Represents a grid layout option available in the current launcher.
 */
public class GridOption implements CustomizationOption {
public class GridOption implements CustomizationOption<GridOption> {

    private final String mTitle;
    private final boolean mIsCurrent;
@@ -67,7 +68,7 @@ public class GridOption implements CustomizationOption {
    }

    @Override
    public boolean isActive(Context context) {
    public boolean isActive(CustomizationManager<GridOption> manager) {
        return mIsCurrent;
    }

Loading