Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inform user for uploading same file again #12941

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.nextcloud.client.network.ConnectivityService
import com.nextcloud.client.preferences.AppPreferences
import com.nextcloud.model.WorkerState
import com.nextcloud.model.WorkerStateLiveData
import com.nextcloud.utils.extensions.showToast
import com.owncloud.android.R
import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.datamodel.ThumbnailsCacheManager
import com.owncloud.android.datamodel.UploadsStorageManager
Expand Down Expand Up @@ -263,6 +265,7 @@ class FileUploadWorker(
uploadFileOperation.user, File(uploadFileOperation.storagePath), uploadFileOperation.remotePath, context
)
) {
context.showToast(R.string.file_upload_worker_same_file_already_exists)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.widget.Toast
import com.owncloud.android.datamodel.ReceiverFlag

@SuppressLint("UnspecifiedRegisterReceiverFlag")
Expand All @@ -23,3 +26,11 @@ fun Context.registerBroadcastReceiver(receiver: BroadcastReceiver?, filter: Inte
registerReceiver(receiver, filter)
}
}

fun Context.showToast(message: String) {
Handler(Looper.getMainLooper()).post {
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
}
}

fun Context.showToast(messageId: Int) = showToast(getString(messageId))
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
<string name="uploader_upload_files_behaviour_only_upload">Keep file in source folder</string>
<string name="uploader_upload_files_behaviour_upload_and_delete_from_source">Delete file from source folder</string>
<string name="file_list_seconds_ago">seconds ago</string>
<string name="file_upload_worker_same_file_already_exists">Same file already exists, no conflict detected</string>
<string name="file_list_live">LIVE</string>
<string name="file_list_empty_headline">No files here</string>
<string name="folder_list_empty_headline">No folders here</string>
Expand Down