mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Merge pull request #12241 from nextcloud/chore/revertMerge
Revert "Merge pull request #12228
This commit is contained in:
commit
72dae180c1
5 changed files with 72 additions and 118 deletions
|
@ -23,7 +23,6 @@
|
||||||
package com.nextcloud.client.jobs
|
package com.nextcloud.client.jobs
|
||||||
|
|
||||||
import android.accounts.Account
|
import android.accounts.Account
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -254,54 +253,9 @@ class FilesUploadWorker(
|
||||||
// TODO generalize for automated uploads
|
// TODO generalize for automated uploads
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createConflictResolveAction(context: Context, uploadFileOperation: UploadFileOperation): PendingIntent {
|
|
||||||
val intent = ConflictsResolveActivity.createIntent(
|
|
||||||
uploadFileOperation.file,
|
|
||||||
uploadFileOperation.user,
|
|
||||||
uploadFileOperation.ocUploadId,
|
|
||||||
Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
|
||||||
context
|
|
||||||
)
|
|
||||||
|
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
||||||
PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_MUTABLE)
|
|
||||||
} else {
|
|
||||||
PendingIntent.getActivity(
|
|
||||||
context,
|
|
||||||
0,
|
|
||||||
intent,
|
|
||||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun addConflictResolveActionToNotification(uploadFileOperation: UploadFileOperation) {
|
|
||||||
val intent: PendingIntent = createConflictResolveAction(context, uploadFileOperation)
|
|
||||||
|
|
||||||
notificationBuilder.addAction(
|
|
||||||
R.drawable.ic_cloud_upload,
|
|
||||||
context.getString(R.string.upload_list_resolve_conflict),
|
|
||||||
intent
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun addUploadListContentIntent(uploadFileOperation: UploadFileOperation) {
|
|
||||||
val uploadListIntent = createUploadListIntent(uploadFileOperation)
|
|
||||||
|
|
||||||
notificationBuilder.setContentIntent(
|
|
||||||
PendingIntent.getActivity(
|
|
||||||
context,
|
|
||||||
System.currentTimeMillis().toInt(),
|
|
||||||
uploadListIntent,
|
|
||||||
PendingIntent.FLAG_IMMUTABLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adapted from [com.owncloud.android.files.services.FileUploader.notifyUploadResult]
|
* adapted from [com.owncloud.android.files.services.FileUploader.notifyUploadResult]
|
||||||
*/
|
*/
|
||||||
@SuppressLint("RestrictedApi")
|
|
||||||
private fun notifyUploadResult(
|
private fun notifyUploadResult(
|
||||||
uploadFileOperation: UploadFileOperation,
|
uploadFileOperation: UploadFileOperation,
|
||||||
uploadResult: RemoteOperationResult<Any?>
|
uploadResult: RemoteOperationResult<Any?>
|
||||||
|
@ -330,7 +284,6 @@ class FilesUploadWorker(
|
||||||
// check file conflict
|
// check file conflict
|
||||||
tickerId = R.string.uploader_upload_failed_sync_conflict_error
|
tickerId = R.string.uploader_upload_failed_sync_conflict_error
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationBuilder
|
notificationBuilder
|
||||||
.setTicker(context.getString(tickerId))
|
.setTicker(context.getString(tickerId))
|
||||||
.setContentTitle(context.getString(tickerId))
|
.setContentTitle(context.getString(tickerId))
|
||||||
|
@ -341,16 +294,23 @@ class FilesUploadWorker(
|
||||||
|
|
||||||
val content = ErrorMessageAdapter.getErrorCauseMessage(uploadResult, uploadFileOperation, context.resources)
|
val content = ErrorMessageAdapter.getErrorCauseMessage(uploadResult, uploadFileOperation, context.resources)
|
||||||
|
|
||||||
addUploadListContentIntent(uploadFileOperation)
|
|
||||||
|
|
||||||
if (uploadResult.code == ResultCode.SYNC_CONFLICT) {
|
|
||||||
addConflictResolveActionToNotification(uploadFileOperation)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needsToUpdateCredentials) {
|
if (needsToUpdateCredentials) {
|
||||||
createUpdateCredentialsNotification(uploadFileOperation.user.toPlatformAccount())
|
createUpdateCredentialsNotification(uploadFileOperation.user.toPlatformAccount())
|
||||||
|
} else {
|
||||||
|
val intent = if (uploadResult.code == ResultCode.SYNC_CONFLICT) {
|
||||||
|
createResolveConflictIntent(uploadFileOperation)
|
||||||
|
} else {
|
||||||
|
createUploadListIntent(uploadFileOperation)
|
||||||
|
}
|
||||||
|
notificationBuilder.setContentIntent(
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
context,
|
||||||
|
System.currentTimeMillis().toInt(),
|
||||||
|
intent,
|
||||||
|
PendingIntent.FLAG_IMMUTABLE
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationBuilder.setContentText(content)
|
notificationBuilder.setContentText(content)
|
||||||
if (!uploadResult.isSuccess) {
|
if (!uploadResult.isSuccess) {
|
||||||
notificationManager.notify(SecureRandom().nextInt(), notificationBuilder.build())
|
notificationManager.notify(SecureRandom().nextInt(), notificationBuilder.build())
|
||||||
|
@ -367,6 +327,16 @@ class FilesUploadWorker(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createResolveConflictIntent(uploadFileOperation: UploadFileOperation): Intent {
|
||||||
|
return ConflictsResolveActivity.createIntent(
|
||||||
|
uploadFileOperation.file,
|
||||||
|
uploadFileOperation.user,
|
||||||
|
uploadFileOperation.ocUploadId,
|
||||||
|
Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||||
|
context
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun createUpdateCredentialsNotification(account: Account) {
|
private fun createUpdateCredentialsNotification(account: Account) {
|
||||||
// let the user update credentials with one click
|
// let the user update credentials with one click
|
||||||
val updateAccountCredentials = Intent(context, AuthenticatorActivity::class.java)
|
val updateAccountCredentials = Intent(context, AuthenticatorActivity::class.java)
|
||||||
|
|
|
@ -129,6 +129,7 @@ import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFER
|
||||||
* Contains methods to build the "static" strings. These strings were before constants in different classes
|
* Contains methods to build the "static" strings. These strings were before constants in different classes
|
||||||
*/
|
*/
|
||||||
public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||||
|
|
||||||
public static final OwnCloudVersion OUTDATED_SERVER_VERSION = NextcloudVersion.nextcloud_23;
|
public static final OwnCloudVersion OUTDATED_SERVER_VERSION = NextcloudVersion.nextcloud_23;
|
||||||
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_16;
|
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_16;
|
||||||
|
|
||||||
|
|
|
@ -1052,7 +1052,6 @@ public class FileUploader extends Service
|
||||||
i.putExtra(FileUploader.KEY_ACCOUNT, user.toPlatformAccount());
|
i.putExtra(FileUploader.KEY_ACCOUNT, user.toPlatformAccount());
|
||||||
i.putExtra(FileUploader.KEY_RETRY_UPLOAD, upload);
|
i.putExtra(FileUploader.KEY_RETRY_UPLOAD, upload);
|
||||||
|
|
||||||
// FIXME Conflict files not uploading successfully
|
|
||||||
if (useFilesUploadWorker(context)) {
|
if (useFilesUploadWorker(context)) {
|
||||||
new FilesUploadHelper().retryUpload(upload, user);
|
new FilesUploadHelper().retryUpload(upload, user);
|
||||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
private Clock clock;
|
private Clock clock;
|
||||||
private UploadGroup[] uploadGroups;
|
private UploadGroup[] uploadGroups;
|
||||||
private boolean showUser;
|
private boolean showUser;
|
||||||
private final ViewThemeUtils viewThemeUtils;
|
private final ViewThemeUtils viewThemeUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSectionCount() {
|
public int getSectionCount() {
|
||||||
|
@ -235,7 +235,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
// file size
|
// file size
|
||||||
if (item.getFileSize() != 0) {
|
if (item.getFileSize() != 0) {
|
||||||
itemViewHolder.binding.uploadFileSize.setText(String.format("%s, ",
|
itemViewHolder.binding.uploadFileSize.setText(String.format("%s, ",
|
||||||
DisplayUtils.bytesToHumanReadable(item.getFileSize())));
|
DisplayUtils.bytesToHumanReadable(item.getFileSize())));
|
||||||
} else {
|
} else {
|
||||||
itemViewHolder.binding.uploadFileSize.setText("");
|
itemViewHolder.binding.uploadFileSize.setText("");
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
binder.removeDatatransferProgressListener(
|
binder.removeDatatransferProgressListener(
|
||||||
progressListener,
|
progressListener,
|
||||||
progressListener.getUpload() // the one that was added
|
progressListener.getUpload() // the one that was added
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// ... then, bind the current progress bar to listen for updates
|
// ... then, bind the current progress bar to listen for updates
|
||||||
progressListener = new ProgressListener(item, itemViewHolder.binding.uploadProgressBar);
|
progressListener = new ProgressListener(item, itemViewHolder.binding.uploadProgressBar);
|
||||||
|
@ -383,16 +383,16 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
DisplayUtils.showSnackMessage(
|
DisplayUtils.showSnackMessage(
|
||||||
v.getRootView().findViewById(android.R.id.content),
|
v.getRootView().findViewById(android.R.id.content),
|
||||||
R.string.local_file_not_found_message
|
R.string.local_file_not_found_message
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) {
|
} else if (item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED){
|
||||||
itemViewHolder.binding.uploadListItemLayout.setOnClickListener(v -> onUploadedItemClick(item));
|
itemViewHolder.binding.uploadListItemLayout.setOnClickListener(v -> onUploadedItemClick(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// click on thumbnail to open locally
|
// click on thumbnail to open locally
|
||||||
if (item.getUploadStatus() != UploadStatus.UPLOAD_SUCCEEDED) {
|
if (item.getUploadStatus() != UploadStatus.UPLOAD_SUCCEEDED){
|
||||||
itemViewHolder.binding.thumbnail.setOnClickListener(v -> onUploadingItemClick(item));
|
itemViewHolder.binding.thumbnail.setOnClickListener(v -> onUploadingItemClick(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,17 +405,17 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
fakeFileToCheatThumbnailsCacheManagerInterface.setMimeType(item.getMimeType());
|
fakeFileToCheatThumbnailsCacheManagerInterface.setMimeType(item.getMimeType());
|
||||||
|
|
||||||
boolean allowedToCreateNewThumbnail = ThumbnailsCacheManager.cancelPotentialThumbnailWork(
|
boolean allowedToCreateNewThumbnail = ThumbnailsCacheManager.cancelPotentialThumbnailWork(
|
||||||
fakeFileToCheatThumbnailsCacheManagerInterface, itemViewHolder.binding.thumbnail
|
fakeFileToCheatThumbnailsCacheManagerInterface, itemViewHolder.binding.thumbnail
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO this code is duplicated; refactor to a common place
|
// TODO this code is duplicated; refactor to a common place
|
||||||
if (MimeTypeUtil.isImage(fakeFileToCheatThumbnailsCacheManagerInterface)
|
if (MimeTypeUtil.isImage(fakeFileToCheatThumbnailsCacheManagerInterface)
|
||||||
&& fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId() != null &&
|
&& fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId() != null &&
|
||||||
item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) {
|
item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) {
|
||||||
// Thumbnail in Cache?
|
// Thumbnail in Cache?
|
||||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||||
String.valueOf(fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId())
|
String.valueOf(fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId())
|
||||||
);
|
);
|
||||||
if (thumbnail != null && !fakeFileToCheatThumbnailsCacheManagerInterface.isUpdateThumbnailNeeded()) {
|
if (thumbnail != null && !fakeFileToCheatThumbnailsCacheManagerInterface.isUpdateThumbnailNeeded()) {
|
||||||
itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail);
|
itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail);
|
||||||
} else {
|
} else {
|
||||||
|
@ -423,11 +423,11 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
Optional<User> user = parentActivity.getUser();
|
Optional<User> user = parentActivity.getUser();
|
||||||
if (allowedToCreateNewThumbnail && user.isPresent()) {
|
if (allowedToCreateNewThumbnail && user.isPresent()) {
|
||||||
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
||||||
new ThumbnailsCacheManager.ThumbnailGenerationTask(
|
new ThumbnailsCacheManager.ThumbnailGenerationTask(
|
||||||
itemViewHolder.binding.thumbnail,
|
itemViewHolder.binding.thumbnail,
|
||||||
parentActivity.getStorageManager(),
|
parentActivity.getStorageManager(),
|
||||||
user.get()
|
user.get()
|
||||||
);
|
);
|
||||||
if (thumbnail == null) {
|
if (thumbnail == null) {
|
||||||
if (MimeTypeUtil.isVideo(fakeFileToCheatThumbnailsCacheManagerInterface)) {
|
if (MimeTypeUtil.isVideo(fakeFileToCheatThumbnailsCacheManagerInterface)) {
|
||||||
thumbnail = ThumbnailsCacheManager.mDefaultVideo;
|
thumbnail = ThumbnailsCacheManager.mDefaultVideo;
|
||||||
|
@ -436,20 +436,20 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
||||||
new ThumbnailsCacheManager.AsyncThumbnailDrawable(
|
new ThumbnailsCacheManager.AsyncThumbnailDrawable(
|
||||||
parentActivity.getResources(),
|
parentActivity.getResources(),
|
||||||
thumbnail,
|
thumbnail,
|
||||||
task
|
task
|
||||||
);
|
);
|
||||||
itemViewHolder.binding.thumbnail.setImageDrawable(asyncDrawable);
|
itemViewHolder.binding.thumbnail.setImageDrawable(asyncDrawable);
|
||||||
task.execute(new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(
|
task.execute(new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(
|
||||||
fakeFileToCheatThumbnailsCacheManagerInterface, null));
|
fakeFileToCheatThumbnailsCacheManagerInterface, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("image/png".equals(item.getMimeType())) {
|
if ("image/png".equals(item.getMimeType())) {
|
||||||
itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources()
|
itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources()
|
||||||
.getColor(R.color.bg_default));
|
.getColor(R.color.bg_default));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -457,14 +457,14 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
File file = new File(item.getLocalPath());
|
File file = new File(item.getLocalPath());
|
||||||
// Thumbnail in Cache?
|
// Thumbnail in Cache?
|
||||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||||
String.valueOf(file.hashCode()));
|
String.valueOf(file.hashCode()));
|
||||||
if (thumbnail != null) {
|
if (thumbnail != null) {
|
||||||
itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail);
|
itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail);
|
||||||
} else {
|
} else {
|
||||||
// generate new Thumbnail
|
// generate new Thumbnail
|
||||||
if (allowedToCreateNewThumbnail) {
|
if (allowedToCreateNewThumbnail) {
|
||||||
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
||||||
new ThumbnailsCacheManager.ThumbnailGenerationTask(itemViewHolder.binding.thumbnail);
|
new ThumbnailsCacheManager.ThumbnailGenerationTask(itemViewHolder.binding.thumbnail);
|
||||||
|
|
||||||
if (MimeTypeUtil.isVideo(file)) {
|
if (MimeTypeUtil.isVideo(file)) {
|
||||||
thumbnail = ThumbnailsCacheManager.mDefaultVideo;
|
thumbnail = ThumbnailsCacheManager.mDefaultVideo;
|
||||||
|
@ -484,7 +484,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
|
|
||||||
if ("image/png".equalsIgnoreCase(item.getMimeType())) {
|
if ("image/png".equalsIgnoreCase(item.getMimeType())) {
|
||||||
itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources()
|
itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources()
|
||||||
.getColor(R.color.bg_default));
|
.getColor(R.color.bg_default));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (optionalUser.isPresent()) {
|
if (optionalUser.isPresent()) {
|
||||||
|
@ -503,14 +503,21 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
OCUpload item,
|
OCUpload item,
|
||||||
String status) {
|
String status) {
|
||||||
String remotePath = item.getRemotePath();
|
String remotePath = item.getRemotePath();
|
||||||
OCFile ocFile = storageManager.getFileByEncryptedRemotePath(remotePath);
|
OCFile ocFile = storageManager.getFileByPath(remotePath);
|
||||||
|
|
||||||
if (ocFile == null) {
|
if (ocFile == null) {
|
||||||
// Remote file doesn't exist, try to refresh folder
|
// Remote file doesn't exist, try to refresh folder
|
||||||
OCFile folder = storageManager.getFileByEncryptedRemotePath(new File(remotePath).getParent() + "/");
|
OCFile folder = storageManager.getFileByPath(new File(remotePath).getParent() + "/");
|
||||||
|
|
||||||
if (folder != null && folder.isFolder()) {
|
if (folder != null && folder.isFolder()) {
|
||||||
refreshFolderAndUpdateUI(itemViewHolder, user, folder, remotePath, item, status);
|
this.refreshFolder(itemViewHolder, user, folder, (caller, result) -> {
|
||||||
|
itemViewHolder.binding.uploadStatus.setText(status);
|
||||||
|
if (result.isSuccess()) {
|
||||||
|
OCFile file = storageManager.getFileByPath(remotePath);
|
||||||
|
if (file != null) {
|
||||||
|
this.openConflictActivity(file, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,29 +533,6 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshFolderAndUpdateUI(ItemViewHolder holder, User user, OCFile folder, String remotePath, OCUpload item, String status) {
|
|
||||||
Context context = MainApp.getAppContext();
|
|
||||||
|
|
||||||
this.refreshFolder(context, holder, user, folder, (caller, result) -> {
|
|
||||||
holder.binding.uploadStatus.setText(status);
|
|
||||||
|
|
||||||
if (result.isSuccess()) {
|
|
||||||
OCFile file = storageManager.getFileByEncryptedRemotePath(remotePath);
|
|
||||||
|
|
||||||
if (file != null) {
|
|
||||||
openConflictActivity(file, item);
|
|
||||||
} else {
|
|
||||||
displayFileNotFoundError(holder.itemView, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayFileNotFoundError(View itemView, Context context) {
|
|
||||||
String message = context.getString(R.string.uploader_file_not_found_message);
|
|
||||||
DisplayUtils.showSnackMessage(itemView, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showItemConflictPopup(User user,
|
private void showItemConflictPopup(User user,
|
||||||
ItemViewHolder itemViewHolder,
|
ItemViewHolder itemViewHolder,
|
||||||
OCUpload item,
|
OCUpload item,
|
||||||
|
@ -576,13 +560,13 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshFolder(
|
private void refreshFolder(
|
||||||
Context context,
|
|
||||||
ItemViewHolder view,
|
ItemViewHolder view,
|
||||||
User user,
|
User user,
|
||||||
OCFile folder,
|
OCFile folder,
|
||||||
OnRemoteOperationListener listener) {
|
OnRemoteOperationListener listener) {
|
||||||
view.binding.uploadListItemLayout.setClickable(false);
|
view.binding.uploadListItemLayout.setClickable(false);
|
||||||
view.binding.uploadStatus.setText(R.string.uploads_view_upload_status_fetching_server_version);
|
view.binding.uploadStatus.setText(R.string.uploads_view_upload_status_fetching_server_version);
|
||||||
|
Context context = MainApp.getAppContext();
|
||||||
new RefreshFolderOperation(folder,
|
new RefreshFolderOperation(folder,
|
||||||
clock.getCurrentTime(),
|
clock.getCurrentTime(),
|
||||||
false,
|
false,
|
||||||
|
@ -614,7 +598,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the status text to show to the user according to the status and last result of the the given upload.
|
* Gets the status text to show to the user according to the status and last result of the
|
||||||
|
* the given upload.
|
||||||
*
|
*
|
||||||
* @param upload Upload to describe.
|
* @param upload Upload to describe.
|
||||||
* @return Text describing the status of the given upload.
|
* @return Text describing the status of the given upload.
|
||||||
|
@ -695,8 +680,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
case SSL_RECOVERABLE_PEER_UNVERIFIED:
|
case SSL_RECOVERABLE_PEER_UNVERIFIED:
|
||||||
status =
|
status =
|
||||||
parentActivity.getString(
|
parentActivity.getString(
|
||||||
R.string.uploads_view_upload_status_failed_ssl_certificate_not_trusted
|
R.string.uploads_view_upload_status_failed_ssl_certificate_not_trusted
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
status = parentActivity.getString(R.string.uploads_view_upload_status_unknown_fail);
|
status = parentActivity.getString(R.string.uploads_view_upload_status_unknown_fail);
|
||||||
|
@ -706,7 +691,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
break;
|
break;
|
||||||
case DELAYED_IN_POWER_SAVE_MODE:
|
case DELAYED_IN_POWER_SAVE_MODE:
|
||||||
status = parentActivity.getString(
|
status = parentActivity.getString(
|
||||||
R.string.uploads_view_upload_status_waiting_exit_power_save_mode);
|
R.string.uploads_view_upload_status_waiting_exit_power_save_mode);
|
||||||
break;
|
break;
|
||||||
case VIRUS_DETECTED:
|
case VIRUS_DETECTED:
|
||||||
status = parentActivity.getString(R.string.uploads_view_upload_status_virus_detected);
|
status = parentActivity.getString(R.string.uploads_view_upload_status_virus_detected);
|
||||||
|
@ -778,17 +763,17 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
*/
|
*/
|
||||||
private void onUploadedItemClick(OCUpload upload) {
|
private void onUploadedItemClick(OCUpload upload) {
|
||||||
final OCFile file = parentActivity.getStorageManager().getFileByEncryptedRemotePath(upload.getRemotePath());
|
final OCFile file = parentActivity.getStorageManager().getFileByEncryptedRemotePath(upload.getRemotePath());
|
||||||
if (file == null) {
|
if (file == null){
|
||||||
DisplayUtils.showSnackMessage(parentActivity, R.string.error_retrieving_file);
|
DisplayUtils.showSnackMessage(parentActivity, R.string.error_retrieving_file);
|
||||||
Log_OC.i(TAG, "Could not find uploaded file on remote.");
|
Log_OC.i(TAG, "Could not find uploaded file on remote.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PreviewImageFragment.canBePreviewed(file)) {
|
if (PreviewImageFragment.canBePreviewed(file)){
|
||||||
//show image preview and stay in uploads tab
|
//show image preview and stay in uploads tab
|
||||||
Intent intent = FileDisplayActivity.openFileIntent(parentActivity, parentActivity.getUser().get(), file);
|
Intent intent = FileDisplayActivity.openFileIntent(parentActivity, parentActivity.getUser().get(), file);
|
||||||
parentActivity.startActivity(intent);
|
parentActivity.startActivity(intent);
|
||||||
} else {
|
}else{
|
||||||
Intent intent = new Intent(parentActivity, FileDisplayActivity.class);
|
Intent intent = new Intent(parentActivity, FileDisplayActivity.class);
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.putExtra(FileDisplayActivity.KEY_FILE_PATH, upload.getRemotePath());
|
intent.putExtra(FileDisplayActivity.KEY_FILE_PATH, upload.getRemotePath());
|
||||||
|
|
|
@ -912,7 +912,6 @@
|
||||||
<string name="failed_to_start_editor">Failed to start editor</string>
|
<string name="failed_to_start_editor">Failed to start editor</string>
|
||||||
<string name="create_rich_workspace">Add folder info</string>
|
<string name="create_rich_workspace">Add folder info</string>
|
||||||
<string name="creates_rich_workspace">creates folder info</string>
|
<string name="creates_rich_workspace">creates folder info</string>
|
||||||
<string name="uploader_file_not_found_message">File not found. Are you sure this file exist or conflict not solved before?</string>
|
|
||||||
<string name="uploader_upload_failed_sync_conflict_error">File upload conflict</string>
|
<string name="uploader_upload_failed_sync_conflict_error">File upload conflict</string>
|
||||||
<string name="uploader_upload_failed_sync_conflict_error_content">Pick which version to keep of %1$s</string>
|
<string name="uploader_upload_failed_sync_conflict_error_content">Pick which version to keep of %1$s</string>
|
||||||
<string name="upload_list_resolve_conflict">Resolve conflict</string>
|
<string name="upload_list_resolve_conflict">Resolve conflict</string>
|
||||||
|
|
Loading…
Reference in a new issue