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
Change-Id: If2e08a9a9557ec66a3b31ef18cd2e15943098a59
This commit is contained in:
Chaohui Wang
2023-10-24 23:48:10 +08:00
parent 86bf501829
commit 71d1f021af
49 changed files with 174 additions and 188 deletions

View File

@@ -21,7 +21,6 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Switch;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.RestrictedLockUtils;
@@ -39,10 +38,9 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
public interface OnBeforeCheckedChangeListener {
/**
* @param switchView The Switch view whose state has changed.
* @param isChecked The new checked state of switchView.
* @param isChecked The new checked state of switchView.
*/
boolean onBeforeCheckedChanged(Switch switchView, boolean isChecked);
boolean onBeforeCheckedChanged(boolean isChecked);
}
private EnforcedAdmin mEnforcedAdmin;
@@ -117,7 +115,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
@Override
public void setChecked(boolean checked) {
if (mOnBeforeListener != null
&& mOnBeforeListener.onBeforeCheckedChanged(mSwitch, checked)) {
&& mOnBeforeListener.onBeforeCheckedChanged(checked)) {
return;
}
super.setChecked(checked);