mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-30 22:34:02 +01:00
Convert upload client to kotlin (#5568)
* Write unit tests for the UploadClient (with gentle refactoring to make it testable) * Convert Upload client to kotlin
This commit is contained in:
parent
728712c4e1
commit
f0a1d036a5
10 changed files with 552 additions and 247 deletions
|
|
@ -5,6 +5,7 @@ import android.os.Parcelable
|
|||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import fr.free.nrw.commons.CommonsApplication
|
||||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.upload.UploadItem
|
||||
|
|
@ -13,7 +14,8 @@ import fr.free.nrw.commons.upload.WikidataPlace
|
|||
import fr.free.nrw.commons.upload.WikidataPlace.Companion.from
|
||||
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import java.util.*
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
@Entity(tableName = "contribution")
|
||||
@Parcelize
|
||||
|
|
@ -117,4 +119,19 @@ data class Contribution constructor(
|
|||
descriptions.filter { it.descriptionText.isNotEmpty() }
|
||||
.joinToString(separator = "") { "{{${it.languageCode}|1=${it.descriptionText}}}" }
|
||||
}
|
||||
|
||||
val fileKey : String? get() = chunkInfo?.uploadResult?.filekey
|
||||
val localUriPath: File? get() = localUri?.path?.let { File(it) }
|
||||
|
||||
fun isCompleted(): Boolean {
|
||||
return chunkInfo != null && chunkInfo!!.totalChunks == chunkInfo!!.indexOfNextChunkToUpload
|
||||
}
|
||||
|
||||
fun isPaused(): Boolean {
|
||||
return CommonsApplication.pauseUploads[pageId] ?: false
|
||||
}
|
||||
|
||||
fun unpause() {
|
||||
CommonsApplication.pauseUploads[pageId] = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue