From 8fd19f2d7c9b4bc6242fb4e47aace82cf9a8bc27 Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Fri, 8 Mar 2024 15:24:40 +0530 Subject: [PATCH] samsung: Migrate to CompoundButton.OnCheckedChangeListener Switch and SwitchCompat are both CompoundButton. Using CompoundButton in Java will helps migration in the future. Bug: 306658427 | AOSP Test: manual - check Settings pages Test: m RunSettingsLibRoboTests Signed-off-by: RisenID Change-Id: I85a70d4c504d8584030ea4a058f30d74206ab835 --- dap/src/org/lineageos/dap/DolbyFragment.kt | 8 ++++---- .../org/lineageos/settings/doze/SamsungDozeSettings.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dap/src/org/lineageos/dap/DolbyFragment.kt b/dap/src/org/lineageos/dap/DolbyFragment.kt index 2331b65f..29834343 100644 --- a/dap/src/org/lineageos/dap/DolbyFragment.kt +++ b/dap/src/org/lineageos/dap/DolbyFragment.kt @@ -17,17 +17,17 @@ package org.lineageos.dap import android.os.Bundle -import android.widget.Switch +import android.widget.CompoundButton +import android.widget.CompoundButton.OnCheckedChangeListener import androidx.preference.PreferenceFragment import com.android.settingslib.widget.MainSwitchPreference -import com.android.settingslib.widget.OnMainSwitchChangeListener import com.android.settingslib.widget.RadioButtonPreference import org.lineageos.dap.R -class DolbyFragment : PreferenceFragment(), OnMainSwitchChangeListener { +class DolbyFragment : PreferenceFragment(), OnCheckedChangeListener { private lateinit var switchBar: MainSwitchPreference @@ -47,7 +47,7 @@ class DolbyFragment : PreferenceFragment(), OnMainSwitchChangeListener { } } - override fun onSwitchChanged(switchView: Switch, isChecked: Boolean) { + override fun onCheckedChanged(buttonView: CompoundButton, isChecked: Boolean) { DolbyCore.setEnabled(isChecked) } diff --git a/doze/src/org/lineageos/settings/doze/SamsungDozeSettings.java b/doze/src/org/lineageos/settings/doze/SamsungDozeSettings.java index f0f9b525..0bc7fb84 100644 --- a/doze/src/org/lineageos/settings/doze/SamsungDozeSettings.java +++ b/doze/src/org/lineageos/settings/doze/SamsungDozeSettings.java @@ -19,7 +19,8 @@ package org.lineageos.settings.doze; import android.os.Bundle; import android.os.Handler; -import android.widget.Switch; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; import androidx.preference.Preference; import androidx.preference.Preference.OnPreferenceChangeListener; @@ -27,12 +28,11 @@ import androidx.preference.PreferenceFragment; import androidx.preference.SwitchPreference; import com.android.settingslib.widget.MainSwitchPreference; -import com.android.settingslib.widget.OnMainSwitchChangeListener; import org.lineageos.internal.util.ScreenType; public class SamsungDozeSettings extends PreferenceFragment - implements OnPreferenceChangeListener, OnMainSwitchChangeListener { + implements OnPreferenceChangeListener, OnCheckedChangeListener { private MainSwitchPreference mSwitchBar; @@ -108,7 +108,7 @@ public class SamsungDozeSettings extends PreferenceFragment } @Override - public void onSwitchChanged(Switch switchView, boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Utils.enableDoze(getActivity(), isChecked); Utils.checkDozeService(getActivity());