layouting changes so file list, local list and uploader list look the same

This commit is contained in:
Andy Scherzinger 2016-06-13 18:27:44 +02:00
parent 8c863a642b
commit 0db0ab1fd5
5 changed files with 62 additions and 18 deletions

View file

@ -19,7 +19,7 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_height="72dp"
android:background="@drawable/list_selector"
android:orientation="horizontal">
@ -33,7 +33,7 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="72dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
@ -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" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="4dp"
android:orientation="horizontal">
<TextView
android:id="@+id/file_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Size MB"
android:textColor="@color/list_item_lastmod_and_filesize_text"
android:textSize="@dimen/two_line_secondary_text_size"/>
<TextView
android:id="@+id/file_separator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text=", "
android:textColor="@color/list_item_lastmod_and_filesize_text"
android:textSize="@dimen/two_line_secondary_text_size"/>
<TextView
android:id="@+id/last_mod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:text="TextView"
android:gravity="right"
android:text="Mod Date"
android:textColor="@color/list_item_lastmod_and_filesize_text"
android:textSize="12dip" />
android:textSize="@dimen/two_line_secondary_text_size"/>
</LinearLayout>
</LinearLayout>

View file

@ -191,7 +191,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
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);

View file

@ -124,13 +124,14 @@ public class LocalFileListAdapter extends BaseAdapter implements ListAdapter {
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 class LocalFileListAdapter extends BaseAdapter implements ListAdapter {
} else {
fileSizeSeparatorV.setVisibility(View.GONE);
fileSizeV.setVisibility(View.GONE);
lastModV.setVisibility(View.GONE);
checkBoxV.setVisibility(View.GONE);
}

View file

@ -76,7 +76,19 @@ public class UploaderAdapter extends SimpleAdapter {
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){

View file

@ -172,9 +172,16 @@ public class DisplayUtils {
}
}
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")