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

@@ -27,7 +27,8 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.widget.Switch;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
@@ -45,13 +46,12 @@ import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.FooterPreference;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
/**
* Screen pinning settings.
*/
@SearchIndexable
public class ScreenPinningSettings extends SettingsPreferenceFragment
implements OnMainSwitchChangeListener, DialogInterface.OnClickListener {
implements OnCheckedChangeListener, DialogInterface.OnClickListener {
private static final String KEY_USE_SCREEN_LOCK = "use_screen_lock";
private static final String KEY_FOOTER = "screen_pinning_settings_screen_footer";
@@ -198,7 +198,7 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
* Listens to the state change of the overall lock-to-app switch.
*/
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
new AlertDialog.Builder(getContext())
.setMessage(R.string.screen_pinning_dialog_message)