diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-05-04 11:40:41 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-04 11:40:41 -0700 |
commit | dc94f04ed1593cf209cb4dd5709f8b8345045b45 (patch) | |
tree | 1109294434a4c3c89dc25da2eb63f01e2c9af038 | |
parent | a4763c19f12420a76d8c5b2c54e11b23541675bb (diff) | |
parent | 3ea5096568f147941b4302070ffc2024bad8e18f (diff) | |
download | android_packages_providers_DownloadProvider-dc94f04ed1593cf209cb4dd5709f8b8345045b45.tar.gz android_packages_providers_DownloadProvider-dc94f04ed1593cf209cb4dd5709f8b8345045b45.tar.bz2 android_packages_providers_DownloadProvider-dc94f04ed1593cf209cb4dd5709f8b8345045b45.zip |
am 3ea50965: Merge "Updated layout for download items." into jb-dev
* commit '3ea5096568f147941b4302070ffc2024bad8e18f':
Updated layout for download items.
-rw-r--r-- | ui/res/layout/download_list.xml | 6 | ||||
-rw-r--r-- | ui/res/layout/download_list_item.xml | 106 | ||||
-rw-r--r-- | ui/src/com/android/providers/downloads/ui/DownloadAdapter.java | 17 | ||||
-rw-r--r-- | ui/src/com/android/providers/downloads/ui/DownloadItem.java | 3 |
4 files changed, 65 insertions, 67 deletions
diff --git a/ui/res/layout/download_list.xml b/ui/res/layout/download_list.xml index 18f44d10..e4ebf7c9 100644 --- a/ui/res/layout/download_list.xml +++ b/ui/res/layout/download_list.xml @@ -35,14 +35,16 @@ android:paddingBottom="16dip" android:clipToPadding="false" android:layout_width="match_parent" - android:layout_height="match_parent"/> + android:layout_height="match_parent" + android:scrollbarStyle="outsideOverlay" /> <ListView android:id="@+id/size_ordered_list" android:paddingLeft="16dip" android:paddingRight="16dip" android:paddingBottom="16dip" android:clipToPadding="false" android:layout_width="match_parent" - android:layout_height="match_parent"/> + android:layout_height="match_parent" + android:scrollbarStyle="outsideOverlay" /> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/empty" android:layout_width="match_parent" diff --git a/ui/res/layout/download_list_item.xml b/ui/res/layout/download_list_item.xml index 8548e3cc..a87ce7bd 100644 --- a/ui/res/layout/download_list_item.xml +++ b/ui/res/layout/download_list_item.xml @@ -21,69 +21,57 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingRight="?android:attr/scrollbarSize" - android:descendantFocusability="blocksDescendants" - android:gravity="center_vertical"> - + android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" + android:paddingRight="?android:attr/listPreferredItemPaddingRight" + android:paddingTop="8dip" + android:paddingBottom="8dip" + android:columnCount="4" + android:descendantFocusability="blocksDescendants"> <!-- Clicks are handled directly by DownloadItem --> - <CheckBox android:id="@+id/download_checkbox" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:paddingLeft="8dip" - android:scaleType="fitCenter" - android:layout_centerVertical="true" - android:clickable="false"/> + <CheckBox + android:id="@+id/download_checkbox" + android:layout_rowSpan="3" + android:layout_gravity="center_vertical" + android:clickable="false" /> - <ImageView android:id="@+id/download_icon" - android:layout_width="@android:dimen/app_icon_size" - android:layout_height="@android:dimen/app_icon_size" - android:paddingLeft="8dip" - android:layout_toRightOf="@id/download_checkbox" - android:layout_centerVertical="true" - android:scaleType="fitCenter" /> + <ImageView + android:id="@+id/download_icon" + android:layout_width="@android:dimen/app_icon_size" + android:layout_height="@android:dimen/app_icon_size" + android:layout_rowSpan="3" + android:layout_marginRight="8dip" + android:layout_gravity="center_vertical" + android:scaleType="centerInside" /> - <TextView android:id="@+id/download_title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_toRightOf="@id/download_icon" - android:maxLines="1" - android:paddingLeft="8dip" - android:textStyle="bold" - android:textAppearance="?android:attr/textAppearanceSmall" /> - <TextView android:id="@+id/domain" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/download_title" - android:layout_toRightOf="@id/download_icon" - android:maxLines="1" - android:paddingLeft="8dip" - android:textAppearance="?android:attr/textAppearanceSmall" /> + <TextView + android:id="@+id/download_title" + android:layout_columnSpan="2" + android:layout_gravity="fill_horizontal" + android:singleLine="true" + android:ellipsize="marquee" + android:textStyle="bold" + android:textAppearance="?android:attr/textAppearance" /> - <TextView android:id="@+id/last_modified_date" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/domain" - android:layout_alignParentRight="true" - android:maxLines="1" - android:textAppearance="?android:attr/textAppearanceSmall" /> + <TextView + android:id="@+id/domain" + android:layout_columnSpan="2" + android:layout_gravity="fill_horizontal" + android:singleLine="true" + android:ellipsize="marquee" + android:textAppearance="?android:attr/textAppearanceSmall" /> - <TextView android:id="@+id/status_text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/domain" - android:layout_toRightOf="@id/download_icon" - android:paddingLeft="8dip" - android:textAppearance="?android:attr/textAppearanceSmall" /> - <TextView android:id="@+id/size_text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_below="@id/domain" - android:layout_toRightOf="@id/status_text" - android:maxLines="1" - android:textAppearance="?android:attr/textAppearanceSmall" - android:paddingLeft="15dp"/> -</com.android.providers.downloads.ui.DownloadItem> + <TextView + android:id="@+id/size_text" + android:layout_width="0dip" + android:layout_gravity="fill_horizontal" + android:singleLine="true" + android:ellipsize="marquee" + android:textAppearance="?android:attr/textAppearanceSmall" /> + + <TextView + android:id="@+id/status_text" + android:layout_marginLeft="8dip" + android:textAppearance="?android:attr/textAppearanceSmall" /> +</com.android.providers.downloads.ui.DownloadItem> diff --git a/ui/src/com/android/providers/downloads/ui/DownloadAdapter.java b/ui/src/com/android/providers/downloads/ui/DownloadAdapter.java index 27967f8a..9ce2a986 100644 --- a/ui/src/com/android/providers/downloads/ui/DownloadAdapter.java +++ b/ui/src/com/android/providers/downloads/ui/DownloadAdapter.java @@ -107,8 +107,15 @@ public class DownloadAdapter extends CursorAdapter { setTextForView(convertView, R.id.download_title, title); setTextForView(convertView, R.id.domain, mCursor.getString(mDescriptionColumnId)); setTextForView(convertView, R.id.size_text, getSizeText()); - setTextForView(convertView, R.id.status_text, mResources.getString(getStatusStringId())); - setTextForView(convertView, R.id.last_modified_date, getDateString()); + + final int status = mCursor.getInt(mStatusColumnId); + final CharSequence statusText; + if (status == DownloadManager.STATUS_SUCCESSFUL) { + statusText = getDateString(); + } else { + statusText = mResources.getString(getStatusStringId(status)); + } + setTextForView(convertView, R.id.status_text, statusText); ((DownloadItem) convertView).getCheckBox() .setChecked(mDownloadList.isDownloadSelected(downloadId)); @@ -141,8 +148,8 @@ public class DownloadAdapter extends CursorAdapter { return sizeText; } - private int getStatusStringId() { - switch (mCursor.getInt(mStatusColumnId)) { + private int getStatusStringId(int status) { + switch (status) { case DownloadManager.STATUS_FAILED: return R.string.download_error; @@ -189,7 +196,7 @@ public class DownloadAdapter extends CursorAdapter { iconView.setVisibility(View.VISIBLE); } - private void setTextForView(View parent, int textViewId, String text) { + private void setTextForView(View parent, int textViewId, CharSequence text) { TextView view = (TextView) parent.findViewById(textViewId); view.setText(text); } diff --git a/ui/src/com/android/providers/downloads/ui/DownloadItem.java b/ui/src/com/android/providers/downloads/ui/DownloadItem.java index 4cbcd332..25f58638 100644 --- a/ui/src/com/android/providers/downloads/ui/DownloadItem.java +++ b/ui/src/com/android/providers/downloads/ui/DownloadItem.java @@ -21,6 +21,7 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.CheckBox; import android.widget.Checkable; +import android.widget.GridLayout; import android.widget.RelativeLayout; /** @@ -29,7 +30,7 @@ import android.widget.RelativeLayout; * also keeps an ID associated with the currently displayed download and notifies a listener upon * selection changes with that ID. */ -public class DownloadItem extends RelativeLayout implements Checkable { +public class DownloadItem extends GridLayout implements Checkable { private static float CHECKMARK_AREA = -1; private boolean mIsInDownEvent = false; |