|
@@ -47,6 +47,7 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.request.target.BitmapImageViewTarget;
|
|
import com.bumptech.glide.request.target.BitmapImageViewTarget;
|
|
|
|
+import com.nextcloud.client.account.User;
|
|
import com.nextcloud.client.account.UserAccountManager;
|
|
import com.nextcloud.client.account.UserAccountManager;
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.R;
|
|
@@ -117,7 +118,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
private Set<OCFile> checkedFiles;
|
|
private Set<OCFile> checkedFiles;
|
|
|
|
|
|
private FileDataStorageManager mStorageManager;
|
|
private FileDataStorageManager mStorageManager;
|
|
- private Account account;
|
|
+ private User user;
|
|
private OCFileListFragmentInterface ocFileListFragmentInterface;
|
|
private OCFileListFragmentInterface ocFileListFragmentInterface;
|
|
|
|
|
|
private FilesFilter mFilesFilter;
|
|
private FilesFilter mFilesFilter;
|
|
@@ -135,7 +136,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
|
|
|
public OCFileListAdapter(
|
|
public OCFileListAdapter(
|
|
Context context,
|
|
Context context,
|
|
- Account account,
|
|
+ User user,
|
|
AppPreferences preferences,
|
|
AppPreferences preferences,
|
|
UserAccountManager accountManager,
|
|
UserAccountManager accountManager,
|
|
ComponentsGetter transferServiceGetter,
|
|
ComponentsGetter transferServiceGetter,
|
|
@@ -147,16 +148,16 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
mContext = context;
|
|
mContext = context;
|
|
this.preferences = preferences;
|
|
this.preferences = preferences;
|
|
this.accountManager = accountManager;
|
|
this.accountManager = accountManager;
|
|
- this.account = account;
|
|
+ this.user = user;
|
|
mHideItemOptions = argHideItemOptions;
|
|
mHideItemOptions = argHideItemOptions;
|
|
this.gridView = gridView;
|
|
this.gridView = gridView;
|
|
checkedFiles = new HashSet<>();
|
|
checkedFiles = new HashSet<>();
|
|
|
|
|
|
this.transferServiceGetter = transferServiceGetter;
|
|
this.transferServiceGetter = transferServiceGetter;
|
|
|
|
|
|
- if (account != null) {
|
|
+ if (this.user != null) {
|
|
AccountManager platformAccountManager = AccountManager.get(mContext);
|
|
AccountManager platformAccountManager = AccountManager.get(mContext);
|
|
- userId = platformAccountManager.getUserData(account,
|
|
+ userId = platformAccountManager.getUserData(this.user.toPlatformAccount(),
|
|
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
|
|
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
|
|
} else {
|
|
} else {
|
|
userId = "";
|
|
userId = "";
|
|
@@ -399,7 +400,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
showFederatedShareAvatar(sharee.getUserId(), avatarRadius, resources, avatar);
|
|
showFederatedShareAvatar(sharee.getUserId(), avatarRadius, resources, avatar);
|
|
} else {
|
|
} else {
|
|
avatar.setTag(sharee);
|
|
avatar.setTag(sharee);
|
|
- DisplayUtils.setAvatar(account,
|
|
+ DisplayUtils.setAvatar(user.toPlatformAccount(),
|
|
sharee.getUserId(),
|
|
sharee.getUserId(),
|
|
sharee.getDisplayName(),
|
|
sharee.getDisplayName(),
|
|
this,
|
|
this,
|
|
@@ -460,17 +461,17 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
OperationsService.OperationsServiceBinder operationsServiceBinder = transferServiceGetter.getOperationsServiceBinder();
|
|
OperationsService.OperationsServiceBinder operationsServiceBinder = transferServiceGetter.getOperationsServiceBinder();
|
|
FileDownloader.FileDownloaderBinder fileDownloaderBinder = transferServiceGetter.getFileDownloaderBinder();
|
|
FileDownloader.FileDownloaderBinder fileDownloaderBinder = transferServiceGetter.getFileDownloaderBinder();
|
|
FileUploader.FileUploaderBinder fileUploaderBinder = transferServiceGetter.getFileUploaderBinder();
|
|
FileUploader.FileUploaderBinder fileUploaderBinder = transferServiceGetter.getFileUploaderBinder();
|
|
- if (operationsServiceBinder != null && operationsServiceBinder.isSynchronizing(account, file)) {
|
|
+ if (operationsServiceBinder != null && operationsServiceBinder.isSynchronizing(user.toPlatformAccount(), file)) {
|
|
|
|
|
|
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
|
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
|
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
|
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
|
|
|
|
|
- } else if (fileDownloaderBinder != null && fileDownloaderBinder.isDownloading(account, file)) {
|
|
+ } else if (fileDownloaderBinder != null && fileDownloaderBinder.isDownloading(user.toPlatformAccount(), file)) {
|
|
|
|
|
|
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
|
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
|
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
|
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
|
|
|
|
|
- } else if (fileUploaderBinder != null && fileUploaderBinder.isUploading(account, file)) {
|
|
+ } else if (fileUploaderBinder != null && fileUploaderBinder.isUploading(user.toPlatformAccount(), file)) {
|
|
|
|
|
|
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
|
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing);
|
|
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
|
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
|
@@ -575,13 +576,17 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView)) {
|
|
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView)) {
|
|
try {
|
|
try {
|
|
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
|
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
|
- new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView, mStorageManager,
|
|
+ new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView,
|
|
- account, asyncTasks);
|
|
+ mStorageManager,
|
|
|
|
+ user.toPlatformAccount(),
|
|
|
|
+ asyncTasks);
|
|
|
|
|
|
if (thumbnail == null) {
|
|
if (thumbnail == null) {
|
|
thumbnail = BitmapUtils.drawableToBitmap(
|
|
thumbnail = BitmapUtils.drawableToBitmap(
|
|
- MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
|
|
+ MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
|
- account, mContext));
|
|
+ file.getFileName(),
|
|
|
|
+ user.toPlatformAccount(),
|
|
|
|
+ mContext));
|
|
}
|
|
}
|
|
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
|
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
|
new ThumbnailsCacheManager.AsyncThumbnailDrawable(mContext.getResources(),
|
|
new ThumbnailsCacheManager.AsyncThumbnailDrawable(mContext.getResources(),
|
|
@@ -602,7 +607,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
} else {
|
|
} else {
|
|
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
|
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
|
file.getFileName(),
|
|
file.getFileName(),
|
|
- account,
|
|
+ user.toPlatformAccount(),
|
|
mContext));
|
|
mContext));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -685,7 +690,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
sharedIconView.setImageResource(R.drawable.ic_unshared);
|
|
sharedIconView.setImageResource(R.drawable.ic_unshared);
|
|
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_share));
|
|
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_share));
|
|
}
|
|
}
|
|
- if (accountManager.accountOwnsFile(file, account)) {
|
|
+ if (accountManager.accountOwnsFile(file, user.toPlatformAccount())) {
|
|
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
|
|
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
|
|
} else {
|
|
} else {
|
|
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.showShareDetailView(file));
|
|
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.showShareDetailView(file));
|
|
@@ -703,7 +708,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
* @param limitToMimeType show only files of this mimeType
|
|
* @param limitToMimeType show only files of this mimeType
|
|
*/
|
|
*/
|
|
public void swapDirectory(
|
|
public void swapDirectory(
|
|
- Account account,
|
|
+ User account,
|
|
OCFile directory,
|
|
OCFile directory,
|
|
FileDataStorageManager updatedStorageManager,
|
|
FileDataStorageManager updatedStorageManager,
|
|
boolean onlyOnDevice, String limitToMimeType
|
|
boolean onlyOnDevice, String limitToMimeType
|
|
@@ -712,8 +717,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
|
|
|
if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
|
|
if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
|
|
mStorageManager = updatedStorageManager;
|
|
mStorageManager = updatedStorageManager;
|
|
- showShareAvatar = mStorageManager.getCapability(account.name).getVersion().isShareesOnDavSupported();
|
|
+ showShareAvatar = mStorageManager.getCapability(account.getAccountName()).getVersion().isShareesOnDavSupported();
|
|
- this.account = account;
|
|
+ this.user = account;
|
|
}
|
|
}
|
|
if (mStorageManager != null) {
|
|
if (mStorageManager != null) {
|
|
mFiles = mStorageManager.getFolderContent(directory, onlyOnDevice);
|
|
mFiles = mStorageManager.getFolderContent(directory, onlyOnDevice);
|
|
@@ -744,11 +749,11 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
FileDataStorageManager storageManager, OCFile folder, boolean clear) {
|
|
FileDataStorageManager storageManager, OCFile folder, boolean clear) {
|
|
if (storageManager != null && mStorageManager == null) {
|
|
if (storageManager != null && mStorageManager == null) {
|
|
mStorageManager = storageManager;
|
|
mStorageManager = storageManager;
|
|
- showShareAvatar = mStorageManager.getCapability(account.name).getVersion().isShareesOnDavSupported();
|
|
+ showShareAvatar = mStorageManager.getCapability(user.getAccountName()).getVersion().isShareesOnDavSupported();
|
|
}
|
|
}
|
|
|
|
|
|
if (mStorageManager == null) {
|
|
if (mStorageManager == null) {
|
|
- mStorageManager = new FileDataStorageManager(account, mContext.getContentResolver());
|
|
+ mStorageManager = new FileDataStorageManager(user.toPlatformAccount(), mContext.getContentResolver());
|
|
}
|
|
}
|
|
|
|
|
|
if (clear) {
|
|
if (clear) {
|
|
@@ -808,12 +813,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
shares.add(ocShare);
|
|
shares.add(ocShare);
|
|
|
|
|
|
|
|
|
|
- RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(account,
|
|
+ RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(user.toPlatformAccount(),
|
|
mContext);
|
|
mContext);
|
|
|
|
|
|
if (result.isSuccess()) {
|
|
if (result.isSuccess()) {
|
|
OCFile file = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
|
|
OCFile file = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
|
|
- FileStorageUtils.searchForLocalFileInDefaultPath(file, account);
|
|
+ FileStorageUtils.searchForLocalFileInDefaultPath(file, user.toPlatformAccount());
|
|
file = mStorageManager.saveFileWithParent(file, mContext);
|
|
file = mStorageManager.saveFileWithParent(file, mContext);
|
|
|
|
|
|
ShareType newShareType = ocShare.getShareType();
|
|
ShareType newShareType = ocShare.getShareType();
|
|
@@ -868,7 +873,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
|
|
|
for (Object remoteFile : objects) {
|
|
for (Object remoteFile : objects) {
|
|
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) remoteFile);
|
|
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) remoteFile);
|
|
- FileStorageUtils.searchForLocalFileInDefaultPath(ocFile, account);
|
|
+ FileStorageUtils.searchForLocalFileInDefaultPath(ocFile, user.toPlatformAccount());
|
|
|
|
|
|
try {
|
|
try {
|
|
if (ExtendedListFragment.SearchType.PHOTO_SEARCH == searchType) {
|
|
if (ExtendedListFragment.SearchType.PHOTO_SEARCH == searchType) {
|
|
@@ -885,9 +890,9 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
true,
|
|
true,
|
|
false,
|
|
false,
|
|
mStorageManager,
|
|
mStorageManager,
|
|
- account,
|
|
+ user.toPlatformAccount(),
|
|
mContext);
|
|
mContext);
|
|
- refreshFolderOperation.execute(account, mContext);
|
|
+ refreshFolderOperation.execute(user.toPlatformAccount(), mContext);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|