diff --git a/src/main/java/com/owncloud/android/ui/activities/ActivitiesActivity.java b/src/main/java/com/owncloud/android/ui/activities/ActivitiesActivity.java index 571d5c9199..dad3d46f8b 100644 --- a/src/main/java/com/owncloud/android/ui/activities/ActivitiesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activities/ActivitiesActivity.java @@ -170,7 +170,7 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte PorterDuff.Mode.SRC_IN); FileDataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver()); - adapter = new ActivityListAdapter(this, this, storageManager); + adapter = new ActivityListAdapter(this, this, storageManager, false); recyclerView.setAdapter(adapter); LinearLayoutManager layoutManager = new LinearLayoutManager(this); diff --git a/src/main/java/com/owncloud/android/ui/adapter/ActivityAndVersionListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/ActivityAndVersionListAdapter.java index 5e1849d799..9ce7384881 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/ActivityAndVersionListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/ActivityAndVersionListAdapter.java @@ -12,6 +12,7 @@ import android.widget.TextView; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; +import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.resources.activities.models.Activity; import com.owncloud.android.lib.resources.files.FileVersion; import com.owncloud.android.ui.interfaces.ActivityListInterface; @@ -33,14 +34,17 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter { public ActivityAndVersionListAdapter(Context context, ActivityListInterface activityListInterface, VersionListInterface.View versionListInterface, FileDataStorageManager storageManager) { - super(context, activityListInterface, storageManager); + super(context, activityListInterface, storageManager, true); this.versionListInterface = versionListInterface; } - public void setActivityAndVersionItems(ArrayList items, boolean clear) { + public void setActivityAndVersionItems(ArrayList items, OwnCloudClient newClient, boolean clear) { + if (client == null) { + client = newClient; + } if (clear) { - mValues.clear(); + values.clear(); Collections.sort(items, (o1, o2) -> { long o1Date; long o2Date; @@ -79,11 +83,11 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter { } if (sTime.equalsIgnoreCase(time)) { - mValues.add(item); + values.add(item); } else { sTime = time; - mValues.add(sTime); - mValues.add(item); + values.add(sTime); + values.add(item); } } @@ -107,7 +111,7 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder instanceof VersionViewHolder) { final VersionViewHolder versionViewHolder = (VersionViewHolder) holder; - FileVersion fileVersion = (FileVersion) mValues.get(position); + FileVersion fileVersion = (FileVersion) values.get(position); versionViewHolder.size.setText(DisplayUtils.bytesToHumanReadable(fileVersion.getFileLength())); versionViewHolder.time.setText(DateFormat.format("HH:mm", new Date(fileVersion.getModifiedTimestamp()) @@ -121,7 +125,7 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter { @Override public int getItemViewType(int position) { - Object value = mValues.get(position); + Object value = values.get(position); if (value instanceof Activity) return ACTIVITY_TYPE; diff --git a/src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java index 47b6e82fc2..bb1ed169e3 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/ActivityListAdapter.java @@ -82,27 +82,29 @@ public class ActivityListAdapter extends RecyclerView.Adapter mValues; + protected List values; + private boolean isDetailView; public ActivityListAdapter(Context context, ActivityListInterface activityListInterface, - FileDataStorageManager storageManager) { - this.mValues = new ArrayList<>(); + FileDataStorageManager storageManager, boolean isDetailView) { + this.values = new ArrayList<>(); this.context = context; this.activityListInterface = activityListInterface; this.storageManager = storageManager; px = getThumbnailDimension(); + this.isDetailView = isDetailView; } public void setActivityItems(List activityItems, OwnCloudClient client, boolean clear) { - this.mClient = client; + this.client = client; String sTime = ""; if (clear) { - mValues.clear(); + values.clear(); } for (Object o : activityItems) { @@ -117,11 +119,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter activityListInterface.onActivityClicked(richObject)); - setBitmap(file, imageView); + setBitmap(file, imageView, isDetailView); return imageView; } - private void setBitmap(OCFile file, ImageView fileIcon) { + private void setBitmap(OCFile file, ImageView fileIcon, boolean isDetailView) { // No Folder if (!file.isFolder()) { if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file))) { @@ -246,20 +248,29 @@ public class ActivityListAdapter extends RecyclerView.Adapter activities, boolean clear) { - adapter.setActivityAndVersionItems(activities, clear); + adapter.setActivityAndVersionItems(activities, ownCloudClient, clear); } private void setEmptyContent(String headline, String message) { if (emptyContentContainer != null && emptyContentMessage != null) { - emptyContentIcon.setImageDrawable(getContext().getResources().getDrawable(R.drawable.ic_activity_light_grey)); + emptyContentIcon.setImageDrawable(requireContext().getResources().getDrawable(R.drawable.ic_activity_light_grey)); emptyContentHeadline.setText(headline); emptyContentMessage.setText(message); @@ -376,7 +376,7 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi private void setErrorContent(String message) { if (emptyContentContainer != null && emptyContentMessage != null) { emptyContentHeadline.setText(R.string.common_error); - emptyContentIcon.setImageDrawable(getContext().getResources().getDrawable(R.drawable.ic_alert_octagon)); + emptyContentIcon.setImageDrawable(requireContext().getResources().getDrawable(R.drawable.ic_alert_octagon)); emptyContentMessage.setText(message); emptyContentMessage.setVisibility(View.VISIBLE); diff --git a/src/main/res/layout/activity_list_item.xml b/src/main/res/layout/activity_list_item.xml index a4d1307a1e..01b8782893 100644 --- a/src/main/res/layout/activity_list_item.xml +++ b/src/main/res/layout/activity_list_item.xml @@ -61,7 +61,7 @@ android:layout_height="wrap_content" android:ellipsize="end" android:text="@string/placeholder_sentence" - android:textColor="?android:attr/textColorSecondary"/> + android:textAppearance="?android:attr/textAppearanceListItem"/>