Skip to content

Commit

Permalink
feat: update openfeedback library to support comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Nov 8, 2023
1 parent 465033c commit 2e70429
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -131,7 +131,7 @@ fun MainMobile(
) {
ScheduleDetailVM(
scheduleId = it.arguments?.getString("scheduleId")!!,
openFeedbackState = openFeedbackState,
openfeedbackFirebaseConfig = openfeedbackFirebaseConfig,
agendaRepository = agendaRepository,
onBackClicked = {
navController.popBackStack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -78,7 +79,7 @@ fun ScheduleDetail(
OpenFeedbackSection(
openFeedbackProjectId = talk.openFeedbackProjectId!!,
openFeedbackSessionId = talk.openFeedbackSessionId!!,
openFeedbackState = openFeedbackState,
openfeedbackFirebaseConfig = openfeedbackFirebaseConfig,
canGiveFeedback = talk.canGiveFeedback
)
}
Expand All @@ -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 = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ 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

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ScheduleDetailVM(
scheduleId: String,
openFeedbackState: OpenFeedbackConfig,
openfeedbackFirebaseConfig: OpenFeedbackFirebaseConfig,
agendaRepository: AgendaRepository,
onBackClicked: () -> Unit,
onSpeakerClicked: (id: String) -> Unit,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
Expand All @@ -35,10 +34,9 @@ fun OpenFeedbackSection(
style = subtitleTextStyle
)
OpenFeedback(
config = openFeedbackState,
config = openfeedbackFirebaseConfig,
projectId = openFeedbackProjectId,
sessionId = openFeedbackSessionId,
language = Locale.getDefault().language
sessionId = openFeedbackSessionId
)
}
}
Expand Down

0 comments on commit 2e70429

Please sign in to comment.