Skip to content

Commit

Permalink
Merge pull request #1659 from nextcloud/activityListDesign
Browse files Browse the repository at this point in the history
Enhance activity list design
  • Loading branch information
AndyScherzinger authored Oct 19, 2017
2 parents ff32f5e + dfebdad commit 390a2e4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
2 changes: 1 addition & 1 deletion scripts/lint/lint-results.txt
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@

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;
Expand Down Expand Up @@ -58,15 +62,13 @@
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;
import com.owncloud.android.utils.svg.SvgSoftwareLayerSetter;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
Expand Down Expand Up @@ -103,19 +105,16 @@ public void setActivityItems(List<Object> activityItems, OwnCloudClient client)
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);
Expand Down Expand Up @@ -144,11 +143,10 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
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 &&
Expand Down Expand Up @@ -304,10 +302,14 @@ private SpannableStringBuilder addClickablePart(RichElement richElement) {
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);
}
Expand Down Expand Up @@ -349,6 +351,15 @@ private int getThumbnailDimension() {
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;
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/owncloud/android/utils/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public static Set<String> toAccountNameSet(Collection<Account> accountList) {
}

/**
* 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.
Expand All @@ -300,6 +300,7 @@ public static CharSequence getRelativeTimestamp(Context context, long modificati
DateUtils.WEEK_IN_MILLIS, 0);
}


/**
* determines the info level color based on certain thresholds
* {@link #RELATIVE_THRESHOLD_WARNING} and {@link #RELATIVE_THRESHOLD_CRITICAL}.
Expand All @@ -323,8 +324,8 @@ public static int getRelativeInfoColor(Context context, int relative) {
}
}

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 = "";

Expand All @@ -333,7 +334,7 @@ public static CharSequence getRelativeDateTimeString(
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);
Expand All @@ -347,7 +348,7 @@ else if ((System.currentTimeMillis() - time) < 60 * 1000) {
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();
}

Expand Down
7 changes: 5 additions & 2 deletions src/main/res/layout/activity_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/main/res/layout/activity_list_item_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 390a2e4

Please sign in to comment.