OSDN Git Service

use standard android dimensions. support for dark theme on listcontent
authorKoushik Dutta <koushd@gmail.com>
Tue, 26 Feb 2013 08:07:56 +0000 (00:07 -0800)
committerKoushik Dutta <koushd@gmail.com>
Tue, 26 Feb 2013 08:07:56 +0000 (00:07 -0800)
21 files changed:
Widgets/res/drawable/list_content_left.xml
Widgets/res/drawable/list_content_left_dark.xml [new file with mode: 0644]
Widgets/res/drawable/list_content_right.xml
Widgets/res/drawable/list_content_right_dark.xml [new file with mode: 0644]
Widgets/res/layout-large/list_content.xml
Widgets/res/layout-large/list_item_selectable.xml
Widgets/res/layout-v14/list_item_base.xml
Widgets/res/layout/list_item.xml
Widgets/res/layout/list_item_base.xml
Widgets/res/layout/list_item_selectable.xml
Widgets/res/values-v14/styles.xml [new file with mode: 0644]
Widgets/res/values/attrs.xml [new file with mode: 0644]
Widgets/res/values/color.xml
Widgets/res/values/dimens.xml
Widgets/res/values/styles.xml [new file with mode: 0644]
Widgets/src/com/koushikdutta/widgets/ListContentFragment.java
WidgetsSample/AndroidManifest.xml
WidgetsSample/gen/com/koushikdutta/widgets/R.java
WidgetsSample/gen/com/koushikdutta/widgets/sample/R.java
WidgetsSample/res/values-v14/styles.xml
WidgetsSample/res/values/styles.xml

index f7f062f..1c95273 100644 (file)
@@ -8,7 +8,7 @@
     </item>
     <item android:left="1dp" android:top="1dp" android:bottom="1dp">
         <shape android:shape="rectangle" >
-            <solid android:color="@android:color/white" />
+            <solid android:color="@android:color/background_light" />
         </shape>
     </item>
 
diff --git a/Widgets/res/drawable/list_content_left_dark.xml b/Widgets/res/drawable/list_content_left_dark.xml
new file mode 100644 (file)
index 0000000..61a6012
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item>
+        <shape android:shape="rectangle" >
+            <solid android:color="@android:color/darker_gray" />
+        </shape>
+    </item>
+    <item android:left="1dp" android:top="1dp" android:bottom="1dp">
+        <shape android:shape="rectangle" >
+            <solid android:color="@android:color/background_dark" />
+        </shape>
+    </item>
+
+</layer-list>
\ No newline at end of file
index c952bcc..8e6970f 100644 (file)
@@ -8,7 +8,7 @@
     </item>
     <item android:left="1dp" android:right="1dp" android:top="1dp" android:bottom="1dp">
         <shape android:shape="rectangle" >
-            <solid android:color="@android:color/white" />
+            <solid android:color="@android:color/background_light" />
         </shape>
     </item>
 
diff --git a/Widgets/res/drawable/list_content_right_dark.xml b/Widgets/res/drawable/list_content_right_dark.xml
new file mode 100644 (file)
index 0000000..6f50759
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item>
+        <shape android:shape="rectangle" >
+            <solid android:color="@android:color/darker_gray" />
+        </shape>
+    </item>
+    <item android:left="1dp" android:right="1dp" android:top="1dp" android:bottom="1dp">
+        <shape android:shape="rectangle" >
+            <solid android:color="@android:color/background_dark" />
+        </shape>
+    </item>
+
+</layer-list>
\ No newline at end of file
index 78637b4..a8ce9f1 100644 (file)
@@ -2,7 +2,7 @@
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
-    android:background="@color/list_content_background" >
+    android:background="?attr/listContentBackground" >
 
     <ImageView
         android:id="@+id/watermark"
@@ -38,7 +38,7 @@
                 android:layout_height="wrap_content"
                 android:layout_marginTop="16dp"
                 android:layout_weight="1"
-                android:background="@drawable/list_content_left"
+                android:background="?attr/listItemsLeftBackground"
                 android:orientation="vertical" >
 
                 <ListView
@@ -64,7 +64,7 @@
                 android:layout_width="0dp"
                 android:layout_height="fill_parent"
                 android:layout_weight="@dimen/golden_ratio"
-                android:background="@drawable/list_content_right"
+                android:background="?attr/listItemsRightBackground"
                 android:orientation="vertical" />
         </LinearLayout>
 
index f5efabe..182db02 100644 (file)
@@ -2,7 +2,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
-    android:minHeight="64dp"
+    android:minHeight="?android:attr/listPreferredItemHeight"
     android:orientation="horizontal" >
 
     <View
         android:layout_height="match_parent"
         android:background="?android:attr/activatedBackgroundIndicator" />
 
