Snap for 13190096 from c847dc7e0e to 25Q2-release

Change-Id: Iac3bcc01420bf43f3b967b3ce77d984a741fbe55
This commit is contained in:
Android Build Coastguard Worker
2025-03-10 16:21:25 -07:00
29 changed files with 157 additions and 186 deletions

View File

@@ -16,7 +16,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:theme="@style/Theme.Material3.DynamicColors.DayNight" android:theme="@style/Theme.Network"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@@ -49,13 +49,12 @@
android:visibility="gone"> android:visibility="gone">
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/vpn_label" style="@style/vpn_input_label"
android:id="@+id/name_layout" android:id="@+id/name_layout"
android:hint="@string/vpn_name" android:hint="@string/vpn_name"
app:endIconMode="clear_text" app:endIconMode="clear_text"
app:helperTextEnabled="true" app:helperTextEnabled="true"
app:helperText="@string/vpn_required" app:helperText="@string/vpn_field_required">
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/vpn_value" style="@style/vpn_value"
android:id="@+id/name" android:id="@+id/name"
@@ -71,13 +70,12 @@
android:entries="@array/vpn_types"/> android:entries="@array/vpn_types"/>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/vpn_label" style="@style/vpn_input_label"
android:id="@+id/server_layout" android:id="@+id/server_layout"
android:hint="@string/vpn_server" android:hint="@string/vpn_server"
app:endIconMode="clear_text" app:endIconMode="clear_text"
app:helperTextEnabled="true" app:helperTextEnabled="true"
app:helperText="@string/vpn_required" app:helperText="@string/vpn_field_required">
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/vpn_value" style="@style/vpn_value"
android:id="@+id/server"/> android:id="@+id/server"/>
@@ -89,13 +87,12 @@
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone"> android:visibility="gone">
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/vpn_label" style="@style/vpn_input_label"
android:id="@+id/ipsec_identifier_layout" android:id="@+id/ipsec_identifier_layout"
android:hint="@string/vpn_ipsec_identifier" android:hint="@string/vpn_ipsec_identifier"
app:endIconMode="clear_text" app:endIconMode="clear_text"
app:helperTextEnabled="true" app:helperTextEnabled="true"
app:helperText="@string/vpn_required" app:helperText="@string/vpn_field_required">
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/vpn_value" style="@style/vpn_value"
android:id="@+id/ipsec_identifier"/> android:id="@+id/ipsec_identifier"/>
@@ -108,13 +105,12 @@
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone"> android:visibility="gone">
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/vpn_label" style="@style/vpn_input_label"
android:id="@+id/ipsec_secret_layout" android:id="@+id/ipsec_secret_layout"
android:hint="@string/vpn_ipsec_secret" android:hint="@string/vpn_ipsec_secret"
app:endIconMode="password_toggle" app:endIconMode="password_toggle"
app:helperTextEnabled="true" app:helperTextEnabled="true"
app:helperText="@string/vpn_required" app:helperText="@string/vpn_field_required">
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/vpn_value" style="@style/vpn_value"
android:id="@+id/ipsec_secret" android:id="@+id/ipsec_secret"
@@ -184,13 +180,10 @@
android:visibility="gone" > android:visibility="gone" >
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/vpn_label" style="@style/vpn_input_label"
android:id="@+id/vpn_proxy_host_layout" android:id="@+id/vpn_proxy_host_layout"
android:hint="@string/proxy_hostname_label" android:hint="@string/proxy_hostname_label"
app:endIconMode="clear_text" app:endIconMode="clear_text">
app:helperTextEnabled="true"
app:helperText="@string/vpn_optional"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/vpn_value" style="@style/vpn_value"
android:id="@+id/vpn_proxy_host" android:id="@+id/vpn_proxy_host"
@@ -198,13 +191,10 @@
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/vpn_label" style="@style/vpn_input_label"
android:id="@+id/vpn_proxy_port_layout" android:id="@+id/vpn_proxy_port_layout"
android:hint="@string/proxy_port_label" android:hint="@string/proxy_port_label"
app:endIconMode="clear_text" app:endIconMode="clear_text">
app:helperTextEnabled="true"
app:helperText="@string/vpn_optional"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/vpn_value" style="@style/vpn_value"
android:id="@+id/vpn_proxy_port" android:id="@+id/vpn_proxy_port"
@@ -219,26 +209,20 @@
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/vpn_label" style="@style/vpn_input_label"
android:id="@+id/username_layout" android:id="@+id/username_layout"
android:hint="@string/vpn_username" android:hint="@string/vpn_username_optional"
app:endIconMode="clear_text" app:endIconMode="clear_text">
app:helperTextEnabled="true"
app:helperText="@string/vpn_optional"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/vpn_value" style="@style/vpn_value"
android:id="@+id/username"/> android:id="@+id/username"/>
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/vpn_label" style="@style/vpn_input_label"
android:id="@+id/password_layout" android:id="@+id/password_layout"
android:hint="@string/vpn_password" android:hint="@string/vpn_password_optional"
app:endIconMode="password_toggle" app:endIconMode="password_toggle">
app:helperTextEnabled="true"
app:helperText="@string/vpn_optional"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
style="@style/vpn_value" style="@style/vpn_value"
android:id="@+id/password" android:id="@+id/password"

View File

