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

Feature/accessibility #78

Merged
merged 8 commits into from
Nov 21, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ private fun CourseDetailNativeContent(
.aspectRatio(1.86f)
.padding(6.dp),
courseImage = course.media.image?.large,
courseCertificate = null
courseCertificate = null,
courseName = course.name
)
if (!course.media.courseVideo?.uri.isNullOrEmpty()) {
IconButton(
Expand All @@ -348,7 +349,7 @@ private fun CourseDetailNativeContent(
Icon(
modifier = Modifier.size(40.dp),
painter = painterResource(courseR.drawable.course_ic_play),
contentDescription = null,
contentDescription = stringResource(id = R.string.course_accessibility_play_video),
tint = Color.LightGray
)
}
Expand Down Expand Up @@ -466,7 +467,8 @@ private fun CourseDetailNativeContentLandscape(
.width(263.dp)
.height(200.dp),
courseImage = course.media.image?.large,
courseCertificate = null
courseCertificate = null,
courseName = course.name
)
if (!course.media.courseVideo?.uri.isNullOrEmpty()) {
IconButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ internal fun CourseOutlineScreen(
.padding(6.dp),
courseImage = uiState.courseStructure.media?.image?.large
?: "",
courseCertificate = uiState.courseStructure.certificate
courseCertificate = uiState.courseStructure.certificate,
courseName = uiState.courseStructure.name
)
}
if (uiState.resumeBlock != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Devices
Expand Down Expand Up @@ -290,12 +291,15 @@ private fun CourseSubsectionItem(
onClick: (Block) -> Unit,
onDownloadClick: (Block) -> Unit
) {
val icon =
if (block.completion == 1.0) painterResource(R.drawable.course_ic_task_alt) else painterResource(
id = getUnitBlockIcon(block)
)
val iconColor =
val completedIconPainter =
if (block.completion == 1.0) painterResource(R.drawable.course_ic_task_alt) else painterResource(R.drawable.ic_course_chapter_icon)
val completedIconColor =
if (block.completion == 1.0) MaterialTheme.appColors.primary else MaterialTheme.appColors.onSurface
val completedIconDescription = if (block.completion == 1.0) {
stringResource(id = R.string.course_accessibility_section_completed)
} else {
stringResource(id = R.string.course_accessibility_section_uncompleted)
}

val iconModifier = Modifier.size(24.dp)

Expand All @@ -312,9 +316,9 @@ private fun CourseSubsectionItem(
horizontalArrangement = Arrangement.SpaceBetween
) {
Icon(
painter = icon,
contentDescription = null,
tint = iconColor
painter = completedIconPainter,
contentDescription = completedIconDescription,
tint = completedIconColor
)
Spacer(modifier = Modifier.width(16.dp))
Text(
Expand All @@ -332,16 +336,21 @@ private fun CourseSubsectionItem(
verticalAlignment = Alignment.CenterVertically
) {
if (downloadedState == DownloadedState.DOWNLOADED || downloadedState == DownloadedState.NOT_DOWNLOADED) {
val iconPainter = if (downloadedState == DownloadedState.DOWNLOADED) {
val downloadIconPainter = if (downloadedState == DownloadedState.DOWNLOADED) {
painterResource(id = R.drawable.course_ic_remove_download)
} else {
painterResource(id = R.drawable.course_ic_start_download)
}
val downloadIconDescription = if (downloadedState == DownloadedState.DOWNLOADED) {
stringResource(id = R.string.course_accessibility_remove_course_section)
} else {
stringResource(id = R.string.course_accessibility_download_course_section)
}
IconButton(modifier = iconModifier,
onClick = { onDownloadClick(block) }) {
Icon(
painter = iconPainter,
contentDescription = null,
painter = downloadIconPainter,
contentDescription = downloadIconDescription,
tint = MaterialTheme.appColors.textPrimary
)
}
Expand All @@ -360,7 +369,7 @@ private fun CourseSubsectionItem(
onClick = { onDownloadClick(block) }) {
Icon(
imageVector = Icons.Filled.Close,
contentDescription = null,
contentDescription = stringResource(id = R.string.course_accessibility_stop_downloading_course_section),
tint = MaterialTheme.appColors.error
)
}
Expand Down
43 changes: 28 additions & 15 deletions course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fun CourseImageHeader(
modifier: Modifier,
courseImage: String?,
courseCertificate: Certificate?,
courseName: String
) {
val configuration = LocalConfiguration.current
val windowSize = rememberWindowSize()
Expand All @@ -121,7 +122,7 @@ fun CourseImageHeader(
.error(org.openedx.core.R.drawable.core_no_image_course)
.placeholder(org.openedx.core.R.drawable.core_no_image_course)
.build(),
contentDescription = null,
contentDescription = stringResource(id = R.string.course_accessibility_header_image_for, courseName),
contentScale = contentScale,
modifier = Modifier
.fillMaxSize()
Expand All @@ -138,7 +139,7 @@ fun CourseImageHeader(
) {
Icon(
painter = painterResource(id = R.drawable.ic_course_completed_mark),
contentDescription = null,
contentDescription = stringResource(id = R.string.course_congratulations),
tint = Color.White
)
Spacer(Modifier.height(6.dp))
Expand Down Expand Up @@ -190,15 +191,19 @@ fun CourseSectionCard(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
val icon =
val completedIconPainter =
if (block.completion == 1.0) painterResource(R.drawable.course_ic_task_alt) else painterResource(R.drawable.ic_course_chapter_icon)
val iconColor =
val completedIconColor =
if (block.completion == 1.0) MaterialTheme.appColors.primary else MaterialTheme.appColors.onSurface

val completedIconDescription = if (block.completion == 1.0) {
stringResource(id = R.string.course_accessibility_section_completed)
} else {
stringResource(id = R.string.course_accessibility_section_uncompleted)
}
Icon(
painter = icon,
contentDescription = null,
tint = iconColor
painter = completedIconPainter,
contentDescription = completedIconDescription,
tint = completedIconColor
)
Spacer(modifier = Modifier.width(16.dp))
Text(
Expand All @@ -216,16 +221,21 @@ fun CourseSectionCard(
verticalAlignment = Alignment.CenterVertically
) {
if (downloadedState == DownloadedState.DOWNLOADED || downloadedState == DownloadedState.NOT_DOWNLOADED) {
val iconPainter = if (downloadedState == DownloadedState.DOWNLOADED) {
val downloadIconPainter = if (downloadedState == DownloadedState.DOWNLOADED) {
painterResource(id = R.drawable.course_ic_remove_download)
} else {
painterResource(id = R.drawable.course_ic_start_download)
}
val downloadIconDescription = if (downloadedState == DownloadedState.DOWNLOADED) {
stringResource(id = R.string.course_accessibility_remove_course_section)
} else {
stringResource(id = R.string.course_accessibility_download_course_section)
}
IconButton(modifier = iconModifier,
onClick = { onDownloadClick(block) }) {
Icon(
painter = iconPainter,
contentDescription = null,
painter = downloadIconPainter,
contentDescription = downloadIconDescription,
tint = MaterialTheme.appColors.textPrimary
)
}
Expand All @@ -244,7 +254,7 @@ fun CourseSectionCard(
onClick = { onDownloadClick(block) }) {
Icon(
imageVector = Icons.Filled.Close,
contentDescription = null,
contentDescription = stringResource(id = R.string.course_accessibility_stop_downloading_course_section),
tint = MaterialTheme.appColors.error
)
}
Expand Down Expand Up @@ -462,11 +472,13 @@ fun Indicator(
) {
val size by animateDpAsState(
targetValue = if (isSelected) selectedSize else defaultRadius,
animationSpec = tween(300)
animationSpec = tween(300),
label = ""
)
val color by animateColorAsState(
targetValue = if (isSelected) selectedColor else defaultColor,
animationSpec = tween(300)
animationSpec = tween(300),
label = ""
)

Box(
Expand Down Expand Up @@ -685,7 +697,8 @@ private fun CourseHeaderPreview() {
.height(200.dp)
.padding(6.dp),
courseCertificate = Certificate(""),
courseImage = ""
courseImage = "",
courseName = ""
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ private fun CourseVideosScreen(
.padding(6.dp),
courseImage = uiState.courseStructure.media?.image?.large
?: "",
courseCertificate = uiState.courseStructure.certificate
courseCertificate = uiState.courseStructure.certificate,
courseName = uiState.courseStructure.name
)
}
items(uiState.courseStructure.blockData) { block ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:contentDescription="@string/course_accessibility_video_player"
app:cardCornerRadius="20dp"
app:cardElevation="0dp"
app:layout_constraintDimensionRatio="W,9:16"
Expand All @@ -48,15 +49,14 @@
android:id="@+id/subtitles"
android:layout_width="560dp"
android:layout_height="0dp"
android:layout_marginTop="28dp"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="28dp"
android:layout_marginBottom="64dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardView"
/>
app:layout_constraintTop_toBottomOf="@id/cardView" />

<androidx.compose.ui.platform.ComposeView
android:id="@+id/cv_rotateHelper"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/course_accessibility_video_player"
app:cardCornerRadius="20dp"
app:cardElevation="0dp"
app:layout_constraintDimensionRatio="W,9:16"
Expand All @@ -46,15 +47,14 @@
android:id="@+id/subtitles"
android:layout_width="560dp"
android:layout_height="0dp"
android:layout_marginTop="28dp"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="28dp"
android:layout_marginBottom="64dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardView"
/>
app:layout_constraintTop_toBottomOf="@id/cardView" />

<androidx.compose.ui.platform.ComposeView
android:id="@+id/cv_rotateHelper"
Expand Down
8 changes: 4 additions & 4 deletions course/src/main/res/layout/fragment_video_unit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/course_accessibility_video_player"
app:cardCornerRadius="20dp"
app:cardElevation="0dp"
app:layout_constraintDimensionRatio="W,9:16"
Expand All @@ -41,15 +42,14 @@
android:id="@+id/subtitles"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="28dp"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="28dp"
android:layout_marginBottom="64dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/cardView"
/>
app:layout_constraintTop_toBottomOf="@id/cardView" />

<androidx.compose.ui.platform.ComposeView
android:id="@+id/connectionError"
Expand Down
10 changes: 10 additions & 0 deletions course/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@
<string name="course_continue_with">Остання активність:</string>
<string name="course_continue">Продовжити</string>
<string name="course_to_proceed">Щоб перейти до \"%s\", натисніть \"Наступний розділ\".</string>

<!-- Accessibility -->
<string name="course_accessibility_header_image_for">Заглавне зображення для курсу %1$s</string>
<string name="course_accessibility_play_video">Відтворити відео</string>
<string name="course_accessibility_video_player">Відеоплеєр</string>
<string name="course_accessibility_remove_course_section">Видалити секцію курсу</string>
<string name="course_accessibility_download_course_section">Завантажити секцію курсу</string>
<string name="course_accessibility_stop_downloading_course_section">Зупинити завантаження секції курсу</string>
<string name="course_accessibility_section_completed">Секція завершена</string>
<string name="course_accessibility_section_uncompleted">Секція не завершена</string>
</resources>
10 changes: 10 additions & 0 deletions course/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@
<string name="course_continue_with">Continue with:</string>
<string name="course_continue">Continue</string>
<string name="course_to_proceed">To proceed with \"%s\" press \"Next section\".</string>

<!-- Accessibility -->
<string name="course_accessibility_header_image_for">Header image for %1$s</string>
<string name="course_accessibility_play_video">Play video</string>
<string name="course_accessibility_video_player">Video player</string>
<string name="course_accessibility_remove_course_section">Remove course section</string>
<string name="course_accessibility_download_course_section">Download course section</string>
<string name="course_accessibility_stop_downloading_course_section">Stop downloading course section</string>
<string name="course_accessibility_section_completed">Section completed</string>
<string name="course_accessibility_section_uncompleted">Section uncompleted</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import org.openedx.discussion.presentation.ui.ThreadMainItem
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import org.openedx.discussion.R


class DiscussionCommentsFragment : Fragment() {
Expand Down Expand Up @@ -387,7 +388,7 @@ private fun DiscussionCommentsScreen(
maxLines = 3,
placeholder = {
Text(
text = stringResource(id = org.openedx.discussion.R.string.discussion_add_response),
text = stringResource(id = R.string.discussion_add_response),
color = MaterialTheme.appColors.textFieldHint,
style = MaterialTheme.appTypography.labelLarge,
)
Expand Down Expand Up @@ -416,8 +417,8 @@ private fun DiscussionCommentsScreen(
) {
Icon(
modifier = Modifier.padding(7.dp),
painter = painterResource(id = org.openedx.discussion.R.drawable.discussion_ic_send),
contentDescription = null,
painter = painterResource(id = R.drawable.discussion_ic_send),
contentDescription = stringResource(id = R.string.discussion_add_response),
tint = iconButtonColor
)
}
Expand Down
Loading