-    <include layout="@layout/list_item_base" />
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        android:paddingBottom="8dip"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:paddingTop="8dip" >
+
+        <include layout="@layout/list_item_base" />
+    </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
index 3741985..e334edb 100644 (file)
@@ -1,16 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:minHeight="64dp"
-    android:orientation="horizontal" >
+<merge xmlns:android="http://schemas.android.com/apk/res/android" >
 
     <ImageView
         android:id="@+id/image"
-        android:layout_width="48dp"
-        android:layout_height="32dp"
+        android:layout_width="@android:dimen/app_icon_size"
+        android:layout_height="@android:dimen/app_icon_size"
         android:layout_gravity="center_vertical"
-        android:layout_marginLeft="@dimen/section_padding"
         android:scaleType="fitCenter" >
     </ImageView>
 
@@ -40,8 +35,7 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center"
-        android:layout_margin="@dimen/section_padding"
         android:focusable="false"
         android:focusableInTouchMode="false" />
 
-</LinearLayout>
\ No newline at end of file
+</merge>
\ No newline at end of file
index 64bf459..a09ac7e 100644 (file)
@@ -1,8 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:paddingTop="8dip"
+    android:paddingBottom="8dip"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
-    android:minHeight="64dp"
+    android:minHeight="?android:attr/listPreferredItemHeight"
     android:orientation="horizontal" >
 
     <include layout="@layout/list_item_base" />
index e44df3c..5ae4a1f 100644 (file)
@@ -3,10 +3,9 @@
 
     <ImageView
         android:id="@+id/image"
-        android:layout_width="48dp"
-        android:layout_height="32dp"
+        android:layout_width="@android:dimen/app_icon_size"
+        android:layout_height="@android:dimen/app_icon_size"
         android:layout_gravity="center_vertical"
-        android:layout_marginLeft="@dimen/section_padding"
         android:scaleType="fitCenter" >
     </ImageView>
 
@@ -36,7 +35,6 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center"
-        android:layout_margin="@dimen/section_padding"
         android:focusable="false"
         android:focusableInTouchMode="false" />
 
index 64bf459..7f08477 100644 (file)
@@ -2,8 +2,12 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
-    android:minHeight="64dp"
-    android:orientation="horizontal" >
+    android:minHeight="?android:attr/listPreferredItemHeight"
+    android:orientation="horizontal"
+    android:paddingBottom="8dip"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingTop="8dip" >
 
     <include layout="@layout/list_item_base" />
 
diff --git a/Widgets/res/values-v14/styles.xml b/Widgets/res/values-v14/styles.xml
new file mode 100644 (file)
index 0000000..9fbadcf
--- /dev/null
@@ -0,0 +1,16 @@
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <!--
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    -->
+    <style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
+        <!-- API 14 theme customizations can go here. -->
+    </style>
+
+    <style name="AppBaseDarkTheme" parent="android:Theme.Holo">
+        <!-- API 14 theme customizations can go here. -->
+    </style>
+
+</resources>
\ No newline at end of file
diff --git a/Widgets/res/values/attrs.xml b/Widgets/res/values/attrs.xml
new file mode 100644 (file)
index 0000000..997e0d7
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <attr name="listContentBackground" format="reference|color" />
+    <attr name="listItemsLeftBackground" format="reference|color" />
+    <attr name="listItemsRightBackground" format="reference|color" />
+    
+</resources>
\ No newline at end of file
index bc1b0ea..8cfa571 100644 (file)
@@ -4,8 +4,8 @@
     <color name="holo_blue_light">#ff33b5e5</color>
     <color name="holo_blue_dark">#ff0099cc</color>
     <color name="holo_blue_bright">#ff00ddff</color>
-    <color name="list_content_background">#f1f1f1</color>
     <color name="holo_red_light">#ffff4444</color>
     <color name="holo_red_dark">#ffcc0000</color>
-
+    
+    <color name="list_separator">#f1f1f1</color>
 </resources>
\ No newline at end of file
index f2a9f4a..1f5d284 100644 (file)
@@ -6,7 +6,7 @@
 
     <item type="dimen" name="golden_ratio">1.6180339887498948482</item>
     <dimen name="content_padding">0dp</dimen>
-    <dimen name="section_padding">4dp</dimen>
+    <dimen name="section_padding">8dp</dimen>
     
     <dimen name="list_horizontal_margin">0dp</dimen>
     <dimen name="list_vertical_margin">0dp</dimen>
