Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ee60614 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Small cleanup or DataStore API javadoc."

parents a7c9a5a5 ee3bc34c
Loading
Loading
Loading
Loading
+24 −24
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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) {
@@ -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)
     */
@@ -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)
@@ -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()
@@ -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;
@@ -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() {
@@ -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.
@@ -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
     */
@@ -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}.
+20 −13
Original line number Diff line number Diff line
@@ -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;
@@ -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:
@@ -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
@@ -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() {
@@ -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() {
@@ -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.