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

Commit 8670e6aa authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10635039 from 49493200 to udc-qpr1-release

Change-Id: I9162d1966e93d08c11647b345c0a3da412fd0136
parents fc081567 49493200
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ public interface CustomizationManager<T extends CustomizationOption> {
     */
    void apply(T option, Callback callback);

    /** Preview the given option without committing the change. */
    default void preview(T option) {}

    /**
     * Loads the available options for the type of Customization managed by this class, calling the
     * given callback when done.
+5 −0
Original line number Diff line number Diff line
@@ -98,6 +98,11 @@ public class GridOptionsManager implements CustomizationManager<GridOption> {
        }
    }

    @Override
    public void preview(GridOption option) {
        mProvider.updateView();
    }

    @Override
    public void fetchOptions(OptionsFetchedListener<GridOption> callback, boolean reload) {
        sExecutorService.submit(() -> {
+4 −0
Original line number Diff line number Diff line
@@ -117,6 +117,10 @@ public class LauncherGridOptionsProvider {
        mPreviewUtils.renderPreview(bundle, callback);
    }

    void updateView() {
        mLiveData.postValue(new Object());
    }

    int applyGrid(String name) {
        ContentValues values = new ContentValues();
        values.put("name", name);
+18 −11
Original line number Diff line number Diff line
@@ -17,12 +17,14 @@

package com.android.customization.model.grid.data.repository

import android.content.Context
import androidx.lifecycle.asFlow
import com.android.customization.model.CustomizationManager
import com.android.customization.model.grid.GridOption
import com.android.customization.model.grid.GridOptionsManager
import com.android.customization.model.grid.shared.model.GridOptionItemModel
import com.android.customization.model.grid.shared.model.GridOptionItemsModel
import com.android.wallpaper.config.BaseFlags
import kotlin.coroutines.resume
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
@@ -41,6 +43,7 @@ interface GridRepository {
}

class GridRepositoryImpl(
    private val context: Context,
    private val applicationScope: CoroutineScope,
    private val manager: GridOptionsManager,
    private val backgroundDispatcher: CoroutineDispatcher,
@@ -105,6 +108,9 @@ class GridRepositoryImpl(
    private suspend fun onSelected(option: GridOption) {
        withContext(backgroundDispatcher) {
            suspendCancellableCoroutine { continuation ->
                if (BaseFlags.get().isGridApplyButtonEnabled(context)) {
                    manager.preview(option)
                } else {
                    manager.apply(
                        option,
                        object : CustomizationManager.Callback {
@@ -120,6 +126,7 @@ class GridRepositoryImpl(
                }
            }
        }
    }

    private fun GridOption?.key(): String? {
        return if (this != null) "${cols}x${rows}" else null
+1 −0
Original line number Diff line number Diff line
@@ -580,6 +580,7 @@ internal constructor(
                    applicationScope = getApplicationCoroutineScope(),
                    repository =
                        GridRepositoryImpl(
                            context = appContext,
                            applicationScope = getApplicationCoroutineScope(),
                            manager = GridOptionsManager.getInstance(context),
                            backgroundDispatcher = bgDispatcher,