mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
Merge pull request #1659 from nextcloud/activityListDesign
Enhance activity list design
This commit is contained in:
commit
390a2e40d3
6 changed files with 42 additions and 26 deletions
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue