Skip to content

Commit

Permalink
Merge pull request #163 from PermanentOrg/bug/VSP-845
Browse files Browse the repository at this point in the history
Bug/vsp 845
  • Loading branch information
flaviahandrea-vsp authored Aug 5, 2022
2 parents dae4579 + 5e872ab commit 0d39c8b
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 266 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 31
versionCode 31
versionName "1.1.0"
versionCode 34
versionName "1.2.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/org/permanent/permanent/models/AccessRole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ enum class AccessRole(val backendString: String) : Parcelable {
return values()[parcel.readInt()]
}

fun createFromBackendString(accessRoleString: String?): AccessRole {
return when (accessRoleString) {
OWNER.backendString -> OWNER
MANAGER.backendString -> MANAGER
CURATOR.backendString -> CURATOR
EDITOR.backendString -> EDITOR
CONTRIBUTOR.backendString -> CONTRIBUTOR
else -> VIEWER
}
}

override fun newArray(size: Int): Array<AccessRole?> {
return arrayOfNulls(size)
}
Expand Down
6 changes: 6 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 @@ -21,6 +21,7 @@ open class Record : Parcelable {
var thumbURL2000: String? = null
var isThumbBlurred: Boolean? = null
var type: RecordType? = null
var accessRole: AccessRole? = null
var isRelocateMode: MutableLiveData<Boolean>? = null
var shares: MutableList<Share>? = null
var displayFirstInCarousel = false
Expand All @@ -42,6 +43,7 @@ open class Record : Parcelable {
thumbURL2000 = parcel.readString()
isThumbBlurred = parcel.readValue(Boolean::class.java.classLoader) as? Boolean
type = parcel.readParcelable(RecordType::class.java.classLoader)
accessRole = parcel.readParcelable(AccessRole::class.java.classLoader)
shares = parcel.createTypedArrayList(Share)
displayFirstInCarousel = parcel.readValue(Boolean::class.java.classLoader) as Boolean
isProcessing = parcel.readValue(Boolean::class.java.classLoader) as Boolean
Expand All @@ -61,6 +63,7 @@ open class Record : Parcelable {
thumbURL2000 = recordInfo.thumbURL2000
isThumbBlurred = false
type = if (recordInfo.folderId != null) RecordType.FOLDER else RecordType.FILE
accessRole = AccessRole.createFromBackendString(recordInfo.accessRole)
initShares(recordInfo.ShareVOs)
displayFirstInCarousel = false
isProcessing = recordInfo.thumbURL200.isNullOrEmpty()
Expand All @@ -79,6 +82,7 @@ open class Record : Parcelable {
thumbURL2000 = recordInfo.thumbURL2000
isThumbBlurred = false
type = RecordType.FOLDER
accessRole = AccessRole.createFromBackendString(recordInfo.accessRole)
initShares(recordInfo.ShareVOs)
displayFirstInCarousel = false
isProcessing = recordInfo.thumbURL200.isNullOrEmpty()
Expand All @@ -99,6 +103,7 @@ open class Record : Parcelable {
thumbURL2000 = item.thumbURL2000
isThumbBlurred = false
type = if (item.folderId != null) RecordType.FOLDER else RecordType.FILE
accessRole = AccessRole.createFromBackendString(item.accessRole)
displayFirstInCarousel = false
isProcessing = item.thumbURL200.isNullOrEmpty()
}
Expand Down Expand Up @@ -163,6 +168,7 @@ open class Record : Parcelable {
parcel.writeString(thumbURL2000)
parcel.writeValue(isThumbBlurred)
parcel.writeParcelable(type, flags)
parcel.writeParcelable(accessRole, flags)
parcel.writeTypedList(shares)
parcel.writeValue(displayFirstInCarousel)
parcel.writeValue(isProcessing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ class FileData private constructor() : Parcelable {
folderLinkId = recordVO.folder_linkId ?: -1
archiveId = recordVO.archiveId ?: -1
archiveNr = recordVO.archiveNbr
accessRole = getAccessRole(recordVO.accessRole)
accessRole = AccessRole.createFromBackendString(recordVO.accessRole)
// First we check for the converted video to mp4
val fileVO: FileVO? = if (recordVO.type?.contains(FileType.VIDEO.toString()) == true
&& recordVO.FileVOs?.size!! > 1) {
&& recordVO.FileVOs?.size!! > 1
) {
fileName = recordVO.displayName + ".mp4"
recordVO.FileVOs?.get(1)
} else {
Expand Down Expand Up @@ -79,17 +80,6 @@ class FileData private constructor() : Parcelable {
initTags(recordVO.TagVOs)
}

private fun getAccessRole(accessRole: String?): AccessRole {
return when (accessRole) {
AccessRole.OWNER.backendString -> AccessRole.OWNER
AccessRole.MANAGER.backendString -> AccessRole.MANAGER
AccessRole.CURATOR.backendString -> AccessRole.CURATOR
AccessRole.EDITOR.backendString -> AccessRole.EDITOR
AccessRole.CONTRIBUTOR.backendString -> AccessRole.CONTRIBUTOR
else -> AccessRole.VIEWER
}
}

private fun initTags(tagVOs: List<TagVO>?) {
tags = ArrayList()
tagVOs?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ItemVO {
var displayName: String? = null
var displayDT: String? = null
var type: String? = null
var accessRole: String? = null
var thumbURL200: String? = null
var thumbURL2000: String? = null
var status: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ class SharedXMeFragment : PermanentBaseFragment(), RecordListener {
}
}

fun getRootShares(): LiveData<Void> {
return getRootRecords
}
fun getRootShares(): LiveData<Void> = getRootRecords

override fun onRecordClick(record: Record) {
viewModel.onRecordClick(record)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.permanent.permanent.Constants
import org.permanent.permanent.CurrentArchivePermissionsManager
import org.permanent.permanent.R
import org.permanent.permanent.models.*
import org.permanent.permanent.network.models.RecordVO
Expand All @@ -36,6 +37,7 @@ class SharedXMeViewModel(application: Application) : ObservableAndroidViewModel(
private var refreshJob: Job? = null

val isRoot = MutableLiveData(true)
private val isCreateAvailable = MutableLiveData(true)
private val isListViewMode = MutableLiveData(true)
var existsShares = MutableLiveData(false)
private var existsDownloads = MutableLiveData(false)
Expand Down Expand Up @@ -105,6 +107,8 @@ class SharedXMeViewModel(application: Application) : ObservableAndroidViewModel(
currentFolder.value?.getUploadQueue()?.clearEnqueuedUploadsAndRemoveTheirObservers()
folderPathStack.push(record)
currentFolder.value = NavigationFolder(appContext, record)
isCreateAvailable.value =
record.accessRole != AccessRole.VIEWER && CurrentArchivePermissionsManager.instance.isCreateAvailable()
loadEnqueuedUploads(currentFolder.value, lifecycleOwner)
loadFilesOf(currentFolder.value, currentSortType.value)
} else {
Expand All @@ -121,6 +125,8 @@ class SharedXMeViewModel(application: Application) : ObservableAndroidViewModel(
} else {
val previousFolder = folderPathStack.peek()
currentFolder.value = NavigationFolder(appContext, previousFolder)
isCreateAvailable.value =
previousFolder.accessRole != AccessRole.VIEWER && CurrentArchivePermissionsManager.instance.isCreateAvailable()
loadEnqueuedUploads(currentFolder.value, lifecycleOwner)
loadFilesOf(currentFolder.value, currentSortType.value)
}
Expand All @@ -141,8 +147,8 @@ class SharedXMeViewModel(application: Application) : ObservableAndroidViewModel(
isRoot.value = false
folderName.value = folder.getDisplayName()
existsShares.value = !recordVOs.isNullOrEmpty()
showEmptyFolder.value = isRoot.value == false &&
existsShares.value == false && getExistsUploads().value == false
showEmptyFolder.value =
isRoot.value == false && existsShares.value == false && getExistsUploads().value == false
recordVOs?.let { onRecordsRetrieved.value = getRecords(recordVOs) }
}

Expand Down Expand Up @@ -284,6 +290,8 @@ class SharedXMeViewModel(application: Application) : ObservableAndroidViewModel(

fun getShowMessage(): LiveData<String> = showMessage

fun getIsCreateAvailable(): LiveData<Boolean> = isCreateAvailable

fun getOnShowQuotaExceeded(): SingleLiveEvent<Void> = showQuotaExceeded

fun getOnNewTemporaryFile(): MutableLiveData<Record> = onNewTemporaryFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,11 @@ class SharesViewModel(application: Application) : ObservableAndroidViewModel(app
})
}

fun getIsBusy(): MutableLiveData<Boolean> {
return isBusy
}
fun getIsBusy(): MutableLiveData<Boolean> = isBusy

fun getShowMessage(): LiveData<String> {
return showMessage
}
fun getShowMessage(): LiveData<String> = showMessage

fun getOnSharesByMeRetrieved(): LiveData<MutableList<Record>> {
return onSharesByMeRetrieved
}
fun getOnSharesByMeRetrieved(): LiveData<MutableList<Record>> = onSharesByMeRetrieved

fun getOnSharesWithMeRetrieved(): LiveData<MutableList<Record>> {
return onSharesWithMeRetrieved
}
fun getOnSharesWithMeRetrieved(): LiveData<MutableList<Record>> = onSharesWithMeRetrieved
}
23 changes: 13 additions & 10 deletions app/src/main/res/layout/activity_archive_onboarding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
android:layout_marginBottom="24dp"
android:onClick="@{() -> viewModel.onGetStartedBtnClick()}"
android:text="@string/onboarding_get_started_button"
android:textSize="18sp"
android:visibility="@{viewModel.currentPage == OnboardingPage.START ? View.VISIBLE : View.INVISIBLE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -98,33 +99,34 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/btnBack"
style="@style/customButtonBottomSheetStyle"
android:layout_width="0dp"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="24dp"
android:backgroundTint="@color/middleGrey"
android:text="@string/archive_onboarding_back_button"
android:onClick="@{() -> viewModel.onBackBtnClick()}"
android:text="@string/archive_onboarding_back_button"
android:textSize="16sp"
android:visibility="@{viewModel.currentPage == OnboardingPage.START ? View.GONE : View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btnNameArchive"
app:layout_constraintStart_toStartOf="parent" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnNameArchive"
style="@style/customButtonBottomSheetStyle"
android:layout_width="272dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="24dp"
android:enabled="@{viewModel.isArchiveSelected ? true : false}"
android:text="@string/archive_onboarding_name_archive_button"
android:onClick="@{() -> viewModel.onNameArchiveBtnClick()}"
android:text="@string/archive_onboarding_name_archive_button"
android:textColor="@{viewModel.isArchiveSelected ? @color/white : @color/whiteTransparent}"
android:textSize="16sp"
android:visibility="@{viewModel.currentPage == OnboardingPage.TYPE_SELECTION ? View.VISIBLE : View.INVISIBLE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toEndOf="@+id/btnBack" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnCreateArchive"
Expand All @@ -134,11 +136,12 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="24dp"
android:enabled="@{viewModel.name == null || viewModel.name.trim().isEmpty ? false : true}"
android:onClick="@{() -> viewModel.onCreateArchiveBtnClick()}"
android:text="@string/archive_onboarding_create_archive_button"
android:textColor="@{viewModel.name == null || viewModel.name.trim().isEmpty ? @color/whiteTransparent : @color/white}"
android:enabled="@{viewModel.name == null || viewModel.name.trim().isEmpty ? false : true}"
android:textSize="16sp"
android:visibility="@{viewModel.currentPage == OnboardingPage.NAME_SETTING ? View.VISIBLE : View.INVISIBLE}"
android:onClick="@{() -> viewModel.onCreateArchiveBtnClick()}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/btnBack" />
Expand Down
Loading

0 comments on commit 0d39c8b

Please sign in to comment.