@@ -364,7 +364,7 @@
<!-- HTTP proxy settings. Button to clear the proxy box. --> <!-- HTTP proxy settings. Button to clear the proxy box. -->
<string name="proxy_clear_text">Clear</string> <string name="proxy_clear_text">Clear</string>
<!-- HTTP proxy settings. The port number label. --> <!-- HTTP proxy settings. The port number label. -->
<string name="proxy_port_label">Proxy port</string> <string name="proxy_port_label">Proxy port (optional)</string>
<!-- HTTP proxy settings. The exclusion list label. --> <!-- HTTP proxy settings. The exclusion list label. -->
<string name="proxy_exclusionlist_label">Bypass proxy for</string> <string name="proxy_exclusionlist_label">Bypass proxy for</string>
<!-- HTTP proxy settings. The button to restore the defaults. --> <!-- HTTP proxy settings. The button to restore the defaults. -->
@@ -372,7 +372,7 @@
<!-- HTTP proxy settings. The button to save. --> <!-- HTTP proxy settings. The button to save. -->
<string name="proxy_action_text">Done</string> <string name="proxy_action_text">Done</string>
<!-- HTTP proxy settings. The text field for the hostname --> <!-- HTTP proxy settings. The text field for the hostname -->
<string name="proxy_hostname_label">Proxy hostname</string> <string name="proxy_hostname_label">Proxy hostname (optional)</string>
<!-- HTTP proxy settings. Title if there is an error--> <!-- HTTP proxy settings. Title if there is an error-->
<string name="proxy_error">Attention</string> <string name="proxy_error">Attention</string>
<!-- HTTP proxy settings. Button to get rid of error box--> <!-- HTTP proxy settings. Button to get rid of error box-->
@@ -7262,15 +7262,15 @@ Data usage charges may apply.</string>
<string name="data_usage_metered_yes">Metered</string> <string name="data_usage_metered_yes">Metered</string>
<!-- Input label for the name of a VPN profile. [CHAR LIMIT=40] --> <!-- Input label for the name of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_name">Name</string> <string name="vpn_name">Name*</string>
<!-- Input label for the type of a VPN profile. [CHAR LIMIT=40] --> <!-- Input label for the type of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_type">Type</string> <string name="vpn_type">Type</string>
<!-- Input label for the server address of a VPN profile. [CHAR LIMIT=40] --> <!-- Input label for the server address of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_server">Server address</string> <string name="vpn_server">Server address*</string>
<!-- Input label for the IPSec identifier of a VPN profile. [CHAR LIMIT=40] --> <!-- Input label for the IPSec identifier of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_ipsec_identifier">IPSec identifier</string> <string name="vpn_ipsec_identifier">IPSec identifier*</string>
<!-- Input label for the IPSec pre-shared key of a VPN profile. [CHAR LIMIT=40] --> <!-- Input label for the IPSec pre-shared key of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_ipsec_secret">IPSec pre-shared key</string> <string name="vpn_ipsec_secret">IPSec pre-shared key*</string>
<!-- Selection label for the IPSec user certificate of a VPN profile. [CHAR LIMIT=40] --> <!-- Selection label for the IPSec user certificate of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_ipsec_user_cert">IPSec user certificate</string> <string name="vpn_ipsec_user_cert">IPSec user certificate</string>
<!-- Selection label for the IPSec CA certificate of a VPN profile. [CHAR LIMIT=40] --> <!-- Selection label for the IPSec CA certificate of a VPN profile. [CHAR LIMIT=40] -->
@@ -7279,10 +7279,14 @@ Data usage charges may apply.</string>
<string name="vpn_ipsec_server_cert">IPSec server certificate</string> <string name="vpn_ipsec_server_cert">IPSec server certificate</string>
<!-- Checkbox label to show advanced options of a VPN profile. [CHAR LIMIT=40] --> <!-- Checkbox label to show advanced options of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_show_options">Show advanced options</string> <string name="vpn_show_options">Show advanced options</string>
<!-- Input label for the username of a VPN profile. [CHAR LIMIT=40] --> <!-- Input label for the optional username of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_username">Username</string> <string name="vpn_username_optional">Username (optional)</string>
<!-- Input label for the password of a VPN profile. [CHAR LIMIT=40] --> <!-- Input label for the optional password of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_password">Password</string> <string name="vpn_password_optional">Password (optional)</string>
<!-- Input label for the required username of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_username_required">Username*</string>
<!-- Input label for the required password of a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_password_required">Password*</string>
<!-- Checkbox label to save the username and the password in a VPN profile. [CHAR LIMIT=40] --> <!-- Checkbox label to save the username and the password in a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_save_login">Save account information</string> <string name="vpn_save_login">Save account information</string>
<!-- Hint for not using an optional feature in a VPN profile. [CHAR LIMIT=40] --> <!-- Hint for not using an optional feature in a VPN profile. [CHAR LIMIT=40] -->
@@ -7295,12 +7299,9 @@ Data usage charges may apply.</string>
generic error. [CHAR LIMIT=120] --> generic error. [CHAR LIMIT=120] -->
<string name="vpn_always_on_invalid_reason_other">The information entered doesn\'t support <string name="vpn_always_on_invalid_reason_other">The information entered doesn\'t support
always-on VPN</string> always-on VPN</string>
<!-- Hint for an optional field in a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_optional">(optional)</string>
<!-- Hint for a required field in a VPN profile. [CHAR LIMIT=40] --> <!-- Hint for a required field in a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_required">(required)</string>
<!-- Error message displayed below the VPN EditText when the filed is required. [CHAR LIMIT=NONE] --> <!-- Error message displayed below the VPN EditText when the filed is required. [CHAR LIMIT=NONE] -->
<string name="vpn_field_required">The field is required</string> <string name="vpn_field_required">*required</string>
<!-- Button label to cancel changing a VPN profile. [CHAR LIMIT=40] --> <!-- Button label to cancel changing a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_cancel">Cancel</string> <string name="vpn_cancel">Cancel</string>

