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

Commit b1ad5977 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

New two-pane mode for PreferenceActivity.

This introduces a whole new way to use PreferenceActivity, as
a container for PreferenceFragments that the user can switch
between from a list of headers.

Change-Id: I1c79b7c78b86790dc460a1414a999aba5de80628
parent ee9907b4
Loading
Loading
Loading
Loading
+174 −6
Original line number Diff line number Diff line
@@ -4299,6 +4299,17 @@
 visibility="public"
>
</field>
<field name="fragment"
 type="int"
 transient="false"
 volatile="false"
 value="16843557"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="freezesText"
 type="int"
 transient="false"
@@ -27640,6 +27651,33 @@
 visibility="public"
>
</method>
<method name="instantiate"
 return="android.app.Fragment"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="fname" type="java.lang.String">
</parameter>
<exception name="ClassNotFoundException" type="java.lang.ClassNotFoundException">
</exception>
<exception name="IllegalAccessException" type="java.lang.IllegalAccessException">
</exception>
<exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
</exception>
<exception name="InstantiationException" type="java.lang.InstantiationException">
</exception>
<exception name="InvocationTargetException" type="java.lang.reflect.InvocationTargetException">
</exception>
<exception name="NoSuchMethodException" type="java.lang.NoSuchMethodException">
</exception>
</method>
<method name="isAdded"
 return="boolean"
 abstract="false"
@@ -124117,6 +124155,17 @@
 visibility="public"
>
</field>
<field name="HONEYCOMB"
 type="int"
 transient="false"
 volatile="false"
 value="10000"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="Bundle"
 extends="java.lang.Object"
@@ -134276,7 +134325,7 @@
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="intent" type="android.content.Intent">
@@ -134289,7 +134338,7 @@
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="preferencesResId" type="int">
@@ -134302,7 +134351,7 @@
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="key" type="java.lang.CharSequence">
@@ -134315,7 +134364,7 @@
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</method>
@@ -134326,11 +134375,65 @@
 synchronized="false"
 static="false"
 final="false"
 deprecated="deprecated"
 visibility="public"
>
</method>
<method name="loadHeadersFromResource"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="resid" type="int">
</parameter>
<parameter name="target" type="java.util.List&lt;android.preference.PreferenceActivity.Header&gt;">
</parameter>
</method>
<method name="onPreferenceTreeClick"
<method name="onBuildHeaders"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="target" type="java.util.List&lt;android.preference.PreferenceActivity.Header&gt;">
</parameter>
</method>
<method name="onGetInitialFragment"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onHeaderClick"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="header" type="android.preference.PreferenceActivity.Header">
</parameter>
<parameter name="position" type="int">
</parameter>
</method>
<method name="onIsHidingHeaders"
 return="boolean"
 abstract="false"
 native="false"
@@ -134340,6 +134443,28 @@
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onIsMultiPane"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onPreferenceTreeClick"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="preferenceScreen" type="android.preference.PreferenceScreen">
</parameter>
<parameter name="preference" type="android.preference.Preference">
@@ -134352,12 +134477,55 @@
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="preferenceScreen" type="android.preference.PreferenceScreen">
</parameter>
</method>
<method name="startWithFragment"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="fragmentName" type="java.lang.String">
</parameter>
</method>
<method name="switchToHeader"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="fragmentName" type="java.lang.String">
</parameter>
</method>
</class>
<class name="PreferenceActivity.Header"
 extends="java.lang.Object"
 abstract="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="PreferenceActivity.Header"
 type="android.preference.PreferenceActivity.Header"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
</class>
<class name="PreferenceCategory"
 extends="android.preference.PreferenceGroup"
+21 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.app;

