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

Commit d912f889 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7447836 from d9ee34df to sc-release

Change-Id: Id2717ff4111caae98f0f54834091b3ccd7c357cb
parents def2f506 d9ee34df
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -39,15 +39,21 @@ import com.android.wallpaper.R;
import com.android.wallpaper.model.HubSectionController;
import com.android.wallpaper.model.HubSectionController.HubSectionBatterySaverListener;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Section for dark theme toggle that controls if this section will be shown visually
 */
public class ModeSection implements HubSectionController<ModeSectionView>, LifecycleObserver,
        HubSectionBatterySaverListener {

    private final Lifecycle mLifecycle;
    private final BatterySaverStateReceiver mBatterySaverStateReceiver;

    private static ExecutorService sExecutorService = Executors.newSingleThreadExecutor();

    private Context mContext;
    private Lifecycle mLifecycle;
    private BatterySaverStateReceiver mBatterySaverStateReceiver;
    private ModeSectionView mModeSectionView;

    public ModeSection(Context context, Lifecycle lifecycle) {
@@ -60,18 +66,23 @@ public class ModeSection implements HubSectionController<ModeSectionView>, Lifec
    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    @MainThread
    public void onStart() {
        if (mContext != null) {
        sExecutorService.submit(() -> {
            if (mContext != null && mLifecycle.getCurrentState().isAtLeast(
                    Lifecycle.State.STARTED)) {
                mContext.registerReceiver(mBatterySaverStateReceiver,
                        new IntentFilter(ACTION_POWER_SAVE_MODE_CHANGED));
            }
        });
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    @MainThread
    public void onStop() {
        sExecutorService.submit(() -> {
            if (mContext != null && mBatterySaverStateReceiver != null) {
                mContext.unregisterReceiver(mBatterySaverStateReceiver);
            }
        });
    }

    @Override
+10 −2
Original line number Diff line number Diff line
@@ -25,12 +25,17 @@ import com.android.wallpaper.R;
import com.android.wallpaper.model.HubSectionController;
import com.android.wallpaper.model.WorkspaceViewModel;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/** The {@link HubSectionController} for themed icon section. */
public class ThemedIconSectionController implements HubSectionController<ThemedIconSectionView> {

    private final ThemedIconSwitchProvider mThemedIconOptionsProvider;
    private final WorkspaceViewModel mWorkspaceViewModel;

    private static ExecutorService sExecutorService = Executors.newSingleThreadExecutor();

    public ThemedIconSectionController(ThemedIconSwitchProvider themedIconOptionsProvider,
            WorkspaceViewModel workspaceViewModel) {
        mThemedIconOptionsProvider = themedIconOptionsProvider;
@@ -48,8 +53,11 @@ public class ThemedIconSectionController implements HubSectionController<ThemedI
                (ThemedIconSectionView) LayoutInflater.from(context).inflate(
                        R.layout.themed_icon_section_view, /* root= */ null);
        themedIconColorSectionView.setViewListener(this::onViewActivated);
        themedIconColorSectionView.getSwitch()
                .setChecked(mThemedIconOptionsProvider.fetchThemedIconEnabled());
        sExecutorService.submit(() -> {
            boolean themedIconEnabled = mThemedIconOptionsProvider.fetchThemedIconEnabled();
            themedIconColorSectionView.post(() ->
                    themedIconColorSectionView.getSwitch().setChecked(themedIconEnabled));
        });
        return themedIconColorSectionView;
    }

+2 −1
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ public final class ModeSectionView extends SectionView {
        switchView.setOnCheckedChangeListener((buttonView, isChecked) ->
                switchView.setChecked(mIsDarkModeActivated)
        );
        setOnClickListener(view -> modeToggleClicked());
        setOnClickListener(
                view -> switchView.postDelayed(() -> modeToggleClicked(), /* delayMillis= */ 100));
    }

    private void modeToggleClicked() {