- 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);
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);

View file

@ -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<Object> items, boolean clear) {
public void setActivityAndVersionItems(ArrayList<Object> 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;

View file

@ -82,27 +82,29 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
protected final ActivityListInterface activityListInterface;
private final int px;
private static final String TAG = ActivityListAdapter.class.getSimpleName();
private OwnCloudClient mClient;
protected OwnCloudClient client;
protected Context context;
private FileDataStorageManager storageManager;
protected List<Object> mValues;
protected List<Object> 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<Object> 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<RecyclerView.ViewH
}
if (sTime.equalsIgnoreCase(time)) {
mValues.add(activity);
values.add(activity);
} else {
sTime = time;
mValues.add(sTime);
mValues.add(activity);
values.add(sTime);
values.add(activity);
}
}
notifyDataSetChanged();
@ -143,7 +145,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ActivityViewHolder) {
final ActivityViewHolder activityViewHolder = (ActivityViewHolder) holder;
Activity activity = (Activity) mValues.get(position);
Activity activity = (Activity) values.get(position);
if (activity.getDatetime() != null) {
activityViewHolder.dateTime.setVisibility(View.VISIBLE);
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()) {
if (richObject.getPath() != null) {
ImageView imageView = createThumbnail(richObject);
ImageView imageView = createThumbnail(richObject, isDetailView);
activityViewHolder.list.addView(imageView);
}
}
@ -208,11 +210,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
} else {
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();
OCFile file = storageManager.getFileByPath(path);
@ -229,12 +231,12 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
ImageView imageView = new ImageView(context);
imageView.setLayoutParams(params);
imageView.setOnClickListener(v -> 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<RecyclerView.ViewH
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(), "/");
Glide.with(context).using(new CustomGlideStreamLoader()).load(uri).placeholder(placeholder)
.error(placeholder).into(fileIcon); // using custom fetcher
} 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 {
// Folder
fileIcon.setImageDrawable(
MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
file.isSharedViaLink(), file.isEncrypted(), file.getMountType(), context));
if (isDetailView) {
fileIcon.setVisibility(View.GONE);
} 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
public int getItemViewType(int position) {
if (mValues.get(position) instanceof Activity)
if (values.get(position) instanceof Activity)
return ACTIVITY_TYPE;
else
return HEADER_TYPE;
@ -338,7 +349,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
@Override
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() {
FileDataStorageManager storageManager = new FileDataStorageManager(account, getActivity().getContentResolver());
operationsHelper = ((ComponentsGetter) getActivity()).getFileOperationsHelper();
FileDataStorageManager storageManager = new FileDataStorageManager(account, requireActivity().getContentResolver());
operationsHelper = ((ComponentsGetter) requireActivity()).getFileOperationsHelper();
OCCapability capability = storageManager.getCapability(account.name);
OwnCloudVersion serverVersion = AccountUtils.getServerVersion(account);
@ -358,12 +358,12 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
}
private void populateList(ArrayList<Object> 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);

View file

@ -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"/>
<GridLayout
android:id="@+id/list"