Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable landscape mode #3028

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class DataCollectionFragment : AbstractFragment(), BackPressListener {

binding.dataCollectionToolbar.setNavigationOnClickListener { showExitWarningDialog() }

updateUI(
UiState.TaskListAvailable(
viewModel.tasks,
viewModel.getTaskPosition(viewModel.getCurrentTaskId()),
)
)
return binding.root
}

Expand All @@ -98,7 +104,11 @@ class DataCollectionFragment : AbstractFragment(), BackPressListener {
}
)

lifecycleScope.launch { viewModel.uiState.filterNotNull().collect { updateUI(it) } }
lifecycleScope.launch {
viewModel.uiState.filterNotNull().collect {
updateUI(it)
}
}
}

override fun onResume() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ internal constructor(
}

// LOI creation task is included only on "new data collection site" flow..
private val tasks: List<Task> =
val tasks: List<Task> =
if (isAddLoiFlow) job.tasksSorted else job.tasksSorted.filterNot { it.isAddLoiTask }

val surveyId: String = requireNotNull(surveyRepository.activeSurvey?.id)
Expand Down Expand Up @@ -151,16 +151,14 @@ internal constructor(
savedStateHandle[TASK_POSITION_ID] = taskSequenceHandler.getValidTasks().first().id
}

_uiState.update { UiState.TaskListAvailable(tasks, getTaskPosition(getCurrentTaskId())) }

// Invalidates the cache if any of the task's data is updated.
viewModelScope.launch {
taskDataHandler.dataState.collectLatest { taskSequenceHandler.invalidateCache() }
}
}

/** Returns the ID of the user visible task. */
private fun getCurrentTaskId(): String {
fun getCurrentTaskId(): String {
val taskId = currentTaskId.value
check(taskId.isNotBlank()) { "Task ID can't be blank" }
return taskId
Expand Down Expand Up @@ -336,7 +334,7 @@ internal constructor(
_uiState.update { UiState.TaskUpdated(getTaskPosition(taskId)) }
}

private fun getTaskPosition(taskId: String) = taskSequenceHandler.getTaskPosition(taskId)
fun getTaskPosition(taskId: String) = taskSequenceHandler.getTaskPosition(taskId)

/** Returns true if the given [taskId] is first task in the sequence of displayed tasks. */
fun isFirstPosition(taskId: String): Boolean = taskSequenceHandler.isFirstPosition(taskId)
Expand Down
Loading