diff options
38 files changed, 409 insertions, 211 deletions
diff --git a/api/current.txt b/api/current.txt index 0704018e430e..aa400cd1ea3d 100755..100644 --- a/api/current.txt +++ b/api/current.txt @@ -34633,14 +34633,14 @@ package android.os.strictmode { package android.preference { - public class CheckBoxPreference extends android.preference.TwoStatePreference { + public deprecated class CheckBoxPreference extends android.preference.TwoStatePreference { ctor public CheckBoxPreference(android.content.Context, android.util.AttributeSet, int); ctor public CheckBoxPreference(android.content.Context, android.util.AttributeSet, int, int); ctor public CheckBoxPreference(android.content.Context, android.util.AttributeSet); ctor public CheckBoxPreference(android.content.Context); } - public abstract class DialogPreference extends android.preference.Preference implements android.content.DialogInterface.OnClickListener android.content.DialogInterface.OnDismissListener android.preference.PreferenceManager.OnActivityDestroyListener { + public abstract deprecated class DialogPreference extends android.preference.Preference implements android.content.DialogInterface.OnClickListener android.content.DialogInterface.OnDismissListener android.preference.PreferenceManager.OnActivityDestroyListener { ctor public DialogPreference(android.content.Context, android.util.AttributeSet, int, int); ctor public DialogPreference(android.content.Context, android.util.AttributeSet, int); ctor public DialogPreference(android.content.Context, android.util.AttributeSet); @@ -34673,7 +34673,7 @@ package android.preference { method protected void showDialog(android.os.Bundle); } - public class EditTextPreference extends android.preference.DialogPreference { + public deprecated class EditTextPreference extends android.preference.DialogPreference { ctor public EditTextPreference(android.content.Context, android.util.AttributeSet, int, int); ctor public EditTextPreference(android.content.Context, android.util.AttributeSet, int); ctor public EditTextPreference(android.content.Context, android.util.AttributeSet); @@ -34684,7 +34684,7 @@ package android.preference { method public void setText(java.lang.String); } - public class ListPreference extends android.preference.DialogPreference { + public deprecated class ListPreference extends android.preference.DialogPreference { ctor public ListPreference(android.content.Context, android.util.AttributeSet, int, int); ctor public ListPreference(android.content.Context, android.util.AttributeSet, int); ctor public ListPreference(android.content.Context, android.util.AttributeSet); @@ -34702,7 +34702,7 @@ package android.preference { method public void setValueIndex(int); } - public class MultiSelectListPreference extends android.preference.DialogPreference { + public deprecated class MultiSelectListPreference extends android.preference.DialogPreference { ctor public MultiSelectListPreference(android.content.Context, android.util.AttributeSet, int, int); ctor public MultiSelectListPreference(android.content.Context, android.util.AttributeSet, int); ctor public MultiSelectListPreference(android.content.Context, android.util.AttributeSet); @@ -34718,7 +34718,7 @@ package android.preference { method public void setValues(java.util.Set<java.lang.String>); } - public class Preference implements java.lang.Comparable { + public deprecated class Preference implements java.lang.Comparable { ctor public Preference(android.content.Context, android.util.AttributeSet, int, int); ctor public Preference(android.content.Context, android.util.AttributeSet, int); ctor public Preference(android.content.Context, android.util.AttributeSet); @@ -34815,21 +34815,21 @@ package android.preference { field public static final int DEFAULT_ORDER = 2147483647; // 0x7fffffff } - public static class Preference.BaseSavedState extends android.view.AbsSavedState { + public static deprecated class Preference.BaseSavedState extends android.view.AbsSavedState { ctor public Preference.BaseSavedState(android.os.Parcel); ctor public Preference.BaseSavedState(android.os.Parcelable); field public static final android.os.Parcelable.Creator<android.preference.Preference.BaseSavedState> CREATOR; } - public static abstract interface Preference.OnPreferenceChangeListener { + public static abstract deprecated interface Preference.OnPreferenceChangeListener { method public abstract boolean onPreferenceChange(android.preference.Preference, java.lang.Object); } - public static abstract interface Preference.OnPreferenceClickListener { + public static abstract deprecated interface Preference.OnPreferenceClickListener { method public abstract boolean onPreferenceClick(android.preference.Preference); } - public abstract class PreferenceActivity extends android.app.ListActivity implements android.preference.PreferenceFragment.OnPreferenceStartFragmentCallback { + public abstract deprecated class PreferenceActivity extends android.app.ListActivity implements android.preference.PreferenceFragment.OnPreferenceStartFragmentCallback { ctor public PreferenceActivity(); method public deprecated void addPreferencesFromIntent(android.content.Intent); method public deprecated void addPreferencesFromResource(int); @@ -34869,7 +34869,7 @@ package android.preference { field public static final long HEADER_ID_UNDEFINED = -1L; // 0xffffffffffffffffL } - public static final class PreferenceActivity.Header implements android.os.Parcelable { + public static final deprecated class PreferenceActivity.Header implements android.os.Parcelable { ctor public PreferenceActivity.Header(); method public int describeContents(); method public java.lang.CharSequence getBreadCrumbShortTitle(android.content.res.Resources); @@ -34895,14 +34895,14 @@ package android.preference { field public int titleRes; } - public class PreferenceCategory extends android.preference.PreferenceGroup { + public deprecated class PreferenceCategory extends android.preference.PreferenceGroup { ctor public PreferenceCategory(android.content.Context, android.util.AttributeSet, int, int); ctor public PreferenceCategory(android.content.Context, android.util.AttributeSet, int); ctor public PreferenceCategory(android.content.Context, android.util.AttributeSet); ctor public PreferenceCategory(android.content.Context); } - public abstract interface PreferenceDataStore { + public abstract deprecated interface PreferenceDataStore { method public default boolean getBoolean(java.lang.String, boolean); method public default float getFloat(java.lang.String, float); method public default int getInt(java.lang.String, int); @@ -34932,7 +34932,7 @@ package android.preference { method public abstract boolean onPreferenceStartFragment(android.preference.PreferenceFragment, android.preference.Preference); } - public abstract class PreferenceGroup extends android.preference.Preference { + public abstract deprecated class PreferenceGroup extends android.preference.Preference { ctor public PreferenceGroup(android.content.Context, android.util.AttributeSet, int, int); ctor public PreferenceGroup(android.content.Context, android.util.AttributeSet, int); ctor public PreferenceGroup(android.content.Context, android.util.AttributeSet); @@ -34951,7 +34951,7 @@ package android.preference { method public void setOrderingAsAdded(boolean); } - public class PreferenceManager { + public deprecated class PreferenceManager { method public android.preference.PreferenceScreen createPreferenceScreen(android.content.Context); method public android.preference.Preference findPreference(java.lang.CharSequence); method public static android.content.SharedPreferences getDefaultSharedPreferences(android.content.Context); @@ -34973,19 +34973,19 @@ package android.preference { field public static final java.lang.String METADATA_KEY_PREFERENCES = "android.preference"; } - public static abstract interface PreferenceManager.OnActivityDestroyListener { + public static abstract deprecated interface PreferenceManager.OnActivityDestroyListener { method public abstract void onActivityDestroy(); } - public static abstract interface PreferenceManager.OnActivityResultListener { + public static abstract deprecated interface PreferenceManager.OnActivityResultListener { method public abstract boolean onActivityResult(int, int, android.content.Intent); } - public static abstract interface PreferenceManager.OnActivityStopListener { + public static abstract deprecated interface PreferenceManager.OnActivityStopListener { method public abstract void onActivityStop(); } - public final class PreferenceScreen extends android.preference.PreferenceGroup implements android.widget.AdapterView.OnItemClickListener android.content.DialogInterface.OnDismissListener { + public final deprecated class PreferenceScreen extends android.preference.PreferenceGroup implements android.widget.AdapterView.OnItemClickListener android.content.DialogInterface.OnDismissListener { method public void bind(android.widget.ListView); method public android.app.Dialog getDialog(); method public android.widget.ListAdapter getRootAdapter(); @@ -34994,7 +34994,7 @@ package android.preference { method public void onItemClick(android.widget.AdapterView, android.view.View, int, long); } - public class RingtonePreference extends android.preference.Preference implements android.preference.PreferenceManager.OnActivityResultListener { + public deprecated class RingtonePreference extends android.preference.Preference implements android.preference.PreferenceManager.OnActivityResultListener { ctor public RingtonePreference(android.content.Context, android.util.AttributeSet, int, int); ctor public RingtonePreference(android.content.Context, android.util.AttributeSet, int); ctor public RingtonePreference(android.content.Context, android.util.AttributeSet); @@ -35011,7 +35011,7 @@ package android.preference { method public void setShowSilent(boolean); } - public class SwitchPreference extends android.preference.TwoStatePreference { + public deprecated class SwitchPreference extends android.preference.TwoStatePreference { ctor public SwitchPreference(android.content.Context, android.util.AttributeSet, int, int); ctor public SwitchPreference(android.content.Context, android.util.AttributeSet, int); ctor public SwitchPreference(android.content.Context, android.util.AttributeSet); @@ -35024,7 +35024,7 @@ package android.preference { method public void setSwitchTextOn(int); } - public abstract class TwoStatePreference extends android.preference.Preference { + public abstract deprecated class TwoStatePreference extends android.preference.Preference { ctor public TwoStatePreference(android.content.Context, android.util.AttributeSet, int, int); ctor public TwoStatePreference(android.content.Context, android.util.AttributeSet, int); ctor public TwoStatePreference(android.content.Context, android.util.AttributeSet); diff --git a/api/system-current.txt b/api/system-current.txt index 12c04508efc3..8d800bc172f5 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4357,7 +4357,7 @@ package android.permissionpresenterservice { package android.preference { - public class PreferenceManager { + public deprecated class PreferenceManager { method public boolean isStorageCredentialProtected(); method public void setStorageCredentialProtected(); } diff --git a/core/java/android/preference/CheckBoxPreference.java b/core/java/android/preference/CheckBoxPreference.java index fee3f0f17dbc..948c6aa6a640 100644 --- a/core/java/android/preference/CheckBoxPreference.java +++ b/core/java/android/preference/CheckBoxPreference.java @@ -27,11 +27,18 @@ import android.widget.Checkable; * functionality. * <p> * This preference will store a boolean into the SharedPreferences. - * + * * @attr ref android.R.styleable#CheckBoxPreference_summaryOff * @attr ref android.R.styleable#CheckBoxPreference_summaryOn * @attr ref android.R.styleable#CheckBoxPreference_disableDependentsState + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class CheckBoxPreference extends TwoStatePreference { public CheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr) { diff --git a/core/java/android/preference/DialogPreference.java b/core/java/android/preference/DialogPreference.java index 4b5a7b40fe44..96c85890a472 100644 --- a/core/java/android/preference/DialogPreference.java +++ b/core/java/android/preference/DialogPreference.java @@ -50,7 +50,14 @@ import android.widget.TextView; * @attr ref android.R.styleable#DialogPreference_dialogLayout * @attr ref android.R.styleable#DialogPreference_positiveButtonText * @attr ref android.R.styleable#DialogPreference_negativeButtonText + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public abstract class DialogPreference extends Preference implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener, PreferenceManager.OnActivityDestroyListener { diff --git a/core/java/android/preference/EditTextPreference.java b/core/java/android/preference/EditTextPreference.java index 4d2ac67e42a8..c09cec80139c 100644 --- a/core/java/android/preference/EditTextPreference.java +++ b/core/java/android/preference/EditTextPreference.java @@ -42,7 +42,14 @@ import android.widget.EditText; * This preference will store a string into the SharedPreferences. * <p> * See {@link android.R.styleable#EditText EditText Attributes}. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class EditTextPreference extends DialogPreference { /** * The edit text shown in the dialog. diff --git a/core/java/android/preference/GenericInflater.java b/core/java/android/preference/GenericInflater.java index 3319e6431128..7edc987ee0c1 100644 --- a/core/java/android/preference/GenericInflater.java +++ b/core/java/android/preference/GenericInflater.java @@ -16,13 +16,6 @@ package android.preference; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.util.HashMap; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import android.annotation.XmlRes; import android.content.Context; import android.content.res.XmlResourceParser; @@ -32,6 +25,13 @@ import android.view.ContextThemeWrapper; import android.view.InflateException; import android.view.LayoutInflater; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.util.HashMap; + // TODO: fix generics /** * Generic XML inflater. This has been adapted from {@link LayoutInflater} and @@ -41,7 +41,14 @@ import android.view.LayoutInflater; * @param T The type of the items to inflate * @param P The type of parents (that is those items that contain other items). * Must implement {@link GenericInflater.Parent} + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated abstract class GenericInflater<T, P extends GenericInflater.Parent> { private final boolean DEBUG = false; diff --git a/core/java/android/preference/ListPreference.java b/core/java/android/preference/ListPreference.java index c0c71af8639e..14c1dc81149a 100644 --- a/core/java/android/preference/ListPreference.java +++ b/core/java/android/preference/ListPreference.java @@ -36,7 +36,14 @@ import android.util.AttributeSet; * * @attr ref android.R.styleable#ListPreference_entries * @attr ref android.R.styleable#ListPreference_entryValues + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class ListPreference extends DialogPreference { private CharSequence[] mEntries; private CharSequence[] mEntryValues; diff --git a/core/java/android/preference/MultiCheckPreference.java b/core/java/android/preference/MultiCheckPreference.java index c1260a4e3766..e3d0e26bd59b 100644 --- a/core/java/android/preference/MultiCheckPreference.java +++ b/core/java/android/preference/MultiCheckPreference.java @@ -16,8 +16,6 @@ package android.preference; -import java.util.Arrays; - import android.annotation.ArrayRes; import android.app.AlertDialog.Builder; import android.content.Context; @@ -27,6 +25,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; +import java.util.Arrays; + /** * @hide * A {@link Preference} that displays a list of entries as @@ -34,7 +34,14 @@ import android.util.AttributeSet; * * @attr ref android.R.styleable#ListPreference_entries * @attr ref android.R.styleable#ListPreference_entryValues + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class MultiCheckPreference extends DialogPreference { private CharSequence[] mEntries; private String[] mEntryValues; diff --git a/core/java/android/preference/MultiSelectListPreference.java b/core/java/android/preference/MultiSelectListPreference.java index 138bd8780837..43182d9ebbdd 100644 --- a/core/java/android/preference/MultiSelectListPreference.java +++ b/core/java/android/preference/MultiSelectListPreference.java @@ -35,10 +35,17 @@ import java.util.Set; * This preference will store a set of strings into the SharedPreferences. * This set will contain one or more values from the * {@link #setEntryValues(CharSequence[])} array. - * + * * @attr ref android.R.styleable#MultiSelectListPreference_entries * @attr ref android.R.styleable#MultiSelectListPreference_entryValues + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class MultiSelectListPreference extends DialogPreference { private CharSequence[] mEntries; private CharSequence[] mEntryValues; @@ -65,25 +72,25 @@ public class MultiSelectListPreference extends DialogPreference { public MultiSelectListPreference(Context context, AttributeSet attrs) { this(context, attrs, com.android.internal.R.attr.dialogPreferenceStyle); } - + public MultiSelectListPreference(Context context) { this(context, null); } - + /** * Sets the human-readable entries to be shown in the list. This will be * shown in subsequent dialogs. * <p> * Each entry must have a corresponding index in * {@link #setEntryValues(CharSequence[])}. - * + * * @param entries The entries. * @see #setEntryValues(CharSequence[]) */ public void setEntries(CharSequence[] entries) { mEntries = entries; } - + /** * @see #setEntries(CharSequence[]) * @param entriesResId The entries array as a resource. @@ -91,21 +98,21 @@ public class MultiSelectListPreference extends DialogPreference { public void setEntries(@ArrayRes int entriesResId) { setEntries(getContext().getResources().getTextArray(entriesResId)); } - + /** * The list of entries to be shown in the list in subsequent dialogs. - * + * * @return The list as an array. */ public CharSequence[] getEntries() { return mEntries; } - + /** * The array to find the value to save for a preference when an entry from * entries is selected. If a user clicks on the second item in entries, the * second item in this array will be saved to the preference. - * + * * @param entryValues The array to be used as values to save for the preference. */ public void setEntryValues(CharSequence[] entryValues) { @@ -119,20 +126,20 @@ public class MultiSelectListPreference extends DialogPreference { public void setEntryValues(@ArrayRes int entryValuesResId) { setEntryValues(getContext().getResources().getTextArray(entryValuesResId)); } - + /** * Returns the array of values to be saved for the preference. - * + * * @return The array of values. */ public CharSequence[] getEntryValues() { return mEntryValues; } - + /** * Sets the value of the key. This should contain entries in * {@link #getEntryValues()}. - * + * * @param values The values to set for the key. */ public void setValues(Set<String> values) { @@ -141,17 +148,17 @@ public class MultiSelectListPreference extends DialogPreference { persistStringSet(values); } - + /** * Retrieves the current value of the key. */ public Set<String> getValues() { return mValues; } - + /** * Returns the index of the given value (in the entry values array). - * + * * @param value The value whose index should be returned. * @return The index of the value, or -1 if not found. */ @@ -165,17 +172,17 @@ public class MultiSelectListPreference extends DialogPreference { } return -1; } - + @Override protected void onPrepareDialogBuilder(Builder builder) { super.onPrepareDialogBuilder(builder); - + if (mEntries == null || mEntryValues == null) { throw new IllegalStateException( "MultiSelectListPreference requires an entries array and " + "an entryValues array."); } - + boolean[] checkedItems = getSelectedItems(); builder.setMultiChoiceItems(mEntries, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { @@ -190,24 +197,24 @@ public class MultiSelectListPreference extends DialogPreference { mNewValues.clear(); mNewValues.addAll(mValues); } - + private boolean[] getSelectedItems() { final CharSequence[] entries = mEntryValues; final int entryCount = entries.length; final Set<String> values = mValues; boolean[] result = new boolean[entryCount]; - + for (int i = 0; i < entryCount; i++) { result[i] = values.contains(entries[i].toString()); } - + return result; } - + @Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); - + if (positiveResult && mPreferenceChanged) { final Set<String> values = mNewValues; if (callChangeListener(values)) { @@ -216,25 +223,25 @@ public class MultiSelectListPreference extends DialogPreference { } mPreferenceChanged = false; } - + @Override protected Object onGetDefaultValue(TypedArray a, int index) { final CharSequence[] defaultValues = a.getTextArray(index); final int valueCount = defaultValues.length; final Set<String> result = new HashSet<String>(); - + for (int i = 0; i < valueCount; i++) { result.add(defaultValues[i].toString()); } - + return result; } - + @Override protected void onSetInitialValue(boolean restoreValue, Object defaultValue) { setValues(restoreValue ? getPersistedStringSet(mValues) : (Set<String>) defaultValue); } - + @Override protected Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState(); @@ -242,42 +249,42 @@ public class MultiSelectListPreference extends DialogPreference { // No need to save instance state return superState; } - + final SavedState myState = new SavedState(superState); myState.values = getValues(); return myState; } - + private static class SavedState extends BaseSavedState { Set<String> values; - + public SavedState(Parcel source) { super(source); values = new HashSet<String>(); String[] strings = source.readStringArray(); - + final int stringCount = strings.length; for (int i = 0; i < stringCount; i++) { values.add(strings[i]); } } - + public SavedState(Parcelable superState) { super(superState); } - + @Override public void writeToParcel(Parcel dest, int flags) { super.writeToParcel(dest, flags); dest.writeStringArray(values.toArray(new String[0])); } - + public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() { public SavedState createFromParcel(Parcel in) { return new SavedState(in); } - + public SavedState[] newArray(int size) { return new SavedState[size]; } diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java index 238765702a1d..3c1ba9d02d93 100644 --- a/core/java/android/preference/Preference.java +++ b/core/java/android/preference/Preference.java @@ -86,7 +86,14 @@ import java.util.Set; * @attr ref android.R.styleable#Preference_recycleEnabled * @attr ref android.R.styleable#Preference_singleLineTitle * @attr ref android.R.styleable#Preference_iconSpaceReserved + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class Preference implements Comparable<Preference> { /** * Specify for {@link #setOrder(int)} if a specific order is not required. @@ -165,7 +172,14 @@ public class Preference implements Comparable<Preference> { * {@link Preference} has been changed by the user and is * about to be set and/or persisted. This gives the client a chance * to prevent setting and/or persisting the value. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. + * For more information on using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ + @Deprecated public interface OnPreferenceChangeListener { /** * Called when a Preference has been changed by the user. This is @@ -182,7 +196,14 @@ public class Preference implements Comparable<Preference> { /** * Interface definition for a callback to be invoked when a {@link Preference} is * clicked. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. + * For more information on using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ + @Deprecated public interface OnPreferenceClickListener { /** * Called when a Preference has been clicked. @@ -2070,7 +2091,14 @@ public class Preference implements Comparable<Preference> { /** * A base class for managing the instance state of a {@link Preference}. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. + * For more information on using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ + @Deprecated public static class BaseSavedState extends AbsSavedState { public BaseSavedState(Parcel source) { super(source); diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java index 8ed2605e9e8c..eab5937a370e 100644 --- a/core/java/android/preference/PreferenceActivity.java +++ b/core/java/android/preference/PreferenceActivity.java @@ -97,34 +97,13 @@ import java.util.List; * guide.</p> * </div> * - * <a name="SampleCode"></a> - * <h3>Sample Code</h3> - * - * <p>The following sample code shows a simple preference activity that - * has two different sets of preferences. The implementation, consisting - * of the activity itself as well as its two preference fragments is:</p> - * - * {@sample development/samples/ApiDemos/src/com/example/android/apis/preference/PreferenceWithHeaders.java - * activity} - * - * <p>The preference_headers resource describes the headers to be displayed - * and the fragments associated with them. It is: - * - * {@sample development/samples/ApiDemos/res/xml/preference_headers.xml headers} - * - * <p>The first header is shown by Prefs1Fragment, which populates itself - * from the following XML resource:</p> - * - * {@sample development/samples/ApiDemos/res/xml/fragmented_preferences.xml preferences} - * - * <p>Note that this XML resource contains a preference screen holding another - * fragment, the Prefs1FragmentInner implemented here. This allows the user - * to traverse down a hierarchy of preferences; pressing back will pop each - * fragment off the stack to return to the previous preferences. - * - * <p>See {@link PreferenceFragment} for information on implementing the - * fragments themselves. + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public abstract class PreferenceActivity extends ListActivity implements PreferenceManager.OnPreferenceTreeClickListener, PreferenceFragment.OnPreferenceStartFragmentCallback { @@ -337,7 +316,14 @@ public abstract class PreferenceActivity extends ListActivity implements /** * Description of a single Header item that the user can select. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. + * For more information on using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ + @Deprecated public static final class Header implements Parcelable { /** * Identifier for this header, to correlate with a new list when diff --git a/core/java/android/preference/PreferenceCategory.java b/core/java/android/preference/PreferenceCategory.java index 253481baf1d1..887e46879652 100644 --- a/core/java/android/preference/PreferenceCategory.java +++ b/core/java/android/preference/PreferenceCategory.java @@ -29,7 +29,14 @@ import android.util.AttributeSet; * read the <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a> * guide.</p> * </div> + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class PreferenceCategory extends PreferenceGroup { private static final String TAG = "PreferenceCategory"; diff --git a/core/java/android/preference/PreferenceDataStore.java b/core/java/android/preference/PreferenceDataStore.java index 8caa404d9859..51716329c1ad 100644 --- a/core/java/android/preference/PreferenceDataStore.java +++ b/core/java/android/preference/PreferenceDataStore.java @@ -39,7 +39,14 @@ import java.util.Set; * * @see Preference#setPreferenceDataStore(PreferenceDataStore) * @see PreferenceManager#setPreferenceDataStore(PreferenceDataStore) + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public interface PreferenceDataStore { /** diff --git a/core/java/android/preference/PreferenceFragment.java b/core/java/android/preference/PreferenceFragment.java index 548895e1b618..d6c069f07d22 100644 --- a/core/java/android/preference/PreferenceFragment.java +++ b/core/java/android/preference/PreferenceFragment.java @@ -88,25 +88,14 @@ import android.widget.TextView; * guide.</p> * </div> * - * <a name="SampleCode"></a> - * <h3>Sample Code</h3> - * - * <p>The following sample code shows a simple preference fragment that is - * populated from a resource. The resource it loads is:</p> - * - * {@sample development/samples/ApiDemos/res/xml/preferences.xml preferences} - * - * <p>The fragment implementation itself simply populates the preferences - * when created. Note that the preferences framework takes care of loading - * the current values out of the app preferences and writing them when changed:</p> - * - * {@sample development/samples/ApiDemos/src/com/example/android/apis/preference/FragmentPreferences.java - * fragment} - * * @see Preference * @see PreferenceScreen * - * @deprecated Use {@link android.support.v7.preference.PreferenceFragmentCompat} + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ @Deprecated public abstract class PreferenceFragment extends Fragment implements diff --git a/core/java/android/preference/PreferenceFrameLayout.java b/core/java/android/preference/PreferenceFrameLayout.java index 886338f04c4f..c6678246d649 100644 --- a/core/java/android/preference/PreferenceFrameLayout.java +++ b/core/java/android/preference/PreferenceFrameLayout.java @@ -24,7 +24,14 @@ import android.widget.FrameLayout; /** * @hide + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class PreferenceFrameLayout extends FrameLayout { private static final int DEFAULT_BORDER_TOP = 0; private static final int DEFAULT_BORDER_BOTTOM = 0; diff --git a/core/java/android/preference/PreferenceGroup.java b/core/java/android/preference/PreferenceGroup.java index f135b26fc5df..b33ea4e73f2f 100644 --- a/core/java/android/preference/PreferenceGroup.java +++ b/core/java/android/preference/PreferenceGroup.java @@ -16,15 +16,16 @@ package android.preference; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; import android.text.TextUtils; import android.util.AttributeSet; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * A container for multiple * {@link Preference} objects. It is a base class for Preference objects that are @@ -38,7 +39,14 @@ import android.util.AttributeSet; * </div> * * @attr ref android.R.styleable#PreferenceGroup_orderingFromXml + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public abstract class PreferenceGroup extends Preference implements GenericInflater.Parent<Preference> { /** * The container for child {@link Preference}s. This is sorted based on the diff --git a/core/java/android/preference/PreferenceGroupAdapter.java b/core/java/android/preference/PreferenceGroupAdapter.java index bee45ab0fe32..fb41ea8218b7 100644 --- a/core/java/android/preference/PreferenceGroupAdapter.java +++ b/core/java/android/preference/PreferenceGroupAdapter.java @@ -16,10 +16,6 @@ package android.preference; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import android.graphics.drawable.Drawable; import android.os.Handler; import android.preference.Preference.OnPreferenceChangeInternalListener; @@ -30,6 +26,10 @@ import android.widget.BaseAdapter; import android.widget.FrameLayout; import android.widget.ListView; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * An adapter that returns the {@link Preference} contained in this group. * In most cases, this adapter should be the base class for any custom @@ -49,7 +49,14 @@ import android.widget.ListView; * @see PreferenceCategoryAdapter * * @hide + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class PreferenceGroupAdapter extends BaseAdapter implements OnPreferenceChangeInternalListener { diff --git a/core/java/android/preference/PreferenceInflater.java b/core/java/android/preference/PreferenceInflater.java index 727fbcad9957..04ad1072fa9e 100644 --- a/core/java/android/preference/PreferenceInflater.java +++ b/core/java/android/preference/PreferenceInflater.java @@ -16,16 +16,16 @@ package android.preference; -import com.android.internal.util.XmlUtils; +import android.content.Context; +import android.content.Intent; +import android.util.AttributeSet; -import java.io.IOException; +import com.android.internal.util.XmlUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -import android.content.Context; -import android.content.Intent; -import android.util.AttributeSet; +import java.io.IOException; /** * The {@link PreferenceInflater} is used to inflate preference hierarchies from @@ -34,7 +34,14 @@ import android.util.AttributeSet; * Do not construct this directly, instead use * {@link Context#getSystemService(String)} with * {@link Context#PREFERENCE_INFLATER_SERVICE}. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated class PreferenceInflater extends GenericInflater<Preference, PreferenceGroup> { private static final String TAG = "PreferenceInflater"; private static final String INTENT_TAG_NAME = "intent"; diff --git a/core/java/android/preference/PreferenceManager.java b/core/java/android/preference/PreferenceManager.java index dfee1af1c463..f741bd686beb 100644 --- a/core/java/android/preference/PreferenceManager.java +++ b/core/java/android/preference/PreferenceManager.java @@ -47,7 +47,14 @@ import java.util.List; * {@link PreferenceActivity#addPreferencesFromResource(int)}. * * @see PreferenceActivity + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class PreferenceManager { private static final String TAG = "PreferenceManager"; @@ -1004,7 +1011,14 @@ public class PreferenceManager { * clicked. * * @hide + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. + * For more information on using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ + @Deprecated public interface OnPreferenceTreeClickListener { /** * Called when a preference in the tree rooted at this @@ -1021,7 +1035,14 @@ public class PreferenceManager { /** * Interface definition for a class that will be called when the container's activity * receives an activity result. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. + * For more information on using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ + @Deprecated public interface OnActivityResultListener { /** @@ -1036,7 +1057,14 @@ public class PreferenceManager { /** * Interface definition for a class that will be called when the container's activity * is stopped. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. + * For more information on using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ + @Deprecated public interface OnActivityStopListener { /** @@ -1048,7 +1076,14 @@ public class PreferenceManager { /** * Interface definition for a class that will be called when the container's activity * is destroyed. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. + * For more information on using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ + @Deprecated public interface OnActivityDestroyListener { /** diff --git a/core/java/android/preference/PreferenceScreen.java b/core/java/android/preference/PreferenceScreen.java index dd00a53b4803..c7653c895cd3 100644 --- a/core/java/android/preference/PreferenceScreen.java +++ b/core/java/android/preference/PreferenceScreen.java @@ -86,7 +86,14 @@ import android.widget.TextView; * </div> * * @see PreferenceCategory + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public final class PreferenceScreen extends PreferenceGroup implements AdapterView.OnItemClickListener, DialogInterface.OnDismissListener { diff --git a/core/java/android/preference/RingtonePreference.java b/core/java/android/preference/RingtonePreference.java index cd751cdedd58..025aad0fcaac 100644 --- a/core/java/android/preference/RingtonePreference.java +++ b/core/java/android/preference/RingtonePreference.java @@ -40,7 +40,14 @@ import android.util.AttributeSet; * @attr ref android.R.styleable#RingtonePreference_ringtoneType * @attr ref android.R.styleable#RingtonePreference_showDefault * @attr ref android.R.styleable#RingtonePreference_showSilent + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class RingtonePreference extends Preference implements PreferenceManager.OnActivityResultListener { diff --git a/core/java/android/preference/SeekBarDialogPreference.java b/core/java/android/preference/SeekBarDialogPreference.java index a8e59924f896..32ef82103f6c 100644 --- a/core/java/android/preference/SeekBarDialogPreference.java +++ b/core/java/android/preference/SeekBarDialogPreference.java @@ -28,7 +28,14 @@ import com.android.internal.R; /** * @hide + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class SeekBarDialogPreference extends DialogPreference { private final Drawable mMyIcon; diff --git a/core/java/android/preference/SeekBarPreference.java b/core/java/android/preference/SeekBarPreference.java index cd35f3de87a4..f789e31faa02 100644 --- a/core/java/android/preference/SeekBarPreference.java +++ b/core/java/android/preference/SeekBarPreference.java @@ -29,7 +29,14 @@ import android.widget.SeekBar.OnSeekBarChangeListener; /** * @hide + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class SeekBarPreference extends Preference implements OnSeekBarChangeListener { diff --git a/core/java/android/preference/SeekBarVolumizer.java b/core/java/android/preference/SeekBarVolumizer.java index a871425518e7..f01d5b13b36f 100644 --- a/core/java/android/preference/SeekBarVolumizer.java +++ b/core/java/android/preference/SeekBarVolumizer.java @@ -45,7 +45,14 @@ import com.android.internal.annotations.GuardedBy; /** * Turns a {@link SeekBar} into a volume control. * @hide + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callback { private static final String TAG = "SeekBarVolumizer"; diff --git a/core/java/android/preference/SwitchPreference.java b/core/java/android/preference/SwitchPreference.java index 1ec18bbc94d1..9dea1c829713 100644 --- a/core/java/android/preference/SwitchPreference.java +++ b/core/java/android/preference/SwitchPreference.java @@ -36,7 +36,14 @@ import android.widget.Switch; * @attr ref android.R.styleable#SwitchPreference_switchTextOff * @attr ref android.R.styleable#SwitchPreference_switchTextOn * @attr ref android.R.styleable#SwitchPreference_disableDependentsState + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class SwitchPreference extends TwoStatePreference { @UnsupportedAppUsage private final Listener mListener = new Listener(); diff --git a/core/java/android/preference/TwoStatePreference.java b/core/java/android/preference/TwoStatePreference.java index 2079a63dc810..454472a51556 100644 --- a/core/java/android/preference/TwoStatePreference.java +++ b/core/java/android/preference/TwoStatePreference.java @@ -32,7 +32,14 @@ import android.widget.TextView; * Common base class for preferences that have two selectable states, persist a * boolean value in SharedPreferences, and may have dependent preferences that are * enabled/disabled based on the current state. + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public abstract class TwoStatePreference extends Preference { private CharSequence mSummaryOn; diff --git a/core/java/android/preference/VolumePreference.java b/core/java/android/preference/VolumePreference.java index ea1d1eb11ee3..92d848acc245 100644 --- a/core/java/android/preference/VolumePreference.java +++ b/core/java/android/preference/VolumePreference.java @@ -31,7 +31,14 @@ import com.android.internal.R; /** * @hide + * + * @deprecated Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> + * <a href="{@docRoot}reference/androidx/preference/package-summary.html"> + * Preference Library</a> for consistent behavior across all devices. For more information on + * using the AndroidX Preference Library see + * <a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. */ +@Deprecated public class VolumePreference extends SeekBarDialogPreference implements PreferenceManager.OnActivityStopListener, View.OnKeyListener, SeekBarVolumizer.Callback { @UnsupportedAppUsage diff --git a/core/java/android/preference/package.html b/core/java/android/preference/package.html index d24d5bb78da2..382ed6e76a18 100644 --- a/core/java/android/preference/package.html +++ b/core/java/android/preference/package.html @@ -1,23 +1,9 @@ <HTML> <BODY> -Provides classes that manage application preferences and implement the preferences UI. -Using these ensures that all the preferences within each application are maintained -in the same manner and the user experience is consistent with that of the system and -other applications. -<p> -The preferences portion of an application -should be ran as a separate {@link android.app.Activity} that extends -the {@link android.preference.PreferenceActivity} class. In the PreferenceActivity, a -{@link android.preference.PreferenceScreen} object should be the root element of the layout. -The PreferenceScreen contains {@link android.preference.Preference} elements such as a -{@link android.preference.CheckBoxPreference}, {@link android.preference.EditTextPreference}, -{@link android.preference.ListPreference}, {@link android.preference.PreferenceCategory}, -or {@link android.preference.RingtonePreference}. </p> -<p> -All settings made for a given {@link android.preference.Preference} will be automatically saved -to the application's instance of {@link android.content.SharedPreferences}. Access to the -SharedPreferences is simple with {@link android.preference.Preference#getSharedPreferences()}.</p> -<p> -Note that saved preferences are accessible only to the application that created them.</p> +These classes are deprecated. Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> +<a href="{@docRoot}reference/androidx/preference/package-summary.html"> +Preference Library</a> for consistent behavior across all devices. For more information on +using the AndroidX Preference Library see +<a href="{@docRoot}guide/topics/ui/settings.html">Settings</a>. </BODY> </HTML> diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 5b1544b7b12a..c6155ced9c9f 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -390,7 +390,8 @@ public class Editor { com.android.internal.R.bool.config_enableHapticTextHandle); if (FLAG_USE_MAGNIFIER) { - final Magnifier magnifier = new Magnifier.Builder(mTextView).build(); + final Magnifier magnifier = + Magnifier.createBuilderWithOldMagnifierDefaults(mTextView).build(); mMagnifierAnimator = new MagnifierMotionAnimator(magnifier); } } diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java index 932f182891a5..f4c25c3831be 100644 --- a/core/java/android/widget/Magnifier.java +++ b/core/java/android/widget/Magnifier.java @@ -145,7 +145,47 @@ public final class Magnifier { */ @Deprecated public Magnifier(@NonNull View view) { - this(new Builder(view)); + this(createBuilderWithOldMagnifierDefaults(view)); + } + + static Builder createBuilderWithOldMagnifierDefaults(final View view) { + final Builder params = new Builder(view); + final Context context = view.getContext(); + final TypedArray a = context.obtainStyledAttributes(null, R.styleable.Magnifier, + R.attr.magnifierStyle, 0); + params.mWidth = a.getDimensionPixelSize(R.styleable.Magnifier_magnifierWidth, 0); + params.mHeight = a.getDimensionPixelSize(R.styleable.Magnifier_magnifierHeight, 0); + params.mElevation = a.getDimension(R.styleable.Magnifier_magnifierElevation, 0); + params.mCornerRadius = getDeviceDefaultDialogCornerRadius(context); + params.mZoom = a.getFloat(R.styleable.Magnifier_magnifierZoom, 0); + params.mHorizontalDefaultSourceToMagnifierOffset = + a.getDimensionPixelSize(R.styleable.Magnifier_magnifierHorizontalOffset, 0); + params.mVerticalDefaultSourceToMagnifierOffset = + a.getDimensionPixelSize(R.styleable.Magnifier_magnifierVerticalOffset, 0); + params.mOverlay = new ColorDrawable(a.getColor( + R.styleable.Magnifier_magnifierColorOverlay, Color.TRANSPARENT)); + a.recycle(); + params.mForcePositionWithinWindowSystemInsetsBounds = true; + params.mLeftContentBound = SOURCE_BOUND_MAX_VISIBLE; + params.mTopContentBound = SOURCE_BOUND_MAX_IN_SURFACE; + params.mRightContentBound = SOURCE_BOUND_MAX_VISIBLE; + params.mBottomContentBound = SOURCE_BOUND_MAX_IN_SURFACE; + return params; + } + + /** + * Returns the device default theme dialog corner radius attribute. + * We retrieve this from the device default theme to avoid + * using the values set in the custom application themes. + */ + private static float getDeviceDefaultDialogCornerRadius(final Context context) { + final Context deviceDefaultContext = + new ContextThemeWrapper(context, R.style.Theme_DeviceDefault); + final TypedArray ta = deviceDefaultContext.obtainStyledAttributes( + new int[]{android.R.attr.dialogCornerRadius}); + final float dialogCornerRadius = ta.getDimension(0, 0); + ta.recycle(); + return dialogCornerRadius; } private Magnifier(@NonNull Builder params) { @@ -1105,41 +1145,23 @@ public final class Magnifier { } private void applyDefaults() { - final Context context = mView.getContext(); - final TypedArray a = context.obtainStyledAttributes(null, R.styleable.Magnifier, - R.attr.magnifierStyle, 0); - mWidth = a.getDimensionPixelSize(R.styleable.Magnifier_magnifierWidth, 0); - mHeight = a.getDimensionPixelSize(R.styleable.Magnifier_magnifierHeight, 0); - mElevation = a.getDimension(R.styleable.Magnifier_magnifierElevation, 0); - mCornerRadius = getDeviceDefaultDialogCornerRadius(); - mZoom = a.getFloat(R.styleable.Magnifier_magnifierZoom, 0); + final Resources resources = mView.getContext().getResources(); + mWidth = resources.getDimensionPixelSize(R.dimen.default_magnifier_width); + mHeight = resources.getDimensionPixelSize(R.dimen.default_magnifier_height); + mElevation = resources.getDimension(R.dimen.default_magnifier_elevation); + mCornerRadius = resources.getDimension(R.dimen.default_magnifier_corner_radius); + mZoom = resources.getFloat(R.dimen.default_magnifier_zoom); mHorizontalDefaultSourceToMagnifierOffset = - a.getDimensionPixelSize(R.styleable.Magnifier_magnifierHorizontalOffset, 0); + resources.getDimensionPixelSize(R.dimen.default_magnifier_horizontal_offset); mVerticalDefaultSourceToMagnifierOffset = - a.getDimensionPixelSize(R.styleable.Magnifier_magnifierVerticalOffset, 0); - mOverlay = new ColorDrawable(a.getColor( - R.styleable.Magnifier_magnifierColorOverlay, Color.TRANSPARENT)); - a.recycle(); + resources.getDimensionPixelSize(R.dimen.default_magnifier_vertical_offset); + mOverlay = new ColorDrawable(resources.getColor( + R.color.default_magnifier_color_overlay, null)); mForcePositionWithinWindowSystemInsetsBounds = true; mLeftContentBound = SOURCE_BOUND_MAX_VISIBLE; - mTopContentBound = SOURCE_BOUND_MAX_IN_SURFACE; + mTopContentBound = SOURCE_BOUND_MAX_VISIBLE; mRightContentBound = SOURCE_BOUND_MAX_VISIBLE; - mBottomContentBound = SOURCE_BOUND_MAX_IN_SURFACE; - } - - /** - * Returns the device default theme dialog corner radius attribute. - * We retrieve this from the device default theme to avoid - * using the values set in the custom application themes. - */ - private float getDeviceDefaultDialogCornerRadius() { - final Context deviceDefaultContext = - new ContextThemeWrapper(mView.getContext(), R.style.Theme_DeviceDefault); - final TypedArray ta = deviceDefaultContext.obtainStyledAttributes( - new int[]{android.R.attr.dialogCornerRadius}); - final float dialogCornerRadius = ta.getDimension(0, 0); - ta.recycle(); - return dialogCornerRadius; + mBottomContentBound = SOURCE_BOUND_MAX_VISIBLE; } /** @@ -1186,8 +1208,7 @@ public final class Magnifier { } /** - * Sets the corner radius of the magnifier window, in pixels. - * Defaults to the corner radius defined in the device default theme. + * Sets the corner radius of the magnifier window, in pixels. Defaults to 2dp. * @param cornerRadius the corner radius to be set */ @NonNull @@ -1201,10 +1222,11 @@ public final class Magnifier { /** * Sets an overlay that will be drawn on the top of the magnifier content. * In general, the overlay should not be opaque, in order to let the expected magnifier - * content be partially visible. The default overlay is a white {@link ColorDrawable}, - * with 5% alpha, aiming to make the magnifier distinguishable when shown in dark - * application regions. To disable this default (or in general to have no overlay), the - * parameter should be set to {@code null}. The overlay will be automatically redrawn + * content be partially visible. The default overlay is {@code null} (no overlay). + * As an example, TextView applies a white {@link ColorDrawable} overlay with + * 5% alpha, aiming to make the magnifier distinguishable when shown in dark + * application regions. To disable the overlay, the parameter should be set + * to {@code null}. If not null, the overlay will be automatically redrawn * when the drawable is invalidated. To achieve this, the magnifier will set a new * {@link android.graphics.drawable.Drawable.Callback} for the overlay drawable, * so keep in mind that any existing one set by the application will be lost. @@ -1220,7 +1242,7 @@ public final class Magnifier { * Sets an offset that should be added to the content source center to obtain * the position of the magnifier window, when the {@link #show(float, float)} * method is called. The offset is ignored when {@link #show(float, float, float, float)} - * is used. The offset can be negative, and it defaults to (0dp, -42dp). + * is used. The offset can be negative. It defaults to (0dp, 0dp). * @param horizontalOffset the horizontal component of the offset * @param verticalOffset the vertical component of the offset */ @@ -1406,8 +1428,8 @@ public final class Magnifier { final Resources resources = Resources.getSystem(); final float density = resources.getDisplayMetrics().density; final PointF size = new PointF(); - size.x = resources.getDimension(R.dimen.magnifier_width) / density; - size.y = resources.getDimension(R.dimen.magnifier_height) / density; + size.x = resources.getDimension(R.dimen.default_magnifier_width) / density; + size.y = resources.getDimension(R.dimen.default_magnifier_height) / density; return size; } diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml index ffcd30030271..4122cf02ad20 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -211,6 +211,6 @@ <color name="floating_popup_divider_light">#E9E9E9</color> <!-- Magnifier --> - <color name="magnifier_color_overlay">#0EFFFFFF</color> + <color name="default_magnifier_color_overlay">#00FFFFFF</color> </resources> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index b65c0fd53bd0..e902989094f2 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -578,12 +578,13 @@ <dimen name="floating_toolbar_icon_text_spacing">8dp</dimen> <!-- Magnifier dimensions --> - <dimen name="magnifier_width">100dp</dimen> - <dimen name="magnifier_height">48dp</dimen> - <dimen name="magnifier_elevation">4dp</dimen> - <dimen name="magnifier_vertical_offset">-42dp</dimen> - <dimen name="magnifier_horizontal_offset">0dp</dimen> - <item type="dimen" format="float" name="magnifier_zoom">1.25</item> + <dimen name="default_magnifier_width">100dp</dimen> + <dimen name="default_magnifier_height">48dp</dimen> + <dimen name="default_magnifier_elevation">4dp</dimen> + <dimen name="default_magnifier_corner_radius">2dp</dimen> + <dimen name="default_magnifier_vertical_offset">-42dp</dimen> + <dimen name="default_magnifier_horizontal_offset">0dp</dimen> + <item type="dimen" format="float" name="default_magnifier_zoom">1.25</item> <dimen name="chooser_grid_padding">0dp</dimen> <!-- Spacing around the background change frome service to non-service --> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index ec22f42e14ef..bd53936b596d 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -800,13 +800,13 @@ please see styles_device_defaults.xml. </style> <style name="Widget.Magnifier"> - <item name="magnifierWidth">@dimen/magnifier_width</item> - <item name="magnifierHeight">@dimen/magnifier_height</item> - <item name="magnifierZoom">@dimen/magnifier_zoom</item> - <item name="magnifierElevation">@dimen/magnifier_elevation</item> - <item name="magnifierVerticalOffset">@dimen/magnifier_vertical_offset</item> - <item name="magnifierHorizontalOffset">@dimen/magnifier_horizontal_offset</item> - <item name="magnifierColorOverlay">@color/magnifier_color_overlay</item> + <item name="magnifierWidth">100dp</item> + <item name="magnifierHeight">48dp</item> + <item name="magnifierZoom">1.25</item> + <item name="magnifierElevation">4dp</item> + <item name="magnifierVerticalOffset">-42dp</item> + <item name="magnifierHorizontalOffset">0dp</item> + <item name="magnifierColorOverlay">#0EFFFFFF</item> </style> <!-- Text Appearances --> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index b25e7a8f2793..82c9ff314138 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2637,13 +2637,14 @@ <java-symbol type="attr" name="floatingToolbarDividerColor" /> <!-- Magnifier --> - <java-symbol type="dimen" name="magnifier_width" /> - <java-symbol type="dimen" name="magnifier_height" /> - <java-symbol type="dimen" name="magnifier_elevation" /> - <java-symbol type="dimen" name="magnifier_zoom" /> - <java-symbol type="dimen" name="magnifier_vertical_offset" /> - <java-symbol type="dimen" name="magnifier_horizontal_offset" /> - <java-symbol type="color" name="magnifier_color_overlay" /> + <java-symbol type="dimen" name="default_magnifier_width" /> + <java-symbol type="dimen" name="default_magnifier_height" /> + <java-symbol type="dimen" name="default_magnifier_elevation" /> + <java-symbol type="dimen" name="default_magnifier_corner_radius" /> + <java-symbol type="dimen" name="default_magnifier_zoom" /> + <java-symbol type="dimen" name="default_magnifier_vertical_offset" /> + <java-symbol type="dimen" name="default_magnifier_horizontal_offset" /> + <java-symbol type="color" name="default_magnifier_color_overlay" /> <java-symbol type="attr" name="magnifierWidth" /> <java-symbol type="attr" name="magnifierHeight" /> <java-symbol type="attr" name="magnifierElevation" /> diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml index 163b6b3a3ab7..9e4ea32ed605 100644 --- a/data/etc/privapp-permissions-platform.xml +++ b/data/etc/privapp-permissions-platform.xml @@ -91,7 +91,6 @@ applications that come with the platform <permission name="android.permission.CONNECTIVITY_INTERNAL"/> <permission name="android.permission.CRYPT_KEEPER"/> <permission name="android.permission.DELETE_PACKAGES"/> - <permission name="android.permission.GRANT_PROFILE_OWNER_DEVICE_IDS_ACCESS"/> <permission name="android.permission.INSTALL_PACKAGES"/> <permission name="android.permission.INTERACT_ACROSS_USERS"/> <permission name="android.permission.MANAGE_DEVICE_ADMINS"/> diff --git a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp index 2c73940b9b9c..0331581799b7 100644 --- a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp +++ b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp @@ -461,7 +461,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(RenderNodeDrawable, projectionHwLayer) { ProjectionLayer(int* drawCounter) : SkSurface_Base(SkImageInfo::MakeN32Premul(LAYER_WIDTH, LAYER_HEIGHT), nullptr) , mDrawCounter(drawCounter) {} - virtual sk_sp<SkImage> onNewImageSnapshot() override { + virtual sk_sp<SkImage> onNewImageSnapshot(const SkIRect* bounds) override { EXPECT_EQ(3, (*mDrawCounter)++); EXPECT_EQ(SkRect::MakeLTRB(100 - SCROLL_X, 100 - SCROLL_Y, 300 - SCROLL_X, 300 - SCROLL_Y), diff --git a/libs/hwui/tests/unit/SkiaPipelineTests.cpp b/libs/hwui/tests/unit/SkiaPipelineTests.cpp index 65b4e26ab62f..d16b8be89e20 100644 --- a/libs/hwui/tests/unit/SkiaPipelineTests.cpp +++ b/libs/hwui/tests/unit/SkiaPipelineTests.cpp @@ -247,7 +247,7 @@ public: SkCanvas* onNewCanvas() override { return new T(); } sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override { return nullptr; } - sk_sp<SkImage> onNewImageSnapshot() override { return nullptr; } + sk_sp<SkImage> onNewImageSnapshot(const SkIRect* bounds) override { return nullptr; } T* canvas() { return static_cast<T*>(getCanvas()); } void onCopyOnWrite(ContentChangeMode) override {} void onWritePixels(const SkPixmap&, int x, int y) override {} diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java b/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java index a2bec7917e6f..ee1c1df3f162 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java @@ -969,8 +969,10 @@ class Owners { if (remoteBugreportHash != null) { out.attribute(null, ATTR_REMOTE_BUGREPORT_HASH, remoteBugreportHash); } - out.attribute(null, ATTR_CAN_ACCESS_DEVICE_IDS, - String.valueOf(canAccessDeviceIds)); + if (canAccessDeviceIds) { + out.attribute(null, ATTR_CAN_ACCESS_DEVICE_IDS, + String.valueOf(canAccessDeviceIds)); + } out.endTag(null, tag); } |