From 2e70429b49368c5a5e57d325828dd7c85794b1e2 Mon Sep 17 00:00:00 2001 From: Gerard Paligot Date: Wed, 8 Nov 2023 21:40:57 +0100 Subject: [PATCH] feat: update openfeedback library to support comments. --- .../gdglille/devfest/android/MainActivity.kt | 4 +-- .../devfest/android/MainApplication.kt | 16 +++++------- gradle/libs.versions.toml | 2 +- .../devfest/android/theme/MainMobile.kt | 6 ++--- .../m3/schedules/feature/ScheduleDetail.kt | 26 +++++++++---------- .../m3/schedules/feature/ScheduleDetailVM.kt | 6 ++--- .../ui/schedule/OpenFeedbackSection.kt | 10 +++---- 7 files changed, 32 insertions(+), 38 deletions(-) diff --git a/androidApp/src/main/java/org/gdglille/devfest/android/MainActivity.kt b/androidApp/src/main/java/org/gdglille/devfest/android/MainActivity.kt index 6d49cdb26..439d46988 100644 --- a/androidApp/src/main/java/org/gdglille/devfest/android/MainActivity.kt +++ b/androidApp/src/main/java/org/gdglille/devfest/android/MainActivity.kt @@ -97,7 +97,7 @@ class MainActivity : ComponentActivity() { getSystemService(ALARM_SERVICE) as AlarmManager, AlarmIntentFactoryImpl ) - val openFeedbackState = (application as MainApplication).openFeedbackConfig + val openfeedbackFirebaseConfig = (application as MainApplication).openFeedbackConfig setContent { val inDarkTheme = isSystemInDarkTheme() DisposableEffect(inDarkTheme) { @@ -120,7 +120,7 @@ class MainActivity : ComponentActivity() { userRepository = userRepository, speakerRepository = speakerRepository, alarmScheduler = scheduler, - openFeedbackState = openFeedbackState, + openfeedbackFirebaseConfig = openfeedbackFirebaseConfig, launchUrl = { launchUrl(it) }, onContactExportClicked = { export -> val uri: Uri = FileProvider.getUriForFile( diff --git a/androidApp/src/main/java/org/gdglille/devfest/android/MainApplication.kt b/androidApp/src/main/java/org/gdglille/devfest/android/MainApplication.kt index 4a946bf32..666982538 100644 --- a/androidApp/src/main/java/org/gdglille/devfest/android/MainApplication.kt +++ b/androidApp/src/main/java/org/gdglille/devfest/android/MainApplication.kt @@ -6,24 +6,22 @@ import coil.ImageLoaderFactory import coil.decode.SvgDecoder import coil.disk.DiskCache import coil.memory.MemoryCache -import io.openfeedback.android.OpenFeedbackConfig +import io.openfeedback.android.viewmodels.OpenFeedbackFirebaseConfig private const val MemoryCacheSize = 0.25 private const val DiskCacheSize = 0.10 class MainApplication : Application(), ImageLoaderFactory { - lateinit var openFeedbackConfig: OpenFeedbackConfig + lateinit var openFeedbackConfig: OpenFeedbackFirebaseConfig override fun onCreate() { super.onCreate() - openFeedbackConfig = OpenFeedbackConfig( + openFeedbackConfig = OpenFeedbackFirebaseConfig( context = this, - firebaseConfig = OpenFeedbackConfig.FirebaseConfig( - projectId = BuildConfig.FIREBASE_PROJECT_ID, - applicationId = BuildConfig.APPLICATION_ID, - apiKey = BuildConfig.FIREBASE_API_KEY, - databaseUrl = "https://${BuildConfig.FIREBASE_PROJECT_ID}.firebaseio.com" - ) + projectId = BuildConfig.FIREBASE_PROJECT_ID, + applicationId = BuildConfig.APPLICATION_ID, + apiKey = BuildConfig.FIREBASE_API_KEY, + databaseUrl = "https://${BuildConfig.FIREBASE_PROJECT_ID}.firebaseio.com" ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 204756fef..cbdee9ec6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,7 @@ composeActivity = "1.8.0" composeNavigation = "2.7.2" composeFont = "1.0.0" composeRichText = "0.11.0" -composeOpenfeedback = "0.0.8-SNAPSHOT" +composeOpenfeedback = "1.0.0-SNAPSHOT" gcpFirestore = "3.7.3" gcpStorage = "2.3.0" gcpSecret = "2.3.10" diff --git a/theme-m3/main/mobile/src/main/kotlin/org/gdglille/devfest/android/theme/MainMobile.kt b/theme-m3/main/mobile/src/main/kotlin/org/gdglille/devfest/android/theme/MainMobile.kt index 38eae8fd4..9d0a82102 100644 --- a/theme-m3/main/mobile/src/main/kotlin/org/gdglille/devfest/android/theme/MainMobile.kt +++ b/theme-m3/main/mobile/src/main/kotlin/org/gdglille/devfest/android/theme/MainMobile.kt @@ -9,7 +9,7 @@ import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.navArgument import androidx.navigation.navDeepLink -import io.openfeedback.android.OpenFeedbackConfig +import io.openfeedback.android.viewmodels.OpenFeedbackFirebaseConfig import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview import org.gdglille.devfest.AlarmScheduler @@ -40,7 +40,7 @@ fun MainMobile( userRepository: UserRepository, speakerRepository: SpeakerRepository, alarmScheduler: AlarmScheduler, - openFeedbackState: OpenFeedbackConfig, + openfeedbackFirebaseConfig: OpenFeedbackFirebaseConfig, launchUrl: (String) -> Unit, onContactExportClicked: (ExportNetworkingUi) -> Unit, onReportByPhoneClicked: (String) -> Unit, @@ -131,7 +131,7 @@ fun MainMobile( ) { ScheduleDetailVM( scheduleId = it.arguments?.getString("scheduleId")!!, - openFeedbackState = openFeedbackState, + openfeedbackFirebaseConfig = openfeedbackFirebaseConfig, agendaRepository = agendaRepository, onBackClicked = { navController.popBackStack() diff --git a/theme-m3/schedules/schedules-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/feature/ScheduleDetail.kt b/theme-m3/schedules/schedules-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/feature/ScheduleDetail.kt index 6009e875a..e2deb4db5 100644 --- a/theme-m3/schedules/schedules-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/feature/ScheduleDetail.kt +++ b/theme-m3/schedules/schedules-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/feature/ScheduleDetail.kt @@ -15,30 +15,31 @@ import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import io.openfeedback.android.OpenFeedbackConfig +import io.openfeedback.android.viewmodels.OpenFeedbackFirebaseConfig import kotlinx.collections.immutable.persistentListOf import org.gdglille.devfest.android.theme.m3.navigation.TopActions -import org.gdglille.devfest.android.theme.m3.style.appbars.TopAppBar -import org.gdglille.devfest.android.theme.m3.schedules.ui.speakers.SpeakerSection import org.gdglille.devfest.android.theme.m3.schedules.ui.schedule.OpenFeedbackSection import org.gdglille.devfest.android.theme.m3.schedules.ui.schedule.TalkAbstract import org.gdglille.devfest.android.theme.m3.schedules.ui.schedule.TalkSection +import org.gdglille.devfest.android.theme.m3.schedules.ui.speakers.SpeakerSection import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme import org.gdglille.devfest.android.theme.m3.style.R import org.gdglille.devfest.android.theme.m3.style.actions.TopActionsUi +import org.gdglille.devfest.android.theme.m3.style.appbars.TopAppBar import org.gdglille.devfest.models.ui.TalkUi @ExperimentalMaterial3Api @Composable fun ScheduleDetail( talk: TalkUi, - openFeedbackState: OpenFeedbackConfig, + openfeedbackFirebaseConfig: OpenFeedbackFirebaseConfig, onBackClicked: () -> Unit, onSpeakerClicked: (id: String) -> Unit, onShareClicked: (text: String) -> Unit, modifier: Modifier = Modifier, ) { - val textShared = stringResource(id = R.string.input_share_talk, talk.title, talk.speakersSharing) + val textShared = + stringResource(id = R.string.input_share_talk, talk.title, talk.speakersSharing) Scaffold( modifier = modifier, topBar = { @@ -78,7 +79,7 @@ fun ScheduleDetail( OpenFeedbackSection( openFeedbackProjectId = talk.openFeedbackProjectId!!, openFeedbackSessionId = talk.openFeedbackSessionId!!, - openFeedbackState = openFeedbackState, + openfeedbackFirebaseConfig = openfeedbackFirebaseConfig, canGiveFeedback = talk.canGiveFeedback ) } @@ -105,15 +106,12 @@ private fun ScheduleDetailPreview() { Conferences4HallTheme { ScheduleDetail( talk = TalkUi.fake, - openFeedbackState = OpenFeedbackConfig( + openfeedbackFirebaseConfig = OpenFeedbackFirebaseConfig( context = LocalContext.current, - firebaseConfig = OpenFeedbackConfig.FirebaseConfig( - projectId = "", - applicationId = "", - apiKey = "", - databaseUrl = "" - ), - openFeedbackProjectId = "" + projectId = "", + applicationId = "", + apiKey = "", + databaseUrl = "" ), onBackClicked = {}, onSpeakerClicked = {}, diff --git a/theme-m3/schedules/schedules-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/feature/ScheduleDetailVM.kt b/theme-m3/schedules/schedules-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/feature/ScheduleDetailVM.kt index 2ecfe372b..a9a7d34bf 100644 --- a/theme-m3/schedules/schedules-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/feature/ScheduleDetailVM.kt +++ b/theme-m3/schedules/schedules-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/feature/ScheduleDetailVM.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.lifecycle.viewmodel.compose.viewModel -import io.openfeedback.android.OpenFeedbackConfig +import io.openfeedback.android.viewmodels.OpenFeedbackFirebaseConfig import org.gdglille.devfest.android.theme.m3.style.R import org.gdglille.devfest.repositories.AgendaRepository @@ -15,7 +15,7 @@ import org.gdglille.devfest.repositories.AgendaRepository @Composable fun ScheduleDetailVM( scheduleId: String, - openFeedbackState: OpenFeedbackConfig, + openfeedbackFirebaseConfig: OpenFeedbackFirebaseConfig, agendaRepository: AgendaRepository, onBackClicked: () -> Unit, onSpeakerClicked: (id: String) -> Unit, @@ -31,7 +31,7 @@ fun ScheduleDetailVM( is ScheduleUiState.Failure -> Text(text = stringResource(id = R.string.text_error)) is ScheduleUiState.Success -> ScheduleDetail( talk = (uiState.value as ScheduleUiState.Success).talk, - openFeedbackState = openFeedbackState, + openfeedbackFirebaseConfig = openfeedbackFirebaseConfig, modifier = modifier, onBackClicked = onBackClicked, onSpeakerClicked = onSpeakerClicked, diff --git a/theme-m3/schedules/schedules-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/ui/schedule/OpenFeedbackSection.kt b/theme-m3/schedules/schedules-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/ui/schedule/OpenFeedbackSection.kt index ef6f8b50b..627eb11e5 100644 --- a/theme-m3/schedules/schedules-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/ui/schedule/OpenFeedbackSection.kt +++ b/theme-m3/schedules/schedules-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/schedules/ui/schedule/OpenFeedbackSection.kt @@ -9,17 +9,16 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.unit.dp -import io.openfeedback.android.OpenFeedbackConfig import io.openfeedback.android.m3.OpenFeedback +import io.openfeedback.android.viewmodels.OpenFeedbackFirebaseConfig import org.gdglille.devfest.android.theme.m3.style.R -import java.util.Locale @Composable fun OpenFeedbackSection( openFeedbackProjectId: String, openFeedbackSessionId: String, canGiveFeedback: Boolean, - openFeedbackState: OpenFeedbackConfig, + openfeedbackFirebaseConfig: OpenFeedbackFirebaseConfig, modifier: Modifier = Modifier, subtitleTextStyle: TextStyle = MaterialTheme.typography.titleLarge, ) { @@ -35,10 +34,9 @@ fun OpenFeedbackSection( style = subtitleTextStyle ) OpenFeedback( - config = openFeedbackState, + config = openfeedbackFirebaseConfig, projectId = openFeedbackProjectId, - sessionId = openFeedbackSessionId, - language = Locale.getDefault().language + sessionId = openFeedbackSessionId ) } }