diff --git a/app/src/main/java/com/starry/myne/MainActivity.kt b/app/src/main/java/com/starry/myne/MainActivity.kt index 76a4bfb6..30d5fe06 100644 --- a/app/src/main/java/com/starry/myne/MainActivity.kt +++ b/app/src/main/java/com/starry/myne/MainActivity.kt @@ -38,11 +38,11 @@ import androidx.core.app.ActivityCompat import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.lifecycle.ViewModelProvider import coil.annotation.ExperimentalCoilApi -import com.starry.myne.utils.NetworkObserver import com.starry.myne.ui.screens.main.MainScreen import com.starry.myne.ui.screens.settings.viewmodels.SettingsViewModel import com.starry.myne.ui.screens.settings.viewmodels.ThemeMode import com.starry.myne.ui.theme.MyneTheme +import com.starry.myne.utils.NetworkObserver import dagger.hilt.android.AndroidEntryPoint @ExperimentalMaterialApi @@ -64,7 +64,7 @@ class MainActivity : AppCompatActivity() { settingsViewModel = ViewModelProvider(this)[SettingsViewModel::class.java] mainViewModel = ViewModelProvider(this)[MainViewModel::class.java] - ThemeMode.entries.find { it.ordinal == settingsViewModel.getThemeValue()} + ThemeMode.entries.find { it.ordinal == settingsViewModel.getThemeValue() } ?.let { settingsViewModel.setTheme(it) } settingsViewModel.setMaterialYou(settingsViewModel.getMaterialYouValue()) diff --git a/app/src/main/java/com/starry/myne/MainViewModel.kt b/app/src/main/java/com/starry/myne/MainViewModel.kt index c6f7a2d7..a34a9f84 100644 --- a/app/src/main/java/com/starry/myne/MainViewModel.kt +++ b/app/src/main/java/com/starry/myne/MainViewModel.kt @@ -22,9 +22,9 @@ import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.starry.myne.ui.screens.welcome.viewmodels.WelcomeDataStore import com.starry.myne.ui.navigation.BottomBarScreen import com.starry.myne.ui.navigation.Screens +import com.starry.myne.ui.screens.welcome.viewmodels.WelcomeDataStore import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.delay import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/starry/myne/database/library/LibraryDao.kt b/app/src/main/java/com/starry/myne/database/library/LibraryDao.kt index b9684a40..b6ad40d1 100644 --- a/app/src/main/java/com/starry/myne/database/library/LibraryDao.kt +++ b/app/src/main/java/com/starry/myne/database/library/LibraryDao.kt @@ -17,7 +17,11 @@ limitations under the License. package com.starry.myne.database.library import androidx.lifecycle.LiveData -import androidx.room.* +import androidx.room.Dao +import androidx.room.Delete +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query @Dao interface LibraryDao { diff --git a/app/src/main/java/com/starry/myne/database/reader/ReaderDao.kt b/app/src/main/java/com/starry/myne/database/reader/ReaderDao.kt index 535d1654..13cf66da 100644 --- a/app/src/main/java/com/starry/myne/database/reader/ReaderDao.kt +++ b/app/src/main/java/com/starry/myne/database/reader/ReaderDao.kt @@ -17,7 +17,10 @@ limitations under the License. package com.starry.myne.database.reader -import androidx.room.* +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query @Dao interface ReaderDao { diff --git a/app/src/main/java/com/starry/myne/di/MainModule.kt b/app/src/main/java/com/starry/myne/di/MainModule.kt index e8f9c9d5..775e12f6 100644 --- a/app/src/main/java/com/starry/myne/di/MainModule.kt +++ b/app/src/main/java/com/starry/myne/di/MainModule.kt @@ -19,10 +19,10 @@ package com.starry.myne.di import android.content.Context import com.starry.myne.database.MyneDatabase -import com.starry.myne.ui.screens.welcome.viewmodels.WelcomeDataStore import com.starry.myne.repo.BookRepository -import com.starry.myne.utils.book.BookDownloader +import com.starry.myne.ui.screens.welcome.viewmodels.WelcomeDataStore import com.starry.myne.utils.PreferenceUtil +import com.starry.myne.utils.book.BookDownloader import dagger.Module import dagger.Provides import dagger.hilt.InstallIn diff --git a/app/src/main/java/com/starry/myne/repo/BookRepository.kt b/app/src/main/java/com/starry/myne/repo/BookRepository.kt index e7f63ecd..f09998d4 100644 --- a/app/src/main/java/com/starry/myne/repo/BookRepository.kt +++ b/app/src/main/java/com/starry/myne/repo/BookRepository.kt @@ -17,9 +17,9 @@ limitations under the License. package com.starry.myne.repo import com.google.gson.Gson -import com.starry.myne.utils.book.BookLanguage import com.starry.myne.repo.models.BookSet import com.starry.myne.repo.models.ExtraInfo +import com.starry.myne.utils.book.BookLanguage import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import okhttp3.Call diff --git a/app/src/main/java/com/starry/myne/ui/navigation/BottomBarScreen.kt b/app/src/main/java/com/starry/myne/ui/navigation/BottomBarScreen.kt index d4a4d8ee..16c63792 100644 --- a/app/src/main/java/com/starry/myne/ui/navigation/BottomBarScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/navigation/BottomBarScreen.kt @@ -23,25 +23,25 @@ sealed class BottomBarScreen( val title: Int, val icon: Int ) { - object Home : BottomBarScreen( + data object Home : BottomBarScreen( route = "home", title = R.string.navigation_home, icon = R.drawable.ic_nav_home ) - object Categories : BottomBarScreen( + data object Categories : BottomBarScreen( route = "categories", title = R.string.navigation_categories, icon = R.drawable.ic_nav_categories ) - object Library : BottomBarScreen( + data object Library : BottomBarScreen( route = "library", title = R.string.navigation_library, icon = R.drawable.ic_nav_library ) - object Settings : BottomBarScreen( + data object Settings : BottomBarScreen( route = "settings", title = R.string.navigation_settings, icon = R.drawable.ic_nav_settings diff --git a/app/src/main/java/com/starry/myne/ui/navigation/NavGraph.kt b/app/src/main/java/com/starry/myne/ui/navigation/NavGraph.kt index 47f2fd1d..6517e8bc 100644 --- a/app/src/main/java/com/starry/myne/ui/navigation/NavGraph.kt +++ b/app/src/main/java/com/starry/myne/ui/navigation/NavGraph.kt @@ -36,7 +36,6 @@ import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.navArgument import coil.annotation.ExperimentalCoilApi -import com.starry.myne.utils.NetworkObserver import com.starry.myne.ui.screens.categories.composables.CategoriesScreen import com.starry.myne.ui.screens.categories.composables.CategoryDetailScreen import com.starry.myne.ui.screens.detail.composables.BookDetailScreen @@ -47,6 +46,7 @@ import com.starry.myne.ui.screens.settings.composables.AboutScreen import com.starry.myne.ui.screens.settings.composables.OSLScreen import com.starry.myne.ui.screens.settings.composables.SettingsScreen import com.starry.myne.ui.screens.welcome.composables.WelcomeScreen +import com.starry.myne.utils.NetworkObserver private const val NAVIGATION_ANIM_DURATION = 300 diff --git a/app/src/main/java/com/starry/myne/ui/navigation/Screens.kt b/app/src/main/java/com/starry/myne/ui/navigation/Screens.kt index 722a7480..3d6c2e52 100644 --- a/app/src/main/java/com/starry/myne/ui/navigation/Screens.kt +++ b/app/src/main/java/com/starry/myne/ui/navigation/Screens.kt @@ -21,27 +21,28 @@ const val CATEGORY_DETAIL_ARG_KEY = "category" sealed class Screens(val route: String) { - object BookDetailScreen : Screens("book_detail_screen/{$BOOK_ID_ARG_KEY}") { + data object BookDetailScreen : Screens("book_detail_screen/{$BOOK_ID_ARG_KEY}") { fun withBookId(id: String): String { return this.route.replace("{$BOOK_ID_ARG_KEY}", id) } } - object CategoryDetailScreen : Screens("category_detail_screen/{$CATEGORY_DETAIL_ARG_KEY}") { + data object CategoryDetailScreen : + Screens("category_detail_screen/{$CATEGORY_DETAIL_ARG_KEY}") { fun withCategory(category: String): String { return this.route.replace("{$CATEGORY_DETAIL_ARG_KEY}", category) } } - object ReaderDetailScreen : Screens("reader_detail_screen/{$BOOK_ID_ARG_KEY}") { + data object ReaderDetailScreen : Screens("reader_detail_screen/{$BOOK_ID_ARG_KEY}") { fun withBookId(id: String): String { return this.route.replace("{$BOOK_ID_ARG_KEY}", id) } } - object WelcomeScreen : Screens("welcome_screen") + data object WelcomeScreen : Screens("welcome_screen") - object OSLScreen : Screens("osl_screen") + data object OSLScreen : Screens("osl_screen") - object AboutScreen : Screens("about_screen") + data object AboutScreen : Screens("about_screen") } diff --git a/app/src/main/java/com/starry/myne/ui/screens/categories/composables/CategoryDetailScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/categories/composables/CategoryDetailScreen.kt index c7d7d7a6..4b7ad2ae 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/categories/composables/CategoryDetailScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/categories/composables/CategoryDetailScreen.kt @@ -55,8 +55,6 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController import coil.annotation.ExperimentalCoilApi import com.starry.myne.R -import com.starry.myne.utils.book.BookLanguage -import com.starry.myne.utils.NetworkObserver import com.starry.myne.ui.common.BookItemCard import com.starry.myne.ui.common.CustomTopAppBar import com.starry.myne.ui.common.NoBooksAvailable @@ -66,6 +64,8 @@ import com.starry.myne.ui.screens.categories.viewmodels.CategoryViewModel import com.starry.myne.ui.screens.home.composables.LanguageItem import com.starry.myne.ui.screens.other.NetworkError import com.starry.myne.ui.theme.pacificoFont +import com.starry.myne.utils.NetworkObserver +import com.starry.myne.utils.book.BookLanguage import com.starry.myne.utils.book.BookUtils import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/starry/myne/ui/screens/categories/viewmodels/CategoryViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/categories/viewmodels/CategoryViewModel.kt index 05e04a6e..884b729a 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/categories/viewmodels/CategoryViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/categories/viewmodels/CategoryViewModel.kt @@ -24,12 +24,12 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.starry.myne.utils.book.BookLanguage -import com.starry.myne.utils.Paginator import com.starry.myne.repo.BookRepository import com.starry.myne.repo.models.Book import com.starry.myne.repo.models.BookSet +import com.starry.myne.utils.Paginator import com.starry.myne.utils.PreferenceUtil +import com.starry.myne.utils.book.BookLanguage import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import javax.inject.Inject diff --git a/app/src/main/java/com/starry/myne/ui/screens/detail/composables/BookDetailScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/detail/composables/BookDetailScreen.kt index d40e47e2..cd56ba42 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/detail/composables/BookDetailScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/detail/composables/BookDetailScreen.kt @@ -102,8 +102,8 @@ import com.starry.myne.ui.screens.other.NetworkError import com.starry.myne.ui.screens.settings.viewmodels.ThemeMode import com.starry.myne.ui.theme.figeronaFont import com.starry.myne.ui.theme.pacificoFont -import com.starry.myne.utils.book.BookUtils import com.starry.myne.utils.Utils +import com.starry.myne.utils.book.BookUtils import com.starry.myne.utils.getActivity import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/starry/myne/ui/screens/detail/viewmodels/BookDetailViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/detail/viewmodels/BookDetailViewModel.kt index f91579ab..e902b35d 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/detail/viewmodels/BookDetailViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/detail/viewmodels/BookDetailViewModel.kt @@ -34,9 +34,9 @@ import com.starry.myne.repo.BookRepository import com.starry.myne.repo.models.Book import com.starry.myne.repo.models.BookSet import com.starry.myne.repo.models.ExtraInfo +import com.starry.myne.utils.PreferenceUtil import com.starry.myne.utils.book.BookDownloader import com.starry.myne.utils.book.BookUtils -import com.starry.myne.utils.PreferenceUtil import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/starry/myne/ui/screens/home/composables/HomeScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/home/composables/HomeScreen.kt index a3911dca..dafb6494 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/home/composables/HomeScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/home/composables/HomeScreen.kt @@ -90,8 +90,6 @@ import androidx.navigation.NavController import androidx.navigation.compose.rememberNavController import coil.annotation.ExperimentalCoilApi import com.starry.myne.R -import com.starry.myne.utils.book.BookLanguage -import com.starry.myne.utils.NetworkObserver import com.starry.myne.ui.common.BookItemCard import com.starry.myne.ui.common.ProgressDots import com.starry.myne.ui.navigation.Screens @@ -100,6 +98,8 @@ import com.starry.myne.ui.screens.home.viewmodels.UserAction import com.starry.myne.ui.screens.other.NetworkError import com.starry.myne.ui.theme.figeronaFont import com.starry.myne.ui.theme.pacificoFont +import com.starry.myne.utils.NetworkObserver +import com.starry.myne.utils.book.BookLanguage import com.starry.myne.utils.book.BookUtils import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/starry/myne/ui/screens/home/viewmodels/HomeViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/home/viewmodels/HomeViewModel.kt index 3facd196..57978cee 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/home/viewmodels/HomeViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/home/viewmodels/HomeViewModel.kt @@ -23,13 +23,13 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.starry.myne.utils.book.BookLanguage -import com.starry.myne.utils.NetworkObserver -import com.starry.myne.utils.Paginator import com.starry.myne.repo.BookRepository import com.starry.myne.repo.models.Book import com.starry.myne.repo.models.BookSet +import com.starry.myne.utils.NetworkObserver +import com.starry.myne.utils.Paginator import com.starry.myne.utils.PreferenceUtil +import com.starry.myne.utils.book.BookLanguage import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Job import kotlinx.coroutines.delay @@ -53,8 +53,8 @@ data class TopBarState( ) sealed class UserAction { - object SearchIconClicked : UserAction() - object CloseIconClicked : UserAction() + data object SearchIconClicked : UserAction() + data object CloseIconClicked : UserAction() data class TextFieldInput( val text: String, val networkStatus: NetworkObserver.Status @@ -89,13 +89,6 @@ class HomeViewModel @Inject constructor( }, onError = { allBooksState = allBooksState.copy(error = it?.localizedMessage ?: "unknown-error") }, onSuccess = { bookSet, newPage -> - /** - * usually bookSet.books is not nullable and API simply returns empty list - * when browsing books all books (i.e. without passing language parameter) - * however, when browsing by language it returns a response which looks like - * this: {"detail": "Invalid page."}. Hence the [BookSet] attributes become - * null in this case and can cause crashes. - */ /** * usually bookSet.books is not nullable and API simply returns empty list * when browsing books all books (i.e. without passing language parameter) @@ -104,19 +97,7 @@ class HomeViewModel @Inject constructor( * null in this case and can cause crashes. */ val books = if (bookSet.books != null) { - val books: ArrayList = - bookSet.books.filter { it.formats.applicationepubzip != null } as ArrayList - - // pls ignore (this line doesn't exists)... - if (setOf( - BookLanguage.English, - BookLanguage.AllBooks - ).contains(language.value) && allBooksState.page == 1L - ) { - books.removeAt(0) - } - // returning value - books + bookSet.books.filter { it.formats.applicationepubzip != null } as ArrayList } else { ArrayList() } diff --git a/app/src/main/java/com/starry/myne/ui/screens/main/MainScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/main/MainScreen.kt index b75fe7e1..c1b33710 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/main/MainScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/main/MainScreen.kt @@ -50,12 +50,12 @@ import androidx.navigation.compose.rememberNavController import coil.annotation.ExperimentalCoilApi import com.google.accompanist.systemuicontroller.SystemUiController import com.google.accompanist.systemuicontroller.rememberSystemUiController -import com.starry.myne.utils.NetworkObserver import com.starry.myne.ui.navigation.BottomBarScreen import com.starry.myne.ui.navigation.NavGraph import com.starry.myne.ui.screens.settings.viewmodels.SettingsViewModel import com.starry.myne.ui.screens.settings.viewmodels.ThemeMode import com.starry.myne.ui.theme.figeronaFont +import com.starry.myne.utils.NetworkObserver @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @ExperimentalAnimationApi diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/adapters/ReaderRVAdapter.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/adapters/ReaderRVAdapter.kt index 64b6b2f2..03fd6b5f 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/adapters/ReaderRVAdapter.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/adapters/ReaderRVAdapter.kt @@ -51,6 +51,7 @@ import com.starry.myne.epub.models.EpubChapter import com.starry.myne.ui.screens.reader.activities.ReaderActivity import com.starry.myne.ui.screens.reader.viewmodels.ReaderViewModel import com.starry.myne.ui.theme.MyneTheme +import com.starry.myne.utils.noRippleClickable @ExperimentalMaterialApi @ExperimentalMaterial3Api @@ -78,13 +79,13 @@ class ReaderRVAdapter( set(value) = differ.submitList(value) inner class ReaderComposeViewHolder(view: View) : RecyclerView.ViewHolder(view) { - val composeView: ComposeView = view.findViewById(R.id.ReaderRVItem) - fun bind(position: Int) { + private val composeView: ComposeView = view.findViewById(R.id.ReaderRVItem) + fun bind(position: Int, onClick: () -> Unit) { val chapter = allChapters[position] composeView.setContent { MyneTheme(settingsViewModel = activity.settingsViewModel) { SelectionContainer { - ReaderItem(chapter = chapter, viewModel = viewModel) + ReaderItem(chapter = chapter, viewModel = viewModel, onClick = onClick) } } } @@ -92,11 +93,9 @@ class ReaderRVAdapter( } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ReaderComposeViewHolder { - val viewHolder = ReaderComposeViewHolder( + return ReaderComposeViewHolder( LayoutInflater.from(parent.context).inflate(R.layout.reader_item, parent, false) ) - viewHolder.composeView.setOnClickListener { clickListener.onReaderClick() } - return viewHolder } override fun getItemCount(): Int { @@ -104,14 +103,15 @@ class ReaderRVAdapter( } override fun onBindViewHolder(holder: ReaderComposeViewHolder, position: Int) { - holder.bind(position) + holder.bind(position, onClick = { clickListener.onReaderClick() }) } } @Composable private fun ReaderItem( chapter: EpubChapter, - viewModel: ReaderViewModel + viewModel: ReaderViewModel, + onClick: () -> Unit ) { val paragraphs = chapter.body .splitToSequence("\n\n") @@ -120,7 +120,9 @@ private fun ReaderItem( val epubBook = viewModel.state.epubBook - Column(modifier = Modifier.fillMaxWidth()) { + Column(modifier = Modifier + .fillMaxWidth() + .noRippleClickable { onClick() }) { Text( modifier = Modifier.padding(start = 12.dp, end = 4.dp, top = 10.dp), text = chapter.title, diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderDetailScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderDetailScreen.kt index f0a157fa..c5584412 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderDetailScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderDetailScreen.kt @@ -80,7 +80,6 @@ import coil.compose.AsyncImage import coil.request.ImageRequest import com.starry.myne.MainActivity import com.starry.myne.R -import com.starry.myne.utils.NetworkObserver import com.starry.myne.ui.common.CustomTopAppBar import com.starry.myne.ui.common.ProgressDots import com.starry.myne.ui.common.simpleVerticalScrollbar @@ -88,6 +87,7 @@ import com.starry.myne.ui.screens.reader.activities.ReaderActivity import com.starry.myne.ui.screens.reader.viewmodels.ReaderDetailViewModel import com.starry.myne.ui.screens.settings.viewmodels.ThemeMode import com.starry.myne.ui.theme.figeronaFont +import com.starry.myne.utils.NetworkObserver import com.starry.myne.utils.getActivity @ExperimentalCoilApi diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderDetailViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderDetailViewModel.kt index b8591dc3..b90a474a 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderDetailViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderDetailViewModel.kt @@ -27,8 +27,8 @@ import com.starry.myne.database.reader.ReaderDao import com.starry.myne.database.reader.ReaderItem import com.starry.myne.epub.createEpubBook import com.starry.myne.epub.models.EpubBook -import com.starry.myne.utils.NetworkObserver import com.starry.myne.repo.BookRepository +import com.starry.myne.utils.NetworkObserver import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/starry/myne/ui/screens/settings/composables/AboutScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/settings/composables/AboutScreen.kt index 116cb8be..24609c96 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/settings/composables/AboutScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/settings/composables/AboutScreen.kt @@ -62,9 +62,9 @@ import coil.compose.AsyncImage import coil.request.ImageRequest import com.starry.myne.BuildConfig import com.starry.myne.R -import com.starry.myne.utils.Constants import com.starry.myne.ui.common.CustomTopAppBar import com.starry.myne.ui.theme.figeronaFont +import com.starry.myne.utils.Constants @Composable diff --git a/app/src/main/java/com/starry/myne/utils/Extensions.kt b/app/src/main/java/com/starry/myne/utils/Extensions.kt index 9a455322..7f3eb611 100644 --- a/app/src/main/java/com/starry/myne/utils/Extensions.kt +++ b/app/src/main/java/com/starry/myne/utils/Extensions.kt @@ -20,11 +20,11 @@ import android.content.Context import android.content.ContextWrapper import android.widget.Toast import androidx.appcompat.app.AppCompatActivity -import androidx.compose.foundation.gestures.awaitEachGesture -import androidx.compose.foundation.gestures.awaitFirstDown -import androidx.compose.foundation.gestures.waitForUpOrCancellation -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.input.pointer.PointerInputScope +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.composed fun Context.getActivity(): AppCompatActivity? = when (this) { is AppCompatActivity -> this @@ -36,15 +36,9 @@ fun String.toToast(context: Context, length: Int = Toast.LENGTH_SHORT) { Toast.makeText(context, this, length).show() } -suspend fun PointerInputScope.detectTapGestureIfMatch( - onTap: (Offset) -> Boolean, -) { - awaitEachGesture { - awaitFirstDown() - - val up = waitForUpOrCancellation() - if (up != null && onTap(up.position)) { - up.consume() - } +fun Modifier.noRippleClickable(onClick: () -> Unit): Modifier = composed { + clickable(indication = null, + interactionSource = remember { MutableInteractionSource() }) { + onClick() } } \ No newline at end of file diff --git a/app/src/main/java/com/starry/myne/utils/book/BookDownloader.kt b/app/src/main/java/com/starry/myne/utils/book/BookDownloader.kt index 979d5429..c298bf24 100644 --- a/app/src/main/java/com/starry/myne/utils/book/BookDownloader.kt +++ b/app/src/main/java/com/starry/myne/utils/book/BookDownloader.kt @@ -22,8 +22,8 @@ import android.content.Context import android.database.Cursor import android.net.Uri import android.os.Environment -import com.starry.myne.utils.Constants import com.starry.myne.repo.models.Book +import com.starry.myne.utils.Constants import kotlinx.coroutines.* import kotlinx.coroutines.flow.MutableStateFlow diff --git a/app/src/main/java/com/starry/myne/utils/book/BookLanguage.kt b/app/src/main/java/com/starry/myne/utils/book/BookLanguage.kt index 51a5e816..6fb74545 100644 --- a/app/src/main/java/com/starry/myne/utils/book/BookLanguage.kt +++ b/app/src/main/java/com/starry/myne/utils/book/BookLanguage.kt @@ -11,56 +11,56 @@ sealed class BookLanguage(val name: String, val isoCode: String) { } @Keep - object AllBooks : BookLanguage("All Books", "all") + data object AllBooks : BookLanguage("All Books", "all") @Keep - object Chinese : BookLanguage("Chinese", "zh") + data object Chinese : BookLanguage("Chinese", "zh") @Keep - object Danish : BookLanguage("Danish", "da") + data object Danish : BookLanguage("Danish", "da") @Keep - object Dutch : BookLanguage("Dutch", "nl") + data object Dutch : BookLanguage("Dutch", "nl") @Keep - object English : BookLanguage("English", "en") + data object English : BookLanguage("English", "en") @Keep - object Esperanto : BookLanguage("Esperanto", "eo") + data object Esperanto : BookLanguage("Esperanto", "eo") @Keep - object Finnish : BookLanguage("Finnish", "fi") + data object Finnish : BookLanguage("Finnish", "fi") @Keep - object French : BookLanguage("French", "fr") + data object French : BookLanguage("French", "fr") @Keep - object German : BookLanguage("German", "de") + data object German : BookLanguage("German", "de") @Keep - object Greek : BookLanguage("Greek", "el") + data object Greek : BookLanguage("Greek", "el") @Keep - object Hungarian : BookLanguage("Hungarian", "hu") + data object Hungarian : BookLanguage("Hungarian", "hu") @Keep - object Italian : BookLanguage("Italian", "it") + data object Italian : BookLanguage("Italian", "it") @Keep - object Latin : BookLanguage("Latin", "la") + data object Latin : BookLanguage("Latin", "la") @Keep - object Portuguese : BookLanguage("Portuguese", "pt") + data object Portuguese : BookLanguage("Portuguese", "pt") @Keep - object Russian : BookLanguage("Russian", "ru") + data object Russian : BookLanguage("Russian", "ru") @Keep - object Spanish : BookLanguage("Spanish", "es") + data object Spanish : BookLanguage("Spanish", "es") @Keep - object Swedish : BookLanguage("Swedish", "sv") + data object Swedish : BookLanguage("Swedish", "sv") @Keep - object Tagalog : BookLanguage("Tagalog", "tl") + data object Tagalog : BookLanguage("Tagalog", "tl") }