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

Commit a643bee1 authored by George Lin's avatar George Lin
Browse files

Fix multiple logs of THEMED_ICON_APPLIED

This is due to wrongly listening to the toggle changes for setting the
themed icon. There are casese that the toggle can be set
programmatically and that will also trigger the logging which is not
expcted.

This CL only make sure it logs only when user click events.

Test: Manually tested the logs
Bug: 311704566
Flag: None
Change-Id: I67e2d3eb4bf85d69aa552837b4520bc87322bc9e
parent eef444cf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.customization.picker.themedicon.ThemedIconSectionView;
import com.android.wallpaper.R;
import com.android.wallpaper.model.CustomizationSectionController;

// TODO (b/311712452): Refactor CustomizationSectionController to use recommended arch UI components
/** The {@link CustomizationSectionController} for themed icon section. */
public class ThemedIconSectionController implements
        CustomizationSectionController<ThemedIconSectionView> {
+6 −8
Original line number Diff line number Diff line
@@ -40,18 +40,16 @@ public class ThemedIconSectionView extends SectionView {
    protected void onFinishInflate() {
        super.onFinishInflate();
        mSwitchView = findViewById(R.id.themed_icon_toggle);
        setOnClickListener(v -> mSwitchView.toggle());
        mSwitchView.setOnCheckedChangeListener((buttonView, isChecked) -> viewActivated(isChecked));
        setOnClickListener(v -> {
            mSwitchView.toggle();
            if (mSectionViewListener != null) {
                mSectionViewListener.onViewActivated(getContext(), mSwitchView.isChecked());
            }
        });
    }

    /** Gets the switch view. */
    public Switch getSwitch() {
        return mSwitchView;
    }

    private void viewActivated(boolean isChecked) {
        if (mSectionViewListener != null) {
            mSectionViewListener.onViewActivated(getContext(), isChecked);
        }
    }
}