Skip to content

Commit 0ae4d9f

Browse files
authored
feat(multipleThemesQVST): permite to manage multiple themes on QVST (#36)
1 parent 20d94ca commit 0ae4d9f

File tree

12 files changed

+131
-78
lines changed

12 files changed

+131
-78
lines changed

app/build.gradle

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'com.android.application'
33
id 'org.jetbrains.kotlin.android'
4+
id 'org.jetbrains.kotlin.plugin.compose' version '2.2.0'
45
id 'com.google.gms.google-services'
56
id "com.google.devtools.ksp"
67
id "org.sonarqube" version "4.2.1.3168"
@@ -26,6 +27,8 @@ android {
2627
namespace 'com.xpeho.xpeapp'
2728
compileSdk 36
2829

30+
ndkVersion '28.2.13676358'
31+
2932
defaultConfig {
3033
applicationId "com.xpeho.xpeapp"
3134
minSdk 26
@@ -39,6 +42,12 @@ android {
3942
}
4043
}
4144

45+
packagingOptions {
46+
jniLibs {
47+
useLegacyPackaging = false
48+
}
49+
}
50+
4251
testOptions {
4352
unitTests.all {
4453
jacoco {
@@ -80,10 +89,9 @@ android {
8089
}
8190
buildFeatures {
8291
compose true
83-
buildConfig = true
92+
buildConfig = true // déplacé depuis gradle.properties
8493
}
8594
composeOptions {
86-
kotlinCompilerExtensionVersion = '1.5.1'
8795
}
8896
packagingOptions {
8997
resources {
@@ -153,68 +161,68 @@ sonar {
153161
}
154162

155163
dependencies {
156-
157-
implementation 'androidx.core:core-ktx:1.13.1'
158-
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.6'
159-
implementation 'androidx.activity:activity-compose:1.9.2'
160-
implementation "androidx.compose.ui:ui:$compose_ui_version"
161-
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
162-
implementation("androidx.compose.material3:material3-android:1.3.0")
164+
implementation('org.jetbrains.kotlin:kotlin-stdlib:2.2.0')
165+
implementation 'androidx.core:core-ktx:1.17.0'
166+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.9.4'
167+
implementation 'androidx.activity:activity-compose:1.11.0'
168+
implementation "androidx.compose.ui:ui:1.9.2"
169+
implementation "androidx.compose.ui:ui-tooling-preview:1.9.2"
170+
implementation('androidx.compose.material3:material3-android:1.4.0')
163171
implementation("androidx.core:core-splashscreen:1.0.1")
164-
implementation 'androidx.core:core-ktx:1.13.1'
165-
implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.1'
172+
implementation 'androidx.core:core-ktx:1.17.0'
173+
implementation 'androidx.constraintlayout:constraintlayout-compose:1.1.1'
166174
implementation "androidx.compose.material:material-icons-core:1.7.3"
167-
implementation "androidx.compose.material:material-icons-extended:1.7.3"
168-
implementation "androidx.compose.animation:animation-core:$compose_ui_version"
169-
implementation 'androidx.fragment:fragment:1.3.0'
175+
implementation 'androidx.compose.material:material-icons-extended:1.7.8'
176+
implementation "androidx.compose.animation:animation-core:1.9.2"
177+
implementation 'androidx.fragment:fragment:1.8.9'
170178

171179
// Test
172180
implementation 'androidx.lifecycle:lifecycle-runtime-compose:2.8.6'
173181
testImplementation 'junit:junit:4.13.2'
174-
testImplementation "io.mockk:mockk:1.13.13"
182+
testImplementation 'io.mockk:mockk:1.14.5'
175183

176184
// Android Test
177-
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
178-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
179-
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
185+
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
186+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
187+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.9.2"
180188

181189
// Debug implementation
182-
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
183-
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
190+
debugImplementation "androidx.compose.ui:ui-tooling:1.9.2"
191+
debugImplementation "androidx.compose.ui:ui-test-manifest:1.9.2"
184192

185193
// Import the BoM for the Firebase platform
186-
implementation platform("com.google.firebase:firebase-bom:33.4.0")
194+
implementation platform('com.google.firebase:firebase-bom:34.3.0')
187195

188196
// Firebase
189-
implementation("com.google.firebase:firebase-auth-ktx")
190-
implementation 'com.google.firebase:firebase-firestore-ktx:25.1.0'
191-
implementation 'com.google.firebase:firebase-messaging:24.0.2'
192-
implementation 'com.google.firebase:firebase-storage-ktx:21.0.1'
197+
implementation("com.google.firebase:firebase-auth-ktx:22.3.0")
198+
implementation 'com.google.firebase:firebase-firestore-ktx:25.1.4'
199+
implementation 'com.google.firebase:firebase-messaging:25.0.1'
200+
implementation 'com.google.firebase:firebase-storage-ktx:21.0.2'
193201
implementation "com.google.firebase:firebase-analytics"
194202

195203
// Navigation
196-
implementation "androidx.navigation:navigation-compose:2.8.2"
204+
implementation 'androidx.navigation:navigation-compose:2.9.5'
197205

198206
// Use Json
199-
implementation "com.google.code.gson:gson:2.10.1"
207+
implementation 'com.google.code.gson:gson:2.13.2'
200208

201209
//ViewModel
202-
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.6"
210+
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.9.4'
203211

204212
//Retrofit for http requests
205-
implementation "com.squareup.retrofit2:retrofit:2.9.0"
206-
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
207-
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
208-
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
213+
implementation 'com.squareup.retrofit2:retrofit:3.0.0'
214+
implementation 'com.squareup.retrofit2:converter-gson:3.0.0'
215+
implementation 'com.squareup.okhttp3:logging-interceptor:5.1.0'
216+
implementation 'com.squareup.okhttp3:okhttp:5.1.0'
209217

210218
//Local data storage
211-
implementation "androidx.datastore:datastore-preferences:1.1.1"
219+
implementation 'androidx.datastore:datastore-preferences:1.1.7'
212220
implementation "androidx.security:security-crypto:1.0.0"
213221
implementation "androidx.security:security-identity-credential:1.0.0-alpha03"
214222

215223
//Notifications
216-
implementation("com.google.accompanist:accompanist-systemuicontroller:0.27.0")
217-
implementation("com.google.accompanist:accompanist-permissions:0.31.1-alpha")
224+
implementation('com.google.accompanist:accompanist-systemuicontroller:0.36.0')
225+
implementation('com.google.accompanist:accompanist-permissions:0.37.3')
218226

219227
//XpehoUI
220228
implementation "com.xpeho.packages:xpeho_ui_android:1.7.0"

app/src/main/java/com/xpeho/xpeapp/data/entity/QvstCampaignEntity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.xpeho.xpeapp.data.entity
33
data class QvstCampaignEntity(
44
val id: String,
55
val name: String,
6-
val themeName: String,
6+
val themeNames: List<String>,
77
val status: String,
88
val outdated: Boolean,
99
val completed: Boolean,

app/src/main/java/com/xpeho/xpeapp/data/model/qvst/QvstCampaign.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.google.gson.annotations.SerializedName
55
data class QvstCampaign(
66
val id: String,
77
val name: String,
8-
val theme: QvstTheme,
8+
@SerializedName("themes") val themes: List<QvstTheme> = emptyList(),
99
val status: String,
1010
@SerializedName("start_date") val startDate: String,
1111
@SerializedName("end_date") val endDate: String,

app/src/main/java/com/xpeho/xpeapp/data/service/WordpressRepository.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ class WordpressRepository(
106106

107107
val completed = campaignProgress?.let {
108108
it.answeredQuestions >= it.totalQuestions
109-
} ?: false
109+
} == true
110110

111111
return QvstCampaignEntity(
112112
id = campaign.id,
113113
name = campaign.name,
114-
themeName = campaign.theme.name,
114+
themeNames = campaign.themes.map { it.name },
115115
status = campaign.status,
116116
outdated = remainingDays <= 0,
117117
completed = completed,
@@ -414,4 +414,3 @@ class WordpressRepository(
414414
return today.format(formatter)
415415
}
416416
}
417-

app/src/main/java/com/xpeho/xpeapp/domain/FeatureFlippingManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import kotlinx.coroutines.CoroutineScope
99
import kotlinx.coroutines.Dispatchers
1010
import kotlinx.coroutines.flow.MutableStateFlow
1111
import kotlinx.coroutines.launch
12-
import okhttp3.internal.toImmutableMap
1312
import java.io.IOException
1413

1514
class FeatureFlippingManager(
@@ -62,7 +61,7 @@ class FeatureFlippingManager(
6261
}
6362
}
6463

65-
_featuresState.value = FeatureFlippingState.SUCCESS(featureEnabled.toImmutableMap())
64+
_featuresState.value = FeatureFlippingState.SUCCESS(featureEnabled.toMap())
6665
}
6766
}
6867

app/src/main/java/com/xpeho/xpeapp/ui/components/qvst/QvstCard.kt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package com.xpeho.xpeapp.ui.components.qvst
22

33
import androidx.activity.compose.rememberLauncherForActivityResult
44
import androidx.activity.result.contract.ActivityResultContracts
5+
import androidx.compose.foundation.layout.Row
6+
import androidx.compose.foundation.layout.Spacer
57
import androidx.compose.foundation.layout.size
8+
import androidx.compose.foundation.layout.width
69
import androidx.compose.material3.Icon
710
import androidx.compose.runtime.Composable
811
import androidx.compose.runtime.key
@@ -108,12 +111,17 @@ private fun SeeResultButton(campaign: QvstCampaignEntity) {
108111
private fun getTagsList(campaign: QvstCampaignEntity): @Composable() (() -> Unit) {
109112

110113
// Init the tagsList depending the data that we got
111-
val tagPillTheme: @Composable() () -> Unit = {
112-
TagPill(
113-
label = campaign.themeName,
114-
backgroundColor = XpehoColors.GREEN_DARK_COLOR,
115-
size = 9.sp
116-
)
114+
val tagPillThemes: @Composable() () -> Unit = {
115+
Row {
116+
campaign.themeNames.forEach { theme ->
117+
TagPill(
118+
label = theme,
119+
backgroundColor = XpehoColors.GREEN_DARK_COLOR,
120+
size = 9.sp
121+
)
122+
Spacer(modifier = Modifier.width(8.dp))
123+
}
124+
}
117125
}
118126

119127
var tagPillDeadline: @Composable() () -> Unit
@@ -175,7 +183,7 @@ private fun getTagsList(campaign: QvstCampaignEntity): @Composable() (() -> Unit
175183
}
176184

177185
return {
178-
tagPillTheme.invoke()
186+
tagPillThemes.invoke()
179187
tagPillDeadline.invoke()
180188
tagPillCompletion.invoke()
181189
}

app/src/main/java/com/xpeho/xpeapp/ui/page/qvst/QvstCampaignDetail.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fun QvstCampaignDetailPage(
138138
Column {
139139
campaign?.let {
140140
Title(
141-
label = it.themeName
141+
label = it.name
142142
)
143143
}
144144
Spacer(modifier = Modifier.height(40.dp))
@@ -294,4 +294,14 @@ fun redirectOnSuccess(
294294
)
295295
}
296296
}
297-
}
297+
}
298+
299+
// Extension pour remplacer la dernière virgule par " et "
300+
fun String.replaceLastCommaWithEt(): String {
301+
val lastComma = this.lastIndexOf(", ")
302+
return if (lastComma != -1) {
303+
this.substring(0, lastComma) + " et " + this.substring(lastComma + 2)
304+
} else {
305+
this
306+
}
307+
}

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<string name="qvst_answers_saved_title">QVST</string>
3636
<string name="qvst_campaign_detail_all_questions_answered">Vous avez répondu à toutes les questions</string>
3737
<string name="qvst_campaign_detail_questions_answered">
38-
Vous avez répondu à %s questions sur %s
38+
Vous avez répondu à %1$s questions sur %2$s
3939
</string>
4040
<string name="qvst_campaign_detail_answered_questions">Questions répondues</string>
4141
<string name="qvst_campaign_detail_answer">Réponse : %s</string>

0 commit comments

Comments
 (0)