Fix nested directories navigation and decode file contents
This commit is contained in:
@@ -14,6 +14,7 @@ import fr.uca.iut.clfreville2.teaiswarm.model.FileType
|
|||||||
import fr.uca.iut.clfreville2.teaiswarm.model.RepositoryIdentifier
|
import fr.uca.iut.clfreville2.teaiswarm.model.RepositoryIdentifier
|
||||||
import fr.uca.iut.clfreville2.teaiswarm.model.VersionedFile
|
import fr.uca.iut.clfreville2.teaiswarm.model.VersionedFile
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.io.path.Path
|
||||||
|
|
||||||
const val FILE_PATH = "file_path"
|
const val FILE_PATH = "file_path"
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ class RepositoryDetailsFragment : Fragment(R.layout.repository_details) {
|
|||||||
val bundle = bundleOf(
|
val bundle = bundleOf(
|
||||||
REPOSITORY_OWNER to currentRepositoryOwner,
|
REPOSITORY_OWNER to currentRepositoryOwner,
|
||||||
REPOSITORY_NAME to currentRepositoryName,
|
REPOSITORY_NAME to currentRepositoryName,
|
||||||
FILE_PATH to (currentFilePath ?: "") + file.name
|
FILE_PATH to Path(currentFilePath ?: "", file.name).toString()
|
||||||
)
|
)
|
||||||
when (file.type) {
|
when (file.type) {
|
||||||
FileType.FILE -> {
|
FileType.FILE -> {
|
||||||
|
@@ -1,3 +1,14 @@
|
|||||||
package fr.uca.iut.clfreville2.teaiswarm.model
|
package fr.uca.iut.clfreville2.teaiswarm.model
|
||||||
|
|
||||||
data class FileContent(val type: FileType, val size: Int, val content: String, val last_commit_sha: String)
|
import android.util.Base64
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
|
||||||
|
data class FileContent(
|
||||||
|
val type: FileType,
|
||||||
|
val size: Int,
|
||||||
|
@Json(name = "content") val contentBase64: String,
|
||||||
|
val last_commit_sha: String
|
||||||
|
) {
|
||||||
|
val content: String
|
||||||
|
get() = String(Base64.decode(contentBase64, Base64.DEFAULT))
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user