Skip to content

Commit

Permalink
fixed receiver issue (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco authored May 27, 2024
1 parent 9d9aa89 commit 2729e4a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ object DownloadMonitor {

val newReceiver = DownloadCompleteReceiver(::onDownloadComplete)
val filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
context.applicationContext.registerReceiver(newReceiver, filter)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.applicationContext.registerReceiver(
newReceiver,
filter,
Context.RECEIVER_EXPORTED,
)
} else {
context.applicationContext.registerReceiver(newReceiver, filter)
}
receiver = newReceiver
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun FormScreen(navController: NavController, viewModel: FormViewModel, fragment:
state.formFields.isEmpty() -> emptyList()
state.processOutcomes.isEmpty() -> defaultOutcomes(state)
state.parent.taskEntry.memberOfCandidateGroup == true -> pooledOutcomes(state, viewModel)
else -> customOutcomes(state)
else -> customOutcomes(state, viewModel)
}

when {
Expand All @@ -48,15 +48,27 @@ fun FormScreen(navController: NavController, viewModel: FormViewModel, fragment:
color = colorScheme.background,
contentColor = colorScheme.onBackground,
) {
FormDetailScreen(viewModel, customOutcomes, navController, fragment, snackbarHostState)
FormDetailScreen(
viewModel,
customOutcomes,
navController,
fragment,
snackbarHostState,
)
}
}
}

else -> {
Scaffold(
snackbarHost = { SnackbarHost(snackbarHostState) },
floatingActionButton = { FloatingActionButton(customOutcomes, fragment, viewModel) },
floatingActionButton = {
FloatingActionButton(
customOutcomes,
fragment,
viewModel,
)
},
floatingActionButtonPosition = FabPosition.End,
) { padding ->
val colorScheme = MaterialTheme.colorScheme
Expand All @@ -67,7 +79,13 @@ fun FormScreen(navController: NavController, viewModel: FormViewModel, fragment:
color = colorScheme.background,
contentColor = colorScheme.onBackground,
) {
FormDetailScreen(viewModel, emptyList(), navController, fragment, snackbarHostState)
FormDetailScreen(
viewModel,
emptyList(),
navController,
fragment,
snackbarHostState,
)
}
}
}
Expand Down Expand Up @@ -106,16 +124,21 @@ private fun defaultOutcomes(state: FormViewState): List<OptionsModel> {
}

@Composable
private fun customOutcomes(state: FormViewState): List<OptionsModel> {
private fun customOutcomes(state: FormViewState, viewModel: FormViewModel): List<OptionsModel> {
val dataObj = state.parent.taskEntry
return if (state.parent.processInstanceId == null) {
state.processOutcomes
} else {
listOf(
OptionsModel(
id = DefaultOutcomesID.DEFAULT_SAVE.value(),
name = stringResource(id = R.string.action_text_save),
),
) + state.processOutcomes
if (viewModel.isAssigneeAndLoggedInSame(dataObj.assignee)) {
listOf(
OptionsModel(
id = DefaultOutcomesID.DEFAULT_SAVE.value(),
name = stringResource(id = R.string.action_text_save),
),
) + state.processOutcomes
} else {
emptyList()
}
}
}

Expand Down

0 comments on commit 2729e4a

Please sign in to comment.