Skip to content

Commit

Permalink
Merge pull request #309 from PermanentOrg/bugfix/fixes-for-release
Browse files Browse the repository at this point in the history
Fix crash and move snackbar at the bottom
  • Loading branch information
flaviuvsp authored Oct 8, 2024
2 parents 682e565 + cb15e92 commit 0de797b
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 121 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
applicationId "org.permanent.PermanentArchive"
minSdkVersion 26
targetSdkVersion 34
versionCode 70
versionCode 71
versionName "1.9.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Divider
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
Expand Down Expand Up @@ -98,153 +99,158 @@ fun EditMetadataScreen(
val snackbarEventFlow = remember { MutableSharedFlow<String>() }
val snackbarHostState = remember { SnackbarHostState() }

Column(
modifier = Modifier
.fillMaxSize()
.background(lightBlueColor)
.padding(24.dp)
.verticalScroll(scrollState)
.clickable {
viewModel.applyNewDescriptionToAllRecords(inputDescription)
},
verticalArrangement = Arrangement.Top
) {
Header(iconURL = firstRecordThumb, titleText = headerTitle)

Divider(modifier = Modifier.padding(vertical = 24.dp))

DescriptionView(
blackColor,
regularFont,
subTitleTextSize,
inputDescription,
focusRequester,
whiteColor,
lightGreyColor,
someFilesHaveDescription,
redColor,
smallTextSize,
onTextChange = {
inputDescription = it
}
)
Scaffold(
snackbarHost = {
SnackbarHost(hostState = snackbarHostState)
}
) { it ->
it
Column(
modifier = Modifier
.fillMaxSize()
.background(lightBlueColor)
.padding(24.dp)
.verticalScroll(scrollState)
.clickable {
viewModel.applyNewDescriptionToAllRecords(inputDescription)
},
verticalArrangement = Arrangement.Top
) {
Header(iconURL = firstRecordThumb, titleText = headerTitle)

Divider(modifier = Modifier.padding(vertical = 24.dp))

DescriptionView(
blackColor,
regularFont,
subTitleTextSize,
inputDescription,
focusRequester,
whiteColor,
lightGreyColor,
someFilesHaveDescription,
redColor,
smallTextSize,
onTextChange = {
inputDescription = it
}
)

Divider(modifier = Modifier.padding(vertical = 16.dp))
Divider(modifier = Modifier.padding(vertical = 16.dp))

Row(
modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween
) {
Row(
modifier = Modifier.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp)
modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween
) {
Image(
painter = painterResource(id = R.drawable.ic_tag),
contentDescription = "Description",
modifier = Modifier.size(24.dp),
colorFilter = ColorFilter.tint(lightGreyColor)
)
Text(
text = stringResource(R.string.edit_files_metadata_tags),
color = blackColor,
fontFamily = regularFont,
fontSize = subTitleTextSize
)
}
if (showApplyAllToSelection == true) {
Row(modifier = Modifier
.clickable { viewModel.onApplyAllTagsToSelectionClick() }
.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Text(
text = stringResource(R.string.edit_files_metadata_apply_all_to_selection),
color = primaryColor,
fontFamily = semiboldFont,
fontSize = subTitleTextSize
)
Row(
modifier = Modifier.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
Image(
painter = painterResource(id = R.drawable.ic_done_white),
painter = painterResource(id = R.drawable.ic_tag),
contentDescription = "Description",
modifier = Modifier.size(24.dp),
colorFilter = ColorFilter.tint(primaryColor)
colorFilter = ColorFilter.tint(lightGreyColor)
)
Text(
text = stringResource(R.string.edit_files_metadata_tags),
color = blackColor,
fontFamily = regularFont,
fontSize = subTitleTextSize
)
}
if (showApplyAllToSelection == true) {
Row(modifier = Modifier
.clickable { viewModel.onApplyAllTagsToSelectionClick() }
.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Text(
text = stringResource(R.string.edit_files_metadata_apply_all_to_selection),
color = primaryColor,
fontFamily = semiboldFont,
fontSize = subTitleTextSize
)
Image(
painter = painterResource(id = R.drawable.ic_done_white),
contentDescription = "Description",
modifier = Modifier.size(24.dp),
colorFilter = ColorFilter.tint(primaryColor)
)
}
}
}
}

FlowRow(
modifier = Modifier, horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
allTags?.let { allTagsValue ->
for (tag in allTagsValue) {
TagView(
text = tag.name,
isSelected = tag.isSelected.observeAsState(),
onTagClick = { viewModel.onTagClick(tag) }
) { viewModel.onTagRemoveClick(tag) }
FlowRow(
modifier = Modifier, horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
allTags?.let { allTagsValue ->
for (tag in allTagsValue) {
TagView(
text = tag.name,
isSelected = tag.isSelected.observeAsState(),
onTagClick = { viewModel.onTagClick(tag) }
) { viewModel.onTagRemoveClick(tag) }
}
}
}
NewTagView {
val tagsOfSelectedRecords = arrayListOf<Tag>()
viewModel.getTagsOfSelectedRecords().value?.toList()
?.let { tagsOfSelectedRecords.addAll(it) }
NewTagView {
val tagsOfSelectedRecords = arrayListOf<Tag>()
viewModel.getTagsOfSelectedRecords().value?.toList()
?.let { tagsOfSelectedRecords.addAll(it) }

openNewTagScreen(tagsOfSelectedRecords)
openNewTagScreen(tagsOfSelectedRecords)
}
}
}

Divider(modifier = Modifier.padding(vertical = 16.dp))
Divider(modifier = Modifier.padding(vertical = 16.dp))

FilesMenuView(icon = R.drawable.ic_edit_name,
title = stringResource(id = R.string.file_names),
actionTitle = stringResource(id = R.string.modify)) {
openEditFileNamesScreen(viewModel.getRecords())
}
FilesMenuView(icon = R.drawable.ic_edit_name,
title = stringResource(id = R.string.file_names),
actionTitle = stringResource(id = R.string.modify)) {
openEditFileNamesScreen(viewModel.getRecords())
}

Divider(modifier = Modifier.padding(vertical = 16.dp))
Divider(modifier = Modifier.padding(vertical = 16.dp))

dateMenuName?.let {
FilesMenuView(icon = R.drawable.ic_date_time,
title = it,
actionTitle = stringResource(id = R.string.menu_toolbar_public_add)) {
openDateAndTimeScreen(viewModel.getRecords())
dateMenuName?.let {
FilesMenuView(icon = R.drawable.ic_date_time,
title = it,
actionTitle = stringResource(id = R.string.menu_toolbar_public_add)) {
openDateAndTimeScreen(viewModel.getRecords())
}
}
}

Divider(modifier = Modifier.padding(vertical = 16.dp))
Divider(modifier = Modifier.padding(vertical = 16.dp))

locationMenuName?.let {
FilesMenuView(icon = R.drawable.map_icon,
title = it,
actionTitle = stringResource(id = R.string.menu_toolbar_public_add)) {
openLocationScreen(viewModel.getRecords())
locationMenuName?.let {
FilesMenuView(icon = R.drawable.map_icon,
title = it,
actionTitle = stringResource(id = R.string.menu_toolbar_public_add)) {
openLocationScreen(viewModel.getRecords())
}
}
}
}

LaunchedEffect(errorMessage) {
errorMessage?.let { message ->
coroutineScope.launch {
snackbarHostState.showSnackbar(message)
LaunchedEffect(infoMessage) {
infoMessage?.let { message ->
coroutineScope.launch {
snackbarHostState.showSnackbar(message)
}
}
}
}
}

LaunchedEffect(infoMessage) {
infoMessage?.let { message ->
coroutineScope.launch {
snackbarHostState.showSnackbar(message)
LaunchedEffect(errorMessage) {
errorMessage?.let { message ->
coroutineScope.launch {
snackbarHostState.showSnackbar(message)
}
}
}
}
}

LaunchedEffect(snackbarEventFlow) {
snackbarEventFlow.collect { message ->
snackbarHostState.showSnackbar(message)
LaunchedEffect(snackbarEventFlow) {
snackbarEventFlow.collect { message ->
snackbarHostState.showSnackbar(message)
}
}
}
}

SnackbarHost(hostState = snackbarHostState)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EditDateTimeViewModel(application: Application) : ObservableAndroidViewMod
fun setRecords(records: ArrayList<Record>) {
this.records.addAll(records)
records.firstOrNull()?.displayDate?.let {
val dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
val dateFormat = "yyyy-MM-dd HH:mm:ss"
extractDateHourMinute(it, dateFormat)
}
}
Expand Down

0 comments on commit 0de797b

Please sign in to comment.