Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class RedwoodGraphQLClientConfig @Inject constructor(
adapter: RedwoodAdapter
): DomainServicesGraphQLClientConfig(
url = BuildConfig.REDWOOD_BASE_URL + "/graphql",
httpClient = adapter.buildOHttpClient()
httpClient = adapter.buildOHttpClient(),
fetchPolicy = HttpFetchPolicy.CacheFirst
)

class JourneyGraphQLClientConfig @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class HorizonNotebookPage(private val composeTestRule: ComposeTestRule) {
}

fun assertTextAreaPlaceholderDisplayed() {
composeTestRule.onNodeWithText(context.getString(R.string.addNoteAddANoteLabel))
composeTestRule.onNodeWithText(context.getString(R.string.addNoteAddANoteOptionalLabel))
.assertIsDisplayed()
}

Expand Down Expand Up @@ -151,13 +151,13 @@ class HorizonNotebookPage(private val composeTestRule: ComposeTestRule) {
}

fun enterUserComment(comment: String) {
composeTestRule.onNodeWithText(context.getString(R.string.addNoteAddANoteLabel))
composeTestRule.onNodeWithText(context.getString(R.string.addNoteAddANoteOptionalLabel))
.performClick()
.performTextInput(comment)
}

fun clearUserComment() {
composeTestRule.onNode(hasText(context.getString(R.string.addNoteAddANoteLabel)).not())
composeTestRule.onNode(hasText(context.getString(R.string.addNoteAddANoteOptionalLabel)).not())
.performClick()
.performTextClearance()
}
Expand Down Expand Up @@ -194,7 +194,7 @@ class HorizonNotebookPage(private val composeTestRule: ComposeTestRule) {

fun clearNoteText() {
composeTestRule.onNode(
hasText(context.getString(R.string.addNoteAddANoteLabel)).not()
hasText(context.getString(R.string.addNoteAddANoteOptionalLabel)).not()
)
.performClick()
.performTextClearance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class AddEditNoteScreenUiTest {
AddEditNoteScreen(navController, state) { _, _ -> }
}

composeTestRule.onNodeWithText(context.getString(R.string.addNoteAddANoteLabel))
composeTestRule.onNodeWithText(context.getString(R.string.addNoteAddANoteOptionalLabel))
.assertIsDisplayed()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private fun HomeScreenTopBar(uiState: DashboardUiState, mainNavController: NavCo
)
Spacer(modifier = Modifier.weight(1f))
IconButton(
iconRes = R.drawable.menu_book_notebook,
iconRes = R.drawable.edit_note,
contentDescription = stringResource(R.string.a11y_dashboardNotebookButtonContentDescription),
onClick = {
mainNavController.navigate(MainNavigationRoute.Notebook.route)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fun DashboardTimeSpentSection(
}
DashboardItemState.ERROR -> {
DashboardWidgetCardError(
stringResource(R.string.dashboardTimeSpentTitle),
stringResource(R.string.dashboardTimeLearningTitle),
R.drawable.schedule,
HorizonColors.PrimitivesHoney.honey12(),
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fun DashboardTimeSpentCardContent(
modifier: Modifier = Modifier,
) {
DashboardWidgetCard(
stringResource(R.string.dashboardTimeSpentTitle),
stringResource(R.string.dashboardTimeLearningTitle),
R.drawable.schedule,
HorizonColors.PrimitivesHoney.honey12(),
modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ private fun ModuleItemSequenceContent(
moduleHeaderHeight = coordinates.size.height
val temp = nestedScrollConnection.appBarOffset
nestedScrollConnection =
CollapsingAppBarNestedScrollConnection(moduleHeaderHeight).apply { appBarOffset = temp }
CollapsingAppBarNestedScrollConnection(moduleHeaderHeight).apply {
appBarOffset = temp
}
}
}
) {
Expand All @@ -274,7 +276,10 @@ private fun ModuleItemSequenceContent(
containerColor = Color.Transparent,
modifier = Modifier
.conditional(uiState.loadingState.isLoading || uiState.loadingState.isError) {
background(color = HorizonColors.Surface.pageSecondary(), shape = HorizonCornerRadius.level5)
background(
color = HorizonColors.Surface.pageSecondary(),
shape = HorizonCornerRadius.level5
)
}
.padding(top = moduleHeaderHeight)
) {
Expand Down Expand Up @@ -305,6 +310,7 @@ private fun ModuleItemSequenceContent(
uiState.assignmentToolsOpened,
updateAiContext = uiState.updateAiAssistContext,
updateNotebookContext = uiState.updateObjectTypeAndId,
scrollToNoteId = uiState.scrollToNoteId
)
}
}
Expand Down Expand Up @@ -403,6 +409,7 @@ private fun ModuleItemContentScreen(
assignmentToolsOpened: () -> Unit,
updateAiContext: (AiAssistContextSource, String) -> Unit,
updateNotebookContext: (Pair<String, String>) -> Unit,
scrollToNoteId: String?,
modifier: Modifier = Modifier
) {
if (moduleItemUiState.isLoading) {
Expand Down Expand Up @@ -461,7 +468,8 @@ private fun ModuleItemContentScreen(
uiState = uiState,
scrollState = scrollState,
updateAiContext = { source, content -> updateAiContext(source, content) },
mainNavController = mainNavController
mainNavController = mainNavController,
scrollToNoteId = scrollToNoteId
)
}
composable(
Expand Down Expand Up @@ -546,6 +554,7 @@ private fun ModuleItemSequenceBottomBar(
) {
if (showPreviousButton) IconButton(
iconRes = R.drawable.chevron_left,
contentDescription = stringResource(R.string.a11y_previousModuleItem),
color = IconButtonColor.Inverse,
elevation = HorizonElevation.level4,
onClick = onPreviousClick,
Expand All @@ -559,20 +568,23 @@ private fun ModuleItemSequenceBottomBar(
) {
IconButton(
iconRes = R.drawable.ai,
contentDescription = stringResource(R.string.a11y_openAIAssistant),
enabled = aiAssistEnabled,
color = IconButtonColor.Ai,
elevation = HorizonElevation.level4,
onClick = onAiAssistClick,
)
if (showNotebookButton) IconButton(
iconRes = R.drawable.menu_book_notebook,
iconRes = R.drawable.edit_note,
contentDescription = stringResource(R.string.a11y_openNotebook),
enabled = notebookEnabled,
color = IconButtonColor.Inverse,
elevation = HorizonElevation.level4,
onClick = onNotebookClick,
)
if (showAssignmentToolsButton) IconButton(
iconRes = R.drawable.more_vert,
contentDescription = stringResource(R.string.a11y_openMoreOptions),
color = IconButtonColor.Inverse,
elevation = HorizonElevation.level4,
onClick = onAssignmentToolsClick,
Expand All @@ -587,6 +599,7 @@ private fun ModuleItemSequenceBottomBar(
}
if (showNextButton) IconButton(
iconRes = R.drawable.chevron_right,
contentDescription = stringResource(R.string.a11y_nextModuleItem),
color = IconButtonColor.Inverse,
elevation = HorizonElevation.level4,
onClick = onNextClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ data class ModuleItemSequenceUiState(
val hasUnreadComments: Boolean = false,
val updateAiAssistContext: (AiAssistContextSource, String) -> Unit = { _, _ -> },
val shouldRefreshPreviousScreen: Boolean = false,
val scrollToNoteId: String? = null
)

data class ModuleItemUiState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ class ModuleItemSequenceViewModel @Inject constructor(
private val moduleItemId = savedStateHandle.toRoute<MainNavigationRoute.ModuleItemSequence>().moduleItemId
private val moduleItemAssetType = savedStateHandle.toRoute<MainNavigationRoute.ModuleItemSequence>().moduleItemAssetType
private val moduleItemAssetId = savedStateHandle.toRoute<MainNavigationRoute.ModuleItemSequence>().moduleItemAssetId
private val scrollToNoteId = savedStateHandle.toRoute<MainNavigationRoute.ModuleItemSequence>().scrollToNoteId

private var courseProgressChanged = false

private val _uiState =
MutableStateFlow(
ModuleItemSequenceUiState(
courseId = courseId,
scrollToNoteId = scrollToNoteId,
loadingState = LoadingState(onRefresh = ::refresh),
onPreviousClick = ::previousClicked,
onNextClick = ::nextClicked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import com.instructure.canvasapi2.managers.graphql.horizon.redwood.NoteHighlightedData
import com.instructure.canvasapi2.managers.graphql.horizon.redwood.NoteHighlightedDataRange
import com.instructure.canvasapi2.managers.graphql.horizon.redwood.NoteHighlightedDataTextPosition
import com.instructure.horizon.features.aiassistant.common.model.AiAssistContextSource
import com.instructure.horizon.features.notebook.common.webview.ComposeNotesHighlightingCanvasWebView
import com.instructure.horizon.features.notebook.common.webview.NotesCallback
Expand All @@ -51,7 +54,8 @@ fun PageDetailsContentScreen(
scrollState: ScrollState,
updateAiContext: (AiAssistContextSource, String) -> Unit,
mainNavController: NavHostController,
modifier: Modifier = Modifier
scrollToNoteId: String?,
modifier: Modifier = Modifier,
) {
val activity = LocalContext.current.getActivityOrNull()
LaunchedEffect(uiState.urlToOpen) {
Expand Down Expand Up @@ -81,6 +85,7 @@ fun PageDetailsContentScreen(
ComposeNotesHighlightingCanvasWebView(
content = "<div id=\"parent-container\"><div>$it</div></div>",
notes = uiState.notes,
scrollToNoteId = scrollToNoteId,
applyOnWebView = {
activity?.let { addVideoClient(it) }
overrideHtmlFormatColors = HorizonColors.htmlFormatColors
Expand Down Expand Up @@ -112,20 +117,21 @@ fun PageDetailsContentScreen(
)
},
onNoteAdded = { selectedText, noteType, startContainer, startOffset, endContainer, endOffset, textSelectionStart, textSelectionEnd ->
mainNavController.navigate(
NotebookRoute.AddNotebook(
courseId = uiState.courseId.toString(),
objectType = "Page",
objectId = uiState.pageId.toString(),
highlightedTextStartOffset = startOffset,
highlightedTextEndOffset = endOffset,
highlightedTextStartContainer = startContainer,
highlightedTextEndContainer = endContainer,
highlightedText = selectedText,
textSelectionStart = textSelectionStart,
textSelectionEnd = textSelectionEnd,
noteType = noteType
)
uiState.addNote(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onNoteAdded callback now calls uiState.addNote() instead of navigating directly. This is good architectural change, but ensure that:

  1. The addNote function properly handles all the navigation and state management
  2. Error handling is in place if the note creation fails
  3. The user receives feedback about the note creation status

Could you verify that uiState.addNote is implemented and handles these cases?

NoteHighlightedData(
selectedText = selectedText,
range = NoteHighlightedDataRange(
startOffset = startOffset,
endOffset = endOffset,
startContainer = startContainer,
endContainer = endContainer
),
textPosition = NoteHighlightedDataTextPosition(
start = textSelectionStart,
end = textSelectionEnd
)
),
noteType
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -216,6 +217,7 @@ fun NotebookScreen(
courseId = note.courseId,
moduleItemAssetType = note.objectType.value,
moduleItemAssetId = note.objectId,
scrollToNoteId = note.id
)
)
}
Expand Down Expand Up @@ -303,7 +305,15 @@ private fun FilterContent(
}

if (state.showNoteTypeFilter) {
NotebookTypeSelect(state.selectedFilter, state.onFilterSelected, false, true)
NotebookTypeSelect(
state.selectedFilter,
state.onFilterSelected,
false,
true,
Modifier.conditional(!state.showCourseFilter) { // TalkBack hack to fix focus handling
semantics(true) {}
}
)
}
}
}
Expand Down Expand Up @@ -333,7 +343,7 @@ private fun NoteContent(
modifier = Modifier
.fillMaxWidth()
.horizonBorder(
colorResource(note.type.color).copy(alpha = 0.1f),
colorResource(note.type.highlightColor),
6.dp,
1.dp,
1.dp,
Expand Down
Loading
Loading