View File

@@ -207,6 +207,10 @@
<item name="android:textColorHint">?android:attr/textColorSecondary</item> <item name="android:textColorHint">?android:attr/textColorSecondary</item>
</style> </style>
<style name="vpn_input_label" parent="vpn_label">
<item name="android:paddingBottom">8dp</item>
</style>
<style name="vpn_warning"> <style name="vpn_warning">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>

View File

@@ -28,8 +28,13 @@ import android.os.VibrationAttributes;
import android.os.Vibrator; import android.os.Vibrator;
import android.provider.Settings; import android.provider.Settings;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart; import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop; import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -42,11 +47,12 @@ import com.android.settingslib.core.lifecycle.events.OnStop;
* be disabled by this setting, except the flagged alerts and accessibility touch feedback. * be disabled by this setting, except the flagged alerts and accessibility touch feedback.
*/ */
// LINT.IfChange // LINT.IfChange
public class VibrationMainSwitchPreferenceController extends SettingsMainSwitchPreferenceController public class VibrationMainSwitchPreferenceController extends TogglePreferenceController
implements LifecycleObserver, OnStart, OnStop { implements LifecycleObserver, OnStart, OnStop {
private final ContentObserver mSettingObserver; private final ContentObserver mSettingObserver;
private final Vibrator mVibrator; private final Vibrator mVibrator;
private @Nullable Preference mPreference;
public VibrationMainSwitchPreferenceController(Context context, String preferenceKey) { public VibrationMainSwitchPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
@@ -55,7 +61,9 @@ public class VibrationMainSwitchPreferenceController extends SettingsMainSwitchP
mSettingObserver = new ContentObserver(handler) { mSettingObserver = new ContentObserver(handler) {
@Override @Override
public void onChange(boolean selfChange, Uri uri) { public void onChange(boolean selfChange, Uri uri) {
updateState(mSwitchPreference); if (mPreference != null) {
updateState(mPreference);
}
} }
}; };
} }
@@ -65,6 +73,12 @@ public class VibrationMainSwitchPreferenceController extends SettingsMainSwitchP
return AVAILABLE; return AVAILABLE;
} }
@Override
public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}
@Override @Override
public void onStart() { public void onStart() {
mContext.getContentResolver().registerContentObserver( mContext.getContentResolver().registerContentObserver(

View File

@@ -21,8 +21,6 @@ import android.os.UserManager
import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE
import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC
import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL import android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL
import androidx.preference.Preference
import androidx.preference.PreferenceScreen
import com.android.settings.R import com.android.settings.R
import com.android.settings.contract.KEY_ADAPTIVE_BRIGHTNESS import com.android.settings.contract.KEY_ADAPTIVE_BRIGHTNESS
import com.android.settings.flags.Flags import com.android.settings.flags.Flags
@@ -37,19 +35,16 @@ import com.android.settingslib.datastore.SettingsStore
import com.android.settingslib.datastore.SettingsSystemStore import com.android.settingslib.datastore.SettingsSystemStore
import com.android.settingslib.metadata.BooleanValuePreference import com.android.settingslib.metadata.BooleanValuePreference
import com.android.settingslib.metadata.PreferenceAvailabilityProvider import com.android.settingslib.metadata.PreferenceAvailabilityProvider
import com.android.settingslib.metadata.PreferenceMetadata
import com.android.settingslib.metadata.ProvidePreferenceScreen import com.android.settingslib.metadata.ProvidePreferenceScreen
import com.android.settingslib.metadata.ReadWritePermit import com.android.settingslib.metadata.ReadWritePermit
import com.android.settingslib.metadata.SensitivityLevel import com.android.settingslib.metadata.SensitivityLevel
import com.android.settingslib.metadata.preferenceHierarchy import com.android.settingslib.metadata.preferenceHierarchy
import com.android.settingslib.preference.PreferenceScreenBinding
import com.android.settingslib.preference.PreferenceScreenCreator import com.android.settingslib.preference.PreferenceScreenCreator
@ProvidePreferenceScreen(AutoBrightnessScreen.KEY) @ProvidePreferenceScreen(AutoBrightnessScreen.KEY)
class AutoBrightnessScreen : class AutoBrightnessScreen :
PreferenceScreenCreator, PreferenceScreenCreator,
PreferenceScreenBinding, // binding for screen page PrimarySwitchPreferenceBinding,
PrimarySwitchPreferenceBinding, // binding for screen entry point widget
PreferenceActionMetricsProvider, PreferenceActionMetricsProvider,
PreferenceAvailabilityProvider, PreferenceAvailabilityProvider,
PreferenceRestrictionMixin, PreferenceRestrictionMixin,
@@ -106,12 +101,6 @@ class AutoBrightnessScreen :
override val useAdminDisabledSummary: Boolean override val useAdminDisabledSummary: Boolean
get() = true get() = true
override fun bind(preference: Preference, metadata: PreferenceMetadata) =
when (preference) {
is PreferenceScreen -> super<PreferenceScreenBinding>.bind(preference, metadata)
else -> super<PrimarySwitchPreferenceBinding>.bind(preference, metadata)
}
/** /**
* The datastore for brightness, which is persisted as integer but the external type is boolean. * The datastore for brightness, which is persisted as integer but the external type is boolean.
*/ */

View File

@@ -21,7 +21,6 @@ import android.app.settings.SettingsEnums.ACTION_DARK_THEME
import android.content.Context import android.content.Context
import android.os.PowerManager import android.os.PowerManager
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceScreen
import com.android.settings.R import com.android.settings.R
import com.android.settings.contract.KEY_DARK_THEME import com.android.settings.contract.KEY_DARK_THEME
import com.android.settings.flags.Flags import com.android.settings.flags.Flags
@@ -36,15 +35,13 @@ import com.android.settingslib.metadata.ProvidePreferenceScreen
import com.android.settingslib.metadata.ReadWritePermit import com.android.settingslib.metadata.ReadWritePermit
import com.android.settingslib.metadata.SensitivityLevel import com.android.settingslib.metadata.SensitivityLevel
import com.android.settingslib.metadata.preferenceHierarchy import com.android.settingslib.metadata.preferenceHierarchy
import com.android.settingslib.preference.PreferenceScreenBinding
import com.android.settingslib.preference.PreferenceScreenCreator import com.android.settingslib.preference.PreferenceScreenCreator
// LINT.IfChange // LINT.IfChange
@ProvidePreferenceScreen(DarkModeScreen.KEY) @ProvidePreferenceScreen(DarkModeScreen.KEY)
class DarkModeScreen(context: Context) : class DarkModeScreen(context: Context) :
PreferenceScreenCreator, PreferenceScreenCreator,
PreferenceScreenBinding, // binding for screen page PrimarySwitchPreferenceBinding,
PrimarySwitchPreferenceBinding, // binding for screen entry point widget
PreferenceActionMetricsProvider, PreferenceActionMetricsProvider,
BooleanValuePreference, BooleanValuePreference,
PreferenceSummaryProvider { PreferenceSummaryProvider {
@@ -94,11 +91,8 @@ class DarkModeScreen(context: Context) :
override fun storage(context: Context): KeyValueStore = darkModeStorage override fun storage(context: Context): KeyValueStore = darkModeStorage
override fun bind(preference: Preference, metadata: PreferenceMetadata) { override fun bind(preference: Preference, metadata: PreferenceMetadata) {
super.bind(preference, metadata)
if (preference is DarkModePreference) preference.setCatalystEnabled(true) if (preference is DarkModePreference) preference.setCatalystEnabled(true)
when (preference) {
is PreferenceScreen -> super<PreferenceScreenBinding>.bind(preference, metadata)
else -> super<PrimarySwitchPreferenceBinding>.bind(preference, metadata)
}
} }
override fun isEnabled(context: Context) = !context.isPowerSaveMode() override fun isEnabled(context: Context) = !context.isPowerSaveMode()

View File

@@ -27,34 +27,44 @@ import android.os.Looper;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart; import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop; import com.android.settingslib.core.lifecycle.events.OnStop;
/** The controller to handle double tap power button main switch enable or disable state. */ /** The controller to handle double tap power button main switch enable or disable state. */
public class DoubleTapPowerMainSwitchPreferenceController public class DoubleTapPowerMainSwitchPreferenceController
extends SettingsMainSwitchPreferenceController extends TogglePreferenceController
implements LifecycleObserver, OnStart, OnStop { implements LifecycleObserver, OnStart, OnStop {
private final ContentObserver mSettingsObserver = private final ContentObserver mSettingsObserver =
new ContentObserver(new Handler(Looper.getMainLooper())) { new ContentObserver(new Handler(Looper.getMainLooper())) {
@Override @Override
public void onChange(boolean selfChange, @Nullable Uri uri) { public void onChange(boolean selfChange, @Nullable Uri uri) {
if (mSwitchPreference == null || uri == null) { if (mPreference == null || uri == null) {
return; return;
} }
updateState(mSwitchPreference); updateState(mPreference);
} }
}; };
private @Nullable Preference mPreference;
public DoubleTapPowerMainSwitchPreferenceController( public DoubleTapPowerMainSwitchPreferenceController(
@NonNull Context context, @NonNull String preferenceKey) { @NonNull Context context, @NonNull String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
} }
@Override
public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return DoubleTapPowerSettingsUtils return DoubleTapPowerSettingsUtils

View File

@@ -76,6 +76,7 @@ public class AppLocalePickerFragment extends DashboardFragment implements
private static final String TAG = "AppLocalePickerFragment"; private static final String TAG = "AppLocalePickerFragment";
private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view"; private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
private static final String EXTRA_SEARCH_VIEW_QUERY = "search_view_query";
private static final String KEY_PREFERENCE_APP_LOCALE_LIST = "app_locale_list"; private static final String KEY_PREFERENCE_APP_LOCALE_LIST = "app_locale_list";
private static final String KEY_PREFERENCE_APP_LOCALE_SUGGESTED_LIST = private static final String KEY_PREFERENCE_APP_LOCALE_SUGGESTED_LIST =
"app_locale_suggested_list"; "app_locale_suggested_list";
@@ -108,6 +109,7 @@ public class AppLocalePickerFragment extends DashboardFragment implements
@Nullable @Nullable
private ApplicationInfo mApplicationInfo; private ApplicationInfo mApplicationInfo;
private boolean mIsNumberingMode; private boolean mIsNumberingMode;
private CharSequence mPreviousSearch = null;
@Override @Override
public void onCreate(@NonNull Bundle icicle) { public void onCreate(@NonNull Bundle icicle) {
@@ -137,6 +139,7 @@ public class AppLocalePickerFragment extends DashboardFragment implements
mExpandSearch = mActivity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false); mExpandSearch = mActivity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
if (icicle != null) { if (icicle != null) {
mExpandSearch = icicle.getBoolean(EXTRA_EXPAND_SEARCH_VIEW); mExpandSearch = icicle.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
mPreviousSearch = icicle.getCharSequence(EXTRA_SEARCH_VIEW_QUERY);
} }
AppLocaleCollector appLocaleCollector = new AppLocaleCollector(mActivity, mPackageName); AppLocaleCollector appLocaleCollector = new AppLocaleCollector(mActivity, mPackageName);
@@ -163,6 +166,7 @@ public class AppLocalePickerFragment extends DashboardFragment implements
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
if (mSearchView != null) { if (mSearchView != null) {
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified()); outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
outState.putCharSequence(EXTRA_SEARCH_VIEW_QUERY, mSearchView.getQuery());
} }
} }
@@ -181,6 +185,15 @@ public class AppLocalePickerFragment extends DashboardFragment implements
if (mExpandSearch) { if (mExpandSearch) {
searchMenuItem.expandActionView(); searchMenuItem.expandActionView();
} }
// Restore previous search status
if (!TextUtils.isEmpty(mPreviousSearch)) {
searchMenuItem.expandActionView();
mSearchView.setIconified(false);
mSearchView.setActivated(true);
mSearchView.setQuery(mPreviousSearch, true /* submit */);
} else {
mSearchView.setQuery(null, false /* submit */);
}
} }
} }

View File

@@ -69,6 +69,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
private static final String TAG = "SystemLocalePickerFragment"; private static final String TAG = "SystemLocalePickerFragment";
private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view"; private static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
private static final String EXTRA_SEARCH_VIEW_QUERY = "search_view_query";
private static final String KEY_PREFERENCE_SYSTEM_LOCALE_LIST = "system_locale_list"; private static final String KEY_PREFERENCE_SYSTEM_LOCALE_LIST = "system_locale_list";
private static final String KEY_PREFERENCE_SYSTEM_LOCALE_SUGGESTED_LIST = private static final String KEY_PREFERENCE_SYSTEM_LOCALE_SUGGESTED_LIST =
"system_locale_suggested_list"; "system_locale_suggested_list";
@@ -90,6 +91,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
private RecyclerView mRecyclerView; private RecyclerView mRecyclerView;
private Activity mActivity; private Activity mActivity;
private boolean mExpandSearch; private boolean mExpandSearch;
private CharSequence mPreviousSearch = null;
@Override @Override
public void onCreate(@NonNull Bundle icicle) { public void onCreate(@NonNull Bundle icicle) {
@@ -103,6 +105,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
mExpandSearch = mActivity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false); mExpandSearch = mActivity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
if (icicle != null) { if (icicle != null) {
mExpandSearch = icicle.getBoolean(EXTRA_EXPAND_SEARCH_VIEW); mExpandSearch = icicle.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
mPreviousSearch = icicle.getCharSequence(EXTRA_SEARCH_VIEW_QUERY);
} }
SystemLocaleCollector systemLocaleCollector = new SystemLocaleCollector(getContext(), null); SystemLocaleCollector systemLocaleCollector = new SystemLocaleCollector(getContext(), null);
@@ -135,6 +138,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
if (mSearchView != null) { if (mSearchView != null) {
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified()); outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
outState.putCharSequence(EXTRA_SEARCH_VIEW_QUERY, mSearchView.getQuery());
} }
} }
@@ -153,6 +157,15 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
if (mExpandSearch) { if (mExpandSearch) {
searchMenuItem.expandActionView(); searchMenuItem.expandActionView();
} }
// Restore previous search status
if (!TextUtils.isEmpty(mPreviousSearch)) {
searchMenuItem.expandActionView();
mSearchView.setIconified(false);
mSearchView.setActivated(true);
mSearchView.setQuery(mPreviousSearch, true /* submit */);
} else {
mSearchView.setQuery(null, false /* submit */);
}
} }
} }