diff --git a/Widgets/res/values/styles.xml b/Widgets/res/values/styles.xml
new file mode 100644 (file)
index 0000000..afa2a49
--- /dev/null
@@ -0,0 +1,35 @@
+<resources>
+
+    <!--
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    -->
+    <style name="AppBaseTheme" parent="@android:style/Theme.Light">
+        <!--
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        -->
+    </style>
+
+    <!-- Application theme. -->
+    <style name="AppTheme" parent="AppBaseTheme">
+
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+        <item name="listContentBackground">#f1f1f1</item>
+        <item name="listItemsLeftBackground">@drawable/list_content_left</item>
+        <item name="listItemsRightBackground">@drawable/list_content_right</item>
+    </style>
+
+    <style name="AppBaseDarkTheme" parent="android:Theme.Black"></style>
+
+    <!-- Application theme. -->
+    <style name="AppDarkTheme" parent="AppBaseDarkTheme">
+
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+        <item name="listContentBackground">#0f0f0f</item>
+        <item name="listItemsLeftBackground">@drawable/list_content_left_dark</item>
+        <item name="listItemsRightBackground">@drawable/list_content_right_dark</item>
+    </style>
+
+</resources>
\ No newline at end of file
index ed6e011..11fd3e6 100644 (file)
@@ -74,15 +74,6 @@ public class ListContentFragment extends BetterListFragment {
         }
         return false;
     }
-    
-    @Override
-    void onListItemClick(ListItem li) {
-        super.onListItemClick(li);
-//        if (mContentAdapter == null)
-//            return;
-//        
-//        setContent(mContentAdapter.getFragment(li, mCurrentContent));
-    }
 
     @Override
     protected int getListItemResource() {
@@ -103,13 +94,4 @@ public class ListContentFragment extends BetterListFragment {
         super.onConfigurationChanged(newConfig);
         setPadding();
     }
-//    
-//    ListContentAdapter mContentAdapter;
-//    public ListContentAdapter getContentAdapter() {
-//        return mContentAdapter;
-//    }
-//    
-//    public void setContentAdapter(ListContentAdapter adapter) {
-//        mContentAdapter = adapter;
-//    }
 }
index 197f0a1..a4d7313 100644 (file)
@@ -26,7 +26,7 @@
             android:name=".MainActivityDark" 
             android:theme="@style/AppDarkTheme" />
         <activity
-            android:name=".ListContentTest"/>
+            android:name=".ListContentTest"  />
     </application>
 
 </manifest>
\ No newline at end of file
index 05ab5fa..7421ebc 100644 (file)
@@ -21,12 +21,18 @@ public final class R {
                public static final int list_content_container = 0x7f080000;
                public static final int listview = 0x7f080004;
        }
