From 0db0ab1fd563ffd6ca60fea71df6e6dde0b50ace Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 13 Jun 2016 18:27:44 +0200 Subject: [PATCH] layouting changes so file list, local list and uploader list look the same --- res/layout/uploader_list_item_layout.xml | 45 ++++++++++++++----- .../ui/adapter/FileListListAdapter.java | 2 +- .../ui/adapter/LocalFileListAdapter.java | 6 +-- .../android/ui/adapter/UploaderAdapter.java | 14 +++++- .../owncloud/android/utils/DisplayUtils.java | 13 ++++-- 5 files changed, 62 insertions(+), 18 deletions(-) diff --git a/res/layout/uploader_list_item_layout.xml b/res/layout/uploader_list_item_layout.xml index 34639a2126d..70ad5a2c834 100644 --- a/res/layout/uploader_list_item_layout.xml +++ b/res/layout/uploader_list_item_layout.xml @@ -19,7 +19,7 @@ --> @@ -33,7 +33,7 @@ @@ -43,7 +43,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_marginLeft="4dp" + android:layout_marginLeft="0dp" android:layout_marginRight="4dp" android:ellipsize="middle" android:singleLine="true" @@ -51,15 +51,40 @@ android:textColor="@color/textColor" android:textSize="16dip" /> - + android:orientation="horizontal"> + + + + + + + + diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 2fca38cadff..1aca7cd78b6 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -191,7 +191,7 @@ public View getView(int position, View convertView, ViewGroup parent) { ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox); lastModV.setVisibility(View.VISIBLE); - lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file)); + lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file.getModificationTimestamp())); checkBoxV.setVisibility(View.GONE); diff --git a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java index fa963fd24e2..3769a9ab47d 100644 --- a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java @@ -124,13 +124,14 @@ public View getView(int position, View convertView, ViewGroup parent) { TextView fileSizeSeparatorV = (TextView) view.findViewById(R.id.file_separator); TextView lastModV = (TextView) view.findViewById(R.id.last_mod); ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox); + lastModV.setVisibility(View.VISIBLE); + lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file.lastModified())); + if (!file.isDirectory()) { fileSizeSeparatorV.setVisibility(View.VISIBLE); fileSizeV.setVisibility(View.VISIBLE); fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.length())); - lastModV.setVisibility(View.VISIBLE); - lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.lastModified())); ListView parentList = (ListView) parent; if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { checkBoxV.setVisibility(View.GONE); @@ -179,7 +180,6 @@ public View getView(int position, View convertView, ViewGroup parent) { } else { fileSizeSeparatorV.setVisibility(View.GONE); fileSizeV.setVisibility(View.GONE); - lastModV.setVisibility(View.GONE); checkBoxV.setVisibility(View.GONE); } diff --git a/src/com/owncloud/android/ui/adapter/UploaderAdapter.java b/src/com/owncloud/android/ui/adapter/UploaderAdapter.java index af83af8b2ad..e5a4e03b695 100644 --- a/src/com/owncloud/android/ui/adapter/UploaderAdapter.java +++ b/src/com/owncloud/android/ui/adapter/UploaderAdapter.java @@ -76,7 +76,19 @@ public View getView(int position, View convertView, ViewGroup parent) { fileIcon.setTag(file.getFileId()); TextView lastModV = (TextView) vi.findViewById(R.id.last_mod); - lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file)); + lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file.getModificationTimestamp())); + + TextView fileSizeV = (TextView) vi.findViewById(R.id.file_size); + TextView fileSizeSeparatorV = (TextView) vi.findViewById(R.id.file_separator); + + if(!file.isFolder()) { + fileSizeV.setVisibility(View.VISIBLE); + fileSizeSeparatorV.setVisibility(View.VISIBLE); + fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength())); + } else { + fileSizeV.setVisibility(View.GONE); + fileSizeSeparatorV.setVisibility(View.GONE); + } // get Thumbnail if file is image if (file.isImage() && file.getRemoteId() != null){ diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index 73a2632cba7..241fc604c64 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -172,9 +172,16 @@ public static String convertIdn(String url, boolean toASCII) { } } - public static CharSequence getRelativeTimestamp(Context context, OCFile file) { - return getRelativeDateTimeString(context, file.getModificationTimestamp(), - DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); + /** + * calculates the relative time string based on the given modificaion timestamp. + * + * @param context the app's context + * @param modificationTimestamp the UNIX timestamp of the file modification time. + * @return a relative time string + */ + public static CharSequence getRelativeTimestamp(Context context, long modificationTimestamp) { + return getRelativeDateTimeString(context, modificationTimestamp, DateUtils.SECOND_IN_MILLIS, + DateUtils.WEEK_IN_MILLIS, 0); } @SuppressWarnings("deprecation")