|
@@ -288,9 +288,9 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
|
|
|
if (isCheckedFile(file)) {
|
|
|
gridViewHolder.itemLayout.setBackgroundColor(mContext.getResources()
|
|
|
- .getColor(R.color.selected_item_background));
|
|
|
+ .getColor(R.color.selected_item_background));
|
|
|
gridViewHolder.checkbox.setImageDrawable(ThemeUtils.tintDrawable(R.drawable.ic_checkbox_marked,
|
|
|
- ThemeUtils.primaryColor(mContext)));
|
|
|
+ ThemeUtils.primaryColor(mContext)));
|
|
|
} else {
|
|
|
gridViewHolder.itemLayout.setBackgroundColor(Color.WHITE);
|
|
|
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_blank_outline);
|
|
@@ -301,7 +301,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
if (!mHideItemOptions) {
|
|
|
gridViewHolder.itemLayout.setLongClickable(true);
|
|
|
gridViewHolder.itemLayout.setOnLongClickListener(v ->
|
|
|
- ocFileListFragmentInterface.onLongItemClicked(file));
|
|
|
+ ocFileListFragmentInterface.onLongItemClicked(file));
|
|
|
}
|
|
|
|
|
|
// unread comments
|
|
@@ -352,14 +352,14 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
itemViewHolder.fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
|
|
}
|
|
|
itemViewHolder.lastModification.setText(DisplayUtils.getRelativeTimestamp(mContext,
|
|
|
- file.getModificationTimestamp()));
|
|
|
+ file.getModificationTimestamp()));
|
|
|
|
|
|
if (multiSelect || gridView || mHideItemOptions) {
|
|
|
itemViewHolder.overflowMenu.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
itemViewHolder.overflowMenu.setVisibility(View.VISIBLE);
|
|
|
itemViewHolder.overflowMenu.setOnClickListener(view -> ocFileListFragmentInterface
|
|
|
- .onOverflowIconClicked(file, view));
|
|
|
+ .onOverflowIconClicked(file, view));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -422,49 +422,50 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void showFederatedShareAvatar(OCFile file, float avatarRadius, Resources resources,
|
|
|
- OCFileListItemViewHolder itemViewHolder) {
|
|
|
- // maybe federated share
|
|
|
- String userId = file.getOwnerId().split("@")[0];
|
|
|
- String server = file.getOwnerId().split("@")[1];
|
|
|
-
|
|
|
- String url = "https://" + server + "/avatar/" + userId + "/" +
|
|
|
- DisplayUtils.convertDpToPixel(avatarRadius, mContext);
|
|
|
-
|
|
|
- Drawable placeholder;
|
|
|
- try {
|
|
|
- placeholder = TextDrawable.createAvatarByUserId(userId, avatarRadius);
|
|
|
- } catch (Exception e) {
|
|
|
- Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
|
|
|
- placeholder = resources.getDrawable(R.drawable.account_circle_white);
|
|
|
- }
|
|
|
-
|
|
|
- itemViewHolder.sharedAvatar.setTag(null);
|
|
|
- Glide.with(mContext).load(url)
|
|
|
- .asBitmap()
|
|
|
- .placeholder(placeholder)
|
|
|
- .error(placeholder)
|
|
|
- .into(new BitmapImageViewTarget(itemViewHolder.sharedAvatar) {
|
|
|
- @Override
|
|
|
- protected void setResource(Bitmap resource) {
|
|
|
- RoundedBitmapDrawable circularBitmapDrawable =
|
|
|
- RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
|
|
|
- circularBitmapDrawable.setCircular(true);
|
|
|
- itemViewHolder.sharedAvatar.setImageDrawable(circularBitmapDrawable);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ private void showFederatedShareAvatar(OCFile file, float avatarRadius, Resources resources,
|
|
|
+ OCFileListItemViewHolder itemViewHolder) {
|
|
|
+ // maybe federated share
|
|
|
+ String userId = file.getOwnerId().split("@")[0];
|
|
|
+ String server = file.getOwnerId().split("@")[1];
|
|
|
+
|
|
|
+ String url = "https://" + server + "/avatar/" + userId + "/" +
|
|
|
+ DisplayUtils.convertDpToPixel(avatarRadius, mContext);
|
|
|
+
|
|
|
+ Drawable placeholder;
|
|
|
+ try {
|
|
|
+ placeholder = TextDrawable.createAvatarByUserId(userId, avatarRadius);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
|
|
|
+ placeholder = resources.getDrawable(R.drawable.account_circle_white);
|
|
|
+ }
|
|
|
+
|
|
|
+ itemViewHolder.sharedAvatar.setTag(null);
|
|
|
+ Glide.with(mContext).load(url)
|
|
|
+ .asBitmap()
|
|
|
+ .placeholder(placeholder)
|
|
|
+ .error(placeholder)
|
|
|
+ .into(new BitmapImageViewTarget(itemViewHolder.sharedAvatar) {
|
|
|
+ @Override
|
|
|
+ protected void setResource(Bitmap resource) {
|
|
|
+ RoundedBitmapDrawable circularBitmapDrawable =
|
|
|
+ RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
|
|
|
+ circularBitmapDrawable.setCircular(true);
|
|
|
+ itemViewHolder.sharedAvatar.setImageDrawable(circularBitmapDrawable);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
private void setThumbnail(OCFile file, ImageView thumbnailView) {
|
|
|
if (file.isFolder()) {
|
|
|
- thumbnailView.setImageDrawable(MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() ||
|
|
|
- file.isSharedWithSharee(), file.isSharedViaLink(), file.isEncrypted(), file.getMountType(),
|
|
|
- mContext));
|
|
|
+ thumbnailView.setImageDrawable(MimeTypeUtil
|
|
|
+ .getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
|
|
|
+ file.isSharedViaLink(), file.isEncrypted(),
|
|
|
+ file.getMountType(), mContext));
|
|
|
} else {
|
|
|
if (file.getRemoteId() != null && file.isPreviewAvailable()) {
|
|
|
// Thumbnail in cache?
|
|
|
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
|
|
- ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.getRemoteId()
|
|
|
+ ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.getRemoteId()
|
|
|
);
|
|
|
|
|
|
if (thumbnail != null && !file.isUpdateThumbnailNeeded()) {
|
|
@@ -479,8 +480,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView)) {
|
|
|
try {
|
|
|
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
|
|
- new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView, mStorageManager,
|
|
|
- mAccount, asyncTasks);
|
|
|
+ new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView, mStorageManager,
|
|
|
+ mAccount, asyncTasks);
|
|
|
|
|
|
if (thumbnail == null) {
|
|
|
if (MimeTypeUtil.isVideo(file)) {
|
|
@@ -490,12 +491,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
}
|
|
|
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
|
|
- new ThumbnailsCacheManager.AsyncThumbnailDrawable(mContext.getResources(),
|
|
|
- thumbnail, task);
|
|
|
+ new ThumbnailsCacheManager.AsyncThumbnailDrawable(mContext.getResources(),
|
|
|
+ thumbnail, task);
|
|
|
thumbnailView.setImageDrawable(asyncDrawable);
|
|
|
asyncTasks.add(task);
|
|
|
task.execute(new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file,
|
|
|
- file.getRemoteId()));
|
|
|
+ file.getRemoteId()));
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
Log_OC.d(TAG, "ThumbnailGenerationTask : " + e.getMessage());
|
|
|
}
|
|
@@ -507,7 +508,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
} else {
|
|
|
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
|
|
|
- mAccount, mContext));
|
|
|
+ mAccount, mContext));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -545,7 +546,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
output = resources.getQuantityString(R.plurals.file_list__footer__folder, foldersCount, foldersCount);
|
|
|
} else {
|
|
|
output = resources.getQuantityString(R.plurals.file_list__footer__file, filesCount, filesCount) + ", " +
|
|
|
- resources.getQuantityString(R.plurals.file_list__footer__folder, foldersCount, foldersCount);
|
|
|
+ resources.getQuantityString(R.plurals.file_list__footer__folder, foldersCount, foldersCount);
|
|
|
}
|
|
|
|
|
|
return output;
|
|
@@ -598,10 +599,10 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
|
|
|
/**
|
|
|
* Change the adapted directory for a new one
|
|
|
- * @param directory New folder to adapt. Can be NULL, meaning
|
|
|
- * "no content to adapt".
|
|
|
+ *
|
|
|
+ * @param directory New folder to adapt. Can be NULL, meaning "no content to adapt".
|
|
|
* @param updatedStorageManager Optional updated storage manager; used to replace
|
|
|
- * @param limitToMimeType show only files of this mimeType
|
|
|
+ * @param limitToMimeType show only files of this mimeType
|
|
|
*/
|
|
|
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager,
|
|
|
boolean onlyOnDevice, String limitToMimeType) {
|
|
@@ -688,7 +689,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
|
|
|
// get ocFile from Server to have an up-to-date copy
|
|
|
RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(mAccount,
|
|
|
- mContext);
|
|
|
+ mContext);
|
|
|
|
|
|
if (result.isSuccess()) {
|
|
|
OCFile file = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
|
|
@@ -699,7 +700,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
if (newShareType == ShareType.PUBLIC_LINK) {
|
|
|
file.setSharedViaLink(true);
|
|
|
} else if (newShareType == ShareType.USER || newShareType == ShareType.GROUP ||
|
|
|
- newShareType == ShareType.EMAIL || newShareType == ShareType.FEDERATED) {
|
|
|
+ newShareType == ShareType.EMAIL || newShareType == ShareType.FEDERATED) {
|
|
|
file.setSharedWithSharee(true);
|
|
|
}
|
|
|
|
|
@@ -747,7 +748,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
if (ocFile.isFolder()) {
|
|
|
long currentSyncTime = System.currentTimeMillis();
|
|
|
RemoteOperation refreshFolderOperation = new RefreshFolderOperation(ocFile, currentSyncTime, false,
|
|
|
- false, mStorageManager, mAccount, mContext);
|
|
|
+ false, mStorageManager, mAccount, mContext);
|
|
|
refreshFolderOperation.execute(mAccount, mContext);
|
|
|
}
|
|
|
|
|
@@ -810,7 +811,6 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
|
|
|
private class FilesFilter extends Filter {
|
|
|
-
|
|
|
@Override
|
|
|
protected FilterResults performFiltering(CharSequence constraint) {
|
|
|
FilterResults results = new FilterResults();
|
|
@@ -820,8 +820,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
for (OCFile file : mFilesAll) {
|
|
|
if (file.getParentRemotePath().equals(currentDirectory.getRemotePath()) &&
|
|
|
file.getFileName().toLowerCase(Locale.getDefault()).contains(
|
|
|
- constraint.toString().toLowerCase(Locale.getDefault())) &&
|
|
|
- !filteredFiles.contains(file)) {
|
|
|
+ constraint.toString().toLowerCase(Locale.getDefault())) &&
|
|
|
+ !filteredFiles.contains(file)) {
|
|
|
filteredFiles.add(file);
|
|
|
}
|
|
|
}
|
|
@@ -852,7 +852,6 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Filter for hidden files
|
|
|
*
|
|
@@ -901,7 +900,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
gridView = bool;
|
|
|
}
|
|
|
|
|
|
- static class OCFileListItemViewHolder extends OCFileListGridItemViewHolder {
|
|
|
+ static class OCFileListItemViewHolder extends OCFileListGridItemViewHolder {
|
|
|
@BindView(R.id.file_size)
|
|
|
public TextView fileSize;
|
|
|
|
|
@@ -920,7 +919,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static class OCFileListGridItemViewHolder extends OCFileListGridImageViewHolder {
|
|
|
+ static class OCFileListGridItemViewHolder extends OCFileListGridImageViewHolder {
|
|
|
@BindView(R.id.Filename) public TextView fileName;
|
|
|
|
|
|
private OCFileListGridItemViewHolder(View itemView) {
|
|
@@ -929,26 +928,26 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static class OCFileListGridImageViewHolder extends RecyclerView.ViewHolder {
|
|
|
- @BindView(R.id.thumbnail)
|
|
|
- public ImageView thumbnail;
|
|
|
+ static class OCFileListGridImageViewHolder extends RecyclerView.ViewHolder {
|
|
|
+ @BindView(R.id.thumbnail)
|
|
|
+ public ImageView thumbnail;
|
|
|
|
|
|
- @BindView(R.id.favorite_action)
|
|
|
- public ImageView favorite;
|
|
|
+ @BindView(R.id.favorite_action)
|
|
|
+ public ImageView favorite;
|
|
|
|
|
|
- @BindView(R.id.localFileIndicator)
|
|
|
- public ImageView localFileIndicator;
|
|
|
+ @BindView(R.id.localFileIndicator)
|
|
|
+ public ImageView localFileIndicator;
|
|
|
|
|
|
- @BindView(R.id.sharedIcon)
|
|
|
- public ImageView shared;
|
|
|
+ @BindView(R.id.sharedIcon)
|
|
|
+ public ImageView shared;
|
|
|
|
|
|
- @BindView(R.id.custom_checkbox)
|
|
|
- public ImageView checkbox;
|
|
|
+ @BindView(R.id.custom_checkbox)
|
|
|
+ public ImageView checkbox;
|
|
|
|
|
|
- @BindView(R.id.ListItemLayout)
|
|
|
- public LinearLayout itemLayout;
|
|
|
+ @BindView(R.id.ListItemLayout)
|
|
|
+ public LinearLayout itemLayout;
|
|
|
|
|
|
- @BindView(R.id.unreadComments)
|
|
|
+ @BindView(R.id.unreadComments)
|
|
|
public ImageView unreadComments;
|
|
|
|
|
|
private OCFileListGridImageViewHolder(View itemView) {
|
|
@@ -957,7 +956,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static class OCFileListFooterViewHolder extends RecyclerView.ViewHolder {
|
|
|
+ static class OCFileListFooterViewHolder extends RecyclerView.ViewHolder {
|
|
|
@BindView(R.id.footerText)
|
|
|
public TextView footerText;
|
|
|
|