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

Commit 30346c43 authored by Romain Guy's avatar Romain Guy
Browse files

Add support for XML-defined adapters.

This is preliminary work for new types of Launcher widgets.

See javadoc in android.widget.Adapters for more details.

Change-Id: I413b8d5f97673e255d84dc07ad112c333c0ce9dc
parent 9fadfe3a
Loading
Loading
Loading
Loading
+321 −0
Original line number Diff line number Diff line
@@ -1802,6 +1802,17 @@
 visibility="public"
>
</field>
<field name="adapter"
 type="int"
 transient="false"
 volatile="false"
 value="16843454"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="addStatesFromChildren"
 type="int"
 transient="false"
@@ -2011,6 +2022,17 @@
 visibility="public"
>
</field>
<field name="as"
 type="int"
 transient="false"
 volatile="false"
 value="16843460"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="author"
 type="int"
 transient="false"
@@ -2671,6 +2693,17 @@
 visibility="public"
>
</field>
<field name="column"
 type="int"
 transient="false"
 volatile="false"
 value="16843463"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="columnDelay"
 type="int"
 transient="false"
@@ -3837,6 +3870,17 @@
 visibility="public"
>
</field>
<field name="from"
 type="int"
 transient="false"
 volatile="false"
 value="16843458"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="fromAlpha"
 type="int"
 transient="false"
@@ -3859,6 +3903,17 @@
 visibility="public"
>
</field>
<field name="fromValue"
 type="int"
 transient="false"
 volatile="false"
 value="16843461"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="fromXDelta"
 type="int"
 transient="false"
@@ -7247,6 +7302,17 @@
 visibility="public"
>
</field>
<field name="selection"
 type="int"
 transient="false"
 volatile="false"
 value="16843455"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="settingsActivity"
 type="int"
 transient="false"
@@ -7434,6 +7500,17 @@
 visibility="public"
>
</field>
<field name="sortOrder"
 type="int"
 transient="false"
 volatile="false"
 value="16843456"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="soundEffectsEnabled"
 type="int"
 transient="false"
@@ -8622,6 +8699,17 @@
 visibility="public"
>
</field>
<field name="to"
 type="int"
 transient="false"
 volatile="false"
 value="16843459"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="toAlpha"
 type="int"
 transient="false"
@@ -8644,6 +8732,17 @@
 visibility="public"
>
</field>
<field name="toValue"
 type="int"
 transient="false"
 volatile="false"
 value="16843462"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="toXDelta"
 type="int"
 transient="false"
@@ -8820,6 +8919,17 @@
 visibility="public"
>
</field>
<field name="uri"
 type="int"
 transient="false"
 volatile="false"
 value="16843457"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="useLevel"
 type="int"
 transient="false"
@@ -9370,6 +9480,28 @@
 visibility="public"
>
</field>
<field name="withClass"
 type="int"
 transient="false"
 volatile="false"
 value="16843465"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="withExpression"
 type="int"
 transient="false"
 volatile="false"
 value="16843464"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="writePermission"
 type="int"
 transient="false"
@@ -197697,6 +197829,195 @@
</parameter>
</method>
</interface>
<class name="Adapters"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="Adapters"
 type="android.widget.Adapters"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
<method name="loadAdapter"
 return="android.widget.BaseAdapter"
 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="id" type="int">
</parameter>
<parameter name="parameters" type="java.lang.Object...">
</parameter>
</method>
<method name="loadCursorAdapter"
 return="android.widget.CursorAdapter"
 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="id" type="int">
</parameter>
<parameter name="uri" type="java.lang.String">
</parameter>
<parameter name="parameters" type="java.lang.Object...">
</parameter>
</method>
<method name="loadCursorAdapter"
 return="android.widget.CursorAdapter"
 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="id" type="int">
</parameter>
<parameter name="cursor" type="android.database.Cursor">
</parameter>
<parameter name="parameters" type="java.lang.Object...">
</parameter>
</method>
</class>
<class name="Adapters.CursorBinder"
 extends="java.lang.Object"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="Adapters.CursorBinder"
 type="android.widget.Adapters.CursorBinder"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="transformation" type="android.widget.Adapters.CursorTransformation">
</parameter>
</constructor>
<method name="bind"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="view" type="android.view.View">
</parameter>
<parameter name="cursor" type="android.database.Cursor">
</parameter>
<parameter name="columnIndex" type="int">
</parameter>
</method>
<field name="mContext"
 type="android.content.Context"
 transient="false"
 volatile="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="protected"
>
</field>
<field name="mTransformation"
 type="android.widget.Adapters.CursorTransformation"
 transient="false"
 volatile="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="protected"
>
</field>
</class>
<class name="Adapters.CursorTransformation"
 extends="java.lang.Object"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="Adapters.CursorTransformation"
 type="android.widget.Adapters.CursorTransformation"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
