Skip to content

Commit 8998fe8

Browse files
fix: changes according code review
1 parent b2b3340 commit 8998fe8

File tree

19 files changed

+122
-176
lines changed

19 files changed

+122
-176
lines changed

app/src/main/java/org/openedx/app/MainFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import org.openedx.core.presentation.dialog.appupgrade.AppUpgradeDialogFragment
2626
import org.openedx.core.presentation.global.appupgrade.AppUpgradeRecommendedBox
2727
import org.openedx.core.presentation.global.appupgrade.UpgradeRequiredFragment
2828
import org.openedx.core.presentation.global.viewBinding
29-
import org.openedx.dates.presentation.dates.DatesFragment
3029
import org.openedx.core.system.notifier.app.AppUpgradeEvent
30+
import org.openedx.dates.presentation.dates.DatesFragment
3131
import org.openedx.discovery.presentation.DiscoveryRouter
3232
import org.openedx.downloads.presentation.download.DownloadsFragment
3333
import org.openedx.learn.presentation.LearnFragment
@@ -180,6 +180,7 @@ class MainFragment : Fragment(R.layout.fragment_main) {
180180
} else {
181181
R.id.fragmentLearn
182182
}
183+
183184
HomeTab.DATES.name -> R.id.fragmentDates
184185
HomeTab.PROFILE.name -> R.id.fragmentProfile
185186
else -> R.id.fragmentLearn

app/src/main/java/org/openedx/app/data/networking/HeadersInterceptor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HeadersInterceptor(
2525
addHeader("Accept", "application/json")
2626

2727
val httpAgent = System.getProperty("http.agent") ?: ""
28-
addHeader("User-Agent", "$httpAgent ${appData.versionName}")
28+
addHeader("User-Agent", "$httpAgent ${appData.appUserAgent}")
2929
}.build()
3030
)
3131
}

app/src/main/java/org/openedx/app/room/AppDatabase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import androidx.room.RoomDatabase
66
import androidx.room.TypeConverters
77
import org.openedx.core.data.model.room.CourseCalendarEventEntity
88
import org.openedx.core.data.model.room.CourseCalendarStateEntity
9-
import org.openedx.core.data.model.room.CourseDatesResponseEntity
9+
import org.openedx.core.data.model.room.CourseDateEntity
1010
import org.openedx.core.data.model.room.CourseEnrollmentDetailsEntity
1111
import org.openedx.core.data.model.room.CourseProgressEntity
1212
import org.openedx.core.data.model.room.CourseStructureEntity

app/src/main/res/drawable/app_ic_dates_selector.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<selector xmlns:android="http://schemas.android.com/apk/res/android">
33
<item android:drawable="@drawable/app_ic_dates_cloud_fill" android:state_checked="true" />
44
<item android:drawable="@drawable/app_ic_dates_cloud_outline" />
5-
</selector>
5+
</selector>

core/src/main/java/org/openedx/core/data/api/CourseApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,5 @@ interface CourseApi {
125125
): CourseProgressResponse
126126

127127
@POST("/api/course_experience/v1/reset_all_relative_course_deadlines/")
128-
suspend fun shiftDueDate()
128+
suspend fun shiftAllDueDates()
129129
}

