- same text size

- show only previews on file detail

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2018-06-22 10:31:34 +02:00
parent 11e2856571
commit c884189162
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
5 changed files with 52 additions and 37 deletions

View file

@ -170,7 +170,7 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
PorterDuff.Mode.SRC_IN); PorterDuff.Mode.SRC_IN);
FileDataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver()); FileDataStorageManager storageManager = new FileDataStorageManager(getAccount(), getContentResolver());
adapter = new ActivityListAdapter(this, this, storageManager); adapter = new ActivityListAdapter(this, this, storageManager, false);
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(this); LinearLayoutManager layoutManager = new LinearLayoutManager(this);

View file

@ -12,6 +12,7 @@ import android.widget.TextView;
import com.owncloud.android.R; import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager; 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.activities.models.Activity;
import com.owncloud.android.lib.resources.files.FileVersion; import com.owncloud.android.lib.resources.files.FileVersion;
import com.owncloud.android.ui.interfaces.ActivityListInterface; import com.owncloud.android.ui.interfaces.ActivityListInterface;
@ -33,14 +34,17 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter {
public ActivityAndVersionListAdapter(Context context, ActivityListInterface activityListInterface, public ActivityAndVersionListAdapter(Context context, ActivityListInterface activityListInterface,
VersionListInterface.View versionListInterface, VersionListInterface.View versionListInterface,
FileDataStorageManager storageManager) { FileDataStorageManager storageManager) {
super(context, activityListInterface, storageManager); super(context, activityListInterface, storageManager, true);
this.versionListInterface = versionListInterface; this.versionListInterface = versionListInterface;
} }
public void setActivityAndVersionItems(ArrayList<Object> items, boolean clear) { public void setActivityAndVersionItems(ArrayList<Object> items, OwnCloudClient newClient, boolean clear) {
if (client == null) {
client = newClient;
}
if (clear) { if (clear) {
mValues.clear(); values.clear();
Collections.sort(items, (o1, o2) -> { Collections.sort(items, (o1, o2) -> {
long o1Date; long o1Date;
long o2Date; long o2Date;
@ -79,11 +83,11 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter {
} }
if (sTime.equalsIgnoreCase(time)) { if (sTime.equalsIgnoreCase(time)) {
mValues.add(item); values.add(item);
} else { } else {
sTime = time; sTime = time;
mValues.add(sTime); values.add(sTime);
mValues.add(item); values.add(item);
} }
} }
@ -107,7 +111,7 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter {
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof VersionViewHolder) { if (holder instanceof VersionViewHolder) {
final VersionViewHolder versionViewHolder = (VersionViewHolder) holder; 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.size.setText(DisplayUtils.bytesToHumanReadable(fileVersion.getFileLength()));
versionViewHolder.time.setText(DateFormat.format("HH:mm", new Date(fileVersion.getModifiedTimestamp()) versionViewHolder.time.setText(DateFormat.format("HH:mm", new Date(fileVersion.getModifiedTimestamp())
@ -121,7 +125,7 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter {
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
Object value = mValues.get(position); Object value = values.get(position);
if (value instanceof Activity) if (value instanceof Activity)
return ACTIVITY_TYPE; return ACTIVITY_TYPE;

View file

@ -82,27 +82,29 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
protected final ActivityListInterface activityListInterface; protected final ActivityListInterface activityListInterface;
private final int px; private final int px;
private static final String TAG = ActivityListAdapter.class.getSimpleName(); private static final String TAG = ActivityListAdapter.class.getSimpleName();
private OwnCloudClient mClient; protected OwnCloudClient client;
protected Context context; protected Context context;
private FileDataStorageManager storageManager; private FileDataStorageManager storageManager;
protected List<Object> mValues; protected List<Object> values;
private boolean isDetailView;
public ActivityListAdapter(Context context, ActivityListInterface activityListInterface, public ActivityListAdapter(Context context, ActivityListInterface activityListInterface,
FileDataStorageManager storageManager) { FileDataStorageManager storageManager, boolean isDetailView) {
this.mValues = new ArrayList<>(); this.values = new ArrayList<>();
this.context = context; this.context = context;
this.activityListInterface = activityListInterface; this.activityListInterface = activityListInterface;
this.storageManager = storageManager; this.storageManager = storageManager;
px = getThumbnailDimension(); px = getThumbnailDimension();
this.isDetailView = isDetailView;
} }
public void setActivityItems(List<Object> activityItems, OwnCloudClient client, boolean clear) { public void setActivityItems(List<Object> activityItems, OwnCloudClient client, boolean clear) {
this.mClient = client; this.client = client;
String sTime = ""; String sTime = "";
if (clear) { if (clear) {
mValues.clear(); values.clear();
} }
for (Object o : activityItems) { for (Object o : activityItems) {
@ -117,11 +119,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} }
if (sTime.equalsIgnoreCase(time)) { if (sTime.equalsIgnoreCase(time)) {
mValues.add(activity); values.add(activity);
} else { } else {
sTime = time; sTime = time;
mValues.add(sTime); values.add(sTime);
mValues.add(activity); values.add(activity);
} }
} }
notifyDataSetChanged(); notifyDataSetChanged();
@ -143,7 +145,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ActivityViewHolder) { if (holder instanceof ActivityViewHolder) {
final ActivityViewHolder activityViewHolder = (ActivityViewHolder) holder; final ActivityViewHolder activityViewHolder = (ActivityViewHolder) holder;
Activity activity = (Activity) mValues.get(position); Activity activity = (Activity) values.get(position);
if (activity.getDatetime() != null) { if (activity.getDatetime() != null) {
activityViewHolder.dateTime.setVisibility(View.VISIBLE); activityViewHolder.dateTime.setVisibility(View.VISIBLE);
activityViewHolder.dateTime.setText(DateFormat.format("HH:mm", activity.getDatetime().getTime())); activityViewHolder.dateTime.setText(DateFormat.format("HH:mm", activity.getDatetime().getTime()));
@ -197,7 +199,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
for (RichObject richObject : activity.getRichSubjectElement().getRichObjectList()) { for (RichObject richObject : activity.getRichSubjectElement().getRichObjectList()) {
if (richObject.getPath() != null) { if (richObject.getPath() != null) {
ImageView imageView = createThumbnail(richObject); ImageView imageView = createThumbnail(richObject, isDetailView);
activityViewHolder.list.addView(imageView); activityViewHolder.list.addView(imageView);
} }
} }
@ -208,11 +210,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} }
} else { } else {
ActivityViewHeaderHolder activityViewHeaderHolder = (ActivityViewHeaderHolder) holder; ActivityViewHeaderHolder activityViewHeaderHolder = (ActivityViewHeaderHolder) holder;
activityViewHeaderHolder.title.setText((String) mValues.get(position)); activityViewHeaderHolder.title.setText((String) values.get(position));
} }
} }
private ImageView createThumbnail(final RichObject richObject) { private ImageView createThumbnail(final RichObject richObject, boolean isDetailView) {
String path = FileUtils.PATH_SEPARATOR + richObject.getPath(); String path = FileUtils.PATH_SEPARATOR + richObject.getPath();
OCFile file = storageManager.getFileByPath(path); OCFile file = storageManager.getFileByPath(path);
@ -229,12 +231,12 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
ImageView imageView = new ImageView(context); ImageView imageView = new ImageView(context);
imageView.setLayoutParams(params); imageView.setLayoutParams(params);
imageView.setOnClickListener(v -> activityListInterface.onActivityClicked(richObject)); imageView.setOnClickListener(v -> activityListInterface.onActivityClicked(richObject));
setBitmap(file, imageView); setBitmap(file, imageView, isDetailView);
return imageView; return imageView;
} }
private void setBitmap(OCFile file, ImageView fileIcon) { private void setBitmap(OCFile file, ImageView fileIcon, boolean isDetailView) {
// No Folder // No Folder
if (!file.isFolder()) { if (!file.isFolder()) {
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file))) { if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file))) {
@ -246,20 +248,29 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
placeholder = R.drawable.file_movie; placeholder = R.drawable.file_movie;
} }
String uri = mClient.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px + String uri = client.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px +
Uri.encode(file.getRemotePath(), "/"); Uri.encode(file.getRemotePath(), "/");
Glide.with(context).using(new CustomGlideStreamLoader()).load(uri).placeholder(placeholder) Glide.with(context).using(new CustomGlideStreamLoader()).load(uri).placeholder(placeholder)
.error(placeholder).into(fileIcon); // using custom fetcher .error(placeholder).into(fileIcon); // using custom fetcher
} else { } else {
fileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(), context)); if (isDetailView) {
fileIcon.setVisibility(View.GONE);
} else {
fileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
context));
}
} }
} else { } else {
// Folder // Folder
fileIcon.setImageDrawable( if (isDetailView) {
MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(), fileIcon.setVisibility(View.GONE);
file.isSharedViaLink(), file.isEncrypted(), file.getMountType(), context)); } else {
fileIcon.setImageDrawable(
MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
file.isSharedViaLink(), file.isEncrypted(), file.getMountType(), context));
}
} }
} }
@ -330,7 +341,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
if (mValues.get(position) instanceof Activity) if (values.get(position) instanceof Activity)
return ACTIVITY_TYPE; return ACTIVITY_TYPE;
else else
return HEADER_TYPE; return HEADER_TYPE;
@ -338,7 +349,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
@Override @Override
public int getItemCount() { public int getItemCount() {
return mValues.size(); return values.size();
} }
/** /**

View file

@ -223,8 +223,8 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
} }
private void setupView() { private void setupView() {
FileDataStorageManager storageManager = new FileDataStorageManager(account, getActivity().getContentResolver()); FileDataStorageManager storageManager = new FileDataStorageManager(account, requireActivity().getContentResolver());
operationsHelper = ((ComponentsGetter) getActivity()).getFileOperationsHelper(); operationsHelper = ((ComponentsGetter) requireActivity()).getFileOperationsHelper();
OCCapability capability = storageManager.getCapability(account.name); OCCapability capability = storageManager.getCapability(account.name);
OwnCloudVersion serverVersion = AccountUtils.getServerVersion(account); OwnCloudVersion serverVersion = AccountUtils.getServerVersion(account);
@ -358,12 +358,12 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
} }
private void populateList(ArrayList<Object> activities, boolean clear) { private void populateList(ArrayList<Object> activities, boolean clear) {
adapter.setActivityAndVersionItems(activities, clear); adapter.setActivityAndVersionItems(activities, ownCloudClient, clear);
} }
private void setEmptyContent(String headline, String message) { private void setEmptyContent(String headline, String message) {
if (emptyContentContainer != null && emptyContentMessage != null) { 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); emptyContentHeadline.setText(headline);
emptyContentMessage.setText(message); emptyContentMessage.setText(message);
@ -376,7 +376,7 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
private void setErrorContent(String message) { private void setErrorContent(String message) {
if (emptyContentContainer != null && emptyContentMessage != null) { if (emptyContentContainer != null && emptyContentMessage != null) {
emptyContentHeadline.setText(R.string.common_error); 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.setText(message);
emptyContentMessage.setVisibility(View.VISIBLE); emptyContentMessage.setVisibility(View.VISIBLE);

View file

@ -61,7 +61,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:text="@string/placeholder_sentence" android:text="@string/placeholder_sentence"
android:textColor="?android:attr/textColorSecondary"/> android:textAppearance="?android:attr/textAppearanceListItem"/>
<GridLayout <GridLayout
android:id="@+id/list" android:id="@+id/list"