Migrate to TwoStatePreference

SwitchPreference and SwitchPreferenceCompat are both TwoStatePreference.

Using TwoStatePreference in Java will helps migration in the future.

Bug: 306771414
Test: manual - check Settings pages
Change-Id: I84e1d7b09451106797c2b23d127855c6976678ca
This commit is contained in:
Chaohui Wang
2023-10-23 12:38:18 +08:00
parent 7976f1e76d
commit 15ca95a31b
141 changed files with 391 additions and 395 deletions

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -51,7 +51,7 @@ public class AdbAuthorizationTimeoutPreferenceController extends
Settings.Global.DEFAULT_ADB_ALLOWED_CONNECTION_TIME);
// An authTimeout of 0 indicates this preference is enabled and adb authorizations will not
// be automatically revoked.
((SwitchPreference) mPreference).setChecked(authTimeout == 0);
((TwoStatePreference) mPreference).setChecked(authTimeout == 0);
}
@Override
@@ -64,7 +64,7 @@ public class AdbAuthorizationTimeoutPreferenceController extends
public void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeSetting(false);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
private void writeSetting(boolean isEnabled) {