+       public static final class style {
+               public static final int AppBaseDarkTheme = 0x7f060002;
+               public static final int AppDarkTheme = 0x7f060003;
+               public static final int AppBaseTheme = 0x7f060000;
+               public static final int AppTheme = 0x7f060001;
+       }
        public static final class color {
-               public static final int holo_red_light = 0x7f040004;
-               public static final int list_content_background = 0x7f040003;
+               public static final int holo_red_light = 0x7f040003;
+               public static final int list_content_background = 0x7f040005;
                public static final int holo_blue_bright = 0x7f040002;
                public static final int holo_blue_light = 0x7f040000;
-               public static final int holo_red_dark = 0x7f040005;
+               public static final int holo_red_dark = 0x7f040004;
                public static final int holo_blue_dark = 0x7f040001;
        }
        public static final class layout {
@@ -39,9 +45,13 @@ public final class R {
                public static final int list_fragment = 0x7f030002;
        }
        public static final class drawable {
-               public static final int list_content_right = 0x7f020005;
+               public static final int list_content_right = 0x7f020006;
                public static final int list_content_left = 0x7f020004;
        }
+       public static final class attr {
+               public static final int listContentBackground = 0x7f010000;
+               public static final int listItemsLeftBackground = 0x7f010001;
+       }
        public static final class dimen {
                public static final int list_horizontal_margin = 0x7f050005;
                public static final int golden_ratio = 0x7f050002;
index a5dd061..dd5fa3e 100644 (file)
@@ -9,14 +9,32 @@ package com.koushikdutta.widgets.sample;
 
 public final class R {
     public static final class attr {
+        /** <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+         */
+        public static final int listContentBackground=0x7f010000;
+        /** <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+         */
+        public static final int listItemsLeftBackground=0x7f010001;
+        /** <p>May be a reference to another resource, in the form "<code>@[+][<i>package</i>:]<i>type</i>:<i>name</i></code>"
+or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>".
+<p>May be a color value, in the form of "<code>#<i>rgb</i></code>", "<code>#<i>argb</i></code>",
+"<code>#<i>rrggbb</i></code>", or "<code>#<i>aarrggbb</i></code>".
+         */
+        public static final int listItemsRightBackground=0x7f010002;
     }
     public static final class color {
         public static final int holo_blue_bright=0x7f040002;
         public static final int holo_blue_dark=0x7f040001;
         public static final int holo_blue_light=0x7f040000;
-        public static final int holo_red_dark=0x7f040005;
-        public static final int holo_red_light=0x7f040004;
-        public static final int list_content_background=0x7f040003;
+        public static final int holo_red_dark=0x7f040004;
+        public static final int holo_red_light=0x7f040003;
+        public static final int list_content_background=0x7f040005;
     }
     public static final class dimen {
         /**  Default screen margins, per the Android Design guidelines. 
@@ -47,8 +65,10 @@ public final class R {
         public static final int dropbox=0x7f020002;
         public static final int ic_launcher=0x7f020003;
         public static final int list_content_left=0x7f020004;
-        public static final int list_content_right=0x7f020005;
-        public static final int nexusone=0x7f020006;
+        public static final int list_content_left_dark=0x7f020005;
+        public static final int list_content_right=0x7f020006;
+        public static final int list_content_right_dark=0x7f020007;
+        public static final int nexusone=0x7f020008;
     }
     public static final class id {
         public static final int checkbox=0x7f08000b;
@@ -74,18 +94,18 @@ public final class R {
         public static final int list_item_selectable=0x7f030006;
     }
     public static final class string {
-        public static final int app_name=0x7f060000;
-        public static final int box=0x7f060005;
-        public static final int cloud=0x7f060001;
-        public static final int devices=0x7f060006;
-        public static final int dropbox=0x7f060004;
-        public static final int googledrive=0x7f060002;
-        public static final int googledrive_summary=0x7f060003;
+        public static final int app_name=0x7f070000;
+        public static final int box=0x7f070005;
+        public static final int cloud=0x7f070001;
+        public static final int devices=0x7f070006;
+        public static final int dropbox=0x7f070004;
+        public static final int googledrive=0x7f070002;
+        public static final int googledrive_summary=0x7f070003;
     }
     public static final class style {
         /**  API 14 theme customizations can go here. 
          */
-        public static final int AppBaseDarkTheme=0x7f070002;
+        public static final int AppBaseDarkTheme=0x7f060002;
         /** 
         Base application theme, dependent on API level. This theme is replaced
         by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
@@ -102,15 +122,13 @@ public final class R {
     
  API 14 theme customizations can go here. 
          */
-        public static final int AppBaseTheme=0x7f070000;
+        public static final int AppBaseTheme=0x7f060000;
         /**  Application theme. 
- All customizations that are NOT specific to a particular API-level can go here. 
          */
-        public static final int AppDarkTheme=0x7f070003;
+        public static final int AppDarkTheme=0x7f060003;
         /**  Application theme. 
- All customizations that are NOT specific to a particular API-level can go here. 
          */
-        public static final int AppTheme=0x7f070001;
-        public static final int RequestTheme=0x7f070004;
+        public static final int AppTheme=0x7f060001;
+        public static final int RequestTheme=0x7f060004;
     }
 }
index 7f8e15e..97ad5ed 100644 (file)
@@ -1,15 +1,15 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <!--
+<!--     
         Base application theme for API 14+. This theme completely replaces
         AppBaseTheme from BOTH res/values/styles.xml and
         res/values-v11/styles.xml on API 14+ devices.
-    -->
+   
     <style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
-        <!-- API 14 theme customizations can go here. -->
+        API 14 theme customizations can go here.
     </style>
 
     <style name="AppBaseDarkTheme" parent="android:Theme.Holo">
-        <!-- API 14 theme customizations can go here. -->
-    </style>
+        API 14 theme customizations can go here.
+    </style> -->
 </resources>
\ No newline at end of file
index d912b55..a9bd45f 100644 (file)
@@ -1,29 +1,29 @@
 <resources>
 
-    <!--
+<!--     
         Base application theme, dependent on API level. This theme is replaced
         by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-    -->
+   
     <style name="AppBaseTheme" parent="@android:style/Theme.Light">
-        <!--
+        
             Theme customizations available in newer API levels can go in
             res/values-vXX/styles.xml, while customizations related to
             backward-compatibility can go here.
-        -->
+       
     </style>
 
-    <!-- Application theme. -->
+    Application theme.
     <style name="AppTheme" parent="AppBaseTheme">
-        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+        All customizations that are NOT specific to a particular API-level can go here.
     </style>
     
     <style name="AppBaseDarkTheme" parent="android:Theme.Black">
         
     </style>
     
-    <!-- Application theme. -->
+    Application theme.
     <style name="AppDarkTheme" parent="AppBaseDarkTheme">
-        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+        All customizations that are NOT specific to a particular API-level can go here.
     </style>
-    
+     -->
 </resources>
\ No newline at end of file