</constructor>
<method name="transform"
 return="java.lang.String"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="cursor" type="android.database.Cursor">
</parameter>
<parameter name="columnIndex" type="int">
</parameter>
</method>
<method name="transformToResource"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="cursor" type="android.database.Cursor">
</parameter>
<parameter name="columnIndex" type="int">
</parameter>
</method>
<field name="mContext"
 type="android.content.Context"
 transient="false"
 volatile="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="protected"
>
</field>
</class>
<class name="AlphabetIndexer"
 extends="android.database.DataSetObserver"
 abstract="false"
+10 −0
Original line number Diff line number Diff line
@@ -560,6 +560,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        boolean smoothScrollbar = a.getBoolean(R.styleable.AbsListView_smoothScrollbar, true);
        setSmoothScrollbarEnabled(smoothScrollbar);
        
        final int adapterId = a.getResourceId(R.styleable.AbsListView_adapter, 0);
        if (adapterId != 0) {
            final Context c = context;
            post(new Runnable() {
                public void run() {
                    setAdapter(Adapters.loadAdapter(c, adapterId));
                }
            });
        }

        a.recycle();
    }

+1176 −0

File added.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
@@ -62,7 +62,8 @@ public class SimpleCursorAdapter extends ResourceCursorAdapter {
    private int mStringConversionColumn = -1;
    private CursorToStringConverter mCursorToStringConverter;
    private ViewBinder mViewBinder;
    private String[] mOriginalFrom;

    String[] mOriginalFrom;

    /**
     * Constructor.
+65 −0
Original line number Diff line number Diff line
@@ -1510,6 +1510,8 @@
             will use only the number of items in the adapter and the number of items visible
             on screen to determine the scrollbar's properties. -->
        <attr name="smoothScrollbar" format="boolean" />
        <!-- A reference to an XML description of the adapter to attach to the list. -->
        <attr name="adapter" format="reference" />
    </declare-styleable>
    <declare-styleable name="AbsSpinner">
        <!-- Reference to an array resource that will populate the Spinner.  For static content,
@@ -3618,4 +3620,67 @@
        <attr name="settingsActivity" />
    </declare-styleable>
    
    <!-- =============================== -->
    <!-- Adapters attributes             -->
    <!-- =============================== -->
    <eat-comment />
    
    <!-- Adapter used to bind cursors. -->
    <declare-styleable name="CursorAdapter">
        <!-- URI to get the cursor from. Optional. -->
        <attr name="uri" format="string" />
        <!-- Selection statement for the query. Optional. -->
        <attr name="selection" format="string" />
        <!-- Sort order statement for the query. Optional. -->
        <attr name="sortOrder" format="string" />
        <!-- Layout resource used to display each row from the cursor. Mandatory. -->
        <attr name="layout" />
    </declare-styleable>
    
    <!-- Attributes used in bind items for XML cursor adapters. -->
    <declare-styleable name="CursorAdapter_BindItem">
        <!-- The name of the column to bind from. Mandatory. -->
        <attr name="from" format="string" />
        <!-- The resource id of the view to bind to. Mandatory. -->
        <attr name="to" format="reference" />
        <!-- The type of binding. If this value is not specified, the type will be
             inferred from the type of the "to" target view. Mandatory.
             
             The type can be one of:
             <ul>
             <li>string, The content of the column is interpreted as a string.</li>
             <li>image, The content of the column is interpreted as a blob describing an image.</li>
             <li>image-uri, The content of the column is interpreted as a URI to an image.</li>
             <li>drawable, The content of the column is interpreted as a resource id to a drawable.</li>
             <li>A fully qualified class name, corresponding to an implementation of
                 android.widget.Adapters.CursorBinder.</li>
             </ul>
         -->
        <attr name="as" format="string" />
    </declare-styleable>
    
    <!-- Attributes used in select items for XML cursor adapters. -->
    <declare-styleable name="CursorAdapter_SelectItem">
        <!-- The name of the column to select. Mandatory. -->
        <attr name="column" format="string" />
    </declare-styleable>

    <!-- Attributes used to map values to new values in XML cursor adapters' bind items. -->
    <declare-styleable name="CursorAdapter_MapItem">
        <!-- The original value from the column. Mandatory. -->
        <attr name="fromValue" format="string" />
        <!-- The new value from the column. Mandatory. -->
        <attr name="toValue" format="string" />
    </declare-styleable>
    
    <!-- Attributes used to map values to new values in XML cursor adapters' bind items. -->
    <declare-styleable name="CursorAdapter_TransformItem">
        <!-- The transformation expression. Mandatory if "withClass" is not specified. -->
        <attr name="withExpression" format="string" />
        <!-- The transformation class, an implementation of
             android.widget.Adapters.CursorTransformation. Mandatory if "withExpression"
             is not specified. -->
        <attr name="withClass" format="string" />
    </declare-styleable>

</resources>
Loading