Skip to content

Commit

Permalink
Merge pull request #306 from PermanentOrg/release/1.9.3
Browse files Browse the repository at this point in the history
Update version
  • Loading branch information
flaviuvsp authored Oct 22, 2024
2 parents 82c7673 + 6a654fc commit 5bed5dd
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 127 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "org.permanent.PermanentArchive"
minSdkVersion 26
targetSdkVersion 34
versionCode 68
versionName "1.9.2"
versionCode 72
versionName "1.9.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/org/permanent/permanent/models/Record.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ open class Record : Parcelable {
folderLinkId = recordInfo.folder_linkId
parentFolderLinkId = recordInfo.parentFolder_linkId
displayName = recordInfo.displayName
displayDate = recordInfo.displayDT
displayDate = recordInfo.displayDT?.replace("T", " ")
showArchiveThumb = false
thumbURL200 = recordInfo.thumbURL200
thumbURL2000 = recordInfo.thumbURL2000
Expand All @@ -100,7 +100,7 @@ open class Record : Parcelable {
folderLinkId = recordInfo.folder_linkId
parentFolderLinkId = recordInfo.parentFolder_linkId
displayName = recordInfo.displayName
displayDate = recordInfo.displayDT
displayDate = recordInfo.displayDT?.replace("T", " ")
showArchiveThumb = false
thumbURL200 = recordInfo.thumbURL200
thumbURL2000 = recordInfo.thumbURL2000
Expand All @@ -127,7 +127,7 @@ open class Record : Parcelable {
folderLinkId = itemVO.folder_linkId
parentFolderLinkId = itemVO.parentFolder_linkId
displayName = itemVO.displayName
displayDate = itemVO.displayDT
displayDate = itemVO.displayDT?.replace("T", " ")
archiveFullName = "The ${archiveVO.fullName} Archive"
archiveThumbURL200 = archiveVO.thumbURL200
showArchiveThumb = showArchiveThumbnail
Expand Down Expand Up @@ -172,7 +172,7 @@ open class Record : Parcelable {
folderLinkId = recordInfo?.folder_linkId
parentFolderLinkId = recordInfo?.parentFolder_linkId
displayName = recordInfo?.displayName
displayDate = recordInfo?.displayDT
displayDate = recordInfo?.displayDT?.replace("T", " ")
thumbURL200 = recordInfo?.thumbURL200
thumbURL2000 = recordInfo?.thumbURL2000
isThumbBlurred = shareByUrlVO.previewToggle == null || shareByUrlVO.previewToggle == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FileData private constructor() : Parcelable {
}
displayName = recordVO.displayName
description = recordVO.description
displayDate = recordVO.displayDT
displayDate = recordVO.displayDT?.replace("T", " ")
createdDate = recordVO.createdDT?.replace("T", " ")
updatedDate = recordVO.updatedDT?.replace("T", " ")
derivedDate = recordVO.derivedDT?.replace("T", " ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.platform.ComposeView
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
Expand All @@ -21,6 +23,7 @@ import org.permanent.permanent.viewmodels.EditFileNamesViewModel
class EditFileNamesFragment : PermanentBottomSheetFragment() {

private lateinit var viewModel: EditFileNamesViewModel
private val onFileNameChanged = MutableLiveData<String>()

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
Expand Down Expand Up @@ -60,12 +63,28 @@ class EditFileNamesFragment : PermanentBottomSheetFragment() {
return bottomSheetDialog
}

override fun connectViewModelEvents() {
private val onFileNameChangedObserver = Observer<String> {
onFileNameChanged.value = it
}

override fun connectViewModelEvents() {
viewModel.getOnFileNameChanged().observe(this, onFileNameChangedObserver)
}

override fun disconnectViewModelEvents() {
viewModel.getOnFileNameChanged().removeObserver(onFileNameChangedObserver)
}

override fun onResume() {
super.onResume()
connectViewModelEvents()
}

override fun onPause() {
super.onPause()
disconnectViewModelEvents()
}

fun getOnFilenameChanged() = onFileNameChanged

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.platform.ComposeView
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.google.android.material.snackbar.Snackbar
import org.permanent.permanent.models.Record
import org.permanent.permanent.models.Tag
import org.permanent.permanent.ui.PermanentBaseFragment
Expand All @@ -21,6 +22,7 @@ class EditMetadataFragment : PermanentBaseFragment() {
private var newTagFragment: NewTagFragment? = null
private var locationFragment: EditLocationFragment? = null
private var dateFragment: EditDateTimeFragment? = null
private var fileNameFragment: EditFileNamesFragment? = null
private var records = ArrayList<Record>()

override fun onCreateView(
Expand Down Expand Up @@ -49,9 +51,11 @@ class EditMetadataFragment : PermanentBaseFragment() {
?.observe(lifecycleOwner, onTagsAddedToSelectionObserver)
},
openEditFileNamesScreen = {
var fragment = EditFileNamesFragment()
fragment?.setBundleArguments(records)
fragment?.show(parentFragmentManager, fragment?.tag)
fileNameFragment = EditFileNamesFragment()
fileNameFragment?.setBundleArguments(records)
fileNameFragment?.show(parentFragmentManager, fileNameFragment?.tag)
fileNameFragment?.getOnFilenameChanged()
?.observe(lifecycleOwner, onFilenameChangedObserver)
},
openDateAndTimeScreen = {
dateFragment = EditDateTimeFragment()
Expand Down Expand Up @@ -85,6 +89,10 @@ class EditMetadataFragment : PermanentBaseFragment() {
viewModel.onDateChanged(it)
}

private val onFilenameChangedObserver = Observer<String> {
viewModel.showInfoMessage.value = it
}


override fun connectViewModelEvents() {

Expand All @@ -94,6 +102,7 @@ class EditMetadataFragment : PermanentBaseFragment() {
newTagFragment?.getOnTagsAddedToSelection()?.removeObserver(onTagsAddedToSelectionObserver)
locationFragment?.getOnLocationChanged()?.removeObserver(onLocationChangedObserver)
dateFragment?.getOnDateChanged()?.removeObserver(onDateChangedObserver)
fileNameFragment?.getOnFilenameChanged()?.removeObserver(onFilenameChangedObserver)
}

override fun onResume() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.DatePicker
import androidx.compose.material3.DatePickerDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.SelectableDates
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TimePicker
Expand Down Expand Up @@ -47,6 +48,7 @@ import androidx.core.content.ContextCompat
import org.permanent.permanent.R
import org.permanent.permanent.viewmodels.EditDateTimeViewModel
import java.text.SimpleDateFormat
import java.time.LocalDate
import java.util.Date
import java.util.Locale

Expand All @@ -63,8 +65,10 @@ fun EditDateTimeScreen(
val openAlertDialog = remember { mutableStateOf(false) }

val datePickerState = rememberDatePickerState(
initialSelectedDateMillis = viewModel.initialDateMilis
initialSelectedDateMillis = viewModel.initialDateMilis,
selectableDates = PastOrPresentSelectableDates
)

val selectedDate = datePickerState.selectedDateMillis?.let {
convertMillisToDate(it)
} ?: ""
Expand Down Expand Up @@ -216,7 +220,7 @@ fun EditDateTimeScreen(
cancelButtonText = stringResource(id = R.string.button_cancel),
onConfirm = {
openAlertDialog.value = false
viewModel.updateDate(dateString = "${selectedDate}T${selectedTime}")
viewModel.updateDate(dateString = "$selectedDate $selectedTime")
}) {
openAlertDialog.value = false
}
Expand Down Expand Up @@ -264,4 +268,15 @@ fun convertTimeToString(hour: Int, min: Int, sec: Int): String {
val secString = String.format("%02d", sec)

return "$hourString:$minString:$secString"
}

@OptIn(ExperimentalMaterial3Api::class)
private object PastOrPresentSelectableDates: SelectableDates {
override fun isSelectableDate(utcTimeMillis: Long): Boolean {
return utcTimeMillis <= System.currentTimeMillis()
}

override fun isSelectableYear(year: Int): Boolean {
return year <= LocalDate.now().year
}
}
Loading

0 comments on commit 5bed5dd

Please sign in to comment.