Merge "Separate conversations from channels"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6785966..c73ee8d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3032,7 +3032,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
<service
@@ -3044,7 +3044,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
<service
@@ -3056,7 +3056,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
<service
@@ -3068,7 +3068,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
@@ -3081,7 +3081,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
@@ -3094,7 +3094,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
diff --git a/res/layout/preference_static_text.xml b/res/layout/preference_static_text.xml
index b36fd58..41968a2 100644
--- a/res/layout/preference_static_text.xml
+++ b/res/layout/preference_static_text.xml
@@ -34,7 +34,7 @@
android:paddingTop="16dp"
android:paddingBottom="4dp">
<ImageView
- android:id="@+android:id/icon"
+ android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
@@ -45,11 +45,11 @@
android:paddingBottom="16dp"
android:paddingTop="16dp">
- <TextView android:id="@+android:id/title"
+ <TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
- <TextView android:id="@+android:id/summary"
+ <TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
@@ -57,9 +57,10 @@
android:textColor="?android:attr/textColorSecondary"/>
</RelativeLayout>
- <LinearLayout android:id="@+android:id/widget_frame"
+ <LinearLayout android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" />
+
</LinearLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f0b4daa..ad56f21 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2856,7 +2856,7 @@
<!-- Wallpaper settings fragment title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_fragment_title">Choose wallpaper from</string>
<!-- Styles and Wallpaper settings title [CHAR_LIMIT=46] -->
- <string name="style_suggestion_title">Customize your Pixel</string>
+ <string name="style_suggestion_title">Customize your phone</string>
<!-- Styles and Wallpapers summary [CHAR_LIMIT=70] -->
<string name="style_suggestion_summary">Try different styles, wallpapers, and more</string>
<!-- Display settings screen, trigger for screen saver options -->
@@ -4806,7 +4806,7 @@
<!-- Summary for the accessibility magnification setting indicating both "Magnify with button" and "Magnify with triple-tap" are enabled [CHAR LIMIT=50] -->
<string name="accessibility_screen_magnification_state_navbar_gesture">Magnify with shortcut & triple-tap</string>
<!-- Title for the footer text to explain what accessibility service does. [CHAR LIMIT=35] -->
- <string name="accessibility_footer_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
+ <string name="accessibility_introduction_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
<!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
<string name="accessibility_screen_option">Options</string>
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
diff --git a/res/xml/accessibility_daltonizer_settings.xml b/res/xml/accessibility_daltonizer_settings.xml
index 0d9911c..b2ab5ef 100644
--- a/res/xml/accessibility_daltonizer_settings.xml
+++ b/res/xml/accessibility_daltonizer_settings.xml
@@ -53,7 +53,7 @@
</PreferenceCategory>
<PreferenceCategory
- android:key="daltonizer_footer_category" >
+ android:key="daltonizer_footer_category">
<com.android.settingslib.widget.FooterPreference
android:key="daltonizer_footer"
diff --git a/res/xml/accessibility_shortcut_settings.xml b/res/xml/accessibility_shortcut_settings.xml
index f431dec..0bfd6b6 100644
--- a/res/xml/accessibility_shortcut_settings.xml
+++ b/res/xml/accessibility_shortcut_settings.xml
@@ -14,21 +14,22 @@
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/accessibility_global_gesture_preference_title" >
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/accessibility_global_gesture_preference_title">
<Preference
- android:key="accessibility_shortcut_service"
- android:title="@string/accessibility_shortcut_service_title"
- android:fragment="com.android.settings.accessibility.ShortcutServicePickerFragment"/>
+ android:fragment="com.android.settings.accessibility.ShortcutServicePickerFragment"
+ android:key="accessibility_shortcut_service"
+ android:title="@string/accessibility_shortcut_service_title" />
<SwitchPreference
- android:key="accessibility_shortcut_on_lock_screen"
- android:title="@string/accessibility_shortcut_service_on_lock_screen_title"/>
+ android:key="accessibility_shortcut_on_lock_screen"
+ android:title="@string/accessibility_shortcut_service_on_lock_screen_title" />
<com.android.settingslib.widget.FooterPreference
android:key="accessibility_shortcut_footer"
- android:title="@string/accessibility_shortcut_description"
android:selectable="false"
- settings:searchable="false"/>
-</PreferenceScreen>
\ No newline at end of file
+ android:title="@string/accessibility_shortcut_description"
+ settings:searchable="false" />
+
+</PreferenceScreen>
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
index 55edf50..659eaca 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
@@ -15,6 +15,9 @@
*/
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+
import android.accessibilityservice.AccessibilityServiceInfo;
import android.annotation.Nullable;
import android.app.settings.SettingsEnums;
@@ -28,15 +31,14 @@
import android.provider.Settings;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
-import android.widget.Switch;
import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.android.internal.accessibility.AccessibilityShortcutController;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.accessibility.AccessibilityUtils;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
@@ -79,7 +81,7 @@
mOnLockScreenSwitchPreference.setOnPreferenceChangeListener((Preference p, Object o) -> {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
- ((Boolean) o) ? 1 : 0);
+ ((Boolean) o) ? ON : OFF);
return true;
});
}
@@ -87,7 +89,12 @@
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mShortcutPreference.setVisible(false);
+
+ final PreferenceScreen preferenceScreen = getPreferenceScreen();
+ preferenceScreen.findPreference(KEY_GENERAL_CATEGORY).setVisible(false);
+
+ preferenceScreen.setOrderingAsAdded(false);
+ mToggleServiceDividerSwitchPreference.setOrder(mServicePreference.getOrder() - 1);
}
@Override
@@ -111,34 +118,42 @@
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
- mSwitchBar.addOnSwitchChangeListener((Switch switchView, boolean enabled) -> {
+ protected void onRemoveSwitchPreferenceToggleSwitch() {
+ super.onRemoveSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
+ }
+
+ @Override
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
+ boolean enabled = ((SwitchPreference) preference).isChecked();
Context context = getContext();
if (enabled && !shortcutFeatureAvailable(context)) {
- // If no service is configured, we'll disable the shortcut shortly. Give the
- // user a chance to select a service. We'll update the preferences when we resume.
- Settings.Secure.putInt(
- getContentResolver(), Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 1);
+ // If no service is configured, we'll disable the shortcut shortly. Give the user
+ // a chance to select a service. We'll update the preferences when we resume.
+ Settings.Secure.putInt(getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON);
mServicePreference.setEnabled(true);
mServicePreference.performClick();
} else {
onPreferenceToggled(Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, enabled);
}
+ return true;
});
}
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? 1 : 0);
+ Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? ON : OFF);
updatePreferences();
}
@Override
- protected void updateSwitchBarText(SwitchBar switchBar) {
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
getString(R.string.accessibility_global_gesture_preference_title));
- switchBar.setSwitchBarText(switchBarText, switchBarText);
+ switchPreference.setTitle(switchBarText);
}
private void updatePreferences() {
@@ -148,21 +163,21 @@
if (!shortcutFeatureAvailable(context)) {
// If no service is configured, make sure the overall shortcut is turned off
Settings.Secure.putInt(
- getContentResolver(), Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 0);
+ getContentResolver(), Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, OFF);
}
boolean isEnabled = Settings.Secure
- .getInt(cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 1) == 1;
- mSwitchBar.setChecked(isEnabled);
+ .getInt(cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON) == ON;
+ mToggleServiceDividerSwitchPreference.setChecked(isEnabled);
// The shortcut is enabled by default on the lock screen as long as the user has
// enabled the shortcut with the warning dialog
final int dialogShown = Settings.Secure.getInt(
- cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 0);
+ cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, OFF);
final boolean enabledFromLockScreen = Settings.Secure.getInt(
- cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, dialogShown) == 1;
+ cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, dialogShown) == ON;
mOnLockScreenSwitchPreference.setChecked(enabledFromLockScreen);
// Only enable changing the service and lock screen behavior if the shortcut is on
- mServicePreference.setEnabled(mToggleSwitch.isChecked());
- mOnLockScreenSwitchPreference.setEnabled(mToggleSwitch.isChecked());
+ mServicePreference.setEnabled(mToggleServiceDividerSwitchPreference.isChecked());
+ mOnLockScreenSwitchPreference.setEnabled(mToggleServiceDividerSwitchPreference.isChecked());
}
/**
diff --git a/src/com/android/settings/accessibility/AnimatedImagePreference.java b/src/com/android/settings/accessibility/AnimatedImagePreference.java
index ea9e1f8..1609a3c 100644
--- a/src/com/android/settings/accessibility/AnimatedImagePreference.java
+++ b/src/com/android/settings/accessibility/AnimatedImagePreference.java
@@ -33,7 +33,6 @@
*/
public class AnimatedImagePreference extends Preference {
- private boolean mDividerAllowedAbove = false;
private Uri mImageUri;
AnimatedImagePreference(Context context) {
@@ -44,7 +43,6 @@
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- holder.setDividerAllowedAbove(mDividerAllowedAbove);
final ImageView imageView = holder.itemView.findViewById(R.id.animated_img);
if (imageView != null && mImageUri != null) {
@@ -60,18 +58,6 @@
}
/**
- * Sets divider whether to show in preference above.
- *
- * @param allowed true will be drawn on above this item
- */
- public void setDividerAllowedAbove(boolean allowed) {
- if (allowed != mDividerAllowedAbove) {
- mDividerAllowedAbove = allowed;
- notifyChanged();
- }
- }
-
- /**
* Set image uri to display image in {@link ImageView}
*
* @param imageUri the Uri of an image
diff --git a/src/com/android/settings/accessibility/DividerSwitchPreference.java b/src/com/android/settings/accessibility/DividerSwitchPreference.java
new file mode 100644
index 0000000..34b0429
--- /dev/null
+++ b/src/com/android/settings/accessibility/DividerSwitchPreference.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 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 android.content.Context;
+
+import androidx.preference.PreferenceViewHolder;
+import androidx.preference.SwitchPreference;
+
+/**
+ * A switch preference that has a divider below and above. Used for Accessibility Settings use
+ * service.
+ */
+public final class DividerSwitchPreference extends SwitchPreference {
+
+ private Boolean mDividerAllowedAbove;
+ private Boolean mDividerAllowBelow;
+
+ public DividerSwitchPreference(Context context) {
+ super(context);
+ mDividerAllowedAbove = true;
+ mDividerAllowBelow = true;
+ }
+
+ /**
+ * Sets divider whether to show in preference above.
+ *
+ * @param allowed true will be drawn on above this item
+ */
+ public void setDividerAllowedAbove(boolean allowed) {
+ if (mDividerAllowedAbove != allowed) {
+ mDividerAllowedAbove = allowed;
+ notifyChanged();
+ }
+ }
+
+ /**
+ * Sets divider whether to show in preference below.
+ *
+ * @param allowed true will be drawn on below this item
+ */
+ public void setDividerAllowedBelow(boolean allowed) {
+ if (mDividerAllowedAbove != allowed) {
+ mDividerAllowBelow = allowed;
+ notifyChanged();
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ holder.setDividerAllowedAbove(mDividerAllowedAbove);
+ holder.setDividerAllowedBelow(mDividerAllowBelow);
+ }
+}
diff --git a/src/com/android/settings/accessibility/HtmlTextPreference.java b/src/com/android/settings/accessibility/HtmlTextPreference.java
index 0c295e3..fcf4725 100644
--- a/src/com/android/settings/accessibility/HtmlTextPreference.java
+++ b/src/com/android/settings/accessibility/HtmlTextPreference.java
@@ -32,7 +32,6 @@
*/
public final class HtmlTextPreference extends StaticTextPreference {
- private boolean mDividerAllowedAbove = false;
private int mFlag = Html.FROM_HTML_MODE_COMPACT;
private Html.ImageGetter mImageGetter;
private Html.TagHandler mTagHandler;
@@ -45,7 +44,6 @@
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- holder.setDividerAllowedAbove(mDividerAllowedAbove);
final TextView summaryView = holder.itemView.findViewById(android.R.id.summary);
if (summaryView != null && !TextUtils.isEmpty(getSummary())) {
@@ -55,18 +53,6 @@
}
/**
- * Sets divider whether to show in preference above.
- *
- * @param allowed true will be drawn on above this item
- */
- public void setDividerAllowedAbove(boolean allowed) {
- if (allowed != mDividerAllowedAbove) {
- mDividerAllowedAbove = allowed;
- notifyChanged();
- }
- }
-
- /**
* Sets the flag to which text format to be applied.
*
* @param flag to indicate that html text format
diff --git a/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
index a48b71f..93064c5 100644
--- a/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
@@ -17,29 +17,27 @@
package com.android.settings.accessibility;
import android.accessibilityservice.AccessibilityServiceInfo;
-import android.os.Bundle;
import android.view.View;
import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.accessibility.AccessibilityUtils;
/**
- * For accessibility services that target SDK > Q, and
- * {@link AccessibilityServiceInfo#FLAG_REQUEST_ACCESSIBILITY_BUTTON}
- * is set.
+ * Fragment that does not have toggle bar to turn on service to use.
+ *
+ * <p>The child {@link ToggleAccessibilityServicePreferenceFragment} shows the actual UI for
+ * providing basic accessibility service setup.
+ *
+ * <p>For accessibility services that target SDK > Q, and
+ * {@link AccessibilityServiceInfo#FLAG_REQUEST_ACCESSIBILITY_BUTTON} is set.
*/
public class InvisibleToggleAccessibilityServicePreferenceFragment extends
ToggleAccessibilityServicePreferenceFragment implements ShortcutPreference.OnClickListener{
@Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- final SettingsActivity activity = (SettingsActivity) getActivity();
- final SwitchBar mSwitchBar = activity.getSwitchBar();
- mSwitchBar.hide();
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setVisible(false);
}
/**
diff --git a/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
index 0a65709..2739b6b 100644
--- a/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
@@ -25,7 +25,14 @@
import com.google.common.collect.ImmutableSet;
-/** For accessibility services that target SDK <= Q. */
+/**
+ * Fragment that only allowed hardware {@link UserShortcutType} for shortcut to open.
+ *
+ * <p>The child {@link ToggleAccessibilityServicePreferenceFragment} shows the actual UI for
+ * providing basic accessibility service setup.
+ *
+ * <p>For accessibility services that target SDK <= Q.
+ */
public class LegacyAccessibilityServicePreferenceFragment extends
ToggleAccessibilityServicePreferenceFragment {
@@ -38,7 +45,6 @@
mShortcutPreference.setSummary(hardwareTitle);
mShortcutPreference.setSettingsVisibility(View.GONE);
- // Only allowed hardware PreferredShortcutType in this fragment.
setAllowedPreferredShortcutType(UserShortcutType.HARDWARE);
}
diff --git a/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
index c9257a9..82d80e0 100644
--- a/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -28,7 +28,7 @@
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
- mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
}
@Override
@@ -39,10 +39,10 @@
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
- if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
- mToggleSwitch.isChecked());
+ mToggleServiceDividerSwitchPreference.isChecked());
}
super.onStop();
diff --git a/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
index 2c8485b..9953faf 100644
--- a/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -28,7 +28,7 @@
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
- mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
}
@Override
@@ -39,10 +39,10 @@
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
- if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
- mToggleSwitch.isChecked());
+ mToggleServiceDividerSwitchPreference.isChecked());
}
super.onStop();
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 6d64a23..a75c536 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -39,12 +39,13 @@
import android.view.View;
import android.view.accessibility.AccessibilityManager;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.password.ConfirmDeviceCredentialActivity;
-import com.android.settings.widget.SwitchBar;
-import com.android.settings.widget.ToggleSwitch;
import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.List;
@@ -186,21 +187,21 @@
}
@Override
- protected void updateSwitchBarText(SwitchBar switchBar) {
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
final String switchBarText = (info == null) ? "" :
getString(R.string.accessibility_service_master_switch_title,
info.getResolveInfo().loadLabel(getPackageManager()));
- switchBar.setSwitchBarText(switchBarText, switchBarText);
+ switchPreference.setTitle(switchBarText);
}
private void updateSwitchBarToggleSwitch() {
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getPrefContext())
.contains(mComponentName);
- if (mSwitchBar.isChecked() == checked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
return;
}
- mSwitchBar.setCheckedInternal(checked);
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
}
/**
@@ -251,7 +252,7 @@
}
private void handleConfirmServiceEnabled(boolean confirmed) {
- mSwitchBar.setCheckedInternal(confirmed);
+ mToggleServiceDividerSwitchPreference.setChecked(confirmed);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, confirmed);
onPreferenceToggled(mPreferenceKey, confirmed);
}
@@ -274,9 +275,9 @@
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(this::onBeforeCheckedChanged);
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(this::onPreferenceClick);
}
@Override
@@ -410,9 +411,10 @@
mDialog.dismiss();
}
- private boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
+ private boolean onPreferenceClick(Preference preference) {
+ boolean checked = ((DividerSwitchPreference) preference).isChecked();
if (checked) {
- mSwitchBar.setCheckedInternal(false);
+ mToggleServiceDividerSwitchPreference.setChecked(false);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED,
/* disableService */ false);
if (!mShortcutPreference.getChecked()) {
@@ -424,7 +426,7 @@
}
}
} else {
- mSwitchBar.setCheckedInternal(true);
+ mToggleServiceDividerSwitchPreference.setChecked(true);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED,
/* enableService */ true);
showDialog(DialogEnums.DISABLE_WARNING_FROM_TOGGLE);
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index d25be83..ffde1e3 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -31,10 +31,10 @@
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
@@ -66,22 +66,22 @@
}
@Override
- protected void onRemoveSwitchBarToggleSwitch() {
- super.onRemoveSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(null);
+ protected void onRemoveSwitchPreferenceToggleSwitch() {
+ super.onRemoveSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
}
@Override
- protected void updateSwitchBarText(SwitchBar switchBar) {
- switchBar.setSwitchBarText(R.string.accessibility_display_inversion_switch_title,
- R.string.accessibility_display_inversion_switch_title);
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
+ switchPreference.setTitle(R.string.accessibility_display_inversion_switch_title);
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
updateSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
+ boolean checked = ((SwitchPreference) preference).isChecked();
onPreferenceToggled(mPreferenceKey, checked);
return false;
});
@@ -135,10 +135,10 @@
private void updateSwitchBarToggleSwitch() {
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
- if (mSwitchBar.isChecked() == checked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
return;
}
- mSwitchBar.setCheckedInternal(checked);
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 9a6aefd..f2b84e5 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -34,10 +34,10 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
@@ -51,6 +51,7 @@
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
private static final String CATEGORY_FOOTER_KEY = "daltonizer_footer_category";
+ private static final String CATEGORY_MODE_KEY = "daltonizer_mode_category";
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
private final Handler mHandler = new Handler();
private SettingsContentObserver mSettingsContentObserver;
@@ -98,6 +99,11 @@
super.onViewCreated(view, savedInstanceState);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.setOrderingAsAdded(false);
+
+ final PreferenceCategory modeCategory = preferenceScreen.findPreference(
+ CATEGORY_MODE_KEY);
+ modeCategory.setOrder(Integer.MAX_VALUE - 1);
+
final PreferenceCategory footerCategory = preferenceScreen.findPreference(
CATEGORY_FOOTER_KEY);
footerCategory.setOrder(Integer.MAX_VALUE);
@@ -148,22 +154,22 @@
}
@Override
- protected void onRemoveSwitchBarToggleSwitch() {
- super.onRemoveSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(null);
+ protected void onRemoveSwitchPreferenceToggleSwitch() {
+ super.onRemoveSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
}
@Override
- protected void updateSwitchBarText(SwitchBar switchBar) {
- switchBar.setSwitchBarText(R.string.accessibility_daltonizer_master_switch_title,
- R.string.accessibility_daltonizer_master_switch_title);
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
+ switchPreference.setTitle(R.string.accessibility_daltonizer_master_switch_title);
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
updateSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
+ boolean checked = ((SwitchPreference) preference).isChecked();
onPreferenceToggled(mPreferenceKey, checked);
return false;
});
@@ -177,10 +183,10 @@
private void updateSwitchBarToggleSwitch() {
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
- if (mSwitchBar.isChecked() == checked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
return;
}
- mSwitchBar.setCheckedInternal(checked);
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 8764b12..5571591 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -40,13 +40,14 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.widget.SwitchBar;
-import com.android.settings.widget.ToggleSwitch;
+import com.android.settingslib.widget.FooterPreference;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -64,8 +65,7 @@
public abstract class ToggleFeaturePreferenceFragment extends SettingsPreferenceFragment
implements ShortcutPreference.OnClickListener {
- protected SwitchBar mSwitchBar;
- protected ToggleSwitch mToggleSwitch;
+ protected DividerSwitchPreference mToggleServiceDividerSwitchPreference;
protected ShortcutPreference mShortcutPreference;
protected Preference mSettingsPreference;
protected String mPreferenceKey;
@@ -76,11 +76,10 @@
protected ComponentName mComponentName;
protected CharSequence mPackageName;
protected Uri mImageUri;
- protected CharSequence mStaticDescription;
protected CharSequence mHtmlDescription;
private static final String ANCHOR_TAG = "a";
private static final String DRAWABLE_FOLDER = "drawable";
-
+ protected static final String KEY_GENERAL_CATEGORY = "categories";
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
@@ -133,28 +132,32 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- SettingsActivity activity = (SettingsActivity) getActivity();
- mSwitchBar = activity.getSwitchBar();
- mToggleSwitch = mSwitchBar.getSwitch();
-
- onProcessArguments(getArguments());
- updateSwitchBarText(mSwitchBar);
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+ final SwitchBar switchBar = activity.getSwitchBar();
+ switchBar.hide();
PreferenceScreen preferenceScreen = getPreferenceScreen();
if (mImageUri != null) {
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
getPrefContext());
animatedImagePreference.setImageUri(mImageUri);
- animatedImagePreference.setDividerAllowedAbove(true);
+ animatedImagePreference.setSelectable(false);
preferenceScreen.addPreference(animatedImagePreference);
}
- final PreferenceCategory category = new PreferenceCategory(getPrefContext());
- category.setTitle(R.string.accessibility_screen_option);
- preferenceScreen.addPreference(category);
+ mToggleServiceDividerSwitchPreference = new DividerSwitchPreference(getPrefContext());
+ preferenceScreen.addPreference(mToggleServiceDividerSwitchPreference);
+
+ onProcessArguments(getArguments());
+ updateToggleServiceTitle(mToggleServiceDividerSwitchPreference);
+
+ final PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
+ groupCategory.setKey(KEY_GENERAL_CATEGORY);
+ groupCategory.setTitle(R.string.accessibility_screen_option);
+ preferenceScreen.addPreference(groupCategory);
initShortcutPreference(savedInstanceState);
- category.addPreference(mShortcutPreference);
+ groupCategory.addPreference(mShortcutPreference);
// Show the "Settings" menu as if it were a preference screen.
if (mSettingsTitle != null && mSettingsIntent != null) {
@@ -166,37 +169,27 @@
// The downloaded app may not show Settings. The framework app has Settings.
if (mSettingsPreference != null) {
- category.addPreference(mSettingsPreference);
+ groupCategory.addPreference(mSettingsPreference);
}
- if (mStaticDescription != null || mHtmlDescription != null) {
- final PreferenceCategory footerCategory = new PreferenceCategory(getPrefContext());
- final CharSequence title = getString(R.string.accessibility_footer_title, mPackageName);
- footerCategory.setTitle(title);
- preferenceScreen.addPreference(footerCategory);
+ if (mHtmlDescription != null) {
+ final PreferenceCategory introductionCategory = new PreferenceCategory(
+ getPrefContext());
+ final CharSequence title = getString(R.string.accessibility_introduction_title,
+ mPackageName);
+ introductionCategory.setTitle(title);
+ preferenceScreen.addPreference(introductionCategory);
- if (mStaticDescription != null) {
- final StaticTextPreference staticTextPreference = new StaticTextPreference(
- getPrefContext());
- staticTextPreference.setSummary(mStaticDescription);
- staticTextPreference.setSelectable(/* selectable= */ false);
- footerCategory.addPreference(staticTextPreference);
- }
+ // For accessibility service, avoid malicious links made by third party developer.
+ final List<String> unsupportedTagList = new ArrayList<>();
+ unsupportedTagList.add(ANCHOR_TAG);
- if (mHtmlDescription != null) {
- // For accessibility service, avoid malicious links made by third party developer.
- final List<String> unsupportedTagList = new ArrayList<>();
- unsupportedTagList.add(ANCHOR_TAG);
-
- final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
- getPrefContext());
- htmlTextPreference.setSummary(mHtmlDescription);
- htmlTextPreference.setImageGetter(mImageGetter);
- htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
- htmlTextPreference.setDividerAllowedAbove(true);
- htmlTextPreference.setSelectable(/* selectable= */ false);
- footerCategory.addPreference(htmlTextPreference);
- }
+ final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(getPrefContext());
+ htmlTextPreference.setSummary(mHtmlDescription);
+ htmlTextPreference.setImageGetter(mImageGetter);
+ htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
+ htmlTextPreference.setSelectable(false);
+ introductionCategory.addPreference(htmlTextPreference);
}
}
@@ -311,31 +304,27 @@
removeActionBarToggleSwitch();
}
- protected void updateSwitchBarText(SwitchBar switchBar) {
- // Implement this to provide meaningful text in switch bar.
- switchBar.setSwitchBarText(R.string.accessibility_service_master_switch_title,
- R.string.accessibility_service_master_switch_title);
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
+ switchPreference.setTitle(R.string.accessibility_service_master_switch_title);
}
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
- protected void onInstallSwitchBarToggleSwitch() {
+ protected void onInstallSwitchPreferenceToggleSwitch() {
// Implement this to set a checked listener.
}
- protected void onRemoveSwitchBarToggleSwitch() {
+ protected void onRemoveSwitchPreferenceToggleSwitch() {
// Implement this to reset a checked listener.
}
private void installActionBarToggleSwitch() {
- mSwitchBar.show();
- onInstallSwitchBarToggleSwitch();
+ onInstallSwitchPreferenceToggleSwitch();
}
private void removeActionBarToggleSwitch() {
- mToggleSwitch.setOnBeforeCheckedChangeListener(null);
- onRemoveSwitchBarToggleSwitch();
- mSwitchBar.hide();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
+ onRemoveSwitchPreferenceToggleSwitch();
}
public void setTitle(String title) {
@@ -349,7 +338,7 @@
// Enabled.
if (arguments.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
final boolean enabled = arguments.getBoolean(AccessibilitySettings.EXTRA_CHECKED);
- mSwitchBar.setCheckedInternal(enabled);
+ mToggleServiceDividerSwitchPreference.setChecked(enabled);
}
// Title.
@@ -363,11 +352,11 @@
// Summary.
if (arguments.containsKey(AccessibilitySettings.EXTRA_SUMMARY_RES)) {
final int summary = arguments.getInt(AccessibilitySettings.EXTRA_SUMMARY_RES);
- mStaticDescription = getText(summary);
+ createFooterPreference(getText(summary));
} else if (arguments.containsKey(AccessibilitySettings.EXTRA_SUMMARY)) {
final CharSequence summary = arguments.getCharSequence(
AccessibilitySettings.EXTRA_SUMMARY);
- mStaticDescription = summary;
+ createFooterPreference(summary);
}
}
@@ -493,8 +482,9 @@
if (info.isEmpty()) {
info = new HashSet<>();
} else {
- final Set<String> filtered = info.stream().filter(
- str -> str.contains(componentName)).collect(Collectors.toSet());
+ final Set<String> filtered = info.stream()
+ .filter(str -> str.contains(componentName))
+ .collect(Collectors.toSet());
info.removeAll(filtered);
}
final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(
@@ -538,9 +528,9 @@
final Set<String> info = SharedPreferenceUtils.getUserShortcutType(context);
final String componentName = mComponentName.flattenToString();
- final Set<String> filtered = info.stream().filter(
- str -> str.contains(componentName)).collect(
- Collectors.toSet());
+ final Set<String> filtered = info.stream()
+ .filter(str -> str.contains(componentName))
+ .collect(Collectors.toSet());
if (filtered.isEmpty()) {
return defaultValue;
}
@@ -635,4 +625,10 @@
public void onSettingsClicked(ShortcutPreference preference) {
mUserShortcutTypeCache = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
}
+
+ private void createFooterPreference(CharSequence title) {
+ final PreferenceScreen preferenceScreen = getPreferenceScreen();
+ preferenceScreen.addPreference(new FooterPreference.Builder(getActivity()).setTitle(
+ title).build());
+ }
}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 5182593..7ca2abf 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -60,10 +60,13 @@
import java.util.StringJoiner;
import java.util.stream.Collectors;
+/**
+ * Fragment that shows the actual UI for providing basic magnification accessibility service setup
+ * and does not have toggle bar to turn on service to use.
+ */
public class ToggleScreenMagnificationPreferenceFragment extends
ToggleFeaturePreferenceFragment {
- private static final String SETTINGS_KEY = "screen_magnification_settings";
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
@@ -429,11 +432,9 @@
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
-
- // Magnify is temporary-use app which uses shortcut to magnify screen, not by toggle.
- mSwitchBar.hide();
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setVisible(false);
}
@Override
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
index 5fe62a7..3b786ff 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
@@ -32,11 +32,12 @@
// Log the final choice in value if it's different from the previous value.
Bundle args = getArguments();
if ((args != null) && args.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
- if (mToggleSwitch.isChecked() != args.getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != args.getBoolean(
+ AccessibilitySettings.EXTRA_CHECKED)) {
// TODO: Distinguish between magnification modes
mMetricsFeatureProvider.action(getContext(),
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION,
- mToggleSwitch.isChecked());
+ mToggleServiceDividerSwitchPreference.isChecked());
}
}
super.onStop();
diff --git a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
index 29c031d..0f114fd 100644
--- a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -27,7 +27,7 @@
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
- mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
}
@Override
@@ -38,11 +38,11 @@
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
- if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
- SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER, mToggleSwitch.isChecked());
+ SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
+ mToggleServiceDividerSwitchPreference.isChecked());
}
-
super.onStop();
}
}
diff --git a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
index da94abc..09598f6 100644
--- a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -27,7 +27,7 @@
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
- mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
}
@Override
@@ -38,10 +38,10 @@
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
- if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
- mToggleSwitch.isChecked());
+ mToggleServiceDividerSwitchPreference.isChecked());
}
super.onStop();
diff --git a/src/com/android/settings/applications/AppHeaderPreferenceController.java b/src/com/android/settings/applications/AppHeaderPreferenceController.java
index 0f473e7..8a77d6f 100644
--- a/src/com/android/settings/applications/AppHeaderPreferenceController.java
+++ b/src/com/android/settings/applications/AppHeaderPreferenceController.java
@@ -21,11 +21,11 @@
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.util.IconDrawableFactory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.widget.EntityHeaderController;
@@ -94,7 +94,8 @@
EntityHeaderController
.newInstance(activity, mParent, mHeaderPreference.findViewById(R.id.entity_header))
.setRecyclerView(mParent.getListView(), mLifecycle)
- .setIcon(Utils.getBadgedIcon(mParent.getContext(), mPackageInfo.applicationInfo))
+ .setIcon(IconDrawableFactory.newInstance(activity).getBadgedIcon(
+ mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(packageManager))
.setSummary(mPackageInfo)
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
diff --git a/src/com/android/settings/applications/AppInfoWithHeader.java b/src/com/android/settings/applications/AppInfoWithHeader.java
index 7bf9f64..9e3842e 100644
--- a/src/com/android/settings/applications/AppInfoWithHeader.java
+++ b/src/com/android/settings/applications/AppInfoWithHeader.java
@@ -20,11 +20,11 @@
import android.app.Activity;
import android.os.Bundle;
+import android.util.IconDrawableFactory;
import android.util.Log;
import androidx.preference.Preference;
-import com.android.settings.Utils;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
@@ -47,7 +47,8 @@
final Preference pref = EntityHeaderController
.newInstance(activity, this, null /* header */)
.setRecyclerView(getListView(), getSettingsLifecycle())
- .setIcon(Utils.getBadgedIcon(getContext(), mPackageInfo.applicationInfo))
+ .setIcon(IconDrawableFactory.newInstance(getContext())
+ .getBadgedIcon(mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
.setSummary(mPackageInfo)
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 440882f..8e31290 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -29,6 +29,7 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
+import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -146,7 +147,7 @@
* accessibility purposes.
*/
public EntityHeaderController setIcon(ApplicationsState.AppEntry appEntry) {
- mIcon = Utils.getBadgedIcon(mAppContext, appEntry.info);
+ mIcon = IconDrawableFactory.newInstance(mAppContext).getBadgedIcon(appEntry.info);
return this;
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
index 9bebc9a..35a2d19 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
@@ -32,7 +32,6 @@
import com.android.settings.R;
import com.android.settings.accessibility.ToggleFeaturePreferenceFragment.AccessibilityUserShortcutType;
-import com.android.settings.widget.SwitchBar;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -82,9 +81,9 @@
mySet.add(TEST_SERVICE_KEY_2);
mySet.add(TEST_SERVICE_KEY_3);
- final Set<String> filtered = mySet.stream().filter(
- str -> str.contains(TEST_SERVICE_NAME_1)).collect(
- Collectors.toSet());
+ final Set<String> filtered = mySet.stream()
+ .filter(str -> str.contains(TEST_SERVICE_NAME_1))
+ .collect(Collectors.toSet());
mySet.removeAll(filtered);
assertThat(mySet).doesNotContain(TEST_SERVICE_KEY_1);
@@ -93,28 +92,26 @@
@Test
public void stringSet_convertA11yUserShortcutType_shouldReturnPreferredShortcut() {
- int type = 0;
Set<String> mySet = new HashSet<>();
mySet.add(TEST_SERVICE_KEY_1);
mySet.add(TEST_SERVICE_KEY_2);
mySet.add(TEST_SERVICE_KEY_3);
- final Set<String> filtered = mySet.stream().filter(
- str -> str.contains(TEST_SERVICE_NAME_1)).collect(
- Collectors.toSet());
- for (String str : filtered) {
- final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(str);
- type = shortcut.getUserShortcutType();
- }
+ final Set<String> filtered = mySet.stream()
+ .filter(str -> str.contains(TEST_SERVICE_NAME_1))
+ .collect(Collectors.toSet());
+ final String str = (String) filtered.toArray()[0];
+ final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(str);
+ final int type = shortcut.getUserShortcutType();
assertThat(type).isEqualTo(TEST_SERVICE_VALUE_1);
}
@Test
public void createFragment_shouldOnlyAddPreferencesOnce() {
mFragment = spy(new ToggleFeaturePreferenceFragmentTestable());
- FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId*/,
- null /* bundle */);
+ FragmentController.setupFragment(mFragment, FragmentActivity.class,
+ /* containerViewId= */ 0, /* bundle= */null);
// execute exactly once
verify(mFragment).addPreferencesFromResource(R.xml.placeholder_prefs);
@@ -152,11 +149,5 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
// do nothing
}
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- mSwitchBar = mock(SwitchBar.class);
- super.onActivityCreated(savedInstanceState);
- }
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
index a1a0ee1..1f63c9c4 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
@@ -39,7 +39,6 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
-import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
import com.android.settingslib.applications.ApplicationsState;
@@ -59,7 +58,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowEntityHeaderController.class, ShadowUtils.class})
+@Config(shadows = ShadowEntityHeaderController.class)
public class AppInfoWithHeaderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
index 55890c9..c82cbe5 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
@@ -42,7 +42,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.LayoutPreference;
@@ -55,10 +54,8 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowUtils.class)
public class AppHeaderViewPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
index eadd33a..c1f33c6 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
@@ -18,10 +18,7 @@
import android.content.ComponentName;
import android.content.Context;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
import android.hardware.fingerprint.FingerprintManager;
import android.os.UserHandle;
import android.os.UserManager;
@@ -147,11 +144,6 @@
return sResultLinks;
}
- @Implementation
- protected static Drawable getBadgedIcon(Context context, ApplicationInfo appInfo) {
- return new ColorDrawable(0);
- }
-
public static void setHandledDomains(ArraySet<String> links) {
sResultLinks = links;
}
diff --git a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
index df9a2c1..1d600a4 100644
--- a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
@@ -30,6 +30,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.ColorDrawable;
@@ -37,6 +38,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
@@ -44,6 +46,7 @@
import androidx.preference.Preference;
import com.android.settings.R;
+import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.widget.LayoutPreference;
import org.junit.Before;
@@ -255,6 +258,20 @@
}
@Test
+ public void setIcon_usingAppEntry_shouldLoadIconFromDrawableFactory() {
+ final View view = mLayoutInflater
+ .inflate(R.layout.settings_entity_header, null /* root */);
+ final ApplicationsState.AppEntry entry = mock(ApplicationsState.AppEntry.class);
+ entry.info = new ApplicationInfo();
+ mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
+ mController.setIcon(entry).done(mActivity);
+ final ImageView iconView = view.findViewById(R.id.entity_header_icon);
+
+ // ... entry.icon is still empty. This means the icon didn't come from cache.
+ assertThat(entry.icon).isNull();
+ }
+
+ @Test
public void bindButton_hasAppNotifIntent_shouldShowButton() {
final View appLinks = mLayoutInflater
.inflate(R.layout.settings_entity_header, null /* root */);