Skip to content

Commit db686e3

Browse files
committed
Merge branch 'develop'
2 parents 810aeef + 3e07200 commit db686e3

File tree

41 files changed

+1091
-1237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1091
-1237
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ plugins {
2121
android {
2222
namespace = "de.tum.informatics.www1.artemis.native_app.android"
2323

24-
val versionName = "2.1.1"
24+
val versionName = "2.1.2"
2525
val versionCode = 624
2626

2727
setProperty("archivesBaseName", "artemis-android-$versionName-$versionCode")

app/src/main/java/de/tum/informatics/www1/artemis/native_app/android/ui/MainActivity.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ class MainActivity : AppCompatActivity(),
249249
if (updateResult?.updateAvailable == true) {
250250
navController.navigateToUpdateScreen(
251251
updateResult!!.currentVersion,
252-
updateResult!!.minVersion
252+
updateResult!!.minVersion,
253+
updateResult!!.recommendedVersion
253254
)
254255
}
255256
}
@@ -262,7 +263,12 @@ class MainActivity : AppCompatActivity(),
262263
Intent(this@MainActivity, OssLicensesMenuActivity::class.java)
263264
startActivity(intent)
264265
},
265-
onOpenPlayStore = ::openPlayStore
266+
onOpenPlayStore = ::openPlayStore,
267+
onSkipUpdate = {
268+
// Mark this recommended update as dismissed
269+
updateRepository.dismissRecommendedUpdate()
270+
navController.navigateUp()
271+
}
266272
)
267273
}
268274
}

