Merge pull request #12941 from nextcloud/feature/inform-user-for-uploading-same-file-again

Inform user for uploading same file again
This commit is contained in:
Tobias Kaminsky 2024-05-02 16:08:03 +02:00 committed by GitHub
commit e21a023fca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View file

@ -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
@ -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
}

View file

@ -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")
@ -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))

View file

@ -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>