Finish RTL work in Downloads.
Jeff Sharkey [Thu, 21 Mar 2013 21:57:07 +0000 (14:57 -0700)]
Clean up some padding, and handle checkbox clicks based on RTL mode.

Bug: 8133419
Change-Id: I9c0f54218eb1c182fbe6f3f4eeb3e83e7ebc6ea9

ui/res/layout/download_list.xml
ui/res/layout/download_list_item.xml
ui/res/layout/list_group_header.xml
ui/res/values/dimen.xml
ui/src/com/android/providers/downloads/ui/DateSortedExpandableListAdapter.java
ui/src/com/android/providers/downloads/ui/DownloadItem.java

index e4ebf7c..a0ff5ff 100644 (file)
                  android:layout_weight="1">
 
         <ExpandableListView android:id="@+id/date_ordered_list"
-                            android:paddingLeft="16dip"
-                            android:paddingRight="16dip"
+                            android:paddingStart="16dip"
+                            android:paddingEnd="16dip"
                             android:paddingBottom="16dip"
                             android:clipToPadding="false"
                             android:layout_width="match_parent"
                             android:layout_height="match_parent"
                             android:scrollbarStyle="outsideOverlay" />
         <ListView android:id="@+id/size_ordered_list"
-                  android:paddingLeft="16dip"
-                  android:paddingRight="16dip"
+                  android:paddingStart="16dip"
+                  android:paddingEnd="16dip"
                   android:paddingBottom="16dip"
                   android:clipToPadding="false"
                   android:layout_width="match_parent"
index 1884e1a..2435ba7 100644 (file)
@@ -78,7 +78,8 @@
 
     <TextView
         android:id="@+id/status_text"
-        android:layout_marginLeft="8dip"
-        android:textAppearance="?android:attr/textAppearanceSmall" />
+        android:layout_marginStart="8dip"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textAlignment="viewStart" />
 
 </com.android.providers.downloads.ui.DownloadItem>
index 2600f8d..466cd6c 100644 (file)
 -->
 
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="?android:attr/listPreferredItemHeight"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:paddingLeft="43dip"
-        android:layout_gravity="center_vertical"
-        android:gravity="center_vertical"/>
+    android:id="@android:id/text1"
+    android:layout_width="match_parent"
+    android:layout_height="?android:attr/listPreferredItemHeight"
+    android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"
+    android:textAppearance="?android:attr/textAppearanceMedium"
+    android:gravity="center_vertical" />
index 6e48f13..7519b87 100644 (file)
@@ -15,5 +15,5 @@
 -->
 
 <resources>
-    <dimen name="checkmark_area">40dip</dimen>
+    <dimen name="checkmark_area">48dip</dimen>
 </resources>
index 19132a1..f5d7077 100644 (file)
@@ -273,7 +273,7 @@ public class DateSortedExpandableListAdapter implements ExpandableListAdapter {
         TextView item;
         if (null == convertView || !(convertView instanceof TextView)) {
             LayoutInflater factory = LayoutInflater.from(mContext);
-            item = (TextView) factory.inflate(R.layout.list_group_header, null);
+            item = (TextView) factory.inflate(R.layout.list_group_header, parent, false);
         } else {
             item = (TextView) convertView;
         }
index e24ac4a..0562cd0 100644 (file)
@@ -18,12 +18,11 @@ package com.android.providers.downloads.ui;
 
 import android.content.Context;
 import android.util.AttributeSet;
-import android.view.accessibility.AccessibilityEvent;
 import android.view.MotionEvent;
+import android.view.accessibility.AccessibilityEvent;
 import android.widget.CheckBox;
 import android.widget.Checkable;
 import android.widget.GridLayout;
-import android.widget.RelativeLayout;
 
 /**
  * This class customizes RelativeLayout to directly handle clicks on the left part of the view and
@@ -83,12 +82,20 @@ public class DownloadItem extends GridLayout implements Checkable {
         mDownloadList = downloadList;
     }
 
+    private boolean inCheckArea(MotionEvent event) {
+        if (isLayoutRtl()) {
+            return event.getX() > getWidth() - CHECKMARK_AREA;
+        } else {
+            return event.getX() < CHECKMARK_AREA;
+        }
+    }
+
     @Override
     public boolean onTouchEvent(MotionEvent event) {
         boolean handled = false;
         switch(event.getAction()) {
             case MotionEvent.ACTION_DOWN:
-                if (event.getX() < CHECKMARK_AREA) {
+                if (inCheckArea(event)) {
                     mIsInDownEvent = true;
                     handled = true;
                 }
@@ -99,7 +106,7 @@ public class DownloadItem extends GridLayout implements Checkable {
                 break;
 
             case MotionEvent.ACTION_UP:
-                if (mIsInDownEvent && event.getX() < CHECKMARK_AREA) {
+                if (mIsInDownEvent && inCheckArea(event)) {
                     toggle();
                     sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
                     handled = true;