View File

@@ -23,15 +23,14 @@ import android.provider.Settings;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
/** /**
* {@link SettingsMainSwitchPreferenceController} * {@link TogglePreferenceController}
* that controls whether Adaptive connectivity option is enabled. * that controls whether Adaptive connectivity option is enabled.
*/ */
// LINT.IfChange // LINT.IfChange
public class AdaptiveConnectivityTogglePreferenceController extends public class AdaptiveConnectivityTogglePreferenceController extends TogglePreferenceController {
SettingsMainSwitchPreferenceController {
private final WifiManager mWifiManager; private final WifiManager mWifiManager;

View File

@@ -43,13 +43,13 @@ import com.android.settingslib.metadata.PreferenceMetadata
import com.android.settingslib.metadata.PreferenceSummaryProvider import com.android.settingslib.metadata.PreferenceSummaryProvider
import com.android.settingslib.metadata.ProvidePreferenceScreen import com.android.settingslib.metadata.ProvidePreferenceScreen
import com.android.settingslib.metadata.preferenceHierarchy import com.android.settingslib.metadata.preferenceHierarchy
import com.android.settingslib.preference.PreferenceScreenBinding import com.android.settingslib.preference.PreferenceBinding
import com.android.settingslib.preference.PreferenceScreenCreator import com.android.settingslib.preference.PreferenceScreenCreator
@ProvidePreferenceScreen(MobileNetworkListScreen.KEY) @ProvidePreferenceScreen(MobileNetworkListScreen.KEY)
class MobileNetworkListScreen : class MobileNetworkListScreen :
PreferenceScreenCreator, PreferenceScreenCreator,
PreferenceScreenBinding, PreferenceBinding,
PreferenceAvailabilityProvider, PreferenceAvailabilityProvider,
PreferenceSummaryProvider, PreferenceSummaryProvider,
PreferenceLifecycleProvider, PreferenceLifecycleProvider,

View File

@@ -25,10 +25,12 @@ import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.provider.Settings; import android.provider.Settings;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnPause; import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume; import com.android.settingslib.core.lifecycle.events.OnResume;
@@ -38,10 +40,11 @@ import com.android.settingslib.core.lifecycle.events.OnResume;
* Allows user to turn bubbles on or off for the device. * Allows user to turn bubbles on or off for the device.
*/ */
public class BubbleNotificationPreferenceController extends public class BubbleNotificationPreferenceController extends
SettingsMainSwitchPreferenceController implements LifecycleObserver, OnResume, OnPause { TogglePreferenceController implements LifecycleObserver, OnResume, OnPause {
private static final String TAG = "BubbleNotifPrefContr"; private static final String TAG = "BubbleNotifPrefContr";
private @Nullable Preference mPreference;
private SettingObserver mSettingObserver; private SettingObserver mSettingObserver;
public BubbleNotificationPreferenceController(Context context, String preferenceKey) { public BubbleNotificationPreferenceController(Context context, String preferenceKey) {
@@ -49,10 +52,11 @@ public class BubbleNotificationPreferenceController extends
} }
@Override @Override
public void displayPreference(PreferenceScreen screen) { public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
if (mSwitchPreference != null) { mPreference = screen.findPreference(getPreferenceKey());
mSettingObserver = new SettingObserver(mSwitchPreference); if (mPreference != null) {
mSettingObserver = new SettingObserver(mPreference);
} }
} }

View File

@@ -21,10 +21,9 @@ import android.content.Context;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
public class BundleGlobalPreferenceController extends public class BundleGlobalPreferenceController extends TogglePreferenceController {
SettingsMainSwitchPreferenceController {
NotificationBackend mBackend; NotificationBackend mBackend;

View File

@@ -22,10 +22,9 @@ import android.service.notification.Adjustment;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
public class BundleTypePreferenceController extends public class BundleTypePreferenceController extends TogglePreferenceController {
SettingsMainSwitchPreferenceController {
static final String PROMO_KEY = "promotions"; static final String PROMO_KEY = "promotions";
static final String NEWS_KEY = "news"; static final String NEWS_KEY = "news";

View File

@@ -33,10 +33,10 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.server.notification.Flags; import com.android.server.notification.Flags;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
public class LockScreenNotificationsGlobalPreferenceController public class LockScreenNotificationsGlobalPreferenceController
extends SettingsMainSwitchPreferenceController extends TogglePreferenceController
implements LifecycleEventObserver { implements LifecycleEventObserver {
public static final int ON = 1; public static final int ON = 1;

View File

@@ -22,10 +22,9 @@ import android.provider.Settings;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.android.server.notification.Flags; import com.android.server.notification.Flags;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
public class PoliteNotificationGlobalPreferenceController extends public class PoliteNotificationGlobalPreferenceController extends TogglePreferenceController {
SettingsMainSwitchPreferenceController {
public static final int ON = 1; public static final int ON = 1;
public static final int OFF = 0; public static final int OFF = 0;

View File

@@ -21,10 +21,9 @@ import android.content.Context;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.android.settings.widget.SettingsMainSwitchPreferenceController; import com.android.settings.core.TogglePreferenceController;
public class SummarizationGlobalPreferenceController extends public class SummarizationGlobalPreferenceController extends TogglePreferenceController {
SettingsMainSwitchPreferenceController {
NotificationBackend mBackend; NotificationBackend mBackend;

View File

@@ -76,7 +76,6 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
private TextInputGroup mServerInput; private TextInputGroup mServerInput;
private TextInputGroup mUsernameInput; private TextInputGroup mUsernameInput;
private TextInputGroup mPasswordInput; private TextInputGroup mPasswordInput;
private TextView mPassword;
private Spinner mProxySettings; private Spinner mProxySettings;
private TextView mProxyHost; private TextView mProxyHost;
private TextView mProxyPort; private TextView mProxyPort;
@@ -211,8 +210,10 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
setTitle(context.getString(R.string.vpn_connect_to, mProfile.name)); setTitle(context.getString(R.string.vpn_connect_to, mProfile.name));
setUsernamePasswordVisibility(mProfile.type); setUsernamePasswordVisibility(mProfile.type);
mUsernameInput.setHelperText(context.getString(R.string.vpn_required)); mUsernameInput.setLabel(context.getString(R.string.vpn_username_required));
mPasswordInput.setHelperText(context.getString(R.string.vpn_required)); mUsernameInput.setHelperText(context.getString(R.string.vpn_field_required));
mPasswordInput.setLabel(context.getString(R.string.vpn_password_required));
mPasswordInput.setHelperText(context.getString(R.string.vpn_field_required));
// Create a button to connect the network. // Create a button to connect the network.
setButton(DialogInterface.BUTTON_POSITIVE, setButton(DialogInterface.BUTTON_POSITIVE,

View File

@@ -19,6 +19,7 @@ package com.android.settings.widget
import android.content.Context import android.content.Context
import androidx.preference.Preference import androidx.preference.Preference
import com.android.settingslib.metadata.PreferenceMetadata import com.android.settingslib.metadata.PreferenceMetadata
import com.android.settingslib.metadata.getPreferenceTitle
import com.android.settingslib.preference.PreferenceBinding import com.android.settingslib.preference.PreferenceBinding
import com.android.settingslib.widget.FooterPreference import com.android.settingslib.widget.FooterPreference
import com.android.settingslib.widget.preference.footer.R import com.android.settingslib.widget.preference.footer.R

View File

@@ -1,59 +0,0 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.widget;
import android.content.Context;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.widget.MainSwitchPreference;
/**
* Preference controller for MainSwitchPreference.
*
* @deprecated Use {@link TogglePreferenceController} directly
*/
@Deprecated
public abstract class SettingsMainSwitchPreferenceController extends
TogglePreferenceController implements OnCheckedChangeListener {
protected MainSwitchPreference mSwitchPreference;
public SettingsMainSwitchPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final Preference pref = screen.findPreference(getPreferenceKey());
if (pref != null && pref instanceof MainSwitchPreference) {
mSwitchPreference = (MainSwitchPreference) pref;
mSwitchPreference.addOnSwitchChangeListener(this);
}
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mSwitchPreference.setChecked(isChecked);
setChecked(isChecked);
}
}

View File

@@ -59,6 +59,12 @@ open class TextInputGroup(
editText.addTextChangedListener(watcher) editText.addTextChangedListener(watcher)
} }
var label: String
get() = layout.hint?.toString() ?: ""
set(value) {
layout.setHint(value)
}
var text: String var text: String
get() = editText.text?.toString() ?: "" get() = editText.text?.toString() ?: ""
set(value) { set(value) {
@@ -75,6 +81,7 @@ open class TextInputGroup(
get() = layout.error?.toString() ?: "" get() = layout.error?.toString() ?: ""
set(value) { set(value) {
layout.setError(value) layout.setError(value)
if (value.isEmpty()) layout.isErrorEnabled = false
} }
open fun validate(): Boolean { open fun validate(): Boolean {

View File

@@ -97,7 +97,7 @@ class ColorInversionPreferenceTest {
fun getSummary_colorInversionOn_verifySummary() { fun getSummary_colorInversionOn_verifySummary() {
SettingsSecureStore.get(appContext).setInt(SETTING_KEY, AccessibilityUtil.State.ON) SettingsSecureStore.get(appContext).setInt(SETTING_KEY, AccessibilityUtil.State.ON)
assertThat(colorInversionPreference.getPreferenceSummary(appContext)).isEqualTo( assertThat(colorInversionPreference.getSummary(appContext)).isEqualTo(
appContext.getText( appContext.getText(
R.string.color_inversion_state_on R.string.color_inversion_state_on
) )
@@ -108,7 +108,7 @@ class ColorInversionPreferenceTest {
fun getSummary_colorInversionOff_verifySummary() { fun getSummary_colorInversionOff_verifySummary() {
SettingsSecureStore.get(appContext).setInt(SETTING_KEY, AccessibilityUtil.State.OFF) SettingsSecureStore.get(appContext).setInt(SETTING_KEY, AccessibilityUtil.State.OFF)
assertThat(colorInversionPreference.getPreferenceSummary(appContext)).isEqualTo( assertThat(colorInversionPreference.getSummary(appContext)).isEqualTo(
appContext.getText( appContext.getText(
R.string.color_inversion_state_off R.string.color_inversion_state_off
) )

View File

@@ -97,7 +97,7 @@ class DaltonizerPreferenceTest {
fun getSummary_daltonizerOn_verifySummary() { fun getSummary_daltonizerOn_verifySummary() {
SettingsSecureStore.get(appContext).setInt(SETTING_KEY, AccessibilityUtil.State.ON) SettingsSecureStore.get(appContext).setInt(SETTING_KEY, AccessibilityUtil.State.ON)
assertThat(daltonizerPreference.getPreferenceSummary(appContext)).isEqualTo( assertThat(daltonizerPreference.getSummary(appContext)).isEqualTo(
appContext.getText( appContext.getText(
R.string.daltonizer_state_on R.string.daltonizer_state_on
) )
@@ -108,7 +108,7 @@ class DaltonizerPreferenceTest {
fun getSummary_daltonizerOff_verifySummary() { fun getSummary_daltonizerOff_verifySummary() {
SettingsSecureStore.get(appContext).setInt(SETTING_KEY, AccessibilityUtil.State.OFF) SettingsSecureStore.get(appContext).setInt(SETTING_KEY, AccessibilityUtil.State.OFF)
assertThat(daltonizerPreference.getPreferenceSummary(appContext)).isEqualTo( assertThat(daltonizerPreference.getSummary(appContext)).isEqualTo(
appContext.getText( appContext.getText(
R.string.daltonizer_state_off R.string.daltonizer_state_off
) )

View File

@@ -57,7 +57,7 @@ class TetherScreenTest : CatalystScreenTestCase() {
fun getPreferenceTitle_tetherConfigDisallowed_shouldShowAll() { fun getPreferenceTitle_tetherConfigDisallowed_shouldShowAll() {
ShadowRestrictedLockUtilsInternal.setRestricted(true) ShadowRestrictedLockUtilsInternal.setRestricted(true)
assertThat(preferenceScreenCreator.getPreferenceTitle(appContext)).isEqualTo( assertThat(preferenceScreenCreator.getTitle(appContext)).isEqualTo(
appContext.getString(R.string.tether_settings_title_all)) appContext.getString(R.string.tether_settings_title_all))
} }
@@ -66,7 +66,7 @@ class TetherScreenTest : CatalystScreenTestCase() {
ShadowRestrictedLockUtilsInternal.setRestricted(false) ShadowRestrictedLockUtilsInternal.setRestricted(false)
val tm = appContext.getSystemService(TetheringManager::class.java) val tm = appContext.getSystemService(TetheringManager::class.java)
assertThat(preferenceScreenCreator.getPreferenceTitle(appContext)).isEqualTo( assertThat(preferenceScreenCreator.getTitle(appContext)).isEqualTo(
appContext.getText(Utils.getTetheringLabel(tm))) appContext.getText(Utils.getTetheringLabel(tm)))
} }

View File

@@ -31,7 +31,6 @@ import static org.mockito.Mockito.when;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.provider.Settings; import android.provider.Settings;
import android.widget.Switch;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
@@ -66,9 +65,6 @@ public class BubbleNotificationPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS) @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PreferenceScreen mScreen; private PreferenceScreen mScreen;
@Mock
private Switch mSwitch;
private BubbleNotificationPreferenceController mController; private BubbleNotificationPreferenceController mController;
private MainSwitchPreference mPreference; private MainSwitchPreference mPreference;
@@ -113,7 +109,7 @@ public class BubbleNotificationPreferenceControllerTest {
public void onSwitchChanged_true_settingIsOff_flagShouldOn() { public void onSwitchChanged_true_settingIsOff_flagShouldOn() {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF); Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
mController.onCheckedChanged(mSwitch, true); mController.setChecked(true);
assertThat(Settings.Global.getInt(mContext.getContentResolver(), assertThat(Settings.Global.getInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, OFF)).isEqualTo(ON); NOTIFICATION_BUBBLES, OFF)).isEqualTo(ON);
@@ -123,7 +119,7 @@ public class BubbleNotificationPreferenceControllerTest {
public void onSwitchChanged_false_settingIsOn_flagShouldOff() { public void onSwitchChanged_false_settingIsOn_flagShouldOff() {
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON); Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
mController.onCheckedChanged(mSwitch, false); mController.setChecked(false);
assertThat(Settings.Global.getInt(mContext.getContentResolver(), assertThat(Settings.Global.getInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, ON)).isEqualTo(OFF); NOTIFICATION_BUBBLES, ON)).isEqualTo(OFF);

View File

@@ -18,6 +18,7 @@ package com.android.settings.supervision
import android.content.Context import android.content.Context
import androidx.test.core.app.ApplicationProvider import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@@ -30,7 +31,7 @@ class SupervisionChangePinPreferenceTest {
@Test @Test
fun getTitle() { fun getTitle() {
assertThat(supervisionChangePinPreference.getPreferenceTitle(context)) assertThat(supervisionChangePinPreference.title)
.isEqualTo("Change PIN") .isEqualTo(R.string.supervision_change_pin_preference_title)
} }
} }

View File

@@ -18,6 +18,7 @@ package com.android.settings.supervision
import android.content.Context import android.content.Context
import androidx.test.core.app.ApplicationProvider import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@@ -35,13 +36,13 @@ class SupervisionPinManagementScreenTest {
@Test @Test
fun getTitle() { fun getTitle() {
assertThat(supervisionPinManagementScreen.getPreferenceTitle(context)) assertThat(supervisionPinManagementScreen.title)
.isEqualTo("Manage PIN") .isEqualTo(R.string.supervision_pin_management_preference_title)
} }
@Test @Test
fun getSummary_addPin() { fun getSummary_addPin() {
assertThat(supervisionPinManagementScreen.getPreferenceSummary(context)) assertThat(supervisionPinManagementScreen.summary)
.isEqualTo("Add a PIN recovery method") .isEqualTo(R.string.supervision_pin_management_preference_summary_add)
} }
} }

View File

@@ -18,6 +18,7 @@ package com.android.settings.supervision
import android.content.Context import android.content.Context
import androidx.test.core.app.ApplicationProvider import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@@ -30,7 +31,7 @@ class SupervisionPinRecoveryPreferenceTest {
@Test @Test
fun getTitle() { fun getTitle() {
assertThat(supervisionPinRecoveryPreference.getPreferenceTitle(context)) assertThat(supervisionPinRecoveryPreference.title)
.isEqualTo("Forgot PIN") .isEqualTo(R.string.supervision_add_forgot_pin_preference_title)
} }
} }

View File

@@ -18,6 +18,7 @@ package com.android.settings.supervision
import android.content.Context import android.content.Context
import androidx.test.core.app.ApplicationProvider import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@@ -35,7 +36,7 @@ class SupervisionWebContentFiltersScreenTest {
@Test @Test
fun getTitle() { fun getTitle() {
assertThat(supervisionWebContentFiltersScreen.getPreferenceTitle(context)) assertThat(supervisionWebContentFiltersScreen.title)
.isEqualTo("Web content filters") .isEqualTo(R.string.supervision_web_content_filters_title)
} }
} }