Small refactor and add FireBase Crashlitycs.
This commit is contained in:
parent
9c8d05e578
commit
f6496e485d
9 changed files with 131 additions and 88 deletions
|
|
@ -2,6 +2,8 @@ plugins {
|
|||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.google.gms.google-services'
|
||||
id 'com.google.firebase.crashlytics'
|
||||
id 'dagger.hilt.android.plugin'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
|
@ -130,7 +132,7 @@ dependencies {
|
|||
implementation "com.github.skydoves:landscapist-glide:1.5.2"
|
||||
kapt 'com.github.bumptech.glide:compiler:4.13.2' // this have to be align with landscapist-glide
|
||||
|
||||
// Reorder element in laylist
|
||||
// Reorder element in lazylist
|
||||
implementation "org.burnoutcrew.composereorderable:reorderable:0.9.6"
|
||||
|
||||
// Navigation
|
||||
|
|
@ -142,6 +144,10 @@ dependencies {
|
|||
// Google sign in.
|
||||
implementation "com.google.android.gms:play-services-auth:20.4.1"
|
||||
|
||||
// Firebase
|
||||
implementation platform('com.google.firebase:firebase-bom:31.3.0')
|
||||
implementation 'com.google.firebase:firebase-crashlytics'
|
||||
|
||||
// RetroFit & Gson for webservice call
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
|
|
|
|||
68
app/src/google-services.json
Normal file
68
app/src/google-services.json
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"project_info": {
|
||||
"project_number": "837508873287",
|
||||
"project_id": "biblib-2b8e6",
|
||||
"storage_bucket": "biblib-2b8e6.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:837508873287:android:52368b2f6ecf2304c90562",
|
||||
"android_client_info": {
|
||||
"package_name": "com.pixelized.biblib"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "837508873287-kar6b3a5phks9n5f4ieoib48cfb3r437.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyAU-JemDic4WFaIq6nTp48uf_P1-pxgARo"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "837508873287-kar6b3a5phks9n5f4ieoib48cfb3r437.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:837508873287:android:200c71bdf4129685c90562",
|
||||
"android_client_info": {
|
||||
"package_name": "com.pixelized.biblib.debug"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "837508873287-kar6b3a5phks9n5f4ieoib48cfb3r437.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyAU-JemDic4WFaIq6nTp48uf_P1-pxgARo"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "837508873287-kar6b3a5phks9n5f4ieoib48cfb3r437.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.pixelized.biblib.ui.screen.home.common.item
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Card
|
||||
|
|
@ -16,11 +15,12 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
import com.pixelized.biblib.utils.extention.bibLib
|
||||
import com.pixelized.biblib.utils.extention.default
|
||||
import com.pixelized.biblib.utils.extention.modifier.drawDiagonalLabel
|
||||
import com.pixelized.biblib.utils.extention.placeholder
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
|
@ -36,7 +36,7 @@ data class LargeBookThumbnailUio(
|
|||
fun LargeBookThumbnail(
|
||||
modifier: Modifier = Modifier,
|
||||
thumbnail: LargeBookThumbnailUio?,
|
||||
onClick: (LargeBookThumbnailUio) -> Unit = default<LargeBookThumbnailUio>(),
|
||||
onClick: (LargeBookThumbnailUio) -> Unit,
|
||||
) {
|
||||
Card(
|
||||
modifier = modifier
|
||||
|
|
@ -62,7 +62,7 @@ fun LargeBookThumbnail(
|
|||
private fun LargeBookThumbnailContent(
|
||||
modifier: Modifier = Modifier,
|
||||
thumbnail: LargeBookThumbnailUio,
|
||||
onClick: (LargeBookThumbnailUio) -> Unit = default<LargeBookThumbnailUio>(),
|
||||
onClick: (LargeBookThumbnailUio) -> Unit,
|
||||
) {
|
||||
GlideImage(
|
||||
modifier = Modifier
|
||||
|
|
@ -115,27 +115,25 @@ private fun Modifier.isNew(
|
|||
@Composable
|
||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun LargeBookThumbnailPreview() {
|
||||
private fun LargeBookThumbnailPreview(
|
||||
@PreviewParameter(LargeBookThumbnailPreviewProvider::class) preview: LargeBookThumbnailUio?,
|
||||
) {
|
||||
BibLibTheme {
|
||||
LargeBookThumbnail(
|
||||
modifier = Modifier.width(168.dp),
|
||||
thumbnail = LargeBookThumbnailUio(
|
||||
id = 0,
|
||||
isNew = true,
|
||||
cover = "",
|
||||
),
|
||||
thumbnail = preview,
|
||||
onClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun LargeBookThumbnailEmptyPreview() {
|
||||
BibLibTheme {
|
||||
LargeBookThumbnail(
|
||||
modifier = Modifier.width(168.dp),
|
||||
thumbnail = null,
|
||||
)
|
||||
}
|
||||
private class LargeBookThumbnailPreviewProvider : PreviewParameterProvider<LargeBookThumbnailUio?> {
|
||||
override val values: Sequence<LargeBookThumbnailUio?> = sequenceOf(
|
||||
LargeBookThumbnailUio(
|
||||
id = 0,
|
||||
isNew = true,
|
||||
cover = "",
|
||||
),
|
||||
null
|
||||
)
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@ import androidx.constraintlayout.compose.Dimension
|
|||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
import com.pixelized.biblib.utils.extention.bibLib
|
||||
import com.pixelized.biblib.utils.extention.default
|
||||
import com.pixelized.biblib.utils.extention.modifier.drawDiagonalLabel
|
||||
import com.pixelized.biblib.utils.extention.placeholder
|
||||
import com.skydoves.landscapist.glide.GlideImage
|
||||
|
|
@ -43,7 +42,7 @@ data class SmallBookThumbnailUio(
|
|||
fun SmallBookThumbnail(
|
||||
modifier: Modifier = Modifier,
|
||||
thumbnail: SmallBookThumbnailUio?,
|
||||
onClick: (SmallBookThumbnailUio) -> Unit = default<SmallBookThumbnailUio>(),
|
||||
onClick: (SmallBookThumbnailUio) -> Unit,
|
||||
) {
|
||||
if (thumbnail != null) {
|
||||
SmallBookThumbnailContent(
|
||||
|
|
@ -62,7 +61,7 @@ fun SmallBookThumbnail(
|
|||
private fun SmallBookThumbnailContent(
|
||||
modifier: Modifier = Modifier,
|
||||
thumbnail: SmallBookThumbnailUio,
|
||||
onClick: (SmallBookThumbnailUio) -> Unit = default<SmallBookThumbnailUio>(),
|
||||
onClick: (SmallBookThumbnailUio) -> Unit,
|
||||
) {
|
||||
Card(
|
||||
modifier = modifier
|
||||
|
|
@ -248,13 +247,14 @@ private fun SmallBookThumbnailPreview() {
|
|||
SmallBookThumbnail(
|
||||
thumbnail = SmallBookThumbnailUio(
|
||||
id = 0,
|
||||
genre = "Sci-Fi",
|
||||
title = "Foundation",
|
||||
genre = "Sci-Fi",
|
||||
author = "Asimov",
|
||||
date = "1951",
|
||||
isNew = true,
|
||||
cover = "",
|
||||
)
|
||||
),
|
||||
onClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -266,6 +266,7 @@ private fun SmallBookThumbnailEmptyPreview() {
|
|||
BibLibTheme {
|
||||
SmallBookThumbnail(
|
||||
thumbnail = null,
|
||||
onClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -13,10 +13,7 @@ import androidx.compose.material.Button
|
|||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.RadioButton
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
|
|
@ -52,8 +49,8 @@ fun DetailScreenSendOption(
|
|||
modifier: Modifier = Modifier,
|
||||
optionViewModel: BookOptionViewModel = hiltViewModel(),
|
||||
emails: List<String>,
|
||||
onHelp: (url: String) -> Unit = default<String>(),
|
||||
onSend: (email: String, format: String) -> Unit = { _, _ -> },
|
||||
onHelp: (url: String) -> Unit,
|
||||
onSend: (email: String, format: String) -> Unit,
|
||||
) {
|
||||
LaunchedEffect(key1 = emails) {
|
||||
optionViewModel.updateEmails(amazonEmails = emails)
|
||||
|
|
@ -74,10 +71,10 @@ fun DetailScreenSendOption(
|
|||
modifier: Modifier = Modifier,
|
||||
emails: List<OptionUio>,
|
||||
formats: List<OptionUio>,
|
||||
onHelp: (url: String) -> Unit = default<String>(),
|
||||
onEmail: (OptionUio) -> Unit = { },
|
||||
onFormat: (OptionUio) -> Unit = { },
|
||||
onSend: (email: String, format: String) -> Unit = { _, _ -> },
|
||||
onHelp: (url: String) -> Unit,
|
||||
onEmail: (OptionUio) -> Unit,
|
||||
onFormat: (OptionUio) -> Unit,
|
||||
onSend: (email: String, format: String) -> Unit,
|
||||
) {
|
||||
val amazonHelpUri = stringResource(R.string.detail_send_confirm_help_url)
|
||||
|
||||
|
|
@ -221,15 +218,29 @@ private fun rememberDescription(
|
|||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun DetailScreenEmailListPreview() {
|
||||
BibLibTheme {
|
||||
val emails by remember {
|
||||
mutableStateOf(
|
||||
listOf(
|
||||
OptionUio("R.Giskard.Reventlov.Kindle@gmail.com", selected = true),
|
||||
OptionUio("R.Daneel.Olivaw.Kindle@gmail.com"),
|
||||
)
|
||||
)
|
||||
}
|
||||
val formats by remember {
|
||||
mutableStateOf(
|
||||
listOf(
|
||||
OptionUio(Format.EPUB.capitalize(), selected = true),
|
||||
OptionUio(Format.MOBI.capitalize()),
|
||||
)
|
||||
)
|
||||
}
|
||||
DetailScreenSendOption(
|
||||
emails = listOf(
|
||||
OptionUio("R.Giskard.Reventlov.Kindle@gmail.com", selected = true),
|
||||
OptionUio("R.Daneel.Olivaw.Kindle@gmail.com"),
|
||||
),
|
||||
formats = listOf(
|
||||
OptionUio(Format.EPUB.capitalize(), selected = true),
|
||||
OptionUio(Format.MOBI.capitalize()),
|
||||
),
|
||||
emails = emails,
|
||||
formats = formats,
|
||||
onHelp = { },
|
||||
onEmail = { },
|
||||
onFormat = { },
|
||||
onSend = { _, _ -> },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package com.pixelized.biblib.utils.extention
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
fun Context.showToast(message: String, duration: Int = Toast.LENGTH_SHORT) =
|
||||
Toast.makeText(this, message, duration).show()
|
||||
|
||||
fun Context.notImplemented() {
|
||||
showToast("Not implemented yet")
|
||||
}
|
||||
|
||||
@Deprecated("")
|
||||
@Composable
|
||||
fun default(): () -> Unit {
|
||||
val context = LocalContext.current
|
||||
return { context.notImplemented() }
|
||||
}
|
||||
|
||||
@Deprecated("")
|
||||
@Composable
|
||||
fun <T> default(): (T) -> Unit {
|
||||
val context = LocalContext.current
|
||||
return { context.notImplemented() }
|
||||
}
|
||||
|
|
@ -2,4 +2,4 @@ package com.pixelized.biblib.utils.extention
|
|||
|
||||
fun Int.toBoolean(): Boolean = this != 0
|
||||
|
||||
fun Int?.toBoolean(): Boolean? = if (this == null) null else this != 0
|
||||
fun Int?.toBoolean(): Boolean? = this?.toBoolean()
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.pixelized.biblib.utils.extention
|
||||
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.paging.LoadState
|
||||
import androidx.paging.compose.LazyPagingItems
|
||||
|
||||
val LazyPagingItems<*>.isLoading: Boolean
|
||||
get() {
|
||||
val isLoading by derivedStateOf {
|
||||
loadState.refresh is LoadState.Loading || loadState.append is LoadState.Loading
|
||||
}
|
||||
return isLoading
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.4.2'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10'
|
||||
classpath "com.google.dagger:hilt-android-gradle-plugin:2.43.2"
|
||||
classpath 'com.google.gms:google-services:4.3.15'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue