Inform user for uploading same file again

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-04-26 13:07:54 +02:00 committed by Alper Öztürk
parent 6c8c58f220
commit a53d661d73
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>