diff options
author | George Lin <giolin@google.com> | 2023-11-17 19:07:57 +0000 |
---|---|---|
committer | George Lin <giolin@google.com> | 2023-11-17 19:07:57 +0000 |
commit | a643bee181d4bdc9eb2afb407dad31dde303e6c4 (patch) | |
tree | 0d38fe6f8182997d329048d98c2bbbaaafa366b1 | |
parent | eef444cf57676751eabccba7d84b42f2f23e3685 (diff) | |
download | ThemePicker-a643bee181d4bdc9eb2afb407dad31dde303e6c4.tar.gz |
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
-rw-r--r-- | src/com/android/customization/model/themedicon/ThemedIconSectionController.java | 1 | ||||
-rw-r--r-- | src/com/android/customization/picker/themedicon/ThemedIconSectionView.java | 14 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java index 6c738c70..be7da042 100644 --- a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java +++ b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java @@ -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> { diff --git a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java index 3e03a41c..f83da8c1 100644 --- a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java +++ b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java @@ -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); - } - } } |