Skip to content

Commit 0ff62f0

Browse files
authored
fix: Minor bugbash fixes (#390)
1 parent 44f106d commit 0ff62f0

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

core/src/main/java/org/openedx/core/extension/ViewExt.kt

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,11 @@ fun WebView.loadUrl(url: String, scope: CoroutineScope, cookieManager: AppCookie
6666
}
6767

6868
fun WebView.applyDarkModeIfEnabled(isDarkTheme: Boolean) {
69-
if (isDarkTheme && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
70-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
71-
settings.setAlgorithmicDarkeningAllowed(true)
72-
} else {
73-
// Switch WebView to dark mode; uses default dark theme
74-
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
75-
WebSettingsCompat.setForceDark(
76-
settings,
77-
WebSettingsCompat.FORCE_DARK_ON
78-
)
79-
}
80-
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
81-
WebSettingsCompat.setForceDarkStrategy(
82-
settings,
83-
WebSettingsCompat.DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING
84-
)
85-
}
69+
if (isDarkTheme && WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) {
70+
try {
71+
WebSettingsCompat.setAlgorithmicDarkeningAllowed(settings, true)
72+
} catch (e: Exception) {
73+
e.printStackTrace()
8674
}
8775
}
8876
}

course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fun CourseOutlineScreen(
7979
windowSize: WindowSize,
8080
viewModel: CourseOutlineViewModel,
8181
fragmentManager: FragmentManager,
82-
onResetDatesClick: () -> Unit
82+
onResetDatesClick: () -> Unit,
8383
) {
8484
val uiState by viewModel.uiState.collectAsState()
8585
val uiMessage by viewModel.uiMessage.collectAsState(null)
@@ -288,12 +288,14 @@ private fun CourseOutlineUI(
288288
ResumeCourseTablet(
289289
modifier = Modifier.padding(vertical = 16.dp),
290290
block = uiState.resumeComponent,
291+
displayName = uiState.resumeUnitTitle,
291292
onResumeClick = onResumeClick
292293
)
293294
} else {
294295
ResumeCourse(
295296
modifier = Modifier.padding(vertical = 16.dp),
296297
block = uiState.resumeComponent,
298+
displayName = uiState.resumeUnitTitle,
297299
onResumeClick = onResumeClick
298300
)
299301
}
@@ -341,6 +343,7 @@ private fun CourseOutlineUI(
341343
private fun ResumeCourse(
342344
modifier: Modifier = Modifier,
343345
block: Block,
346+
displayName: String,
344347
onResumeClick: (String) -> Unit,
345348
) {
346349
Column(
@@ -363,7 +366,7 @@ private fun ResumeCourse(
363366
tint = MaterialTheme.appColors.textPrimary
364367
)
365368
Text(
366-
text = block.displayName,
369+
text = displayName,
367370
color = MaterialTheme.appColors.textPrimary,
368371
style = MaterialTheme.appTypography.titleMedium,
369372
maxLines = 1,
@@ -393,6 +396,7 @@ private fun ResumeCourse(
393396
private fun ResumeCourseTablet(
394397
modifier: Modifier = Modifier,
395398
block: Block,
399+
displayName: String,
396400
onResumeClick: (String) -> Unit,
397401
) {
398402
Row(
@@ -421,7 +425,7 @@ private fun ResumeCourseTablet(
421425
tint = MaterialTheme.appColors.textPrimary
422426
)
423427
Text(
424-
text = block.displayName,
428+
text = displayName,
425429
color = MaterialTheme.appColors.textPrimary,
426430
style = MaterialTheme.appTypography.titleMedium,
427431
overflow = TextOverflow.Ellipsis,
@@ -450,7 +454,7 @@ private fun ResumeCourseTablet(
450454
@Composable
451455
private fun CourseProgress(
452456
modifier: Modifier = Modifier,
453-
progress: Progress
457+
progress: Progress,
454458
) {
455459
Column(
456460
modifier = modifier,
@@ -498,6 +502,7 @@ private fun CourseOutlineScreenPreview() {
498502
mockCourseStructure,
499503
mapOf(),
500504
mockChapterBlock,
505+
"Resumed Unit",
501506
mapOf(),
502507
mapOf(),
503508
mapOf(),
@@ -532,6 +537,7 @@ private fun CourseOutlineScreenTabletPreview() {
532537
mockCourseStructure,
533538
mapOf(),
534539
mockChapterBlock,
540+
"Resumed Unit",
535541
mapOf(),
536542
mapOf(),
537543
mapOf(),
@@ -560,7 +566,7 @@ private fun CourseOutlineScreenTabletPreview() {
560566
@Composable
561567
private fun ResumeCoursePreview() {
562568
OpenEdXTheme {
563-
ResumeCourse(block = mockChapterBlock) {}
569+
ResumeCourse(block = mockChapterBlock, displayName = "Resumed Unit") {}
564570
}
565571
}
566572

course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineUIState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sealed class CourseOutlineUIState {
1010
val courseStructure: CourseStructure,
1111
val downloadedState: Map<String, DownloadedState>,
1212
val resumeComponent: Block?,
13+
val resumeUnitTitle: String,
1314
val courseSubSections: Map<String, List<Block>>,
1415
val courseSectionsState: Map<String, Boolean>,
1516
val subSectionsDownloadsCount: Map<String, Int>,

course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class CourseOutlineViewModel(
121121
courseStructure = state.courseStructure,
122122
downloadedState = it.toMap(),
123123
resumeComponent = state.resumeComponent,
124+
resumeUnitTitle = resumeVerticalBlock?.displayName ?: "",
124125
courseSubSections = courseSubSections,
125126
courseSectionsState = state.courseSectionsState,
126127
subSectionsDownloadsCount = subSectionsDownloadsCount,
@@ -155,6 +156,7 @@ class CourseOutlineViewModel(
155156
courseStructure = state.courseStructure,
156157
downloadedState = state.downloadedState,
157158
resumeComponent = state.resumeComponent,
159+
resumeUnitTitle = resumeVerticalBlock?.displayName ?: "",
158160
courseSubSections = courseSubSections,
159161
courseSectionsState = courseSectionsState,
160162
subSectionsDownloadsCount = subSectionsDownloadsCount,
@@ -213,6 +215,7 @@ class CourseOutlineViewModel(
213215
courseStructure = courseStructure,
214216
downloadedState = getDownloadModelsStatus(),
215217
resumeComponent = getResumeBlock(blocks, courseStatus.lastVisitedBlockId),
218+
resumeUnitTitle = resumeVerticalBlock?.displayName ?: "",
216219
courseSubSections = courseSubSections,
217220
courseSectionsState = courseSectionsState,
218221
subSectionsDownloadsCount = subSectionsDownloadsCount,

dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ private fun AllEnrolledCoursesView(
186186
scaffoldState = scaffoldState,
187187
modifier = Modifier
188188
.fillMaxSize()
189+
.navigationBarsPadding()
189190
.semantics {
190191
testTagsAsResourceId = true
191192
},
@@ -262,7 +263,6 @@ private fun AllEnrolledCoursesView(
262263
Box(
263264
modifier = Modifier
264265
.fillMaxWidth()
265-
.navigationBarsPadding()
266266
.pullRefresh(pullRefreshState),
267267
) {
268268
Column(

whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewFragment.kt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.fillMaxHeight
1515
import androidx.compose.foundation.layout.fillMaxSize
1616
import androidx.compose.foundation.layout.fillMaxWidth
1717
import androidx.compose.foundation.layout.height
18+
import androidx.compose.foundation.layout.navigationBarsPadding
1819
import androidx.compose.foundation.layout.padding
1920
import androidx.compose.foundation.layout.width
2021
import androidx.compose.foundation.layout.widthIn
@@ -140,6 +141,7 @@ fun WhatsNewScreen(
140141
.semantics {
141142
testTagsAsResourceId = true
142143
}
144+
.navigationBarsPadding()
143145
.fillMaxSize(),
144146
scaffoldState = scaffoldState,
145147
topBar = {
@@ -247,26 +249,26 @@ private fun WhatsNewScreenPortrait(
247249
.background(MaterialTheme.appColors.background),
248250
contentAlignment = Alignment.TopCenter
249251
) {
250-
HorizontalPager(
251-
modifier = Modifier.fillMaxSize(),
252-
verticalAlignment = Alignment.Top,
253-
state = pagerState
254-
) { page ->
255-
val image = whatsNewItem.messages[page].image
256-
Image(
257-
modifier = Modifier
258-
.fillMaxWidth()
259-
.padding(horizontal = 36.dp, vertical = 48.dp),
260-
painter = painterResource(id = image),
261-
contentDescription = null
262-
)
263-
}
264-
Box(
252+
Column(
265253
modifier = Modifier
266-
.fillMaxSize()
267-
.padding(horizontal = 24.dp, vertical = 120.dp),
268-
contentAlignment = Alignment.BottomCenter
254+
.padding(horizontal = 24.dp, vertical = 36.dp),
255+
verticalArrangement = Arrangement.spacedBy(24.dp),
269256
) {
257+
HorizontalPager(
258+
modifier = Modifier
259+
.fillMaxWidth()
260+
.weight(1.0f),
261+
verticalAlignment = Alignment.Top,
262+
state = pagerState
263+
) { page ->
264+
val image = whatsNewItem.messages[page].image
265+
Image(
266+
modifier = Modifier
267+
.fillMaxWidth(),
268+
painter = painterResource(id = image),
269+
contentDescription = null
270+
)
271+
}
270272
Column(
271273
horizontalAlignment = Alignment.CenterHorizontally,
272274
verticalArrangement = Arrangement.spacedBy(20.dp),

0 commit comments

Comments
 (0)