Browse Source

Merge pull request #1659 from nextcloud/activityListDesign

Enhance activity list design
Andy Scherzinger 7 years ago
parent
commit
390a2e40d3

+ 1 - 1
scripts/lint/lint-results.txt

@@ -1,2 +1,2 @@
 DO NOT TOUCH; GENERATED BY DRONE
-      <span class="mdl-layout-title">Lint Report: 511 warnings</span>
+      <span class="mdl-layout-title">Lint Report: 509 warnings</span>

+ 25 - 14
src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java

@@ -21,12 +21,16 @@ package com.owncloud.android.ui.adapter;
 
 import android.content.Context;
 import android.content.res.Resources;
+import android.graphics.Color;
 import android.graphics.drawable.PictureDrawable;
 import android.net.Uri;
 import android.support.v7.widget.RecyclerView;
 import android.text.Spannable;
 import android.text.SpannableStringBuilder;
+import android.text.TextPaint;
 import android.text.TextUtils;
+import android.text.format.DateFormat;
+import android.text.format.DateUtils;
 import android.text.method.LinkMovementMethod;
 import android.text.style.ClickableSpan;
 import android.text.style.ForegroundColorSpan;
@@ -58,7 +62,6 @@ import com.owncloud.android.lib.resources.files.FileUtils;
 import com.owncloud.android.ui.interfaces.ActivityListInterface;
 import com.owncloud.android.utils.DisplayUtils;
 import com.owncloud.android.utils.MimeTypeUtil;
-import com.owncloud.android.utils.ThemeUtils;
 import com.owncloud.android.utils.glide.CustomGlideStreamLoader;
 import com.owncloud.android.utils.svg.SvgDecoder;
 import com.owncloud.android.utils.svg.SvgDrawableTranscoder;
@@ -66,7 +69,6 @@ import com.owncloud.android.utils.svg.SvgSoftwareLayerSetter;
 
 import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -103,19 +105,16 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
             Activity activity = (Activity) o;
             String time;
             if (activity.getDatetime() != null) {
-                time = DisplayUtils.getRelativeTimestamp(context,
-                        activity.getDatetime().getTime()).toString();
+                time = getHeaderDateString(context, activity.getDatetime().getTime()).toString();
             } else if (activity.getDate() != null) {
-                time = DisplayUtils.getRelativeTimestamp(context,
-                        activity.getDate().getTime()).toString();
+                time = getHeaderDateString(context, activity.getDate().getTime()).toString();
             } else {
-                time = "Unknown";
+                time = context.getString(R.string.date_unknown);
             }
 
             if (sTime.equalsIgnoreCase(time)) {
                 mValues.add(activity);
             } else {
-
                 sTime = time;
                 mValues.add(sTime);
                 mValues.add(activity);
@@ -144,11 +143,10 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
             final ActivityViewHolder activityViewHolder = (ActivityViewHolder) holder;
             Activity activity = (Activity) mValues.get(position);
             if (activity.getDatetime() != null) {
-                activityViewHolder.dateTime.setText(DisplayUtils.getRelativeTimestamp(context,
-                        activity.getDatetime().getTime()));
+                activityViewHolder.dateTime.setVisibility(View.VISIBLE);
+                activityViewHolder.dateTime.setText(DateFormat.format("HH:MM", activity.getDatetime().getTime()));
             } else {
-                activityViewHolder.dateTime.setText(DisplayUtils.getRelativeTimestamp(context,
-                        new Date().getTime()));
+                activityViewHolder.dateTime.setVisibility(View.GONE);
             }
 
             if (activity.getRichSubjectElement() != null &&
@@ -304,10 +302,14 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
                     public void onClick(View widget) {
                         activityListInterface.onActivityClicked(richObject);
                     }
+
+                    @Override
+                    public void updateDrawState(TextPaint ds) {
+                        ds.setUnderlineText(false);
+                    }
                 }, idx1, idx2, 0);
                 ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), idx1, idx2, 0);
-                ssb.setSpan(new ForegroundColorSpan(ThemeUtils.primaryAccentColor()), idx1, idx2,
-                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+                ssb.setSpan(new ForegroundColorSpan(Color.BLACK), idx1, idx2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
             }
             idx1 = text.indexOf("{", idx2);
         }
@@ -349,6 +351,15 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
         return d.intValue();
     }
 
