Sfoglia il codice sorgente

additional enhancements

tobiaskaminsky 7 anni fa
parent
commit
2da83959b2

+ 13 - 2
src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java

@@ -29,6 +29,8 @@ 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;
@@ -104,9 +106,9 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
             Activity activity = (Activity) o;
             String time;
             if (activity.getDatetime() != null) {
-                time = DisplayUtils.getRelativeTimestampDayWise(context, activity.getDatetime().getTime()).toString();
+                time = getHeaderDateString(context, activity.getDatetime().getTime()).toString();
             } else if (activity.getDate() != null) {
-                time = DisplayUtils.getRelativeTimestampDayWise(context, activity.getDate().getTime()).toString();
+                time = getHeaderDateString(context, activity.getDate().getTime()).toString();
             } else {
                 time = context.getString(R.string.date_unknown);
             }
@@ -350,6 +352,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;

+ 0 - 11
src/main/java/com/owncloud/android/utils/DisplayUtils.java

@@ -300,17 +300,6 @@ public class DisplayUtils {
                 DateUtils.WEEK_IN_MILLIS, 0);
     }
 
-    /**
-     * 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.
-     * @return a relative time string
-     */
-    public static CharSequence getRelativeTimestampDayWise(Context context, long modificationTimestamp) {
-        return getRelativeDateTimeString(context, modificationTimestamp, DateUtils.DAY_IN_MILLIS,
-                DateUtils.WEEK_IN_MILLIS, 0);
-    }
 
     /**
      * determines the info level color based on certain thresholds

+ 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="68dp"
+        android:layout_marginStart="68dp"
         android:layout_marginTop="10dp"
-        android:text="@string/placeholder_filename"/>
+        android:text="@string/placeholder_filename"
+        android:textSize="20sp"/>
 
 </LinearLayout>