Loading core/java/android/preference/Preference.java +24 −24 Original line number Diff line number Diff line Loading @@ -457,8 +457,8 @@ public class Preference implements Comparable<Preference> { } /** * Return the extras Bundle object associated with this preference, * returning null if there is not currently one. * Return the extras Bundle object associated with this preference, returning {@code null} if * there is not currently one. */ public Bundle peekExtras() { return mExtras; Loading Loading @@ -996,7 +996,7 @@ public class Preference implements Comparable<Preference> { * the persistent {@link SharedPreferences} storage by default or into * {@link PreferenceDataStore} if assigned. * * @param persistent Set true if it should store its value(s) into the {@link SharedPreferences}. * @param persistent set {@code true} if it should store its value(s) into the storage. */ public void setPersistent(boolean persistent) { mPersistent = persistent; Loading Loading @@ -1057,7 +1057,7 @@ public class Preference implements Comparable<Preference> { * * @param preferenceScreen A {@link PreferenceScreen} whose hierarchy click * listener should be called in the proper order (between other * processing). May be null. * processing). May be {@code null}. * @hide */ public void performClick(PreferenceScreen preferenceScreen) { Loading Loading @@ -1124,9 +1124,9 @@ public class Preference implements Comparable<Preference> { * {@link SharedPreferences}, this is intended behavior to improve * performance. * * @return The {@link SharedPreferences} where this Preference reads its value(s), or null if it * isn't attached to a Preference hierarchy or if {@link PreferenceDataStore} is used * instead. * @return the {@link SharedPreferences} where this Preference reads its value(s). If * this preference isn't attached to a Preference hierarchy or if * a {@link PreferenceDataStore} has been set, this method returns {@code null}. * @see #getEditor() * @see #setPreferenceDataStore(PreferenceDataStore) */ Loading @@ -1151,9 +1151,9 @@ public class Preference implements Comparable<Preference> { * not show up in the SharedPreferences, this is intended behavior to * improve performance. * * @return A {@link SharedPreferences.Editor} where this preference saves its value(s), or null * if it isn't attached to a Preference hierarchy or if {@link PreferenceDataStore} is * used instead. * @return a {@link SharedPreferences.Editor} where this preference saves its value(s). If * this preference isn't attached to a Preference hierarchy or if * a {@link PreferenceDataStore} has been set, this method returns {@code null}. * @see #shouldCommit() * @see #getSharedPreferences() * @see #setPreferenceDataStore(PreferenceDataStore) Loading @@ -1171,7 +1171,7 @@ public class Preference implements Comparable<Preference> { * {@link #getEditor()}. This may return false in situations where batch * committing is being done (by the manager) to improve performance. * * <p>If this preference is using {@link PreferenceDataStore} this value should be irrelevant. * <p>If this preference is using {@link PreferenceDataStore} this value is irrelevant. * * @return Whether the Preference should commit its saved value(s). * @see #getEditor() Loading Loading @@ -1275,10 +1275,10 @@ public class Preference implements Comparable<Preference> { } /** * Assigns a {@link PreferenceGroup} as the parent of this Preference. Set null to remove * the current parent. * Assigns a {@link PreferenceGroup} as the parent of this Preference. Set {@code null} to * remove the current parent. * * @param parentGroup Parent preference group of this Preference or null if none. * @param parentGroup Parent preference group of this Preference or {@code null} if none. */ void assignParent(@Nullable PreferenceGroup parentGroup) { mParentGroup = parentGroup; Loading Loading @@ -1447,10 +1447,10 @@ public class Preference implements Comparable<Preference> { } /** * Returns the {@link PreferenceGroup} which is this Preference assigned to or null if this * preference is not assigned to any group or is a root Preference. * Returns the {@link PreferenceGroup} which is this Preference assigned to or {@code null} if * this preference is not assigned to any group or is a root Preference. * * @return The parent PreferenceGroup or null if not attached to any. * @return the parent PreferenceGroup or {@code null} if not attached to any */ @Nullable public PreferenceGroup getParent() { Loading Loading @@ -1505,7 +1505,7 @@ public class Preference implements Comparable<Preference> { * if {@link #shouldPersist()} is true). * * <p>In case of using {@link PreferenceDataStore}, the <var>restorePersistedValue</var> is * always false. But the default value (if provided) is set. * always {@code true}. But the default value (if provided) is set. * * <p>This may not always be called. One example is if it should not persist * but there is no default value given. Loading Loading @@ -1928,9 +1928,9 @@ public class Preference implements Comparable<Preference> { * state. This state should only contain information that is not persistent * or can be reconstructed later. * * @return A Parcelable object containing the current dynamic state of * this Preference, or null if there is nothing interesting to save. * The default implementation returns null. * @return A Parcelable object containing the current dynamic state of this Preference, or * {@code null} if there is nothing interesting to save. The default implementation * returns {@code null}. * @see #onRestoreInstanceState * @see #saveHierarchyState */ Loading Loading @@ -1976,9 +1976,9 @@ public class Preference implements Comparable<Preference> { } /** * Hook allowing a Preference to re-apply a representation of its internal * state that had previously been generated by {@link #onSaveInstanceState}. * This function will never be called with a null state. * Hook allowing a Preference to re-apply a representation of its internal state that had * previously been generated by {@link #onSaveInstanceState}. This function will never be called * with a {@code null} state. * * @param state The saved state that had previously been returned by * {@link #onSaveInstanceState}. Loading core/java/android/preference/PreferenceManager.java +20 −13 Original line number Diff line number Diff line Loading @@ -93,8 +93,8 @@ public class PreferenceManager { private SharedPreferences mSharedPreferences; /** * Data store to be used by the Preferences or null if {@link android.content.SharedPreferences} * should be used. * Data store to be used by the Preferences or {@code null} if * {@link android.content.SharedPreferences} should be used. */ @Nullable private PreferenceDataStore mPreferenceDataStore; Loading Loading @@ -484,11 +484,16 @@ public class PreferenceManager { /** * Gets a {@link SharedPreferences} instance that preferences managed by this will use. * * @return A {@link SharedPreferences} instance pointing to the file that contains the values of * preferences that are managed by this or null if {@link PreferenceDataStore} is used instead. * @return a {@link SharedPreferences} instance pointing to the file that contains the values of * preferences that are managed by this PreferenceManager. If a * {@link PreferenceDataStore} has been set, this method returns {@code null}. */ public SharedPreferences getSharedPreferences() { if (mSharedPreferences == null && getPreferenceDataStore() == null) { if (mPreferenceDataStore != null) { return null; } if (mSharedPreferences == null) { final Context storageContext; switch (mStorage) { case STORAGE_DEVICE_PROTECTED: Loading Loading @@ -564,8 +569,8 @@ public class PreferenceManager { /** * Finds a {@link Preference} based on its key. * * @param key The key of the preference to retrieve. * @return The {@link Preference} with the key, or null. * @param key the key of the preference to retrieve * @return the {@link Preference} with the key, or {@code null} * @see PreferenceGroup#findPreference(CharSequence) */ @Nullable Loading Loading @@ -659,11 +664,11 @@ public class PreferenceManager { /** * Returns an editor to use when modifying the shared preferences. * <p> * Do NOT commit unless {@link #shouldCommit()} returns true. * * @return An editor to use to write to shared preferences or null if * {@link PreferenceDataStore} is used instead. * <p>Do NOT commit unless {@link #shouldCommit()} returns true. * * @return an editor to use to write to shared preferences. If a {@link PreferenceDataStore} * has been set, this method returns {@code null}. * @see #shouldCommit() */ SharedPreferences.Editor getEditor() { Loading @@ -687,6 +692,8 @@ public class PreferenceManager { * {@link #getEditor()}. This will return false in cases where the writes * should be batched, for example when inflating preferences from XML. * * <p>If preferences are using {@link PreferenceDataStore} this value is irrelevant. * * @return Whether the client should commit. */ boolean shouldCommit() { Loading @@ -711,8 +718,8 @@ public class PreferenceManager { * Returns the activity that shows the preferences. This is useful for doing * managed queries, but in most cases the use of {@link #getContext()} is * preferred. * <p> * This will return null if this class was instantiated with a Context * * <p>This will return {@code null} if this class was instantiated with a Context * instead of Activity. For example, when setting the default values. * * @return The activity that shows the preferences. Loading Loading
core/java/android/preference/Preference.java +24 −24 Original line number Diff line number Diff line Loading @@ -457,8 +457,8 @@ public class Preference implements Comparable<Preference> { } /** * Return the extras Bundle object associated with this preference, * returning null if there is not currently one. * Return the extras Bundle object associated with this preference, returning {@code null} if * there is not currently one. */ public Bundle peekExtras() { return mExtras; Loading Loading @@ -996,7 +996,7 @@ public class Preference implements Comparable<Preference> { * the persistent {@link SharedPreferences} storage by default or into * {@link PreferenceDataStore} if assigned. * * @param persistent Set true if it should store its value(s) into the {@link SharedPreferences}. * @param persistent set {@code true} if it should store its value(s) into the storage. */ public void setPersistent(boolean persistent) { mPersistent = persistent; Loading Loading @@ -1057,7 +1057,7 @@ public class Preference implements Comparable<Preference> { * * @param preferenceScreen A {@link PreferenceScreen} whose hierarchy click * listener should be called in the proper order (between other * processing). May be null. * processing). May be {@code null}. * @hide */ public void performClick(PreferenceScreen preferenceScreen) { Loading Loading @@ -1124,9 +1124,9 @@ public class Preference implements Comparable<Preference> { * {@link SharedPreferences}, this is intended behavior to improve * performance. * * @return The {@link SharedPreferences} where this Preference reads its value(s), or null if it * isn't attached to a Preference hierarchy or if {@link PreferenceDataStore} is used * instead. * @return the {@link SharedPreferences} where this Preference reads its value(s). If * this preference isn't attached to a Preference hierarchy or if * a {@link PreferenceDataStore} has been set, this method returns {@code null}. * @see #getEditor() * @see #setPreferenceDataStore(PreferenceDataStore) */ Loading @@ -1151,9 +1151,9 @@ public class Preference implements Comparable<Preference> { * not show up in the SharedPreferences, this is intended behavior to * improve performance. * * @return A {@link SharedPreferences.Editor} where this preference saves its value(s), or null * if it isn't attached to a Preference hierarchy or if {@link PreferenceDataStore} is * used instead. * @return a {@link SharedPreferences.Editor} where this preference saves its value(s). If * this preference isn't attached to a Preference hierarchy or if * a {@link PreferenceDataStore} has been set, this method returns {@code null}. * @see #shouldCommit() * @see #getSharedPreferences() * @see #setPreferenceDataStore(PreferenceDataStore) Loading @@ -1171,7 +1171,7 @@ public class Preference implements Comparable<Preference> { * {@link #getEditor()}. This may return false in situations where batch * committing is being done (by the manager) to improve performance. * * <p>If this preference is using {@link PreferenceDataStore} this value should be irrelevant. * <p>If this preference is using {@link PreferenceDataStore} this value is irrelevant. * * @return Whether the Preference should commit its saved value(s). * @see #getEditor() Loading Loading @@ -1275,10 +1275,10 @@ public class Preference implements Comparable<Preference> { } /** * Assigns a {@link PreferenceGroup} as the parent of this Preference. Set null to remove * the current parent. * Assigns a {@link PreferenceGroup} as the parent of this Preference. Set {@code null} to * remove the current parent. * * @param parentGroup Parent preference group of this Preference or null if none. * @param parentGroup Parent preference group of this Preference or {@code null} if none. */ void assignParent(@Nullable PreferenceGroup parentGroup) { mParentGroup = parentGroup; Loading Loading @@ -1447,10 +1447,10 @@ public class Preference implements Comparable<Preference> { } /** * Returns the {@link PreferenceGroup} which is this Preference assigned to or null if this * preference is not assigned to any group or is a root Preference. * Returns the {@link PreferenceGroup} which is this Preference assigned to or {@code null} if * this preference is not assigned to any group or is a root Preference. * * @return The parent PreferenceGroup or null if not attached to any. * @return the parent PreferenceGroup or {@code null} if not attached to any */ @Nullable public PreferenceGroup getParent() { Loading Loading @@ -1505,7 +1505,7 @@ public class Preference implements Comparable<Preference> { * if {@link #shouldPersist()} is true). * * <p>In case of using {@link PreferenceDataStore}, the <var>restorePersistedValue</var> is * always false. But the default value (if provided) is set. * always {@code true}. But the default value (if provided) is set. * * <p>This may not always be called. One example is if it should not persist * but there is no default value given. Loading Loading @@ -1928,9 +1928,9 @@ public class Preference implements Comparable<Preference> { * state. This state should only contain information that is not persistent * or can be reconstructed later. * * @return A Parcelable object containing the current dynamic state of * this Preference, or null if there is nothing interesting to save. * The default implementation returns null. * @return A Parcelable object containing the current dynamic state of this Preference, or * {@code null} if there is nothing interesting to save. The default implementation * returns {@code null}. * @see #onRestoreInstanceState * @see #saveHierarchyState */ Loading Loading @@ -1976,9 +1976,9 @@ public class Preference implements Comparable<Preference> { } /** * Hook allowing a Preference to re-apply a representation of its internal * state that had previously been generated by {@link #onSaveInstanceState}. * This function will never be called with a null state. * Hook allowing a Preference to re-apply a representation of its internal state that had * previously been generated by {@link #onSaveInstanceState}. This function will never be called * with a {@code null} state. * * @param state The saved state that had previously been returned by * {@link #onSaveInstanceState}. Loading
core/java/android/preference/PreferenceManager.java +20 −13 Original line number Diff line number Diff line Loading @@ -93,8 +93,8 @@ public class PreferenceManager { private SharedPreferences mSharedPreferences; /** * Data store to be used by the Preferences or null if {@link android.content.SharedPreferences} * should be used. * Data store to be used by the Preferences or {@code null} if * {@link android.content.SharedPreferences} should be used. */ @Nullable private PreferenceDataStore mPreferenceDataStore; Loading Loading @@ -484,11 +484,16 @@ public class PreferenceManager { /** * Gets a {@link SharedPreferences} instance that preferences managed by this will use. * * @return A {@link SharedPreferences} instance pointing to the file that contains the values of * preferences that are managed by this or null if {@link PreferenceDataStore} is used instead. * @return a {@link SharedPreferences} instance pointing to the file that contains the values of * preferences that are managed by this PreferenceManager. If a * {@link PreferenceDataStore} has been set, this method returns {@code null}. */ public SharedPreferences getSharedPreferences() { if (mSharedPreferences == null && getPreferenceDataStore() == null) { if (mPreferenceDataStore != null) { return null; } if (mSharedPreferences == null) { final Context storageContext; switch (mStorage) { case STORAGE_DEVICE_PROTECTED: Loading Loading @@ -564,8 +569,8 @@ public class PreferenceManager { /** * Finds a {@link Preference} based on its key. * * @param key The key of the preference to retrieve. * @return The {@link Preference} with the key, or null. * @param key the key of the preference to retrieve * @return the {@link Preference} with the key, or {@code null} * @see PreferenceGroup#findPreference(CharSequence) */ @Nullable Loading Loading @@ -659,11 +664,11 @@ public class PreferenceManager { /** * Returns an editor to use when modifying the shared preferences. * <p> * Do NOT commit unless {@link #shouldCommit()} returns true. * * @return An editor to use to write to shared preferences or null if * {@link PreferenceDataStore} is used instead. * <p>Do NOT commit unless {@link #shouldCommit()} returns true. * * @return an editor to use to write to shared preferences. If a {@link PreferenceDataStore} * has been set, this method returns {@code null}. * @see #shouldCommit() */ SharedPreferences.Editor getEditor() { Loading @@ -687,6 +692,8 @@ public class PreferenceManager { * {@link #getEditor()}. This will return false in cases where the writes * should be batched, for example when inflating preferences from XML. * * <p>If preferences are using {@link PreferenceDataStore} this value is irrelevant. * * @return Whether the client should commit. */ boolean shouldCommit() { Loading @@ -711,8 +718,8 @@ public class PreferenceManager { * Returns the activity that shows the preferences. This is useful for doing * managed queries, but in most cases the use of {@link #getContext()} is * preferred. * <p> * This will return null if this class was instantiated with a Context * * <p>This will return {@code null} if this class was instantiated with a Context * instead of Activity. For example, when setting the default values. * * @return The activity that shows the preferences. Loading