Clean up code, took a lint ;)

This commit is contained in:
Thomas Andres Gomez 2023-04-07 10:39:23 +02:00
parent 9d79ef49ec
commit 035f853cdb
20 changed files with 62 additions and 33 deletions

View file

@ -21,9 +21,35 @@
# hide the original source file name.
-renamesourcefileattribute SourceFile
# For SerializedName
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keep,allowobfuscation @interface com.google.gson.annotations.SerializedName
# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
##---------------End: proguard configuration for Gson ----------

View file

@ -5,7 +5,6 @@ import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.pixelized.biblib.database.data.GenreDbo
import com.pixelized.biblib.database.data.LanguageDbo
@Dao

View file

@ -5,7 +5,6 @@ import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.pixelized.biblib.database.data.LanguageDbo
import com.pixelized.biblib.database.data.SeriesDbo
@Dao

View file

@ -1,6 +1,6 @@
package com.pixelized.biblib.model.book
import java.util.Date
import java.util.*
data class Book(
val id: Int,

View file

@ -6,8 +6,6 @@ import com.pixelized.biblib.network.data.response.BookListResponse
import com.pixelized.biblib.utils.exception.missingField
import com.pixelized.biblib.utils.extention.toBoolean
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.*
class BookFactory(
private val parser: DateFormat,

View file

@ -3,7 +3,6 @@ package com.pixelized.biblib.network.factory
import com.pixelized.biblib.model.book.Genre
import com.pixelized.biblib.network.data.response.GenreListResponse
import com.pixelized.biblib.utils.exception.missingField
import java.text.DateFormat
class GenreFactory {
fun fromListResponseToGenreHash(

View file

@ -1,7 +1,7 @@
package com.pixelized.biblib.repository.book
import androidx.paging.DataSource
import com.pixelized.biblib.model.book.*
import com.pixelized.biblib.model.book.Book
interface IBookRepository {

View file

@ -1,6 +1,7 @@
package com.pixelized.biblib.ui
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.material.*
import androidx.compose.runtime.Composable
@ -12,7 +13,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
import com.pixelized.biblib.ui.navigation.ScreenNavHost
import com.pixelized.biblib.ui.screen.launch.LauncherViewModel
import com.pixelized.biblib.utils.extention.bibLib
import com.skydoves.landscapist.glide.LocalGlideRequestOptions
val LocalSnackHostState = staticCompositionLocalOf<SnackbarHostState> {
@ -51,6 +51,7 @@ fun MainContent(
content = {
if (launcherViewModel.isLoadingDone) {
ScreenNavHost(
modifier = Modifier.padding(it),
startDestination = launcherViewModel.startDestination
)
}

View file

@ -3,8 +3,11 @@ package com.pixelized.biblib.ui.composable.scaffold
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.material.*
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetState
import androidx.compose.material.ModalBottomSheetValue.Hidden
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.*
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier

View file

@ -4,7 +4,6 @@ import androidx.activity.compose.BackHandler
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetState
import androidx.compose.material.ModalBottomSheetValue.Expanded
import androidx.compose.material.ModalBottomSheetValue.Hidden
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.*

View file

@ -18,6 +18,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.hilt.navigation.compose.hiltViewModel
import com.pixelized.biblib.R
import com.pixelized.biblib.network.client.IBibLibClient
import com.pixelized.biblib.ui.LocalSnackHostState
import com.pixelized.biblib.ui.navigation.LocalScreenNavHostController
@ -26,7 +27,6 @@ import com.pixelized.biblib.ui.screen.authentication.viewModel.AuthenticationFor
import com.pixelized.biblib.ui.screen.authentication.viewModel.AuthenticationViewModel
import com.pixelized.biblib.ui.theme.color.ShadowPalette
import com.pixelized.biblib.utils.extention.bibLib
import com.pixelized.biblib.R
import kotlinx.coroutines.launch
@Stable

View file

@ -11,7 +11,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.common.api.ApiException
import com.pixelized.biblib.R
import com.pixelized.biblib.network.client.IBibLibClient
import com.pixelized.biblib.network.data.query.AuthLoginQuery
import com.pixelized.biblib.repository.credential.ICredentialRepository

View file

@ -15,6 +15,9 @@ import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.pullrefresh.PullRefreshState
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
@ -34,8 +37,6 @@ import androidx.compose.ui.unit.max
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.paging.PagingData
import androidx.paging.compose.collectAsLazyPagingItems
import com.google.accompanist.swiperefresh.SwipeRefresh
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.pixelized.biblib.R
import com.pixelized.biblib.model.search.FilterType
import com.pixelized.biblib.model.search.SortType
@ -103,6 +104,14 @@ fun HomeScreen(
val largeGridState = rememberLazyGridState()
val smallListState = rememberLazyListState()
val microListState = rememberLazyListState()
val refreshState = rememberPullRefreshState(
refreshing = false,
onRefresh = {
scope.launch {
bookViewModel.updateLibrary()
}
},
)
FilterBottomSheet(
sheetState = filterState,
@ -168,11 +177,7 @@ fun HomeScreen(
},
onDisplay = bookViewModel::onDisplay,
isLoading = bookViewModel.updating,
onPullToRefresh = {
scope.launch {
bookViewModel.updateLibrary()
}
},
refreshState = refreshState,
display = bookViewModel.display,
gridState = largeGridState,
items = bookViewModel.paging,
@ -285,6 +290,7 @@ private fun rememberOnFilter(
}
}
@OptIn(ExperimentalMaterialApi::class)
@Composable
private fun HomeScreenContent(
modifier: Modifier = Modifier,
@ -299,7 +305,7 @@ private fun HomeScreenContent(
onSort: () -> Unit,
onDisplay: (HomeDisplay) -> Unit,
isLoading: State<Boolean>,
onPullToRefresh: () -> Unit,
refreshState: PullRefreshState,
display: State<HomeDisplay>,
gridState: LazyGridState,
items: Flow<PagingData<BookThumbnailUio>>,
@ -375,9 +381,8 @@ private fun HomeScreenContent(
bottom = theme.dimen.thumbnail.padding + max(navigationBarsHeight, imeHeight)
)
}
SwipeRefresh(
state = rememberSwipeRefreshState(isRefreshing = false),
onRefresh = onPullToRefresh,
Box(
modifier = Modifier.pullRefresh(refreshState),
) {
BookList(
modifier = Modifier.fillMaxSize(),
@ -625,6 +630,7 @@ private fun CollapseKeyboardOnScrollHandler(
}
}
@OptIn(ExperimentalMaterialApi::class)
@Composable
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@ -648,7 +654,7 @@ private fun HomeScreenPreview() {
onSort = { },
onDisplay = { },
isLoading = remember { mutableStateOf(false) },
onPullToRefresh = { },
refreshState = rememberPullRefreshState(refreshing = false, onRefresh = { }),
display = remember { mutableStateOf(HomeDisplay.MICRO) },
gridState = rememberLazyGridState(),
items = thumbnailPreviewResources(),

View file

@ -9,7 +9,10 @@ import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester

View file

@ -3,7 +3,6 @@ package com.pixelized.biblib.ui.screen.home.filter.viewModel
import android.app.Application
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.focus.FocusRequester
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.paging.*

View file

@ -3,7 +3,9 @@ package com.pixelized.biblib.ui.screen.home.header
import androidx.compose.foundation.layout.Box
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset

View file

@ -23,7 +23,6 @@ import com.pixelized.biblib.network.client.IBibLibClient
import com.pixelized.biblib.ui.navigation.LocalScreenNavHostController
import com.pixelized.biblib.ui.navigation.navigateToAuthentication
import com.pixelized.biblib.ui.theme.BibLibTheme
import com.pixelized.biblib.utils.extention.bibLib
import com.pixelized.biblib.utils.extention.placeholder
@Stable

View file

@ -12,7 +12,6 @@ import com.pixelized.biblib.repository.credential.ICredentialRepository
import com.pixelized.biblib.repository.googleSignIn.IGoogleSingInRepository
import com.pixelized.biblib.repository.user.IUserRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch

View file

@ -11,7 +11,6 @@ import com.pixelized.biblib.repository.credential.ICredentialRepository
import com.pixelized.biblib.repository.googleSignIn.IGoogleSingInRepository
import com.pixelized.biblib.ui.navigation.Screen
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject

View file

@ -3,7 +3,6 @@ package com.pixelized.biblib.ui.theme.typography
import androidx.compose.material.Typography
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import java.time.format.TextStyle
@Stable
@Immutable