sm8350-common: parts: Migrate to CompoundButton.OnCheckedChangeListener

Switch and SwitchCompat are both CompoundButton.

Using CompoundButton in Java will helps migration in the future.

Bug: 306658427
Test: manual - check Settings pages
Test: m RunSettingsLibRoboTests
Change-Id: I85a70d4c504d8584030ea4a058f30d74206ab835
This commit is contained in:
Chaohui Wang 2023-10-24 23:47:35 +08:00 committed by zaidkhan0997
parent 0c19cc9d4b
commit 45e0f630d9
Signed by: zaidkhan0997
GPG Key ID: 6C50557AD547C980

View File

@ -26,7 +26,8 @@ import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.widget.Switch; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener; import androidx.preference.Preference.OnPreferenceChangeListener;
@ -35,13 +36,12 @@ import androidx.preference.PreferenceFragment;
import androidx.preference.SwitchPreference; import androidx.preference.SwitchPreference;
import com.android.settingslib.widget.MainSwitchPreference; import com.android.settingslib.widget.MainSwitchPreference;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
import org.lineageos.settings.R; import org.lineageos.settings.R;
import org.lineageos.settings.utils.FileUtils; import org.lineageos.settings.utils.FileUtils;
public class DozeSettingsFragment extends PreferenceFragment public class DozeSettingsFragment extends PreferenceFragment
implements OnPreferenceChangeListener, OnMainSwitchChangeListener { implements OnPreferenceChangeListener, OnCheckedChangeListener {
private MainSwitchPreference mSwitchBar; private MainSwitchPreference mSwitchBar;
private SwitchPreference mAlwaysOnDisplayPreference; private SwitchPreference mAlwaysOnDisplayPreference;
@ -112,7 +112,7 @@ public class DozeSettingsFragment extends PreferenceFragment
} }
@Override @Override
public void onSwitchChanged(Switch switchView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
DozeUtils.enableDoze(getActivity(), isChecked); DozeUtils.enableDoze(getActivity(), isChecked);
DozeUtils.checkDozeService(getActivity()); DozeUtils.checkDozeService(getActivity());