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:
@@ -7,7 +7,7 @@ import android.os.UserManager;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
@@ -63,7 +63,7 @@ public class LocalTerminalPreferenceController extends DeveloperOptionsPreferenc
|
||||
public void updateState(Preference preference) {
|
||||
final boolean isTerminalEnabled = mPackageManager.getApplicationEnabledSetting(
|
||||
TERMINAL_APP_PACKAGE) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
|
||||
((SwitchPreference) mPreference).setChecked(isTerminalEnabled);
|
||||
((TwoStatePreference) mPreference).setChecked(isTerminalEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +78,7 @@ public class LocalTerminalPreferenceController extends DeveloperOptionsPreferenc
|
||||
super.onDeveloperOptionsSwitchDisabled();
|
||||
mPackageManager.setApplicationEnabledSetting(TERMINAL_APP_PACKAGE,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0 /* flags */);
|
||||
((SwitchPreference) mPreference).setChecked(false);
|
||||
((TwoStatePreference) mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
Reference in New Issue
Block a user