Merge "Remove silky flag from misc files" into sc-dev
diff --git a/res/layout/font_size_activity.xml b/res/layout/font_size_activity.xml
index c3b26ae..8850f86 100644
--- a/res/layout/font_size_activity.xml
+++ b/res/layout/font_size_activity.xml
@@ -56,7 +56,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
- android:layoutDirection="ltr"
android:paddingTop="8dp">
<ImageView
diff --git a/res/values/strings.xml b/res/values/strings.xml
index baa55a2..a02ac79 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -695,9 +695,8 @@
emergency responders when you call or text an emergency number.
</string>
<!-- Location settings footer link to support page [CHAR LIMIT=NONE] -->
- <string name="location_settings_footer_learn_more">
- <a href="<xliff:g example="http://www.google.com"
- id="url"> https://support.google.com/android/answer/3467281</xliff:g>">Learn more</a>
+ <string name="location_settings_footer_learn_more_link" translatable="false">
+ https://support.google.com/android/answer/3467281
</string>
<!-- Location settings footer link content description [CHAR LIMIT=NONE] -->
<string name="location_settings_footer_learn_more_content_description">
@@ -5335,8 +5334,8 @@
<string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up from the bottom of the screen with 3 fingers.\n\nTo switch between features, swipe up with 3 fingers and hold.</string>
<!-- Summary for software shortcut in accessibility edit shortcut dialog when user had enabled the accessibility floating button mode (Floating over other apps). [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_summary_software_floating"><annotation id="link">Customize accessibility button</annotation></string>
- <!-- Summary for footer to show help link. [CHAR LIMIT=NONE] -->
- <string name="footer_learn_more"><annotation id="link">Learn more</annotation></string>
+ <!-- Footer to show help link content description. [CHAR LIMIT=NONE] -->
+ <string name="footer_learn_more_content_description">Learn more about <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
<!-- Title for hardware shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_title_hardware">Hold volume keys</string>
<!-- Part of list to compose user's accessibility shortcut list. [CHAR LIMIT=NONE] -->
@@ -6100,7 +6099,7 @@
<!-- Title for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_limited_temporarily_title">Charging temporarily limited</string>
<!-- Summary for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
- <string name="battery_tip_limited_temporarily_summary">Battery limited temporarily. Learn more.</string>
+ <string name="battery_tip_limited_temporarily_summary">To preserve your battery. Learn more.</string>
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage:</string>
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
diff --git a/res/xml/auto_brightness_detail.xml b/res/xml/auto_brightness_detail.xml
index d0bf334..a7c85e8 100644
--- a/res/xml/auto_brightness_detail.xml
+++ b/res/xml/auto_brightness_detail.xml
@@ -27,10 +27,11 @@
settings:preview="@drawable/aab_brightness"
settings:controller="com.android.settings.widget.VideoPreferenceController"/>
- <com.android.settingslib.widget.MainSwitchPreference
+ <com.android.settings.widget.SettingsMainSwitchPreference
android:key="auto_brightness"
android:title="@string/adaptive_brightness_main_switch_title"
settings:keywords="@string/keywords_display_auto_brightness"
+ settings:userRestriction="no_config_brightness"
settings:controller="com.android.settings.display.AutoBrightnessDetailPreferenceController"/>
<com.android.settingslib.widget.FooterPreference
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index cffab3e..fe87efd 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -71,7 +71,6 @@
<com.android.settingslib.widget.FooterPreference
android:title="@string/location_settings_footer_general"
android:key="location_footer"
- android:selectable="false"
settings:searchable="false"
settings:controller="com.android.settings.location.LocationSettingsFooterPreferenceController"/>
</PreferenceScreen>
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index 229c9df..6d7c0ba 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -70,21 +70,17 @@
settings:controller="com.android.settings.biometrics.face.FaceSettingsLockscreenBypassPreferenceController" />
</PreferenceCategory>
- <PreferenceCategory
- android:key="security_settings_face_button_category"
- android:title="@string/security_settings_face_preference_title">
- <com.android.settingslib.widget.LayoutPreference
- android:key="security_settings_face_delete_faces_container"
- android:title="@string/security_settings_face_settings_remove_face_model"
- android:selectable="false"
- android:layout="@layout/face_remove_button"/>
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="security_settings_face_delete_faces_container"
+ android:title="@string/security_settings_face_settings_remove_face_model"
+ android:selectable="false"
+ android:layout="@layout/face_remove_button"/>
- <com.android.settingslib.widget.LayoutPreference
- android:key="security_settings_face_enroll_faces_container"
- android:title="@string/security_settings_face_settings_enroll"
- android:selectable="false"
- android:layout="@layout/face_enroll_button"/>
- </PreferenceCategory>
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="security_settings_face_enroll_faces_container"
+ android:title="@string/security_settings_face_settings_enroll"
+ android:selectable="false"
+ android:layout="@layout/face_enroll_button"/>
<com.android.settingslib.widget.FooterPreference
android:key="security_face_footer"
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index a276ad7..b8ff60c 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -26,7 +26,6 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.ArrayMap;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -43,11 +42,8 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.search.actionbar.SearchMenuController;
-import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.widget.HighlightablePreferenceGroupAdapter;
import com.android.settings.widget.LoadingViewController;
@@ -129,11 +125,6 @@
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- // TODO(b/176883483): Remove both search and help menu if this feature rolled out
- if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
- SearchMenuController.init(this /* host */);
- HelpMenuController.init(this /* host */);
- }
if (icicle != null) {
mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
diff --git a/src/com/android/settings/accessibility/AccessibilityFooterPreference.java b/src/com/android/settings/accessibility/AccessibilityFooterPreference.java
index d68538e..67b7827 100644
--- a/src/com/android/settings/accessibility/AccessibilityFooterPreference.java
+++ b/src/com/android/settings/accessibility/AccessibilityFooterPreference.java
@@ -17,29 +17,19 @@
package com.android.settings.accessibility;
import android.content.Context;
-import android.content.Intent;
-import android.text.SpannableStringBuilder;
-import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
-import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.preference.PreferenceViewHolder;
-import com.android.settings.R;
-import com.android.settings.utils.AnnotationSpan;
-import com.android.settingslib.HelpUtils;
import com.android.settingslib.widget.FooterPreference;
/**
- * A custom preference acting as footer of a page. It has a field for icon and text. It is added
- * to screen as the last preference and groups of icon and text content in accessibility-focusable
- * {@link android.view.accessibility.AccessibilityNodeInfo} for TalkBack to use.
+ * A custom preference acting as footer of a page. Disables the movement method by default.
*/
public final class AccessibilityFooterPreference extends FooterPreference {
- private CharSequence mIconContentDescription;
private boolean mLinkEnabled;
public AccessibilityFooterPreference(Context context, AttributeSet attrs) {
@@ -65,33 +55,6 @@
} else {
title.setMovementMethod(/* movement= */ null);
}
-
- final LinearLayout infoFrame = holder.itemView.findViewById(R.id.icon_frame);
- if (!TextUtils.isEmpty(mIconContentDescription)) {
- // Groups related content.
- infoFrame.setContentDescription(mIconContentDescription);
- title.setFocusable(false);
- } else {
- infoFrame.setContentDescription(null);
- title.setFocusable(true);
- }
- }
-
- /**
- * Sets the content description of the icon.
- */
- public void setIconContentDescription(CharSequence iconContentDescription) {
- if (!TextUtils.equals(iconContentDescription, mIconContentDescription)) {
- mIconContentDescription = iconContentDescription;
- notifyChanged();
- }
- }
-
- /**
- * Gets the content description of the icon.
- */
- public CharSequence getIconContentDescription() {
- return mIconContentDescription;
}
/**
@@ -110,23 +73,4 @@
public boolean isLinkEnabled() {
return mLinkEnabled;
}
-
- /**
- * Appends {@link AnnotationSpan} with learn more link apart from the other text.
- *
- * @param helpLinkRes The Help Uri Resource key
- */
- public void appendHelpLink(int helpLinkRes) {
- final SpannableStringBuilder sb = new SpannableStringBuilder();
- sb.append(getTitle()).append("\n\n").append(getLearnMoreLink(getContext(), helpLinkRes));
- setTitle(sb);
- }
-
- private CharSequence getLearnMoreLink(Context context, int helpLinkRes) {
- final Intent helpIntent = HelpUtils.getHelpIntent(
- context, context.getString(helpLinkRes), context.getClass().getName());
- final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
- context, AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, helpIntent);
- return AnnotationSpan.linkify(context.getText(R.string.footer_learn_more), linkInfo);
- }
}
diff --git a/src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java
index 9fe4b3a..e3422e4 100644
--- a/src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java
@@ -17,11 +17,13 @@
package com.android.settings.accessibility;
import android.content.Context;
+import android.content.Intent;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.HelpUtils;
/**
* Base class for accessibility preference footer.
@@ -59,13 +61,24 @@
protected abstract String getLabelName();
private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) {
- final String iconContentDescription = mContext.getString(
- R.string.accessibility_introduction_title, getLabelName());
- footerPreference.setIconContentDescription(iconContentDescription);
+ final StringBuffer sb = new StringBuffer();
+ sb.append(mContext.getString(
+ R.string.accessibility_introduction_title, getLabelName()))
+ .append("\n\n")
+ .append(footerPreference.getTitle());
+ footerPreference.setContentDescription(sb);
if (getHelpResource() != 0) {
- footerPreference.appendHelpLink(getHelpResource());
- footerPreference.setLinkEnabled(true);
+ footerPreference.setLearnMoreAction(view -> {
+ final Intent helpIntent = HelpUtils.getHelpIntent(
+ mContext, mContext.getString(getHelpResource()),
+ mContext.getClass().getName());
+ view.startActivityForResult(helpIntent, 0);
+ });
+
+ final String learnMoreContentDescription = mContext.getString(
+ R.string.footer_learn_more_content_description, getLabelName());
+ footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
}
}
}
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 4b1725f..7c18943 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -55,6 +55,7 @@
import com.android.settings.utils.LocaleUtils;
import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settings.widget.SettingsMainSwitchPreference;
+import com.android.settingslib.HelpUtils;
import com.android.settingslib.accessibility.AccessibilityUtils;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
@@ -520,14 +521,25 @@
new AccessibilityFooterPreference(screen.getContext());
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
htmlFooterPreference.setSummary(htmlDescription);
+ htmlFooterPreference.setContentDescription(
+ generateFooterContentDescription(htmlDescription));
+
// Only framework tools support help link
if (getHelpResource() != 0) {
- htmlFooterPreference.appendHelpLink(getHelpResource());
+ htmlFooterPreference.setLearnMoreAction(view -> {
+ final Intent helpIntent = HelpUtils.getHelpIntent(
+ getContext(), getContext().getString(getHelpResource()),
+ getContext().getClass().getName());
+ view.startActivityForResult(helpIntent, 0);
+ });
+
+ final String learnMoreContentDescription = getPrefContext().getString(
+ R.string.footer_learn_more_content_description, mPackageName);
+ htmlFooterPreference.setLearnMoreContentDescription(learnMoreContentDescription);
htmlFooterPreference.setLinkEnabled(true);
} else {
htmlFooterPreference.setLinkEnabled(false);
}
- htmlFooterPreference.setIconContentDescription(iconContentDescription);
screen.addPreference(htmlFooterPreference);
}
@@ -559,14 +571,33 @@
final AccessibilityFooterPreference footerPreference =
new AccessibilityFooterPreference(screen.getContext());
footerPreference.setSummary(summary);
- footerPreference.setIconContentDescription(iconContentDescription);
+ footerPreference.setContentDescription(
+ generateFooterContentDescription(summary));
+
+ // Only framework tools support help link
if (getHelpResource() != 0) {
- footerPreference.appendHelpLink(getHelpResource());
- footerPreference.setLinkEnabled(true);
+ footerPreference.setLearnMoreAction(view -> {
+ final Intent helpIntent = HelpUtils.getHelpIntent(
+ getContext(), getContext().getString(getHelpResource()),
+ getContext().getClass().getName());
+ view.startActivityForResult(helpIntent, 0);
+ });
+
+ final String learnMoreContentDescription = getPrefContext().getString(
+ R.string.footer_learn_more_content_description, mPackageName);
+ footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
}
screen.addPreference(footerPreference);
}
+ private CharSequence generateFooterContentDescription(CharSequence footerContent) {
+ final StringBuffer sb = new StringBuffer();
+ sb.append(getPrefContext().getString(
+ R.string.accessibility_introduction_title, mPackageName))
+ .append("\n\n")
+ .append(footerContent);
+ return sb;
+ }
@VisibleForTesting
void setupEditShortcutDialog(Dialog dialog) {
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index d5162a85..164ef2d 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -123,7 +123,6 @@
import com.android.settings.widget.LoadingViewController;
import com.android.settings.wifi.AppStateChangeWifiStateBridge;
import com.android.settings.wifi.ChangeWifiStateDetails;
-import com.android.settingslib.HelpUtils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
@@ -661,10 +660,6 @@
if (activity == null) {
return;
}
- // TODO(b/176883483): Remove the help menu if this feature rolled out
- if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
- HelpUtils.prepareHelpMenuItem(activity, menu, getHelpResource(), getClass().getName());
- }
mOptionsMenu = menu;
inflater.inflate(R.menu.manage_apps, menu);
diff --git a/src/com/android/settings/core/SettingsBaseActivity.java b/src/com/android/settings/core/SettingsBaseActivity.java
index c5d86e1..fb9780f 100644
--- a/src/com/android/settings/core/SettingsBaseActivity.java
+++ b/src/com/android/settings/core/SettingsBaseActivity.java
@@ -67,7 +67,7 @@
/**
* What type of page transition should be apply.
*/
- public static final String EXTRA_PAGE_TRANSITION_TYPE = "extra_page_transition_type";
+ public static final String EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type";
protected static final boolean DEBUG_TIMING = false;
private static final String TAG = "SettingsBaseActivity";
diff --git a/src/com/android/settings/core/SubSettingLauncher.java b/src/com/android/settings/core/SubSettingLauncher.java
index 2ee404b..893d592 100644
--- a/src/com/android/settings/core/SubSettingLauncher.java
+++ b/src/com/android/settings/core/SubSettingLauncher.java
@@ -17,22 +17,17 @@
package com.android.settings.core;
import android.annotation.StringRes;
-import android.app.Activity;
-import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
-import android.widget.Toolbar;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
-import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SubSettings;
-import com.android.settings.Utils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
@@ -199,14 +194,6 @@
@VisibleForTesting
void launchForResult(Fragment listener, Intent intent, int requestCode) {
- if (Utils.isPageTransitionEnabled(mContext)) {
- final Activity activity = listener.getActivity();
- final Toolbar toolbar = activity.findViewById(R.id.action_bar);
- final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity, toolbar,
- "shared_element_view").toBundle();
- listener.startActivityForResult(intent, requestCode, bundle);
- return;
- }
listener.startActivityForResult(intent, requestCode);
}
diff --git a/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java b/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
index 3138ae0..0a60ed3 100644
--- a/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessDetailPreferenceController.java
@@ -21,7 +21,7 @@
import androidx.preference.PreferenceScreen;
-import com.android.settingslib.widget.MainSwitchPreference;
+import com.android.settings.widget.SettingsMainSwitchPreference;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
/**
@@ -51,7 +51,7 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- MainSwitchPreference pref = (MainSwitchPreference) screen.findPreference(
+ SettingsMainSwitchPreference pref = (SettingsMainSwitchPreference) screen.findPreference(
getPreferenceKey());
pref.addOnSwitchChangeListener(this);
pref.updateStatus(isChecked());
diff --git a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
index 388d87a..854efa0 100644
--- a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
+++ b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
@@ -30,18 +30,14 @@
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
-import android.util.FeatureFlagUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.actionbar.SearchMenuController;
-import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.utils.CandidateInfoExtra;
import com.android.settings.widget.RadioButtonPickerFragment;
@@ -76,11 +72,6 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- // TODO(b/176883483): Remove both search and help menu if this feature rolled out
- if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
- SearchMenuController.init(this /* host */);
- HelpMenuController.init(this /* host */);
- }
SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context)
.getSuggestionFeatureProvider(context);
diff --git a/src/com/android/settings/location/LocationSettingsFooterPreferenceController.java b/src/com/android/settings/location/LocationSettingsFooterPreferenceController.java
index 281cc5a..a3b68be 100644
--- a/src/com/android/settings/location/LocationSettingsFooterPreferenceController.java
+++ b/src/com/android/settings/location/LocationSettingsFooterPreferenceController.java
@@ -31,6 +31,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settingslib.HelpUtils;
import com.android.settingslib.widget.FooterPreference;
import java.util.ArrayList;
@@ -104,15 +105,22 @@
+ footerString;
}
if (mFooterPreference != null) {
- mFooterPreference.setTitle(Html.fromHtml(footerString
- + PARAGRAPH_SEPARATOR
- + mContext.getString(
- R.string.location_settings_footer_learn_more)));
- mFooterPreference.setContentDescription(Html.fromHtml(footerString + mContext.getString(
- R.string.location_settings_footer_learn_more_content_description)));
+ mFooterPreference.setTitle(Html.fromHtml(footerString));
+ mFooterPreference.setLearnMoreAction(v -> openLocationLearnMoreLink());
+ mFooterPreference.setLearnMoreContentDescription(mContext.getString(
+ R.string.location_settings_footer_learn_more_content_description));
}
}
+ private void openLocationLearnMoreLink() {
+ mFragment.startActivityForResult(
+ HelpUtils.getHelpIntent(
+ mContext,
+ mContext.getString(R.string.location_settings_footer_learn_more_link),
+ /*backupContext=*/""),
+ /*requestCode=*/ 0);
+ }
+
/**
* Location footer preference group should always be displayed.
*/
diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
index dd1d63a..4f235e1 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
@@ -33,6 +33,7 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.security.SecurityFeatureProvider;
@@ -44,6 +45,7 @@
import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
import com.android.settingslib.search.SearchIndexableRaw;
+import com.android.settingslib.transition.SettingsTransitionHelper;
import java.util.ArrayList;
import java.util.List;
@@ -128,6 +130,8 @@
.show();
mTrustAgentClickIntent = preference.getIntent();
+ mTrustAgentClickIntent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
+ SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE);
if (!confirmationLaunched && mTrustAgentClickIntent != null) {
// If this returns false, it means no password confirmation is required.
diff --git a/src/com/android/settings/widget/SettingsMainSwitchBar.java b/src/com/android/settings/widget/SettingsMainSwitchBar.java
index ce2dde5..5f752f9 100644
--- a/src/com/android/settings/widget/SettingsMainSwitchBar.java
+++ b/src/com/android/settings/widget/SettingsMainSwitchBar.java
@@ -16,6 +16,8 @@
package com.android.settings.widget;
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.util.AttributeSet;
@@ -47,7 +49,7 @@
}
private ImageView mRestrictedIcon;
- private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
+ private EnforcedAdmin mEnforcedAdmin;
private boolean mDisabledByAdmin;
private final MetricsFeatureProvider mMetricsFeatureProvider;
@@ -87,7 +89,7 @@
* If admin is not null, disables the text and switch but keeps the view clickable (unless the
* switch is disabled for other reasons). Otherwise, calls setEnabled.
*/
- public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) {
+ public void setDisabledByAdmin(EnforcedAdmin admin) {
mEnforcedAdmin = admin;
if (admin != null) {
super.setEnabled(true);
diff --git a/src/com/android/settings/widget/SettingsMainSwitchPreference.java b/src/com/android/settings/widget/SettingsMainSwitchPreference.java
index 04317a8..7f349bc 100644
--- a/src/com/android/settings/widget/SettingsMainSwitchPreference.java
+++ b/src/com/android/settings/widget/SettingsMainSwitchPreference.java
@@ -16,10 +16,13 @@
package com.android.settings.widget;
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
+import android.widget.Switch;
import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.PreferenceViewHolder;
@@ -27,7 +30,7 @@
import com.android.settings.R;
import com.android.settings.widget.SettingsMainSwitchBar.OnBeforeCheckedChangeListener;
-import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedPreferenceHelper;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
import java.util.ArrayList;
@@ -38,7 +41,9 @@
* This component is used as the main switch of the page
* to enable or disable the prefereces on the page.
*/
-public class SettingsMainSwitchPreference extends TwoStatePreference {
+public class SettingsMainSwitchPreference extends TwoStatePreference implements
+ OnMainSwitchChangeListener {
+
private final List<OnBeforeCheckedChangeListener> mBeforeCheckedChangeListeners =
new ArrayList<>();
private final List<OnMainSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
@@ -46,8 +51,8 @@
private SettingsMainSwitchBar mMainSwitchBar;
private CharSequence mTitle;
private boolean mIsVisible;
-
- private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
+ private EnforcedAdmin mEnforcedAdmin;
+ private RestrictedPreferenceHelper mRestrictedHelper;
public SettingsMainSwitchPreference(Context context) {
super(context);
@@ -78,8 +83,8 @@
holder.setDividerAllowedBelow(false);
mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
-
mMainSwitchBar.show();
+ mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
updateStatus(isChecked());
registerListenerToSwitchBar();
@@ -90,6 +95,7 @@
private void init(Context context, AttributeSet attrs) {
setLayoutResource(R.layout.preference_widget_main_switch);
+ mSwitchChangeListeners.add(this);
mIsVisible = true;
if (attrs != null) {
@@ -103,6 +109,8 @@
setTitle(title.toString());
}
a.recycle();
+
+ mRestrictedHelper = new RestrictedPreferenceHelper(context, this, attrs);
}
}
@@ -129,13 +137,17 @@
}
}
+ @Override
+ public void onSwitchChanged(Switch switchView, boolean isChecked) {
+ super.setChecked(isChecked);
+ }
+
/**
* Update the switch status of preference
*/
public void updateStatus(boolean checked) {
setChecked(checked);
if (mMainSwitchBar != null) {
- mMainSwitchBar.setChecked(checked);
mMainSwitchBar.setTitle(mTitle);
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
mMainSwitchBar.show();
@@ -230,7 +242,7 @@
* Otherwise, calls setEnabled which will enables the entire view including
* the text and switch.
*/
- public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) {
+ public void setDisabledByAdmin(EnforcedAdmin admin) {
mEnforcedAdmin = admin;
if (mMainSwitchBar != null) {
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettings.java b/src/com/android/settings/wifi/calling/WifiCallingSettings.java
index 79f34c7..86e7e8d 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettings.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettings.java
@@ -22,7 +22,6 @@
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -35,12 +34,10 @@
import com.android.internal.util.CollectionUtils;
import com.android.settings.R;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.WifiCallingQueryImsState;
import com.android.settings.search.actionbar.SearchMenuController;
-import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settings.widget.RtlCompatibleViewPager;
import com.android.settings.widget.SlidingTabLayout;
@@ -121,12 +118,6 @@
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- // TODO(b/176883483): Remove the option menu if collapsing toolbar feature rolled out
- if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
- setHasOptionsMenu(true);
- SearchMenuController.init(this /* host */);
- HelpMenuController.init(this /* host */);
- }
// TODO: besides in onCreate, we should also update subList when SIM / Sub status
// changes.
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java
deleted file mode 100644
index 2640c81..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java
+++ /dev/null
@@ -1,67 +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.accessibility;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.core.app.ApplicationProvider;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-
-/** Tests for {@link AccessibilityButtonFooterPreferenceController}. */
-@RunWith(RobolectricTestRunner.class)
-public class AccessibilityButtonFooterPreferenceControllerTest {
-
- private static final String TEST_KEY = "test_key";
- private static final String TEST_TITLE = "test_title";
- private final Context mContext = ApplicationProvider.getApplicationContext();
- private PreferenceScreen mScreen;
- private AccessibilityButtonFooterPreferenceController mController;
-
- @Before
- public void setUp() {
- final PreferenceManager preferenceManager = new PreferenceManager(mContext);
- mScreen = preferenceManager.createPreferenceScreen(mContext);
- final AccessibilityFooterPreference footerPreference =
- new AccessibilityFooterPreference(mContext);
- footerPreference.setKey(TEST_KEY);
- footerPreference.setTitle(TEST_TITLE);
- mScreen.addPreference(footerPreference);
- mController = new AccessibilityButtonFooterPreferenceController(mContext, TEST_KEY);
- }
-
- @Test
- public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
- mController.displayPreference(mScreen);
-
- final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
- final String packageName = mContext.getString(R.string.accessibility_button_title);
- final String iconContentDescription = mContext.getString(
- R.string.accessibility_introduction_title,
- packageName);
- assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityControlTimeoutFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityControlTimeoutFooterPreferenceControllerTest.java
deleted file mode 100644
index 23e479b..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityControlTimeoutFooterPreferenceControllerTest.java
+++ /dev/null
@@ -1,69 +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.accessibility;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.core.app.ApplicationProvider;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-
-/** Tests for {@link AccessibilityControlTimeoutFooterPreferenceController}. */
-@RunWith(RobolectricTestRunner.class)
-public class AccessibilityControlTimeoutFooterPreferenceControllerTest {
-
- private static final String TEST_KEY = "test_key";
- private static final String TEST_TITLE = "test_title";
- private final Context mContext = ApplicationProvider.getApplicationContext();
- private PreferenceScreen mScreen;
- private AccessibilityControlTimeoutFooterPreferenceController mController;
-
- @Before
- public void setUp() {
- final PreferenceManager preferenceManager = new PreferenceManager(mContext);
- mScreen = preferenceManager.createPreferenceScreen(mContext);
- final AccessibilityFooterPreference footerPreference =
- new AccessibilityFooterPreference(mContext);
- footerPreference.setKey(TEST_KEY);
- footerPreference.setTitle(TEST_TITLE);
- mScreen.addPreference(footerPreference);
- mController = new AccessibilityControlTimeoutFooterPreferenceController(mContext, TEST_KEY);
- }
-
- @Test
- public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
- mController.displayPreference(mScreen);
-
- final AccessibilityFooterPreference footerPreference =
- mScreen.findPreference(TEST_KEY);
- final String packageName =
- mContext.getString(R.string.accessibility_setting_item_control_timeout_title);
- final String iconContentDescription = mContext.getString(
- R.string.accessibility_introduction_title,
- packageName);
- assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java
index b8f97c7..14c56e8 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java
@@ -19,13 +19,12 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
+import android.text.method.MovementMethod;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.preference.PreferenceViewHolder;
-import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
@@ -39,10 +38,6 @@
@RunWith(RobolectricTestRunner.class)
public final class AccessibilityFooterPreferenceTest {
- private static final String DEFAULT_SUMMARY = "default summary";
- private static final String DEFAULT_DESCRIPTION = "default description";
-
- private Context mContext = ApplicationProvider.getApplicationContext();
private AccessibilityFooterPreference mAccessibilityFooterPreference;
private PreferenceViewHolder mPreferenceViewHolder;
@@ -58,41 +53,22 @@
}
@Test
- public void onBindViewHolder_initTextConfig_parseTextAndFocusable() {
- mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
+ public void onBindViewHolder_LinkDisabledByDefault_notReturnLinkMovement() {
+ mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
+
+ final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
+ android.R.id.title);
+ assertThat(summaryView.getMovementMethod()).isNull();
+ }
+
+ @Test
+ public void onBindViewHolder_setLinkEnabled_returnLinkMovement() {
+ mAccessibilityFooterPreference.setLinkEnabled(true);
mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
android.R.id.title);
- assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY);
- assertThat(summaryView.isFocusable()).isEqualTo(true);
- }
-
- @Test
- public void onBindViewHolder_initTextConfigAndAccessibleIcon_groupContentForAccessible() {
- mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
- mAccessibilityFooterPreference.setIconContentDescription(DEFAULT_DESCRIPTION);
-
- mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder);
-
- final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById(
- android.R.id.title);
- assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY);
- assertThat(summaryView.isFocusable()).isEqualTo(false);
- final LinearLayout infoFrame = (LinearLayout) mPreferenceViewHolder.findViewById(
- R.id.icon_frame);
- assertThat(infoFrame.getContentDescription()).isEqualTo(DEFAULT_DESCRIPTION);
- assertThat(infoFrame.isFocusable()).isEqualTo(false);
- }
-
- @Test
- public void appendHelpLink_timeoutHelpUri_updateSummary() {
- mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
-
- mAccessibilityFooterPreference.appendHelpLink(R.string.help_url_timeout);
-
- final String title = mAccessibilityFooterPreference.getTitle().toString();
- assertThat(title.contains(mContext.getString(R.string.footer_learn_more))).isTrue();
+ assertThat(summaryView.getMovementMethod()).isInstanceOf(MovementMethod.class);
}
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptionFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptionFooterPreferenceControllerTest.java
deleted file mode 100644
index e5f67c5..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/CaptionFooterPreferenceControllerTest.java
+++ /dev/null
@@ -1,67 +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.accessibility;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.core.app.ApplicationProvider;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-
-/** Tests for {@link CaptionFooterPreferenceController}. */
-@RunWith(RobolectricTestRunner.class)
-public class CaptionFooterPreferenceControllerTest {
-
- private static final String TEST_KEY = "test_key";
- private static final String TEST_TITLE = "test_title";
- private final Context mContext = ApplicationProvider.getApplicationContext();
- private PreferenceScreen mScreen;
- private CaptionFooterPreferenceController mController;
-
- @Before
- public void setUp() {
- final PreferenceManager preferenceManager = new PreferenceManager(mContext);
- mScreen = preferenceManager.createPreferenceScreen(mContext);
- final AccessibilityFooterPreference footerPreference =
- new AccessibilityFooterPreference(mContext);
- footerPreference.setKey(TEST_KEY);
- footerPreference.setTitle(TEST_TITLE);
- mScreen.addPreference(footerPreference);
- mController = new CaptionFooterPreferenceController(mContext, TEST_KEY);
- }
-
- @Test
- public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
- mController.displayPreference(mScreen);
-
- final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
- final String packageName = mContext.getString(R.string.accessibility_captioning_title);
- final String iconContentDescription = mContext.getString(
- R.string.accessibility_introduction_title,
- packageName);
- assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleAutoclickFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleAutoclickFooterPreferenceControllerTest.java
deleted file mode 100644
index 2be4752..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleAutoclickFooterPreferenceControllerTest.java
+++ /dev/null
@@ -1,68 +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.accessibility;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.core.app.ApplicationProvider;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-
-/** Tests for {@link ToggleAutoclickFooterPreferenceController}. */
-@RunWith(RobolectricTestRunner.class)
-public class ToggleAutoclickFooterPreferenceControllerTest {
-
- private static final String TEST_KEY = "test_key";
- private static final String TEST_TITLE = "test_title";
- private final Context mContext = ApplicationProvider.getApplicationContext();
- private PreferenceScreen mScreen;
- private ToggleAutoclickFooterPreferenceController mController;
-
- @Before
- public void setUp() {
- final PreferenceManager preferenceManager = new PreferenceManager(mContext);
- mScreen = preferenceManager.createPreferenceScreen(mContext);
- final AccessibilityFooterPreference footerPreference =
- new AccessibilityFooterPreference(mContext);
- footerPreference.setKey(TEST_KEY);
- footerPreference.setTitle(TEST_TITLE);
- mScreen.addPreference(footerPreference);
- mController = new ToggleAutoclickFooterPreferenceController(mContext, TEST_KEY);
- }
-
- @Test
- public void onPreferenceChange_shouldSetCorrectIconContentDescription() {
- mController.displayPreference(mScreen);
-
- final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY);
- final String packageName = mContext.getString(
- R.string.accessibility_autoclick_preference_title);
- final String iconContentDescription = mContext.getString(
- R.string.accessibility_introduction_title,
- packageName);
- assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
index 01e9b38..4f4185c 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
@@ -215,8 +215,6 @@
(AccessibilityFooterPreference) mFragment.getPreferenceScreen().getPreference(
mFragment.getPreferenceScreen().getPreferenceCount() - 1);
assertThat(accessibilityFooterPreference.getSummary()).isEqualTo(DEFAULT_SUMMARY);
- assertThat(accessibilityFooterPreference.getIconContentDescription()).isEqualTo(
- DEFAULT_DESCRIPTION);
assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(true);
assertThat(accessibilityFooterPreference.getOrder()).isEqualTo(Integer.MAX_VALUE - 1);
}
diff --git a/tests/robotests/src/com/android/settings/core/SubSettingLauncherTest.java b/tests/robotests/src/com/android/settings/core/SubSettingLauncherTest.java
index a74c01e..2a0d3df 100644
--- a/tests/robotests/src/com/android/settings/core/SubSettingLauncherTest.java
+++ b/tests/robotests/src/com/android/settings/core/SubSettingLauncherTest.java
@@ -50,7 +50,6 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowUtils.class)
public class SubSettingLauncherTest {
@Mock
@@ -117,7 +116,6 @@
@Test
public void launch_hasRequestListener_shouldStartActivityForResult() {
- ShadowUtils.setIsPageTransitionEnabled(true);
final int requestCode = 123123;
when(mFragment.getActivity()).thenReturn(mActivity);
diff --git a/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java
new file mode 100644
index 0000000..cb53805
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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 static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.view.View;
+import android.widget.ImageView;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class SettingsMainSwitchPreferenceTest {
+
+ @Mock
+ private EnforcedAdmin mEnforcedAdmin;
+ private SettingsMainSwitchPreference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = RuntimeEnvironment.application;
+ final SettingsMainSwitchBar switchBar = new SettingsMainSwitchBar(context);
+ mPreference = new SettingsMainSwitchPreference(context);
+ ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin);
+ ReflectionHelpers.setField(mPreference, "mMainSwitchBar", switchBar);
+ }
+
+ @Test
+ public void updateStatus_isRestricted_restrictIconShouldDisplay() {
+ mPreference.updateStatus(true);
+
+ final SettingsMainSwitchBar switchBar = mPreference.getSwitchBar();
+ final ImageView restrictedIcon = switchBar.findViewById(
+ com.android.settingslib.widget.R.id.restricted_icon);
+
+ assertThat(restrictedIcon.getVisibility() == View.VISIBLE).isTrue();
+ }
+}