import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
@@ -227,7 +228,25 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener
    public Fragment() {
    }

    static Fragment instantiate(Activity activity, String fname)
    /**
     * Create a new instance of a Fragment with the given class name.  This is
     * the same as calling its empty constructor.
     *
     * @param context The calling context being used to instantiate the fragment.
     * This is currently just used to get its ClassLoader.
     * @param fname The class name of the fragment to instantiate.
     * @return Returns a new fragment instance.
     * @throws NoSuchMethodException The fragment does not have an empty constructor.
     * @throws ClassNotFoundException The fragment class does not exist.
     * @throws IllegalArgumentException Bad arguments supplied to fragment class
     * constructor (should not happen).
     * @throws InstantiationException Caller does not have permission to instantiate
     * the fragment (for example its constructor is not public).
     * @throws IllegalAccessException Caller does not have permission to access
     * the given fragment class.
     * @throws InvocationTargetException Failure running the fragment's constructor.
     */
    public static Fragment instantiate(Context context, String fname)
            throws NoSuchMethodException, ClassNotFoundException,
            IllegalArgumentException, InstantiationException,
            IllegalAccessException, InvocationTargetException {
@@ -235,7 +254,7 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener

        if (clazz == null) {
            // Class not found in the cache, see if it's real, and try to add it
            clazz = activity.getClassLoader().loadClass(fname);
            clazz = context.getClassLoader().loadClass(fname);
            sClassMap.put(fname, clazz);
        }
        return (Fragment)clazz.newInstance();
+11 −0
Original line number Diff line number Diff line
@@ -196,6 +196,17 @@ public class Build {
         * </ul>
         */
        public static final int GINGERBREAD = CUR_DEVELOPMENT;

        /**
         * Next next version of Android.
         *
         * <p>Applications targeting this or a later release will get these
         * new changes in behavior:</p>
         * <ul>
         * <li> Alerts UI change?
         * </ul>
         */
        public static final int HONEYCOMB = CUR_DEVELOPMENT;
    }
    
    /** The type of build, like "user" or "eng". */
+443 −79

File changed.

Preview size limit exceeded, changes collapsed.

+19 −11
Original line number Diff line number Diff line
@@ -37,6 +37,17 @@ import android.widget.ListView;
 * {@link PreferenceManager#getDefaultSharedPreferences(android.content.Context)}
 * with a context in the same package as this fragment.
 * <p>
 * Furthermore, the preferences shown will follow the visual style of system
 * preferences. It is easy to create a hierarchy of preferences (that can be
 * shown on multiple screens) via XML. For these reasons, it is recommended to
 * use this fragment (as a superclass) to deal with preferences in applications.
 * <p>
 * A {@link PreferenceScreen} object should be at the top of the preference
 * hierarchy. Furthermore, subsequent {@link PreferenceScreen} in the hierarchy
 * denote a screen break--that is the preferences contained within subsequent
 * {@link PreferenceScreen} should be shown on another screen. The preference
 * framework handles showing these other screens from the preference hierarchy.
 * <p>
 * The preference hierarchy can be formed in multiple ways:
 * <li> From an XML file specifying the hierarchy
 * <li> From different {@link Activity Activities} that each specify its own
@@ -61,24 +72,21 @@ import android.widget.ListView;
 * As a convenience, this fragment implements a click listener for any
 * preference in the current hierarchy, see
 * {@link #onPreferenceTreeClick(PreferenceScreen, Preference)}.
 * <p>
 * See {@link PreferenceActivity} for more details.
 *
 * <a name="SampleCode"></a>
 * <h3>Sample Code</h3>
 *
 * <p>The following sample code shows the use if a PreferenceFragment to
 * embed preferences in a larger activity and switch between them.  The content
 * layout of the activity is:</p>
 * <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/layout/fragment_preferences.xml layout}
 * {@sample development/samples/ApiDemos/res/xml/preferences.xml preferences}
 *
 * <p>The code using this layout consists of an activity and three fragments.
 * One of the fragments is a list of categories the user can select; the other
 * two are the different preference options for the categories.</p>
 * <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/app/FragmentPreferences.java
 *      activity}
 * {@sample development/samples/ApiDemos/src/com/example/android/apis/preference/FragmentPreferences.java
 *      fragment}
 *
 * @see Preference
 * @see PreferenceScreen
Loading