core/src/main/java/org/openedx/core/data/model/CourseDatesResponse.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ data class CourseDatesResponse(
5050
count = count,
5151
next = next,
5252
previous = previous,
53-
results = results
54-
.mapNotNull { it.mapToDomain() }
55-
.sortedBy { it.dueDate }
53+
results = results.mapNotNull { it.mapToDomain() }
5654
)
5755
}
5856
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.openedx.core.data.model.room
2+
3+
import androidx.room.ColumnInfo
4+
import androidx.room.Entity
5+
import androidx.room.PrimaryKey
6+
import org.openedx.core.data.model.CourseDate
7+
import org.openedx.core.utils.TimeUtils
8+
import org.openedx.core.domain.model.CourseDate as DomainCourseDate
9+
10+
@Entity(tableName = "course_dates_table")
11+
data class CourseDateEntity(
12+
@PrimaryKey(autoGenerate = true)
13+
@ColumnInfo("id")
14+
val id: Int,
15+
@ColumnInfo("first_component_block_id")
16+
val firstComponentBlockId: String?,
17+
@ColumnInfo("course_id")
18+
val courseId: String,
19+
@ColumnInfo("due_date")
20+
val dueDate: String?,
21+
@ColumnInfo("assignment_title")
22+
val assignmentTitle: String?,
23+
@ColumnInfo("learner_has_access")
24+
val learnerHasAccess: Boolean?,
25+
@ColumnInfo("relative")
26+
val relative: Boolean?,
27+
@ColumnInfo("course_name")
28+
val courseName: String?,
29+
) {
30+
31+
fun mapToDomain(): DomainCourseDate? {
32+
val dueDate = TimeUtils.iso8601ToDate(dueDate ?: "")
33+
return DomainCourseDate(
34+
courseId = courseId,
35+
firstComponentBlockId = firstComponentBlockId ?: "",
36+
dueDate = dueDate ?: return null,
37+
assignmentTitle = assignmentTitle ?: "",
38+
learnerHasAccess = learnerHasAccess ?: false,
39+
relative = relative ?: false,
40+
courseName = courseName ?: ""
41+
)
42+
}
43+
44+
companion object {
45+
fun createFrom(courseDate: CourseDate): CourseDateEntity {
46+
with(courseDate) {
47+
return CourseDateEntity(
48+
id = 0,
49+
courseId = courseId,
50+
firstComponentBlockId = firstComponentBlockId,
51+
dueDate = dueDate,
52+
assignmentTitle = assignmentTitle,
53+
learnerHasAccess = learnerHasAccess,
54+
relative = relative,
55+
courseName = courseName
56+
)
57+
}
58+
}
59+
}
60+
}

core/src/main/java/org/openedx/core/data/model/room/CourseDatesResponseEntity.kt

Lines changed: 0 additions & 97 deletions
This file was deleted.

core/src/main/java/org/openedx/core/presentation/dates/DatesUI.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import org.openedx.core.ui.theme.appColors
3535
import org.openedx.core.ui.theme.appTypography
3636
import org.openedx.core.utils.TimeUtils.formatToString
3737
import org.openedx.core.utils.clearTime
38+
import org.openedx.core.utils.isToday
3839

3940
@Composable
4041
private fun CourseDateBlockSectionGeneric(
@@ -261,13 +262,15 @@ private fun CourseDateItem(
261262
if (isMiddleChild) {
262263
Spacer(modifier = Modifier.height(20.dp))
263264
}
264-
val timeTitle = formatToString(context, dateBlock.dueDate, useRelativeDates)
265-
Text(
266-
text = timeTitle,
267-
style = MaterialTheme.appTypography.labelMedium,
268-
color = MaterialTheme.appColors.textDark,
269-
maxLines = 1,
270-
)
265+
if (!dateBlock.dueDate.isToday()) {
266+
val timeTitle = formatToString(context, dateBlock.dueDate, useRelativeDates)
267+
Text(
268+
text = timeTitle,
269+
style = MaterialTheme.appTypography.labelMedium,
270+
color = MaterialTheme.appColors.textDark,
271+
maxLines = 1,
272+
)
273+
}
271274
Row(
272275
modifier = Modifier
273276
.fillMaxWidth()

dates/proguard-rules.pro

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
# Add project specific ProGuard rules here.
2-
# You can control the set of applied configuration files using the
3-
# proguardFiles setting in build.gradle.
4-
#
5-
# For more details, see
6-
# http://developer.android.com/guide/developing/tools/proguard.html
7-
8-
# If your project uses WebView with JS, uncomment the following
9-
# and specify the fully qualified class name to the JavaScript interface
10-
# class:
11-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12-
# public *;
13-
#}
14-
15-
# Uncomment this to preserve the line number information for
16-
# debugging stack traces.
17-
#-keepattributes SourceFile,LineNumberTable
18-
19-
# If you keep the line number information, uncomment this to
20-
# hide the original source file name.
21-
#-renamesourcefileattribute SourceFile
1+
# Prevent shrinking, optimization, and obfuscation of the library when consumed by other modules.
2+
# This ensures that all classes and methods remain available for use by the consumer of the library.
3+
# Disabling these steps at the library level is important because the main app module will handle
4+
# shrinking, optimization, and obfuscation for the entire application, including this library.
5+
-dontshrink
6+
-dontoptimize
7+
-dontobfuscate

0 commit comments

Comments
 (0)