Merge pull request #1659 from nextcloud/activityListDesign

Enhance activity list design
This commit is contained in:
Andy Scherzinger 2017-10-19 22:25:53 +02:00 committed by GitHub
commit 390a2e40d3
6 changed files with 42 additions and 26 deletions

View file

@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE 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>

View file

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

View file

@ -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 context the app's context
* @param modificationTimestamp the UNIX timestamp of the file modification time. * @param modificationTimestamp the UNIX timestamp of the file modification time.
@ -300,6 +300,7 @@ public class DisplayUtils {
DateUtils.WEEK_IN_MILLIS, 0); DateUtils.WEEK_IN_MILLIS, 0);
} }
/** /**
* determines the info level color based on certain thresholds * determines the info level color based on certain thresholds
* {@link #RELATIVE_THRESHOLD_WARNING} and {@link #RELATIVE_THRESHOLD_CRITICAL}. * {@link #RELATIVE_THRESHOLD_WARNING} and {@link #RELATIVE_THRESHOLD_CRITICAL}.
@ -323,8 +324,8 @@ public class DisplayUtils {
} }
} }
public static CharSequence getRelativeDateTimeString( public static CharSequence getRelativeDateTimeString(Context c, long time, long minResolution,
Context c, long time, long minResolution, long transitionResolution, int flags) { long transitionResolution, int flags) {
CharSequence dateString = ""; CharSequence dateString = "";
@ -333,7 +334,7 @@ public class DisplayUtils {
return DisplayUtils.unixTimeToHumanReadable(time); return DisplayUtils.unixTimeToHumanReadable(time);
} }
// < 60 seconds -> seconds ago // < 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); return c.getString(R.string.file_list_seconds_ago);
} else { } else {
dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags); dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags);
@ -347,7 +348,7 @@ public class DisplayUtils {
return parts[1]; 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(); return dateString.toString();
} }

View file

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

View file

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

View file

@ -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_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_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="push_notifications_temp_error">Push notifications currently not available.</string>
<string name="date_unknown">Unknown</string>
</resources> </resources>