app/src/main/java/de/tum/informatics/www1/artemis/native_app/android/ui/RootNavGraph.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import de.tum.informatics.www1.artemis.native_app.feature.settings.ui.settingsNa
3535
fun NavGraphBuilder.rootNavGraph(
3636
navController: NavController,
3737
onDisplayThirdPartyLicenses: () -> Unit,
38-
onOpenPlayStore : () -> Unit
38+
onOpenPlayStore: () -> Unit,
39+
onSkipUpdate: () -> Unit
3940
) {
4041
val onNavigateToTextExerciseParticipation =
4142
{ exerciseId: Long, participationId: Long ->
@@ -178,7 +179,8 @@ fun NavGraphBuilder.rootNavGraph(
178179
)
179180

180181
updateNavGraph(
181-
onOpenPlayStore = onOpenPlayStore
182+
onOpenPlayStore = onOpenPlayStore,
183+
onSkipUpdate = onSkipUpdate
182184
)
183185

184186
courseNotificationScreen(

feature/course-notifications/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/coursenotifications/course_notification_model/CourseNotification.kt

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,9 @@ package de.tum.informatics.www1.artemis.native_app.feature.coursenotifications.c
33
import androidx.compose.runtime.Composable
44
import androidx.compose.ui.res.stringResource
55
import de.tum.informatics.www1.artemis.native_app.feature.coursenotifications.R
6-
import de.tum.informatics.www1.artemis.native_app.feature.push.notification_model.ArtemisNotification
7-
import de.tum.informatics.www1.artemis.native_app.feature.push.notification_model.NotificationType
8-
import kotlinx.datetime.Instant
96
import kotlinx.serialization.SerialName
107
import kotlinx.serialization.Serializable
118

12-
@Serializable
13-
data class CourseNotification(
14-
val notificationType: CourseNotificationType,
15-
val notificationId: Int,
16-
val courseId: Int,
17-
val creationDate: Instant,
18-
val category: NotificationCategory,
19-
val status: NotificationStatus,
20-
val notification: ArtemisNotification<NotificationType>
21-
)
22-
23-
@Serializable
24-
data class NotificationPage(
25-
val pageNumber: Int,
26-
val pageSize: Int,
27-
val totalElements: Int,
28-
val totalPages: Int,
29-
val content: List<CourseNotification>?
30-
)
31-
enum class NotificationCategory {
32-
COMMUNICATION,
33-
GENERAL,
34-
UNKNOWN
35-
}
36-
37-
enum class NotificationFilter {
38-
COMMUNICATION,
39-
GENERAL
40-
}
41-
42-
enum class NotificationStatus {
43-
UNSEEN,
44-
SEEN,
45-
UNKNOWN
46-
}
479

4810
@Serializable
4911
enum class CourseNotificationType {

feature/force-update/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/force_update/repository/UpdateRepository.kt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class UpdateRepository(
1919

2020
private var lastCheckedTimestamp: Long = 0L
2121
private var lastResult: UpdateResult? = null
22+
private var isCurrentRecommendedUpdateDismissed = false
2223

2324
private val currentVersionNormalized = appVersionProvider.appVersion.normalized
2425

@@ -31,15 +32,36 @@ class UpdateRepository(
3132
response = response,
3233
currentVersion = currentVersionNormalized
3334
)
35+
36+
// Check if this recommended update should be shown
37+
val shouldShowRecommended = if (result.updateAvailable && !result.forceUpdate) {
38+
!isCurrentRecommendedUpdateDismissed
39+
} else {
40+
result.updateAvailable
41+
}
42+
43+
val finalResult = result.copy(updateAvailable = shouldShowRecommended)
44+
3445
lastCheckedTimestamp = now
35-
lastResult = result
36-
_updateResultFlow.value = result
46+
lastResult = finalResult
47+
_updateResultFlow.value = finalResult
48+
}
49+
50+
fun dismissRecommendedUpdate() {
51+
isCurrentRecommendedUpdateDismissed = true
52+
// Update the current result to not show the update
53+
lastResult?.let { result ->
54+
if (!result.forceUpdate) {
55+
_updateResultFlow.value = result.copy(updateAvailable = false)
56+
}
57+
}
3758
}
3859

3960
data class UpdateResult(
4061
val updateAvailable: Boolean,
4162
val forceUpdate: Boolean,
4263
val currentVersion: NormalizedAppVersion,
43-
val minVersion: NormalizedAppVersion
64+
val minVersion: NormalizedAppVersion,
65+
val recommendedVersion: NormalizedAppVersion
4466
)
4567
}

feature/force-update/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/force_update/repository/UpdateUtil.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,29 @@ object UpdateUtil {
2828

2929
// 🔍 Version check
3030
val serverMinVersion = data.minVersion
31+
val serverRecommendedVersion = data.recommendedVersion
32+
33+
// Check if update is required (current version below min version)
3134
val updateRequired = serverMinVersion > currentVersion
35+
36+
// Check if update is recommended (current version below recommended version but above min version)
37+
val updateRecommended = !updateRequired && serverRecommendedVersion > currentVersion
3238

3339
UpdateRepository.UpdateResult(
34-
updateAvailable = updateRequired,
40+
updateAvailable = updateRequired || updateRecommended,
3541
forceUpdate = updateRequired,
3642
currentVersion = currentVersion,
37-
minVersion = serverMinVersion
43+
minVersion = serverMinVersion,
44+
recommendedVersion = serverRecommendedVersion
3845
)
3946
}
4047

4148
else -> UpdateRepository.UpdateResult(
4249
updateAvailable = false,
4350
forceUpdate = false,
4451
currentVersion = currentVersion,
45-
minVersion = currentVersion
52+
minVersion = currentVersion,
53+
recommendedVersion = currentVersion
4654
)
4755
}
4856
}

feature/force-update/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/force_update/ui/UpdateNavGraph.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,42 @@ import kotlinx.serialization.Serializable
1010
@Serializable
1111
private data class UpdateScreenRoute(
1212
val currentVersion: String,
13-
val minVersion: String
13+
val minVersion: String,
14+
val recommendedVersion: String
1415
)
1516

1617
fun NavController.navigateToUpdateScreen(
1718
currentVersion: NormalizedAppVersion,
18-
minVersion: NormalizedAppVersion
19+
minVersion: NormalizedAppVersion,
20+
recommendedVersion: NormalizedAppVersion
1921
) {
20-
navigate(UpdateScreenRoute(currentVersion.toString(), minVersion.toString())) {
22+
navigate(
23+
UpdateScreenRoute(
24+
currentVersion = currentVersion.toString(),
25+
minVersion = minVersion.toString(),
26+
recommendedVersion = recommendedVersion.toString()
27+
)
28+
) {
2129
popUpTo(graph.startDestinationId) { inclusive = true }
2230
}
2331
}
2432

2533
fun NavGraphBuilder.updateNavGraph(
2634
onOpenPlayStore: () -> Unit,
35+
onSkipUpdate: () -> Unit
2736
) {
2837
composable<UpdateScreenRoute> { backStackEntry ->
2938
val route: UpdateScreenRoute = backStackEntry.toRoute()
3039
val currentVersion = NormalizedAppVersion(route.currentVersion)
3140
val minVersion = NormalizedAppVersion(route.minVersion)
41+
val recommendedVersion = NormalizedAppVersion(route.recommendedVersion)
3242

3343
UpdateScreen(
3444
onDownloadClick = onOpenPlayStore,
45+
onSkipClick = onSkipUpdate,
3546
currentVersion = currentVersion,
36-
minVersion = minVersion
47+
minVersion = minVersion,
48+
recommendedVersion = recommendedVersion
3749
)
3850
}
3951
}

feature/force-update/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/force_update/ui/UpdateScreen.kt

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.compose.material3.Button
1515
import androidx.compose.material3.MaterialTheme
1616
import androidx.compose.material3.Scaffold
1717
import androidx.compose.material3.Text
18+
import androidx.compose.material3.TextButton
1819
import androidx.compose.runtime.Composable
1920
import androidx.compose.ui.Alignment
2021
import androidx.compose.ui.Modifier
@@ -29,9 +30,13 @@ import de.tum.informatics.www1.artemis.native_app.feature.forceupdate.R
2930
@Composable
3031
fun UpdateScreen(
3132
onDownloadClick: () -> Unit,
33+
onSkipClick: () -> Unit,
3234
currentVersion: NormalizedAppVersion,
33-
minVersion: NormalizedAppVersion
35+
minVersion: NormalizedAppVersion,
36+
recommendedVersion: NormalizedAppVersion
3437
) {
38+
val isRecommended = recommendedVersion > currentVersion && currentVersion > minVersion
39+
3540
Scaffold { paddingValues ->
3641
Column(
3742
modifier = Modifier
@@ -63,31 +68,58 @@ fun UpdateScreen(
6368
)
6469

6570
Text(
66-
text = stringResource(R.string.update_screen_download_message),
71+
text = if (isRecommended) {
72+
stringResource(R.string.update_screen_recommended_download_message)
73+
} else {
74+
stringResource(R.string.update_screen_download_message)
75+
},
6776
style = MaterialTheme.typography.bodyLarge,
6877
textAlign = TextAlign.Center
6978
)
7079

7180
Spacer(modifier = Modifier.height(Spacings.UpdateScreen.medium))
7281

7382
Text(
74-
text = stringResource(
75-
R.string.update_screen_version_info,
76-
currentVersion,
77-
minVersion
78-
),
83+
text = if (isRecommended) {
84+
stringResource(
85+
R.string.update_screen_recommended_version_info,
86+
currentVersion,
87+
recommendedVersion
88+
)
89+
} else {
90+
stringResource(
91+
R.string.update_screen_version_info,
92+
currentVersion,
93+
minVersion
94+
)
95+
},
7996
style = MaterialTheme.typography.bodyMedium,
8097
textAlign = TextAlign.Center,
8198
color = MaterialTheme.colorScheme.secondary
8299
)
83100

84101
}
102+
103+
// Download button
85104
Button(
86-
onClick = onDownloadClick,
105+
onClick = {
106+
onDownloadClick()
107+
},
87108
modifier = Modifier.fillMaxWidth()
88109
) {
89110
Text(text = stringResource(R.string.update_screen_downlaod_button))
90111
}
112+
113+
if (isRecommended) {
114+
TextButton(
115+
onClick = {
116+
onSkipClick()
117+
},
118+
modifier = Modifier.fillMaxWidth()
119+
) {
120+
Text(text = "Skip")
121+
}
122+
}
91123
}
92124
}
93125
}

feature/force-update/src/main/res/values/update_screen_strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
<resources>
33
<string name="update_screen_new_update_available">New update available</string>
44
<string name="update_screen_download_message">Please update Artemis to the latest version to ensure you have a smooth experience. You can download the latest version from the Play Store.</string>
5+
<string name="update_screen_recommended_download_message">A new version of Artemis is available with improvements and new features. We recommend updating to the latest version for the best experience.</string>
56
<string name="update_screen_downlaod_button">Download</string>
67
<string name="update_screen_version_info">
78
You are using version %1$s while the oldest version currently supported is %2$s.
89
</string>
10+
<string name="update_screen_recommended_version_info">
11+
You are using version %1$s while the recommended version is %2$s.
12+
</string>
913

1014
</resources>

0 commit comments

Comments
 (0)