Skip to content

Commit

Permalink
layouting changes so file list, local list and uploader list look the…
Browse files Browse the repository at this point in the history
… same
  • Loading branch information
AndyScherzinger committed Jun 14, 2016
1 parent 8c863a6 commit 0db0ab1
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 18 deletions.
45 changes: 35 additions & 10 deletions res/layout/uploader_list_item_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

Expand All @@ -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">
Expand All @@ -43,23 +43,48 @@
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"
android:text="TextView"
android:textColor="@color/textColor"
android:textSize="16dip" />

<TextView
android:id="@+id/last_mod"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="4dp"
android:text="TextView"
android:textColor="@color/list_item_lastmod_and_filesize_text"
android:textSize="12dip" />
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:gravity="right"
android:text="Mod Date"
android:textColor="@color/list_item_lastmod_and_filesize_text"
android:textSize="@dimen/two_line_secondary_text_size"/>

</LinearLayout>

</LinearLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
14 changes: 13 additions & 1 deletion src/com/owncloud/android/ui/adapter/UploaderAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
13 changes: 10 additions & 3 deletions src/com/owncloud/android/utils/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 0db0ab1

Please sign in to comment.