Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Added workaround for donation for when user has no card added. Updated version.
  Deep link to public archive items, after the user logged in mechanism.
  Deep linking to archives.
  Deep link to public archive items.
  • Loading branch information
flaviahandrea-vsp committed Feb 6, 2023
2 parents afdd3a4 + 3cf91c6 commit 5444452
Show file tree
Hide file tree
Showing 26 changed files with 373 additions and 107 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "org.permanent.PermanentArchive"
minSdkVersion 26
targetSdkVersion 32
versionCode 42
versionName "1.6.1"
versionCode 43
versionName "1.6.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/permanent/permanent/models/Record.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ open class Record : Parcelable {
displayInShares = false
}

constructor(archiveNr: String, folderLinkId: Int) {
this.archiveNr = archiveNr
this.folderLinkId = folderLinkId
isThumbBlurred = false
type = RecordType.FOLDER
displayFirstInCarousel = false
isProcessing = false
displayInShares = false
}

constructor(shareByUrlVO: Shareby_urlVO) {
val recordInfo = shareByUrlVO.RecordVO
id = if (recordInfo?.folderId != null) recordInfo.folderId else recordInfo?.recordId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,15 @@ class NetworkClient(private var okHttpClient: OkHttpClient?, context: Context) {
return fileService.getRecord(requestBody)
}

fun getRecord(
fileArchiveNr: String
): Call<ResponseVO> {
val request = toJson(RequestContainer().addRecord(fileArchiveNr))
val requestBody: RequestBody = request.toRequestBody(jsonMediaType)

return fileService.getRecord(requestBody)
}

fun downloadFile(url: String): Call<ResponseBody> {
return fileService.download(url)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ class RequestContainer {
return this
}

fun addRecord(
fileArchiveNr: String,
): RequestContainer {
val recordVO = RecordVO()
recordVO.archiveNbr = fileArchiveNr
RequestVO.data?.get(0)?.RecordVO = recordVO
return this
}

fun addRecord(fileData: FileData): RequestContainer {
val recordVO = RecordVO()
recordVO.folder_linkId = fileData.folderLinkId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
private val prefsHelper = PreferencesHelper(sharedPreferences)

override fun getMyFilesRecord(listener: IRecordListener) {
NetworkClient.instance().getRoot()
.enqueue(object : Callback<ResponseVO> {
NetworkClient.instance().getRoot().enqueue(object : Callback<ResponseVO> {
override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) {
val responseVO = response.body()
val publicRecord = responseVO?.getPublicRecord()
Expand All @@ -47,8 +46,8 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
listener.onSuccess(myFilesRecord)
} else {
listener.onFailed(
responseVO?.Results?.get(0)?.message?.get(0)
?: response.errorBody()?.toString()
responseVO?.Results?.get(0)?.message?.get(0) ?: response.errorBody()
?.toString()
)
}
}
Expand All @@ -60,8 +59,7 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
}

override fun getPublicRoot(archiveNr: String?, listener: IRecordListener) {
NetworkClient.instance()
.getPublicRootForArchive(archiveNr)
NetworkClient.instance().getPublicRootForArchive(archiveNr)
.enqueue(object : Callback<ResponseVO> {
override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) {
val responseVO = response.body()
Expand All @@ -71,8 +69,8 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
listener.onSuccess(publicRecord)
} else {
listener.onFailed(
responseVO?.Results?.get(0)?.message?.get(0)
?: response.errorBody()?.toString()
responseVO?.Results?.get(0)?.message?.get(0) ?: response.errorBody()
?.toString()
)
}
}
Expand Down Expand Up @@ -101,8 +99,7 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
NetworkClient.instance().navigateMin(archiveNr, folderLinkId)
.enqueue(object : Callback<ResponseVO> {
override fun onResponse(
call: Call<ResponseVO>,
response: Response<ResponseVO>
call: Call<ResponseVO>, response: Response<ResponseVO>
) {
val folderLinkIds: MutableList<Int> = ArrayList()
val recordVOs: List<RecordVO?>? = response.body()?.getRecordVOs()
Expand All @@ -122,16 +119,20 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
}

override fun getLeanItems(
archiveNr: String, folderLinkId: Int, sort: String?, childLinkIds: List<Int>,
archiveNr: String,
folderLinkId: Int,
sort: String?,
childLinkIds: List<Int>,
listener: IFileRepository.IOnRecordsRetrievedListener
) {
NetworkClient.instance()
.getLeanItems(archiveNr, folderLinkId, sort, childLinkIds)
NetworkClient.instance().getLeanItems(archiveNr, folderLinkId, sort, childLinkIds)
.enqueue(object : Callback<ResponseVO> {

override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) {
val responseVO = response.body()
listener.onSuccess(responseVO?.getRecordVOs())
listener.onSuccess(
responseVO?.getFolderRecord()?.displayName, responseVO?.getRecordVOs()
)
}

override fun onFailure(call: Call<ResponseVO>, t: Throwable) {
Expand Down Expand Up @@ -162,13 +163,10 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
}

override fun createFolder(
parentFolderIdentifier: NavigationFolderIdentifier,
name: String,
listener: IRecordListener
parentFolderIdentifier: NavigationFolderIdentifier, name: String, listener: IRecordListener
) {
NetworkClient.instance().createFolder(
name, parentFolderIdentifier.folderId,
parentFolderIdentifier.folderLinkId
name, parentFolderIdentifier.folderId, parentFolderIdentifier.folderLinkId
).enqueue(object : Callback<ResponseVO> {

override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) {
Expand Down Expand Up @@ -209,8 +207,7 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
folderId: Int, folderLinkId: Int, file: File, displayName: String, mediaType: MediaType
): Call<GetPresignedUrlResponse> {
return NetworkClient.instance().getPresignedUrlForUpload(
file, displayName,
folderId, folderLinkId, mediaType
file, displayName, folderId, folderLinkId, mediaType
)
}

Expand All @@ -232,32 +229,31 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
s3Url: String
): Call<ResponseVO> {
return NetworkClient.instance().registerRecord(
file, displayName,
folderId, folderLinkId, createdDT, s3Url
file, displayName, folderId, folderLinkId, createdDT, s3Url
)
}

override fun getRecord(folderLinkId: Int, recordId: Int?): Call<ResponseVO> {
return NetworkClient.instance().getRecord(folderLinkId, recordId)
}

override fun getRecord(fileArchiveNr: String): Call<ResponseVO> {
return NetworkClient.instance().getRecord(fileArchiveNr)
}

override fun downloadFile(downloadUrl: String): Call<ResponseBody> {
return NetworkClient.instance().downloadFile(downloadUrl)
}

override fun deleteRecord(
record: Record,
listener: IResponseListener
record: Record, listener: IResponseListener
) {
NetworkClient.instance().deleteRecord(record)
.enqueue(object : Callback<ResponseVO> {
NetworkClient.instance().deleteRecord(record).enqueue(object : Callback<ResponseVO> {
override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) {
val responseVO = response.body()
val firstMessage = responseVO?.getMessages()?.get(0)

if (firstMessage != null && (firstMessage == Constants.FILE_DELETED_SUCCESSFULLY
|| firstMessage == Constants.FOLDER_DELETED_SUCCESSFULLY)
) {
if (firstMessage != null && (firstMessage == Constants.FILE_DELETED_SUCCESSFULLY || firstMessage == Constants.FOLDER_DELETED_SUCCESSFULLY)) {
listener.onSuccess(null)
} else {
listener.onFailed(context.getString(R.string.generic_error))
Expand All @@ -271,9 +267,7 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
}

override fun unshareRecord(
record: Record,
archiveId: Int,
listener: IResponseListener
record: Record, archiveId: Int, listener: IResponseListener
) {
NetworkClient.instance().unshareRecord(record, archiveId)
.enqueue(object : Callback<ResponseVO> {
Expand All @@ -295,13 +289,14 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
}

override fun relocateRecord(
recordToRelocate: Record, destFolderLinkId: Int, relocationType: RelocationType,
recordToRelocate: Record,
destFolderLinkId: Int,
relocationType: RelocationType,
listener: IResponseListener
) {
NetworkClient.instance().relocateRecord(
recordToRelocate, destFolderLinkId, relocationType
)
.enqueue(object : Callback<ResponseVO> {
).enqueue(object : Callback<ResponseVO> {
override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) {
val responseVO = response.body()
if (responseVO?.isSuccessful != null && responseVO.isSuccessful!!) {
Expand All @@ -313,7 +308,8 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
listener.onSuccess(
context.getString(
R.string.relocation_success,
recordToRelocate.type?.name?.lowercase(Locale.getDefault())?.capitalize(),
recordToRelocate.type?.name?.lowercase(Locale.getDefault())
?.capitalize(),
relocationVerb
)
)
Expand All @@ -329,8 +325,7 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
}

override fun updateRecord(fileData: FileData, listener: IResponseListener) {
NetworkClient.instance().updateRecord(fileData)
.enqueue(object : Callback<ResponseVO> {
NetworkClient.instance().updateRecord(fileData).enqueue(object : Callback<ResponseVO> {
override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) {
val responseVO = response.body()

Expand Down Expand Up @@ -386,17 +381,16 @@ class FileRepositoryImpl(val context: Context) : IFileRepository {
}

override fun searchRecords(
query: String?,
tags: List<Tag>,
listener: IFileRepository.IOnRecordsRetrievedListener
query: String?, tags: List<Tag>, listener: IFileRepository.IOnRecordsRetrievedListener
) {
NetworkClient.instance().searchRecords(query, tags)
.enqueue(object : Callback<ResponseVO> {
NetworkClient.instance().searchRecords(query, tags).enqueue(object : Callback<ResponseVO> {
override fun onResponse(call: Call<ResponseVO>, response: Response<ResponseVO>) {
val responseVO = response.body()

if (responseVO?.isSuccessful != null && responseVO.isSuccessful!!) {
listener.onSuccess(responseVO.getData()?.get(0)?.SearchVO?.ChildItemVOs)
listener.onSuccess(
null, responseVO.getData()?.get(0)?.SearchVO?.ChildItemVOs
)
} else {
listener.onFailed(context.getString(R.string.generic_error))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,62 +20,74 @@ interface IFileRepository {
fun getPublicRoot(archiveNr: String?, listener: IRecordListener)

fun getChildRecordsOf(
folderArchiveNr: String, folderLinkId: Int, sort: String?,
folderArchiveNr: String,
folderLinkId: Int,
sort: String?,
listener: IOnRecordsRetrievedListener
)

fun navigateMin(
archiveNr: String,
folderLinkId: Int,
sort: String?,
listener: IOnRecordsRetrievedListener
archiveNr: String, folderLinkId: Int, sort: String?, listener: IOnRecordsRetrievedListener
)

fun getLeanItems(
archiveNr: String, folderLinkId: Int, sort: String?, childLinkIds: List<Int>,
archiveNr: String,
folderLinkId: Int,
sort: String?,
childLinkIds: List<Int>,
listener: IOnRecordsRetrievedListener
)

fun updateProfileBanner(thumbRecord: Record, listener: IResponseListener)

fun createFolder(
parentFolderIdentifier: NavigationFolderIdentifier,
name: String,
listener: IRecordListener
parentFolderIdentifier: NavigationFolderIdentifier, name: String, listener: IRecordListener
)

fun getFolder(
folderLinkId: Int,
listener: IRecordListener
folderLinkId: Int, listener: IRecordListener
)

fun getPresignedUrlForUpload(
folderId: Int, folderLinkId: Int, file: File, displayName: String, mediaType: MediaType
): Call<GetPresignedUrlResponse>

fun uploadFile(
file: File, mediaType: MediaType, uploadDestination: UploadDestination,
file: File,
mediaType: MediaType,
uploadDestination: UploadDestination,
listener: CountingRequestListener
): Call<ResponseBody>?

fun registerRecord(
folderId: Int, folderLinkId: Int, file: File, displayName: String, createdDT: Date, s3Url: String
folderId: Int,
folderLinkId: Int,
file: File,
displayName: String,
createdDT: Date,
s3Url: String
): Call<ResponseVO>

fun getRecord(
folderLinkId: Int,
recordId: Int?,
): Call<ResponseVO>

fun getRecord(
fileArchiveNr: String,
): Call<ResponseVO>

fun downloadFile(downloadUrl: String): Call<ResponseBody>

fun deleteRecord(record: Record, listener: IResponseListener)

fun unshareRecord(record: Record, archiveId: Int, listener: IResponseListener)

fun relocateRecord(
recordToRelocate: Record, destFolderLinkId: Int,
relocationType: RelocationType, listener: IResponseListener
recordToRelocate: Record,
destFolderLinkId: Int,
relocationType: RelocationType,
listener: IResponseListener
)

fun updateRecord(fileData: FileData, listener: IResponseListener)
Expand All @@ -87,7 +99,7 @@ interface IFileRepository {
fun searchRecords(query: String?, tags: List<Tag>, listener: IOnRecordsRetrievedListener)

interface IOnRecordsRetrievedListener {
fun onSuccess(recordVOs: List<RecordVO>?)
fun onSuccess(parentFolderName: String?, recordVOs: List<RecordVO>?)
fun onFailed(error: String?)
}
}
Loading

0 comments on commit 5444452

Please sign in to comment.