Migrate to DashboardFragment in ToggleFeaturePreferenceFragment
Root Cause: ToggleFeaturePrefreferenceFragment becomes heavy when more and more features come in. Solution: Mirgrate to DashboardFragment, a plugin-style preference controllers, can help us separate the preference and its logic into its own controller. * This is the first step for the whole migration. Change to extend DashboardFragment and fill up the missing override functions. * Reorder fields and functions to the recommended general approach. Bug: 171272809 Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.accessibility Change-Id: I852091700a4b3b3c7bbdbc82f0b5dc47c087d61c
This commit is contained in:
@@ -49,9 +49,11 @@ import java.util.List;
|
||||
|
||||
/** Fragment for providing open activity button. */
|
||||
public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||
private static final String TAG = "LaunchA11yActivity";
|
||||
|
||||
private static final String TAG = "LaunchAccessibilityActivityPreferenceFragment";
|
||||
private static final String EMPTY_STRING = "";
|
||||
protected static final String KEY_LAUNCH_PREFERENCE = "launch_preference";
|
||||
|
||||
private ComponentName mTileComponentName;
|
||||
|
||||
@Override
|
||||
@@ -70,10 +72,10 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
// Init new preference to replace the switch preference instead.
|
||||
initLaunchPreference();
|
||||
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
removePreference(KEY_USE_SERVICE_PREFERENCE);
|
||||
return view;
|
||||
}
|
||||
@@ -173,6 +175,7 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
/** Customizes the order by preference key. */
|
||||
protected List<String> getPreferenceOrderList() {
|
||||
final List<String> lists = new ArrayList<>();
|
||||
lists.add(KEY_TOP_INTRO_PREFERENCE);
|
||||
lists.add(KEY_ANIMATED_IMAGE);
|
||||
lists.add(KEY_LAUNCH_PREFERENCE);
|
||||
lists.add(KEY_GENERAL_CATEGORY);
|
||||
@@ -230,4 +233,15 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
|
||||
|
||||
return settingsIntent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
// TODO(b/171272809): Add back when controllers move to static type
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
}
|
||||
|
@@ -61,9 +61,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
|
||||
private static final String TAG = "ToggleAccessibilityServicePreferenceFragment";
|
||||
private static final String KEY_HAS_LOGGED = "has_logged";
|
||||
private AtomicBoolean mIsDialogShown = new AtomicBoolean(/* initialValue= */ false);
|
||||
|
||||
private static final String EMPTY_STRING = "";
|
||||
private final AtomicBoolean mIsDialogShown = new AtomicBoolean(/* initialValue= */ false);
|
||||
|
||||
private Dialog mWarningDialog;
|
||||
private ComponentName mTileComponentName;
|
||||
@@ -85,7 +83,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater infalter) {
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
// Do not call super. We don't want to see the "Help & feedback" option on this page so as
|
||||
// not to confuse users who think they might be able to send feedback about a specific
|
||||
// accessibility service from this page.
|
||||
@@ -125,11 +123,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
updateSwitchBarToggleSwitch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
if (mStartTimeMillsForLogging > 0) {
|
||||
@@ -148,10 +141,8 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
AccessibilityUtils.setAccessibilityServiceState(getPrefContext(), toggledService, enabled);
|
||||
}
|
||||
|
||||
// IMPORTANT: Refresh the info since there are dynamically changing
|
||||
// capabilities. For
|
||||
// example, before JellyBean MR2 the user was granting the explore by touch
|
||||
// one.
|
||||
// IMPORTANT: Refresh the info since there are dynamically changing capabilities. For
|
||||
// example, before JellyBean MR2 the user was granting the explore by touch one.
|
||||
@Nullable
|
||||
AccessibilityServiceInfo getAccessibilityServiceInfo() {
|
||||
final List<AccessibilityServiceInfo> infos = AccessibilityManager.getInstance(
|
||||
@@ -454,6 +445,17 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
unregisterPackageRemoveReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
// TODO(b/171272809): Add back when controllers move to static type
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void onAllowButtonFromEnableToggleClicked() {
|
||||
handleConfirmServiceEnabled(/* confirmed= */ true);
|
||||
if (isServiceSupportAccessibilityButton()) {
|
||||
|
@@ -42,11 +42,39 @@ import java.util.List;
|
||||
/** Settings page for color inversion. */
|
||||
public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||
|
||||
private static final String TAG = "ToggleColorInversionPreferenceFragment";
|
||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
protected void registerKeysToObserverCallback(
|
||||
AccessibilitySettingsContentObserver contentObserver) {
|
||||
super.registerKeysToObserverCallback(contentObserver);
|
||||
|
||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||
enableServiceFeatureKeys.add(ENABLED);
|
||||
contentObserver.registerKeysToObserverCallback(enableServiceFeatureKeys,
|
||||
key -> updateSwitchBarToggleSwitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mComponentName = COLOR_INVERSION_COMPONENT_NAME;
|
||||
mPackageName = getText(R.string.accessibility_display_inversion_preference_title);
|
||||
mHtmlDescription = getText(R.string.accessibility_display_inversion_preference_subtitle);
|
||||
mTopIntroTitle = getText(R.string.accessibility_display_inversion_preference_intro_text);
|
||||
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
||||
.authority(getPrefContext().getPackageName())
|
||||
.appendPath(String.valueOf(R.raw.accessibility_color_inversion_banner))
|
||||
.build();
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
updateFooterPreference();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
final View rootView = getActivity().getWindow().peekDecorView();
|
||||
if (rootView != null) {
|
||||
rootView.setAccessibilityPaneTitle(getString(
|
||||
@@ -78,6 +106,11 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
return R.xml.accessibility_color_inversion_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRemoveSwitchPreferenceToggleSwitch() {
|
||||
super.onRemoveSwitchPreferenceToggleSwitch();
|
||||
@@ -94,33 +127,6 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
return getText(R.string.accessibility_display_inversion_shortcut_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mComponentName = COLOR_INVERSION_COMPONENT_NAME;
|
||||
mPackageName = getText(R.string.accessibility_display_inversion_preference_title);
|
||||
mHtmlDescription = getText(R.string.accessibility_display_inversion_preference_subtitle);
|
||||
mTopIntroTitle = getText(R.string.accessibility_display_inversion_preference_intro_text);
|
||||
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
||||
.authority(getPrefContext().getPackageName())
|
||||
.appendPath(String.valueOf(R.raw.accessibility_color_inversion_banner))
|
||||
.build();
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
updateFooterPreference();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerKeysToObserverCallback(
|
||||
AccessibilitySettingsContentObserver contentObserver) {
|
||||
super.registerKeysToObserverCallback(contentObserver);
|
||||
|
||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||
enableServiceFeatureKeys.add(ENABLED);
|
||||
contentObserver.registerKeysToObserverCallback(enableServiceFeatureKeys,
|
||||
key -> updateSwitchBarToggleSwitch());
|
||||
}
|
||||
|
||||
private void updateFooterPreference() {
|
||||
final String title = getPrefContext().getString(
|
||||
R.string.accessibility_color_inversion_about_title);
|
||||
|
@@ -51,6 +51,7 @@ import java.util.List;
|
||||
public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceFragment
|
||||
implements DaltonizerRadioButtonPreferenceController.OnChangeListener {
|
||||
|
||||
private static final String TAG = "ToggleDaltonizerPreferenceFragment";
|
||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
|
||||
private static final String KEY_PREVIEW = "daltonizer_preview";
|
||||
@VisibleForTesting
|
||||
@@ -70,29 +71,24 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF
|
||||
final String[] daltonizerKeys = resources.getStringArray(
|
||||
R.array.daltonizer_mode_keys);
|
||||
|
||||
for (int i = 0; i < daltonizerKeys.length; i++) {
|
||||
for (String daltonizerKey : daltonizerKeys) {
|
||||
sControllers.add(new DaltonizerRadioButtonPreferenceController(
|
||||
context, lifecycle, daltonizerKeys[i]));
|
||||
context, lifecycle, daltonizerKey));
|
||||
}
|
||||
}
|
||||
return sControllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
final View rootView = getActivity().getWindow().peekDecorView();
|
||||
if (rootView != null) {
|
||||
rootView.setAccessibilityPaneTitle(getString(
|
||||
R.string.accessibility_display_daltonizer_preference_title));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(Preference preference) {
|
||||
for (AbstractPreferenceController controller : sControllers) {
|
||||
controller.updateState(preference);
|
||||
}
|
||||
protected void registerKeysToObserverCallback(
|
||||
AccessibilitySettingsContentObserver contentObserver) {
|
||||
super.registerKeysToObserverCallback(contentObserver);
|
||||
|
||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||
enableServiceFeatureKeys.add(ENABLED);
|
||||
contentObserver.registerKeysToObserverCallback(enableServiceFeatureKeys,
|
||||
key -> updateSwitchBarToggleSwitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,14 +104,20 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerKeysToObserverCallback(
|
||||
AccessibilitySettingsContentObserver contentObserver) {
|
||||
super.registerKeysToObserverCallback(contentObserver);
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
final View rootView = getActivity().getWindow().peekDecorView();
|
||||
if (rootView != null) {
|
||||
rootView.setAccessibilityPaneTitle(getString(
|
||||
R.string.accessibility_display_daltonizer_preference_title));
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||
enableServiceFeatureKeys.add(ENABLED);
|
||||
contentObserver.registerKeysToObserverCallback(enableServiceFeatureKeys,
|
||||
key -> updateSwitchBarToggleSwitch());
|
||||
@Override
|
||||
public void onCheckedChanged(Preference preference) {
|
||||
for (AbstractPreferenceController controller : sControllers) {
|
||||
controller.updateState(preference);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFooterPreference() {
|
||||
@@ -179,6 +181,11 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF
|
||||
return R.xml.accessibility_daltonizer_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||
final boolean isEnabled = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
|
||||
|
@@ -54,10 +54,10 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.utils.LocaleUtils;
|
||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
@@ -76,9 +76,24 @@ import java.util.Locale;
|
||||
* Base class for accessibility fragments with toggle, shortcut, some helper functions
|
||||
* and dialog management.
|
||||
*/
|
||||
public abstract class ToggleFeaturePreferenceFragment extends SettingsPreferenceFragment
|
||||
public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
|
||||
implements ShortcutPreference.OnClickCallback, OnMainSwitchChangeListener {
|
||||
|
||||
public static final String KEY_GENERAL_CATEGORY = "general_categories";
|
||||
public static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||
public static final int NOT_SET = -1;
|
||||
protected static final String KEY_TOP_INTRO_PREFERENCE = "top_intro";
|
||||
protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
|
||||
protected static final String KEY_HTML_DESCRIPTION_PREFERENCE = "html_description";
|
||||
protected static final String KEY_SAVED_USER_SHORTCUT_TYPE = "shortcut_type";
|
||||
protected static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
|
||||
protected static final String KEY_SAVED_QS_TOOLTIP_TYPE = "qs_tooltip_type";
|
||||
protected static final String KEY_ANIMATED_IMAGE = "animated_image";
|
||||
// For html description of accessibility service, must follow the rule, such as
|
||||
// <img src="R.drawable.fileName"/>, a11y settings will get the resources successfully.
|
||||
private static final String IMG_PREFIX = "R.drawable.";
|
||||
private static final String DRAWABLE_FOLDER = "drawable";
|
||||
|
||||
protected TopIntroPreference mTopIntroPreference;
|
||||
protected SettingsMainSwitchPreference mToggleServiceSwitchPreference;
|
||||
protected ShortcutPreference mShortcutPreference;
|
||||
@@ -86,28 +101,17 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
protected AccessibilityFooterPreferenceController mFooterPreferenceController;
|
||||
protected String mPreferenceKey;
|
||||
protected Dialog mDialog;
|
||||
|
||||
protected CharSequence mSettingsTitle;
|
||||
protected Intent mSettingsIntent;
|
||||
// The mComponentName maybe null, such as Magnify
|
||||
protected ComponentName mComponentName;
|
||||
protected CharSequence mPackageName;
|
||||
protected Uri mImageUri;
|
||||
private CharSequence mDescription;
|
||||
protected CharSequence mHtmlDescription;
|
||||
protected CharSequence mTopIntroTitle;
|
||||
|
||||
private static final String DRAWABLE_FOLDER = "drawable";
|
||||
protected static final String KEY_TOP_INTRO_PREFERENCE = "top_intro";
|
||||
protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
|
||||
public static final String KEY_GENERAL_CATEGORY = "general_categories";
|
||||
protected static final String KEY_HTML_DESCRIPTION_PREFERENCE = "html_description";
|
||||
public static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||
protected static final String KEY_SAVED_USER_SHORTCUT_TYPE = "shortcut_type";
|
||||
protected static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
|
||||
protected static final String KEY_SAVED_QS_TOOLTIP_TYPE = "qs_tooltip_type";
|
||||
protected static final String KEY_ANIMATED_IMAGE = "animated_image";
|
||||
|
||||
// Save user's shortcutType value when savedInstance has value (e.g. device rotated).
|
||||
protected int mSavedCheckBoxValue = NOT_SET;
|
||||
private CharSequence mDescription;
|
||||
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
|
||||
private AccessibilitySettingsContentObserver mSettingsContentObserver;
|
||||
|
||||
@@ -117,18 +121,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
private AccessibilityQuickSettingsTooltipWindow mTooltipWindow;
|
||||
private boolean mNeedsQSTooltipReshow = false;
|
||||
private int mNeedsQSTooltipType = QuickSettingsTooltipType.GUIDE_TO_EDIT;
|
||||
|
||||
public static final int NOT_SET = -1;
|
||||
// Save user's shortcutType value when savedInstance has value (e.g. device rotated).
|
||||
protected int mSavedCheckBoxValue = NOT_SET;
|
||||
private boolean mSavedAccessibilityFloatingMenuEnabled;
|
||||
|
||||
// For html description of accessibility service, must follow the rule, such as
|
||||
// <img src="R.drawable.fileName"/>, a11y settings will get the resources successfully.
|
||||
private static final String IMG_PREFIX = "R.drawable.";
|
||||
|
||||
private ImageView mImageGetterCacheView;
|
||||
|
||||
private final Html.ImageGetter mImageGetter = (String str) -> {
|
||||
if (str != null && str.startsWith(IMG_PREFIX)) {
|
||||
final String fileName = str.substring(IMG_PREFIX.length());
|
||||
@@ -211,6 +205,28 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(int dialogId) {
|
||||
switch (dialogId) {
|
||||
case DialogEnums.EDIT_SHORTCUT:
|
||||
final int dialogType = WizardManagerHelper.isAnySetupWizard(getIntent())
|
||||
? DialogType.EDIT_SHORTCUT_GENERIC_SUW : DialogType.EDIT_SHORTCUT_GENERIC;
|
||||
mDialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
getPrefContext(), dialogType, getShortcutTitle(),
|
||||
this::callOnAlertDialogCheckboxClicked);
|
||||
setupEditShortcutDialog(mDialog);
|
||||
return mDialog;
|
||||
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
|
||||
mDialog = AccessibilityGestureNavigationTutorial
|
||||
.createAccessibilityTutorialDialog(getPrefContext(),
|
||||
getUserShortcutTypes(), this::callOnTutorialDialogButtonClicked);
|
||||
mDialog.setCanceledOnTouchOutside(false);
|
||||
return mDialog;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
@@ -268,25 +284,9 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(int dialogId) {
|
||||
switch (dialogId) {
|
||||
case DialogEnums.EDIT_SHORTCUT:
|
||||
final int dialogType = WizardManagerHelper.isAnySetupWizard(getIntent())
|
||||
? DialogType.EDIT_SHORTCUT_GENERIC_SUW : DialogType.EDIT_SHORTCUT_GENERIC;
|
||||
mDialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
getPrefContext(), dialogType, getShortcutTitle(),
|
||||
this::callOnAlertDialogCheckboxClicked);
|
||||
setupEditShortcutDialog(mDialog);
|
||||
return mDialog;
|
||||
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
|
||||
mDialog = AccessibilityGestureNavigationTutorial
|
||||
.createAccessibilityTutorialDialog(getPrefContext(),
|
||||
getUserShortcutTypes(), this::callOnTutorialDialogButtonClicked);
|
||||
mDialog.setCanceledOnTouchOutside(false);
|
||||
return mDialog;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
|
||||
}
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
removeActionBarToggleSwitch();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -311,12 +311,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
removeActionBarToggleSwitch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
onPreferenceToggled(mPreferenceKey, isChecked);
|
||||
@@ -335,7 +329,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
|
||||
protected void updateToggleServiceTitle(SettingsMainSwitchPreference switchPreference) {
|
||||
final CharSequence title =
|
||||
getString(R.string.accessibility_service_primary_switch_title, mPackageName);
|
||||
getString(R.string.accessibility_service_primary_switch_title, mPackageName);
|
||||
switchPreference.setTitle(title);
|
||||
}
|
||||
|
||||
@@ -363,15 +357,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
// Implement this to update the state of switch.
|
||||
}
|
||||
|
||||
private void installActionBarToggleSwitch() {
|
||||
onInstallSwitchPreferenceToggleSwitch();
|
||||
}
|
||||
|
||||
private void removeActionBarToggleSwitch() {
|
||||
mToggleServiceSwitchPreference.setOnPreferenceClickListener(null);
|
||||
onRemoveSwitchPreferenceToggleSwitch();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
getActivity().setTitle(title);
|
||||
}
|
||||
@@ -405,15 +390,13 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
}
|
||||
}
|
||||
|
||||
/** Customizes the order by preference key. */
|
||||
protected List<String> getPreferenceOrderList() {
|
||||
final List<String> lists = new ArrayList<>();
|
||||
lists.add(KEY_TOP_INTRO_PREFERENCE);
|
||||
lists.add(KEY_ANIMATED_IMAGE);
|
||||
lists.add(KEY_USE_SERVICE_PREFERENCE);
|
||||
lists.add(KEY_GENERAL_CATEGORY);
|
||||
lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||
return lists;
|
||||
private void installActionBarToggleSwitch() {
|
||||
onInstallSwitchPreferenceToggleSwitch();
|
||||
}
|
||||
|
||||
private void removeActionBarToggleSwitch() {
|
||||
mToggleServiceSwitchPreference.setOnPreferenceClickListener(null);
|
||||
onRemoveSwitchPreferenceToggleSwitch();
|
||||
}
|
||||
|
||||
private void updatePreferenceOrder() {
|
||||
@@ -431,6 +414,17 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
}
|
||||
}
|
||||
|
||||
/** Customizes the order by preference key. */
|
||||
protected List<String> getPreferenceOrderList() {
|
||||
final List<String> lists = new ArrayList<>();
|
||||
lists.add(KEY_TOP_INTRO_PREFERENCE);
|
||||
lists.add(KEY_ANIMATED_IMAGE);
|
||||
lists.add(KEY_USE_SERVICE_PREFERENCE);
|
||||
lists.add(KEY_GENERAL_CATEGORY);
|
||||
lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||
return lists;
|
||||
}
|
||||
|
||||
private Drawable getDrawableFromUri(Uri imageUri) {
|
||||
if (mImageGetterCacheView == null) {
|
||||
mImageGetterCacheView = new ImageView(getPrefContext());
|
||||
@@ -551,7 +545,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
// TODO(b/171272809): Migrate to DashboardFragment.
|
||||
final String title = getString(R.string.accessibility_introduction_title, mPackageName);
|
||||
mFooterPreferenceController = new AccessibilityFooterPreferenceController(
|
||||
screen.getContext(), htmlFooterPreference.getKey());
|
||||
screen.getContext(), htmlFooterPreference.getKey());
|
||||
mFooterPreferenceController.setIntroductionTitle(title);
|
||||
mFooterPreferenceController.displayPreference(screen);
|
||||
}
|
||||
@@ -568,8 +562,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
* Creates {@link AccessibilityFooterPreference} and append into {@link PreferenceScreen}
|
||||
*
|
||||
* @param screen The preference screen to add the footer preference
|
||||
* @param summary The summary of the preference summary.
|
||||
* @param introductionTitle The title of introduction in the footer.
|
||||
* @param summary The summary of the preference summary
|
||||
* @param introductionTitle The title of introduction in the footer
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void createFooterPreference(PreferenceScreen screen, CharSequence summary,
|
||||
@@ -580,7 +574,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
screen.addPreference(footerPreference);
|
||||
|
||||
mFooterPreferenceController = new AccessibilityFooterPreferenceController(
|
||||
screen.getContext(), footerPreference.getKey());
|
||||
screen.getContext(), footerPreference.getKey());
|
||||
mFooterPreferenceController.setIntroductionTitle(introductionTitle);
|
||||
mFooterPreferenceController.displayPreference(screen);
|
||||
}
|
||||
@@ -649,18 +643,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
return value;
|
||||
}
|
||||
|
||||
private static CharSequence getSoftwareShortcutTypeSummary(Context context) {
|
||||
int resId;
|
||||
if (AccessibilityUtil.isFloatingMenuEnabled(context)) {
|
||||
resId = R.string.accessibility_shortcut_edit_summary_software;
|
||||
} else if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
|
||||
resId = R.string.accessibility_shortcut_edit_summary_software_gesture;
|
||||
} else {
|
||||
resId = R.string.accessibility_shortcut_edit_summary_software;
|
||||
}
|
||||
return context.getText(resId);
|
||||
}
|
||||
|
||||
protected CharSequence getShortcutTypeSummary(Context context) {
|
||||
if (!mShortcutPreference.isSettingsEditable()) {
|
||||
return context.getText(R.string.accessibility_shortcut_edit_dialog_title_hardware);
|
||||
@@ -692,6 +674,18 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
null, LocaleUtils.getConcatenatedString(list));
|
||||
}
|
||||
|
||||
private static CharSequence getSoftwareShortcutTypeSummary(Context context) {
|
||||
int resId;
|
||||
if (AccessibilityUtil.isFloatingMenuEnabled(context)) {
|
||||
resId = R.string.accessibility_shortcut_edit_summary_software;
|
||||
} else if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
|
||||
resId = R.string.accessibility_shortcut_edit_summary_software_gesture;
|
||||
} else {
|
||||
resId = R.string.accessibility_shortcut_edit_summary_software;
|
||||
}
|
||||
return context.getText(resId);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked when a button in the tutorial dialog is clicked.
|
||||
*
|
||||
|
@@ -49,19 +49,30 @@ import java.util.List;
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||
|
||||
private static final String REDUCE_BRIGHT_COLORS_ACTIVATED_KEY =
|
||||
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED;
|
||||
private static final String TAG = "ToggleReduceBrightColorsPreferenceFragment";
|
||||
private static final String KEY_INTENSITY = "rbc_intensity";
|
||||
private static final String KEY_PERSIST = "rbc_persist";
|
||||
private static final String REDUCE_BRIGHT_COLORS_ACTIVATED_KEY =
|
||||
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED;
|
||||
|
||||
private ReduceBrightColorsIntensityPreferenceController mRbcIntensityPreferenceController;
|
||||
private ReduceBrightColorsPersistencePreferenceController mRbcPersistencePreferenceController;
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
|
||||
@Override
|
||||
protected void registerKeysToObserverCallback(
|
||||
AccessibilitySettingsContentObserver contentObserver) {
|
||||
super.registerKeysToObserverCallback(contentObserver);
|
||||
|
||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||
enableServiceFeatureKeys.add(REDUCE_BRIGHT_COLORS_ACTIVATED_KEY);
|
||||
contentObserver.registerKeysToObserverCallback(enableServiceFeatureKeys,
|
||||
key -> updateSwitchBarToggleSwitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
||||
.authority(getPrefContext().getPackageName())
|
||||
.appendPath(String.valueOf(R.raw.extra_dim_banner))
|
||||
@@ -85,17 +96,6 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerKeysToObserverCallback(
|
||||
AccessibilitySettingsContentObserver contentObserver) {
|
||||
super.registerKeysToObserverCallback(contentObserver);
|
||||
|
||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||
enableServiceFeatureKeys.add(REDUCE_BRIGHT_COLORS_ACTIVATED_KEY);
|
||||
contentObserver.registerKeysToObserverCallback(enableServiceFeatureKeys,
|
||||
key -> updateSwitchBarToggleSwitch());
|
||||
}
|
||||
|
||||
private void updateGeneralCategoryOrder() {
|
||||
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
|
||||
final SeekBarPreference intensity = findPreference(KEY_INTENSITY);
|
||||
@@ -114,22 +114,12 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
mFooterPreferenceController.displayPreference(getPreferenceScreen());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateSwitchBarToggleSwitch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.REDUCE_BRIGHT_COLORS_SETTINGS;
|
||||
@@ -137,7 +127,7 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
// TODO(170973645): Link to help support page
|
||||
// TODO(b/170973645): Link to help support page
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -146,6 +136,11 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
return R.xml.reduce_bright_colors_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||
if (enabled) {
|
||||
@@ -186,8 +181,8 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
@Override
|
||||
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return getText(type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_reduce_bright_colors_qs_tooltip_content
|
||||
: R.string.accessibility_reduce_bright_colors_auto_added_qs_tooltip_content);
|
||||
? R.string.accessibility_reduce_bright_colors_qs_tooltip_content
|
||||
: R.string.accessibility_reduce_bright_colors_auto_added_qs_tooltip_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -66,22 +66,22 @@ import java.util.StringJoiner;
|
||||
public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
ToggleFeaturePreferenceFragment implements
|
||||
MagnificationModePreferenceController.DialogHelper {
|
||||
// TODO(b/147021230): Move duplicated functions with android/internal/accessibility into util.
|
||||
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
|
||||
|
||||
private CheckBox mSoftwareTypeCheckBox;
|
||||
private CheckBox mHardwareTypeCheckBox;
|
||||
private CheckBox mTripleTapTypeCheckBox;
|
||||
|
||||
private static final String TAG = "ToggleScreenMagnificationPreferenceFragment";
|
||||
private static final char COMPONENT_NAME_SEPARATOR = ':';
|
||||
private static final TextUtils.SimpleStringSplitter sStringColonSplitter =
|
||||
new TextUtils.SimpleStringSplitter(COMPONENT_NAME_SEPARATOR);
|
||||
|
||||
protected SwitchPreference mFollowingTypingSwitchPreference;
|
||||
|
||||
// TODO(b/147021230): Move duplicated functions with android/internal/accessibility into util.
|
||||
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
|
||||
private CheckBox mSoftwareTypeCheckBox;
|
||||
private CheckBox mHardwareTypeCheckBox;
|
||||
private CheckBox mTripleTapTypeCheckBox;
|
||||
private DialogCreatable mDialogDelegate;
|
||||
private MagnificationFollowTypingPreferenceController mFollowTypingPreferenceController;
|
||||
|
||||
protected SwitchPreference mFollowingTypingSwitchPreference;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -125,6 +125,17 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
// TODO(b/171272809): Add back when controllers move to static type
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
final AccessibilityManager am = getPrefContext().getSystemService(
|
||||
@@ -623,15 +634,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isWindowMagnification(Context context) {
|
||||
final int mode = Settings.Secure.getIntForUser(
|
||||
context.getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE,
|
||||
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN,
|
||||
context.getContentResolver().getUserId());
|
||||
return mode == Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW;
|
||||
}
|
||||
|
||||
private static int getUserShortcutTypeFromSettings(Context context) {
|
||||
int shortcutTypes = UserShortcutType.EMPTY;
|
||||
if (hasMagnificationValuesInSettings(context, UserShortcutType.SOFTWARE)) {
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_QS_TOOLTIP_RESHOW;
|
||||
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -41,7 +40,6 @@ import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.annotation.XmlRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.PreferenceManager;
|
||||
@@ -115,15 +113,15 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
final PreferenceScreen screen = spy(new PreferenceScreen(mContext, null));
|
||||
when(screen.getPreferenceManager()).thenReturn(mPreferenceManager);
|
||||
doReturn(screen).when(mFragment).getPreferenceScreen();
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createFragment_shouldOnlyAddPreferencesOnce() {
|
||||
public void setupFragment_getExpectedPreferenceScreenResId() {
|
||||
FragmentController.setupFragment(mFragment, FragmentActivity.class,
|
||||
/* containerViewId= */ 0, /* bundle= */ null);
|
||||
/* containerViewId= */ 0, Bundle.EMPTY);
|
||||
|
||||
// execute exactly once
|
||||
verify(mFragment).addPreferencesFromResource(R.xml.placeholder_prefs);
|
||||
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.placeholder_prefs);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -186,7 +184,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
|
||||
@Test
|
||||
public void dialogCheckboxClicked_hardwareType_skipTimeoutRestriction() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||
null);
|
||||
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
|
||||
@@ -208,7 +205,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
|
||||
@Test
|
||||
public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
@@ -226,7 +222,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
|
||||
@Test
|
||||
public void setupEditShortcutDialog_shortcutPreferenceOn_checkboxIsSavedValue() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
@@ -248,7 +243,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void restoreValueFromSavedInstanceState_assignShortcutTypeToVariable() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||
mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE,
|
||||
this::callEmptyOnClicked);
|
||||
@@ -273,9 +267,8 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onPreferenceToggledOnDisabledService_notShowTooltipView() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
|
||||
mFragment.onPreferenceToggled(mFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ false);
|
||||
mFragment.onPreferenceToggled(
|
||||
ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ false);
|
||||
|
||||
assertThat(getLatestPopupWindow()).isNull();
|
||||
}
|
||||
@@ -283,9 +276,8 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onPreferenceToggledOnEnabledService_showTooltipView() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
|
||||
mFragment.onPreferenceToggled(mFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
|
||||
mFragment.onPreferenceToggled(
|
||||
ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
}
|
||||
@@ -293,32 +285,16 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onPreferenceToggledOnEnabledService_tooltipViewShown_notShowTooltipView() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
mFragment.onPreferenceToggled(mFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
|
||||
mFragment.onPreferenceToggled(
|
||||
ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
|
||||
getLatestPopupWindow().dismiss();
|
||||
|
||||
mFragment.onPreferenceToggled(mFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
|
||||
mFragment.onPreferenceToggled(
|
||||
ToggleFeaturePreferenceFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void restoreValueFromSavedInstanceState_showTooltipView() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
mFragment.onPreferenceToggled(mFragment.KEY_USE_SERVICE_PREFERENCE, /* enabled= */ true);
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
|
||||
final Bundle savedInstanceState = new Bundle();
|
||||
savedInstanceState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
|
||||
mFragment.onCreate(savedInstanceState);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), mock(ViewGroup.class), Bundle.EMPTY);
|
||||
mFragment.onViewCreated(mFragment.getView(), savedInstanceState);
|
||||
mFragment.onAttach(mContext);
|
||||
|
||||
assertThat(getLatestPopupWindow().isShowing()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initTopIntroPreference_hasTopIntroTitle_shouldSetAsExpectedValue() {
|
||||
mFragment.mTopIntroTitle = DEFAULT_TOP_INTRO;
|
||||
@@ -394,6 +370,21 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
return R.xml.placeholder_prefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProcessArguments(Bundle arguments) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@@ -410,11 +401,6 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPreferencesFromResource(@XmlRes int preferencesResId) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateShortcutPreference() {
|
||||
// UI related function, do nothing in tests
|
||||
|
@@ -468,6 +468,11 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
return mPreferenceManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
// do nothing
|
||||
|
Reference in New Issue
Block a user