+    private CharSequence getHeaderDateString(Context context, long modificationTimestamp) {
+        if ((System.currentTimeMillis() - modificationTimestamp) < DateUtils.WEEK_IN_MILLIS) {
+            return DisplayUtils.getRelativeDateTimeString(context, modificationTimestamp, DateUtils.DAY_IN_MILLIS,
+                    DateUtils.WEEK_IN_MILLIS, 0);
+        } else {
+            return DateFormat.format("EEEE, MMMM d", modificationTimestamp);
+        }
+    }
+
     private class ActivityViewHolder extends RecyclerView.ViewHolder {
 
         private final ImageView activityIcon;

+ 6 - 5
src/main/java/com/owncloud/android/utils/DisplayUtils.java

@@ -289,7 +289,7 @@ public class DisplayUtils {
     }
 
     /**
-     * calculates the relative time string based on the given modificaion timestamp.
+     * calculates the relative time string based on the given modification timestamp.
      *
      * @param context the app's context
      * @param modificationTimestamp the UNIX timestamp of the file modification time.
@@ -300,6 +300,7 @@ public class DisplayUtils {
                 DateUtils.WEEK_IN_MILLIS, 0);
     }
 
+
     /**
      * determines the info level color based on certain thresholds
      * {@link #RELATIVE_THRESHOLD_WARNING} and {@link #RELATIVE_THRESHOLD_CRITICAL}.
@@ -323,8 +324,8 @@ public class DisplayUtils {
         }
     }
 
-    public static CharSequence getRelativeDateTimeString(
-            Context c, long time, long minResolution, long transitionResolution, int flags) {
+    public static CharSequence getRelativeDateTimeString(Context c, long time, long minResolution,
+                                                         long transitionResolution, int flags) {
 
         CharSequence dateString = "";
 
@@ -333,7 +334,7 @@ public class DisplayUtils {
             return DisplayUtils.unixTimeToHumanReadable(time);
         }
         // < 60 seconds -> seconds ago
-        else if ((System.currentTimeMillis() - time) < 60 * 1000) {
+        else if ((System.currentTimeMillis() - time) < 60 * 1000 && minResolution == DateUtils.SECOND_IN_MILLIS) {
             return c.getString(R.string.file_list_seconds_ago);
         } else {
             dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags);
@@ -347,7 +348,7 @@ public class DisplayUtils {
                 return parts[1];
             }
         }
-        //dateString contains unexpected format. fallback: use relative date time string from android api as is.
+        // dateString contains unexpected format. fallback: use relative date time string from android api as is.
         return dateString.toString();
     }
 

+ 5 - 2
src/main/res/layout/activity_list_item.xml

@@ -26,14 +26,15 @@
     android:paddingTop="@dimen/standard_padding"
     android:paddingRight="@dimen/standard_padding"
     android:paddingBottom="@dimen/standard_padding"
-    android:paddingLeft="12dp">
+    android:paddingLeft="@dimen/standard_padding">
 
     <ImageView
         android:id="@+id/activity_icon"
         android:layout_width="@dimen/file_icon_size"
         android:layout_height="@dimen/file_icon_size"
         android:layout_alignParentTop="true"
-        android:layout_marginRight="24dp"
+        android:layout_marginRight="@dimen/standard_padding"
+        android:alpha="0.5"
         android:src="@drawable/ic_activity"/>
 
     <LinearLayout
@@ -65,6 +66,8 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="5dp"
+            android:layout_marginLeft="-3dp"
+            android:layout_marginStart="-3dp"
             android:columnCount="3" />
 
         <TextView

+ 4 - 4
src/main/res/layout/activity_list_item_header.xml

@@ -7,10 +7,10 @@
         android:id="@+id/title_header"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:textSize="20sp"
-        android:layout_marginLeft="10dp"
-        android:layout_marginStart="10dp"
+        android:layout_marginLeft="@dimen/standard_list_item_size"
+        android:layout_marginStart="@dimen/standard_list_item_size"
         android:layout_marginTop="10dp"
-        android:text="@string/placeholder_filename"/>
+        android:text="@string/placeholder_filename"
+        android:textSize="20sp"/>
 
 </LinearLayout>

+ 1 - 0
src/main/res/values/strings.xml

@@ -710,4 +710,5 @@
     <string name="push_notifications_not_implemented">Push notifications disabled due to dependencies on proprietary Google Play services.</string>
     <string name="push_notifications_old_login">No push notifications due to outdated login session. Please consider re-adding your account.</string>
     <string name="push_notifications_temp_error">Push notifications currently not available.</string>
+    <string name="date_unknown">Unknown</string>
 </resources>