From 3843960b466dbcd1733648095e750ccb3fa6d184 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 3 May 2012 18:08:24 -0700 Subject: Updated layout for download items. Switch to using GridLayout, because it's awesome. Also move status display to right-hand side, showing date when in completed state. Bug: 6378944 Change-Id: I540633010ed4aeeae299cedf7a49fdb81e65b431 --- ui/res/layout/download_list.xml | 6 +- ui/res/layout/download_list_item.xml | 106 +++++++++------------ .../providers/downloads/ui/DownloadAdapter.java | 17 +++- .../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" /> + android:layout_height="match_parent" + android:scrollbarStyle="outsideOverlay" /> - + android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" + android:paddingRight="?android:attr/listPreferredItemPaddingRight" + android:paddingTop="8dip" + android:paddingBottom="8dip" + android:columnCount="4" + android:descendantFocusability="blocksDescendants"> - + - + - - + - + - - - + + + + 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; -- cgit v1.2.3