From c4137e846e2c7c14f95cb78358f5168f80b32860 Mon Sep 17 00:00:00 2001 From: starry-shivam Date: Sun, 21 Apr 2024 13:05:20 +0530 Subject: [PATCH] Change package name of util and api classes Also add doc comments Signed-off-by: starry-shivam --- .../main/java/com/starry/myne/MainActivity.kt | 2 +- .../BookRepository.kt => api/BookAPI.kt} | 66 +++++++++++-------- .../com/starry/myne/api/CacheInterceptor.kt | 50 ++++++++++++++ .../myne/{repo => api}/models/Author.kt | 2 +- .../starry/myne/{repo => api}/models/Book.kt | 2 +- .../myne/{repo => api}/models/BookSet.kt | 2 +- .../myne/{repo => api}/models/ExtraInfo.kt | 2 +- .../myne/{repo => api}/models/Formats.kt | 2 +- .../myne/{repo => api}/models/Translator.kt | 2 +- .../com/starry/myne/database/MyneDatabase.kt | 2 +- .../java/com/starry/myne/di/MainModule.kt | 8 +-- .../myne/{utils => helpers}/Constants.kt | 2 +- .../myne/{utils => helpers}/Extensions.kt | 2 +- .../{utils => helpers}/NetworkObserver.kt | 2 +- .../myne/{utils => helpers}/Paginator.kt | 2 +- .../{utils => helpers}/Preferencesutils.kt | 2 +- .../starry/myne/{utils => helpers}/Utils.kt | 2 +- .../{utils => helpers}/book/BookDownloader.kt | 4 +- .../{utils => helpers}/book/BookLanguage.kt | 2 +- .../myne/{utils => helpers}/book/BookUtils.kt | 4 +- .../myne/ui/common/BookLanguageButton.kt | 2 +- .../com/starry/myne/ui/navigation/NavGraph.kt | 2 +- .../composables/CategoryDetailScreen.kt | 6 +- .../viewmodels/CategoryViewModel.kt | 16 ++--- .../detail/composables/BookDetailScreen.kt | 6 +- .../detail/viewmodels/BookDetailViewModel.kt | 22 +++---- .../ui/screens/home/composables/HomeScreen.kt | 6 +- .../screens/home/viewmodels/HomeViewModel.kt | 22 +++---- .../library/composables/LibraryScreen.kt | 6 +- .../library/viewmodels/LibraryViewModel.kt | 4 +- .../starry/myne/ui/screens/main/MainScreen.kt | 2 +- .../reader/activities/ReaderActivity.kt | 2 +- .../reader/composables/ReaderContent.kt | 2 +- .../reader/composables/ReaderDetailScreen.kt | 6 +- .../viewmodels/ReaderDetailViewModel.kt | 8 +-- .../reader/viewmodels/ReaderViewModel.kt | 2 +- .../settings/composables/AboutScreen.kt | 2 +- .../settings/composables/SettingsScreen.kt | 2 +- .../settings/viewmodels/SettingsViewModel.kt | 2 +- .../welcome/viewmodels/WelcomeViewModel.kt | 2 +- .../java/com/starry/myne/BookUtilsTest.kt | 4 +- .../java/com/starry/myne/PaginatorTest.kt | 2 +- .../test/java/com/starry/myne/UtilsTest.kt | 2 +- 43 files changed, 177 insertions(+), 115 deletions(-) rename app/src/main/java/com/starry/myne/{repo/BookRepository.kt => api/BookAPI.kt} (75%) create mode 100644 app/src/main/java/com/starry/myne/api/CacheInterceptor.kt rename app/src/main/java/com/starry/myne/{repo => api}/models/Author.kt (96%) rename app/src/main/java/com/starry/myne/{repo => api}/models/Book.kt (97%) rename app/src/main/java/com/starry/myne/{repo => api}/models/BookSet.kt (96%) rename app/src/main/java/com/starry/myne/{repo => api}/models/ExtraInfo.kt (95%) rename app/src/main/java/com/starry/myne/{repo => api}/models/Formats.kt (97%) rename app/src/main/java/com/starry/myne/{repo => api}/models/Translator.kt (96%) rename app/src/main/java/com/starry/myne/{utils => helpers}/Constants.kt (97%) rename app/src/main/java/com/starry/myne/{utils => helpers}/Extensions.kt (98%) rename app/src/main/java/com/starry/myne/{utils => helpers}/NetworkObserver.kt (98%) rename app/src/main/java/com/starry/myne/{utils => helpers}/Paginator.kt (98%) rename app/src/main/java/com/starry/myne/{utils => helpers}/Preferencesutils.kt (98%) rename app/src/main/java/com/starry/myne/{utils => helpers}/Utils.kt (98%) rename app/src/main/java/com/starry/myne/{utils => helpers}/book/BookDownloader.kt (99%) rename app/src/main/java/com/starry/myne/{utils => helpers}/book/BookLanguage.kt (97%) rename app/src/main/java/com/starry/myne/{utils => helpers}/book/BookUtils.kt (96%) diff --git a/app/src/main/java/com/starry/myne/MainActivity.kt b/app/src/main/java/com/starry/myne/MainActivity.kt index 485bf4a3..ee09a8be 100644 --- a/app/src/main/java/com/starry/myne/MainActivity.kt +++ b/app/src/main/java/com/starry/myne/MainActivity.kt @@ -27,10 +27,10 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.lifecycle.ViewModelProvider +import com.starry.myne.helpers.NetworkObserver import com.starry.myne.ui.screens.main.MainScreen import com.starry.myne.ui.screens.settings.viewmodels.SettingsViewModel import com.starry.myne.ui.theme.MyneTheme -import com.starry.myne.utils.NetworkObserver import dagger.hilt.android.AndroidEntryPoint diff --git a/app/src/main/java/com/starry/myne/repo/BookRepository.kt b/app/src/main/java/com/starry/myne/api/BookAPI.kt similarity index 75% rename from app/src/main/java/com/starry/myne/repo/BookRepository.kt rename to app/src/main/java/com/starry/myne/api/BookAPI.kt index 9eaef68b..3a5b67b6 100644 --- a/app/src/main/java/com/starry/myne/repo/BookRepository.kt +++ b/app/src/main/java/com/starry/myne/api/BookAPI.kt @@ -14,21 +14,19 @@ * limitations under the License. */ -package com.starry.myne.repo +package com.starry.myne.api import android.content.Context import com.google.gson.Gson import com.starry.myne.BuildConfig -import com.starry.myne.repo.models.BookSet -import com.starry.myne.repo.models.ExtraInfo -import com.starry.myne.utils.book.BookLanguage +import com.starry.myne.api.models.BookSet +import com.starry.myne.api.models.ExtraInfo +import com.starry.myne.helpers.book.BookLanguage import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import okhttp3.Cache -import okhttp3.CacheControl import okhttp3.Call import okhttp3.Callback -import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response @@ -42,30 +40,17 @@ import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine -class CacheInterceptor : Interceptor { - companion object { - const val CACHE_SIZE = 32L * 1024L * 1024L // 32 MiB - private const val CACHE_MAX_AGE = 10 // 10 days - } - - override fun intercept(chain: Interceptor.Chain): Response { - val response: Response = chain.proceed(chain.request()) - val cacheControl = CacheControl.Builder() - .maxAge(CACHE_MAX_AGE, TimeUnit.DAYS) - .build() - return response.newBuilder() - .header("Cache-Control", cacheControl.toString()) - .build() - } -} - -class BookRepository(context: Context) { +/** + * This class is responsible for handling all the API requests related to books. + * It uses OkHttp for making network requests and Gson for parsing JSON responses. + * @param context The context of the application. + */ +class BookAPI(context: Context) { private val baseApiUrl = "https://myne.pooloftears.xyz/books" private val googleBooksUrl = "https://www.googleapis.com/books/v1/volumes" - @Suppress("USELESS_ELVIS") private val googleApiKey = BuildConfig.GOOGLE_API_KEY ?: "AIzaSyBCaXx-U0sbEpGVPWylSggC4RaR4gCGkVE" // Backup API key @@ -77,9 +62,15 @@ class BookRepository(context: Context) { .addNetworkInterceptor(CacheInterceptor()) .build() - private val gsonClient = Gson() + private val gsonClient = Gson() // Gson client for parsing JSON responses. + /** + * This function fetches all the books from the API. + * @param page The page number of the books to fetch. + * @param bookLanguage The language of the books to fetch. + * @return A Result object containing the BookSet if the request was successful, or an exception if it failed. + */ suspend fun getAllBooks( page: Long, bookLanguage: BookLanguage = BookLanguage.AllBooks @@ -92,6 +83,11 @@ class BookRepository(context: Context) { return makeApiRequest(request) } + /** + * This function searches for books based on the query provided. + * @param query The query to search for. + * @return A Result object containing the BookSet if the request was successful, or an exception if it failed. + */ suspend fun searchBooks(query: String): Result { val encodedString = withContext(Dispatchers.IO) { URLEncoder.encode(query, "UTF-8") @@ -100,11 +96,23 @@ class BookRepository(context: Context) { return makeApiRequest(request) } + /** + * This function fetches a book by its ID. + * @param bookId The ID of the book to fetch. + * @return A Result object containing the BookSet if the request was successful, or an exception if it failed. + */ suspend fun getBookById(bookId: String): Result { val request = Request.Builder().get().url("${baseApiUrl}?ids=$bookId").build() return makeApiRequest(request) } + /** + * This function fetches books by category. + * @param category The category of the books to fetch. + * @param page The page number of the books to fetch. + * @param bookLanguage The language of the books to fetch. + * @return A Result object containing the BookSet if the request was successful, or an exception if it failed. + */ suspend fun getBooksByCategory( category: String, page: Long, @@ -118,6 +126,7 @@ class BookRepository(context: Context) { return makeApiRequest(request) } + // Helper function to make API requests. private suspend fun makeApiRequest(request: Request): Result = suspendCoroutine { continuation -> okHttpClient.newCall(request).enqueue(object : Callback { @@ -137,6 +146,8 @@ class BookRepository(context: Context) { }) } + // Function to fetch extra info such as cover image, page count, and description of a book. + // From Google Books API. suspend fun getExtraInfo(bookName: String): ExtraInfo? = suspendCoroutine { continuation -> val encodedName = URLEncoder.encode(bookName, "UTF-8") val url = "${googleBooksUrl}?q=$encodedName&startIndex=0&maxResults=1&key=$googleApiKey" @@ -155,7 +166,8 @@ class BookRepository(context: Context) { }) } - fun parseExtraInfoJson(jsonString: String): ExtraInfo? { + // Helper function to parse extra info JSON. + private fun parseExtraInfoJson(jsonString: String): ExtraInfo? { return try { val jsonObj = JSONObject(jsonString) val totalItems = jsonObj.getInt("totalItems") diff --git a/app/src/main/java/com/starry/myne/api/CacheInterceptor.kt b/app/src/main/java/com/starry/myne/api/CacheInterceptor.kt new file mode 100644 index 00000000..51bc8fae --- /dev/null +++ b/app/src/main/java/com/starry/myne/api/CacheInterceptor.kt @@ -0,0 +1,50 @@ +/** + * Copyright (c) [2022 - Present] Stɑrry Shivɑm + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package com.starry.myne.api + +import com.starry.myne.api.CacheInterceptor.Companion.CACHE_MAX_AGE +import com.starry.myne.api.CacheInterceptor.Companion.CACHE_SIZE +import okhttp3.CacheControl +import okhttp3.Interceptor +import okhttp3.Response +import java.util.concurrent.TimeUnit + +/** + * Interceptor to cache the response for a week to + * reduce the number of network calls. + * + * @property CACHE_SIZE 32 MiB + * @property CACHE_MAX_AGE 1 week + */ +class CacheInterceptor : Interceptor { + + companion object { + const val CACHE_SIZE = 32L * 1024L * 1024L // 32 MiB + const val CACHE_MAX_AGE = 7 // 1 week + } + + override fun intercept(chain: Interceptor.Chain): Response { + val response: Response = chain.proceed(chain.request()) + val cacheControl = CacheControl.Builder() + .maxAge(CACHE_MAX_AGE, TimeUnit.DAYS) + .build() + return response.newBuilder() + .header("Cache-Control", cacheControl.toString()) + .build() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/starry/myne/repo/models/Author.kt b/app/src/main/java/com/starry/myne/api/models/Author.kt similarity index 96% rename from app/src/main/java/com/starry/myne/repo/models/Author.kt rename to app/src/main/java/com/starry/myne/api/models/Author.kt index 294d1dc5..47ccc3f4 100644 --- a/app/src/main/java/com/starry/myne/repo/models/Author.kt +++ b/app/src/main/java/com/starry/myne/api/models/Author.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.repo.models +package com.starry.myne.api.models import androidx.annotation.Keep diff --git a/app/src/main/java/com/starry/myne/repo/models/Book.kt b/app/src/main/java/com/starry/myne/api/models/Book.kt similarity index 97% rename from app/src/main/java/com/starry/myne/repo/models/Book.kt rename to app/src/main/java/com/starry/myne/api/models/Book.kt index 568f3939..ecde614f 100644 --- a/app/src/main/java/com/starry/myne/repo/models/Book.kt +++ b/app/src/main/java/com/starry/myne/api/models/Book.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.repo.models +package com.starry.myne.api.models import androidx.annotation.Keep diff --git a/app/src/main/java/com/starry/myne/repo/models/BookSet.kt b/app/src/main/java/com/starry/myne/api/models/BookSet.kt similarity index 96% rename from app/src/main/java/com/starry/myne/repo/models/BookSet.kt rename to app/src/main/java/com/starry/myne/api/models/BookSet.kt index bb533bce..4c033b28 100644 --- a/app/src/main/java/com/starry/myne/repo/models/BookSet.kt +++ b/app/src/main/java/com/starry/myne/api/models/BookSet.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.repo.models +package com.starry.myne.api.models import androidx.annotation.Keep diff --git a/app/src/main/java/com/starry/myne/repo/models/ExtraInfo.kt b/app/src/main/java/com/starry/myne/api/models/ExtraInfo.kt similarity index 95% rename from app/src/main/java/com/starry/myne/repo/models/ExtraInfo.kt rename to app/src/main/java/com/starry/myne/api/models/ExtraInfo.kt index 55dc9181..605b9fa8 100644 --- a/app/src/main/java/com/starry/myne/repo/models/ExtraInfo.kt +++ b/app/src/main/java/com/starry/myne/api/models/ExtraInfo.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.repo.models +package com.starry.myne.api.models import androidx.annotation.Keep diff --git a/app/src/main/java/com/starry/myne/repo/models/Formats.kt b/app/src/main/java/com/starry/myne/api/models/Formats.kt similarity index 97% rename from app/src/main/java/com/starry/myne/repo/models/Formats.kt rename to app/src/main/java/com/starry/myne/api/models/Formats.kt index 1772e058..9b6e808f 100644 --- a/app/src/main/java/com/starry/myne/repo/models/Formats.kt +++ b/app/src/main/java/com/starry/myne/api/models/Formats.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.repo.models +package com.starry.myne.api.models import androidx.annotation.Keep diff --git a/app/src/main/java/com/starry/myne/repo/models/Translator.kt b/app/src/main/java/com/starry/myne/api/models/Translator.kt similarity index 96% rename from app/src/main/java/com/starry/myne/repo/models/Translator.kt rename to app/src/main/java/com/starry/myne/api/models/Translator.kt index 5f5f0881..bc8bba17 100644 --- a/app/src/main/java/com/starry/myne/repo/models/Translator.kt +++ b/app/src/main/java/com/starry/myne/api/models/Translator.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.repo.models +package com.starry.myne.api.models import androidx.annotation.Keep diff --git a/app/src/main/java/com/starry/myne/database/MyneDatabase.kt b/app/src/main/java/com/starry/myne/database/MyneDatabase.kt index 3a05ddcd..6b974131 100644 --- a/app/src/main/java/com/starry/myne/database/MyneDatabase.kt +++ b/app/src/main/java/com/starry/myne/database/MyneDatabase.kt @@ -26,7 +26,7 @@ import com.starry.myne.database.library.LibraryDao import com.starry.myne.database.library.LibraryItem import com.starry.myne.database.reader.ReaderDao import com.starry.myne.database.reader.ReaderData -import com.starry.myne.utils.Constants +import com.starry.myne.helpers.Constants @Database( entities = [LibraryItem::class, ReaderData::class], 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 6151bfd3..cb7b39a5 100644 --- a/app/src/main/java/com/starry/myne/di/MainModule.kt +++ b/app/src/main/java/com/starry/myne/di/MainModule.kt @@ -18,12 +18,12 @@ package com.starry.myne.di import android.content.Context +import com.starry.myne.api.BookAPI import com.starry.myne.database.MyneDatabase import com.starry.myne.epub.EpubParser -import com.starry.myne.repo.BookRepository +import com.starry.myne.helpers.PreferenceUtil +import com.starry.myne.helpers.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 @@ -52,7 +52,7 @@ class MainModule { @Singleton @Provides - fun provideBooksApi(@ApplicationContext context: Context) = BookRepository(context) + fun provideBooksApi(@ApplicationContext context: Context) = BookAPI(context) @Singleton @Provides diff --git a/app/src/main/java/com/starry/myne/utils/Constants.kt b/app/src/main/java/com/starry/myne/helpers/Constants.kt similarity index 97% rename from app/src/main/java/com/starry/myne/utils/Constants.kt rename to app/src/main/java/com/starry/myne/helpers/Constants.kt index 644dd6f4..c33f887a 100644 --- a/app/src/main/java/com/starry/myne/utils/Constants.kt +++ b/app/src/main/java/com/starry/myne/helpers/Constants.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.utils +package com.starry.myne.helpers object Constants { // Database diff --git a/app/src/main/java/com/starry/myne/utils/Extensions.kt b/app/src/main/java/com/starry/myne/helpers/Extensions.kt similarity index 98% rename from app/src/main/java/com/starry/myne/utils/Extensions.kt rename to app/src/main/java/com/starry/myne/helpers/Extensions.kt index e32bf655..898c834e 100644 --- a/app/src/main/java/com/starry/myne/utils/Extensions.kt +++ b/app/src/main/java/com/starry/myne/helpers/Extensions.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.utils +package com.starry.myne.helpers import android.content.Context import android.content.ContextWrapper diff --git a/app/src/main/java/com/starry/myne/utils/NetworkObserver.kt b/app/src/main/java/com/starry/myne/helpers/NetworkObserver.kt similarity index 98% rename from app/src/main/java/com/starry/myne/utils/NetworkObserver.kt rename to app/src/main/java/com/starry/myne/helpers/NetworkObserver.kt index 7546cfc0..11e54ffa 100644 --- a/app/src/main/java/com/starry/myne/utils/NetworkObserver.kt +++ b/app/src/main/java/com/starry/myne/helpers/NetworkObserver.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.utils +package com.starry.myne.helpers import android.content.Context import android.net.ConnectivityManager diff --git a/app/src/main/java/com/starry/myne/utils/Paginator.kt b/app/src/main/java/com/starry/myne/helpers/Paginator.kt similarity index 98% rename from app/src/main/java/com/starry/myne/utils/Paginator.kt rename to app/src/main/java/com/starry/myne/helpers/Paginator.kt index b28bd61a..420fffb1 100644 --- a/app/src/main/java/com/starry/myne/utils/Paginator.kt +++ b/app/src/main/java/com/starry/myne/helpers/Paginator.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.utils +package com.starry.myne.helpers /** * A class that helps in paginating data from a remote source. diff --git a/app/src/main/java/com/starry/myne/utils/Preferencesutils.kt b/app/src/main/java/com/starry/myne/helpers/Preferencesutils.kt similarity index 98% rename from app/src/main/java/com/starry/myne/utils/Preferencesutils.kt rename to app/src/main/java/com/starry/myne/helpers/Preferencesutils.kt index 64979af3..dc9ec9a9 100644 --- a/app/src/main/java/com/starry/myne/utils/Preferencesutils.kt +++ b/app/src/main/java/com/starry/myne/helpers/Preferencesutils.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.utils +package com.starry.myne.helpers import android.content.Context import android.content.SharedPreferences diff --git a/app/src/main/java/com/starry/myne/utils/Utils.kt b/app/src/main/java/com/starry/myne/helpers/Utils.kt similarity index 98% rename from app/src/main/java/com/starry/myne/utils/Utils.kt rename to app/src/main/java/com/starry/myne/helpers/Utils.kt index 3d771de5..9048ee8a 100644 --- a/app/src/main/java/com/starry/myne/utils/Utils.kt +++ b/app/src/main/java/com/starry/myne/helpers/Utils.kt @@ -15,7 +15,7 @@ */ -package com.starry.myne.utils +package com.starry.myne.helpers import android.content.ActivityNotFoundException import android.content.Context diff --git a/app/src/main/java/com/starry/myne/utils/book/BookDownloader.kt b/app/src/main/java/com/starry/myne/helpers/book/BookDownloader.kt similarity index 99% rename from app/src/main/java/com/starry/myne/utils/book/BookDownloader.kt rename to app/src/main/java/com/starry/myne/helpers/book/BookDownloader.kt index eac00f03..0458de17 100644 --- a/app/src/main/java/com/starry/myne/utils/book/BookDownloader.kt +++ b/app/src/main/java/com/starry/myne/helpers/book/BookDownloader.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.starry.myne.utils.book +package com.starry.myne.helpers.book import android.annotation.SuppressLint import android.app.DownloadManager @@ -22,7 +22,7 @@ import android.content.Context import android.database.Cursor import android.net.Uri import android.util.Log -import com.starry.myne.repo.models.Book +import com.starry.myne.api.models.Book import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job diff --git a/app/src/main/java/com/starry/myne/utils/book/BookLanguage.kt b/app/src/main/java/com/starry/myne/helpers/book/BookLanguage.kt similarity index 97% rename from app/src/main/java/com/starry/myne/utils/book/BookLanguage.kt rename to app/src/main/java/com/starry/myne/helpers/book/BookLanguage.kt index 6fb74545..5dd80558 100644 --- a/app/src/main/java/com/starry/myne/utils/book/BookLanguage.kt +++ b/app/src/main/java/com/starry/myne/helpers/book/BookLanguage.kt @@ -1,4 +1,4 @@ -package com.starry.myne.utils.book +package com.starry.myne.helpers.book import androidx.annotation.Keep diff --git a/app/src/main/java/com/starry/myne/utils/book/BookUtils.kt b/app/src/main/java/com/starry/myne/helpers/book/BookUtils.kt similarity index 96% rename from app/src/main/java/com/starry/myne/utils/book/BookUtils.kt rename to app/src/main/java/com/starry/myne/helpers/book/BookUtils.kt index 6cb93602..4b1c8d48 100644 --- a/app/src/main/java/com/starry/myne/utils/book/BookUtils.kt +++ b/app/src/main/java/com/starry/myne/helpers/book/BookUtils.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.starry.myne.utils.book +package com.starry.myne.helpers.book -import com.starry.myne.repo.models.Author +import com.starry.myne.api.models.Author import java.util.Locale object BookUtils { diff --git a/app/src/main/java/com/starry/myne/ui/common/BookLanguageButton.kt b/app/src/main/java/com/starry/myne/ui/common/BookLanguageButton.kt index 0ba2f889..063b839c 100644 --- a/app/src/main/java/com/starry/myne/ui/common/BookLanguageButton.kt +++ b/app/src/main/java/com/starry/myne/ui/common/BookLanguageButton.kt @@ -34,8 +34,8 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.starry.myne.helpers.book.BookLanguage import com.starry.myne.ui.theme.figeronaFont -import com.starry.myne.utils.book.BookLanguage @Composable fun BookLanguageButton(language: BookLanguage, isSelected: Boolean, onClick: () -> Unit) { 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 a8d3adca..f8c6995a 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 @@ -31,6 +31,7 @@ import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.navArgument +import com.starry.myne.helpers.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 @@ -41,7 +42,6 @@ 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/screens/categories/composables/CategoryDetailScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/categories/composables/CategoryDetailScreen.kt index b07efd35..3f5d9fb8 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,6 +55,9 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController import coil.annotation.ExperimentalCoilApi import com.starry.myne.R +import com.starry.myne.helpers.NetworkObserver +import com.starry.myne.helpers.book.BookLanguage +import com.starry.myne.helpers.book.BookUtils import com.starry.myne.ui.common.BookItemCard import com.starry.myne.ui.common.BookLanguageButton import com.starry.myne.ui.common.CustomTopAppBar @@ -64,9 +67,6 @@ import com.starry.myne.ui.common.ProgressDots import com.starry.myne.ui.navigation.Screens import com.starry.myne.ui.screens.categories.viewmodels.CategoryViewModel 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 import java.util.Locale 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 8fa57420..8b452b35 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,13 +24,13 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -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.Constants -import com.starry.myne.utils.Paginator -import com.starry.myne.utils.PreferenceUtil -import com.starry.myne.utils.book.BookLanguage +import com.starry.myne.api.BookAPI +import com.starry.myne.api.models.Book +import com.starry.myne.api.models.BookSet +import com.starry.myne.helpers.Constants +import com.starry.myne.helpers.Paginator +import com.starry.myne.helpers.PreferenceUtil +import com.starry.myne.helpers.book.BookLanguage import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import javax.inject.Inject @@ -45,7 +45,7 @@ data class CategorisedBooksState( @HiltViewModel class CategoryViewModel @Inject constructor( - private val booksApi: BookRepository, + private val booksApi: BookAPI, private val preferenceUtil: PreferenceUtil ) : ViewModel() { 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 775bbd1c..d72b39ae 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 @@ -83,15 +83,15 @@ import com.airbnb.lottie.compose.animateLottieCompositionAsState import com.airbnb.lottie.compose.rememberLottieComposition import com.starry.myne.MainActivity import com.starry.myne.R +import com.starry.myne.helpers.Utils +import com.starry.myne.helpers.book.BookUtils +import com.starry.myne.helpers.getActivity import com.starry.myne.ui.common.BookDetailTopUI import com.starry.myne.ui.common.NetworkError import com.starry.myne.ui.common.ProgressDots import com.starry.myne.ui.screens.detail.viewmodels.BookDetailViewModel import com.starry.myne.ui.theme.figeronaFont import com.starry.myne.ui.theme.pacificoFont -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 import kotlinx.coroutines.withContext 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 c482bbce..8b8084f2 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 @@ -21,16 +21,16 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.starry.myne.api.BookAPI +import com.starry.myne.api.models.Book +import com.starry.myne.api.models.BookSet +import com.starry.myne.api.models.ExtraInfo import com.starry.myne.database.library.LibraryDao import com.starry.myne.database.library.LibraryItem -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.Constants -import com.starry.myne.utils.PreferenceUtil -import com.starry.myne.utils.book.BookDownloader -import com.starry.myne.utils.book.BookUtils +import com.starry.myne.helpers.Constants +import com.starry.myne.helpers.PreferenceUtil +import com.starry.myne.helpers.book.BookDownloader +import com.starry.myne.helpers.book.BookUtils import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -47,7 +47,7 @@ data class BookDetailScreenState( @HiltViewModel class BookDetailViewModel @Inject constructor( - private val bookRepository: BookRepository, + private val bookAPI: BookAPI, val libraryDao: LibraryDao, val bookDownloader: BookDownloader, private val preferenceUtil: PreferenceUtil @@ -61,8 +61,8 @@ class BookDetailViewModel @Inject constructor( fun getBookDetails(bookId: String) { viewModelScope.launch(Dispatchers.IO) { try { - val bookSet = bookRepository.getBookById(bookId).getOrNull()!! - val extraInfo = bookRepository.getExtraInfo(bookSet.books.first().title) + val bookSet = bookAPI.getBookById(bookId).getOrNull()!! + val extraInfo = bookAPI.getExtraInfo(bookSet.books.first().title) // This function is called again when user clicks on retry // button. So, we need to reset the state to default values state = BookDetailScreenState() 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 b258d56d..fb2938a7 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 @@ -85,6 +85,9 @@ import androidx.navigation.NavController import androidx.navigation.compose.rememberNavController import coil.annotation.ExperimentalCoilApi import com.starry.myne.R +import com.starry.myne.helpers.NetworkObserver +import com.starry.myne.helpers.book.BookLanguage +import com.starry.myne.helpers.book.BookUtils import com.starry.myne.ui.common.BookItemCard import com.starry.myne.ui.common.BookLanguageButton import com.starry.myne.ui.common.NetworkError @@ -94,9 +97,6 @@ import com.starry.myne.ui.screens.home.viewmodels.HomeViewModel import com.starry.myne.ui.screens.home.viewmodels.UserAction 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 9ac199b6..ca868748 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,14 +23,14 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -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.Constants -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 com.starry.myne.api.BookAPI +import com.starry.myne.api.models.Book +import com.starry.myne.api.models.BookSet +import com.starry.myne.helpers.Constants +import com.starry.myne.helpers.NetworkObserver +import com.starry.myne.helpers.Paginator +import com.starry.myne.helpers.PreferenceUtil +import com.starry.myne.helpers.book.BookLanguage import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Job import kotlinx.coroutines.delay @@ -66,7 +66,7 @@ sealed class UserAction { @HiltViewModel class HomeViewModel @Inject constructor( - private val bookRepository: BookRepository, + private val bookAPI: BookAPI, private val preferenceUtil: PreferenceUtil ) : ViewModel() { var allBooksState by mutableStateOf(AllBooksState()) @@ -81,7 +81,7 @@ class HomeViewModel @Inject constructor( allBooksState = allBooksState.copy(isLoading = it) }, onRequest = { nextPage -> try { - bookRepository.getAllBooks(nextPage, language.value) + bookAPI.getAllBooks(nextPage, language.value) } catch (exc: Exception) { Result.failure(exc) } @@ -157,7 +157,7 @@ class HomeViewModel @Inject constructor( } private suspend fun searchBooks(query: String) { - val bookSet = bookRepository.searchBooks(query) + val bookSet = bookAPI.searchBooks(query) val books = bookSet.getOrNull()!!.books.filter { it.formats.applicationepubzip != null } topBarState = topBarState.copy(searchResults = books, isSearching = false) } diff --git a/app/src/main/java/com/starry/myne/ui/screens/library/composables/LibraryScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/library/composables/LibraryScreen.kt index 07e53ebd..c6a68c07 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/library/composables/LibraryScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/library/composables/LibraryScreen.kt @@ -103,15 +103,15 @@ import com.starry.myne.BuildConfig import com.starry.myne.MainActivity import com.starry.myne.R import com.starry.myne.database.library.LibraryItem +import com.starry.myne.helpers.Utils +import com.starry.myne.helpers.getActivity +import com.starry.myne.helpers.isScrollingUp import com.starry.myne.ui.common.CustomTopAppBar import com.starry.myne.ui.navigation.Screens import com.starry.myne.ui.screens.library.viewmodels.ImportStatus import com.starry.myne.ui.screens.library.viewmodels.LibraryViewModel import com.starry.myne.ui.screens.settings.viewmodels.ThemeMode import com.starry.myne.ui.theme.figeronaFont -import com.starry.myne.utils.Utils -import com.starry.myne.utils.getActivity -import com.starry.myne.utils.isScrollingUp import kotlinx.coroutines.delay import kotlinx.coroutines.launch import me.saket.swipe.SwipeAction diff --git a/app/src/main/java/com/starry/myne/ui/screens/library/viewmodels/LibraryViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/library/viewmodels/LibraryViewModel.kt index 8f8a6c44..1833dad9 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/library/viewmodels/LibraryViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/library/viewmodels/LibraryViewModel.kt @@ -26,8 +26,8 @@ import androidx.lifecycle.viewModelScope import com.starry.myne.database.library.LibraryDao import com.starry.myne.database.library.LibraryItem import com.starry.myne.epub.EpubParser -import com.starry.myne.utils.PreferenceUtil -import com.starry.myne.utils.book.BookDownloader +import com.starry.myne.helpers.PreferenceUtil +import com.starry.myne.helpers.book.BookDownloader import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay 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 9141914b..a77788fb 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.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import com.google.accompanist.systemuicontroller.SystemUiController import com.google.accompanist.systemuicontroller.rememberSystemUiController +import com.starry.myne.helpers.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") diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt index 349148ee..919c6591 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt @@ -34,13 +34,13 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.lifecycle.ViewModelProvider import com.starry.myne.R +import com.starry.myne.helpers.toToast import com.starry.myne.ui.screens.reader.composables.ReaderContent import com.starry.myne.ui.screens.reader.composables.ReaderScreen import com.starry.myne.ui.screens.reader.composables.TransparentSystemBars import com.starry.myne.ui.screens.reader.viewmodels.ReaderViewModel import com.starry.myne.ui.screens.settings.viewmodels.SettingsViewModel import com.starry.myne.ui.theme.MyneTheme -import com.starry.myne.utils.toToast import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch import java.io.FileInputStream diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderContent.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderContent.kt index 601e4c97..e1ef5eed 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderContent.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/composables/ReaderContent.kt @@ -44,10 +44,10 @@ import coil.compose.AsyncImage import coil.request.ImageRequest import com.starry.myne.epub.BookTextMapper import com.starry.myne.epub.models.EpubChapter +import com.starry.myne.helpers.noRippleClickable import com.starry.myne.ui.screens.reader.viewmodels.ReaderScreenState import com.starry.myne.ui.screens.reader.viewmodels.ReaderViewModel import com.starry.myne.ui.theme.pacificoFont -import com.starry.myne.utils.noRippleClickable private fun chunkText(text: String): List { 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 8fca31f4..6598a4f3 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 @@ -62,6 +62,9 @@ import coil.annotation.ExperimentalCoilApi import com.starry.myne.MainActivity import com.starry.myne.R import com.starry.myne.database.reader.ReaderData +import com.starry.myne.helpers.NetworkObserver +import com.starry.myne.helpers.getActivity +import com.starry.myne.helpers.toToast import com.starry.myne.ui.common.BookDetailTopUI import com.starry.myne.ui.common.CustomTopAppBar import com.starry.myne.ui.common.ProgressDots @@ -71,9 +74,6 @@ import com.starry.myne.ui.screens.reader.activities.ReaderConstants import com.starry.myne.ui.screens.reader.viewmodels.ReaderDetailScreenState import com.starry.myne.ui.screens.reader.viewmodels.ReaderDetailViewModel import com.starry.myne.ui.theme.figeronaFont -import com.starry.myne.utils.NetworkObserver -import com.starry.myne.utils.getActivity -import com.starry.myne.utils.toToast @Composable 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 c3ed37dc..38bf86da 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 @@ -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.api.BookAPI import com.starry.myne.database.library.LibraryDao import com.starry.myne.database.reader.ReaderDao import com.starry.myne.database.reader.ReaderData import com.starry.myne.epub.EpubParser import com.starry.myne.epub.models.EpubBook -import com.starry.myne.repo.BookRepository -import com.starry.myne.utils.NetworkObserver +import com.starry.myne.helpers.NetworkObserver import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay @@ -53,7 +53,7 @@ data class ReaderDetailScreenState( @HiltViewModel class ReaderDetailViewModel @Inject constructor( - private val bookRepository: BookRepository, + private val bookAPI: BookAPI, private val libraryDao: LibraryDao, private val readerDao: ReaderDao, private val epubParser: EpubParser @@ -74,7 +74,7 @@ class ReaderDetailViewModel @Inject constructor( val coverImage: String? = try { if (!libraryItem.isExternalBook && networkStatus == NetworkObserver.Status.Available - ) bookRepository.getExtraInfo(libraryItem.title)?.coverImage else null + ) bookAPI.getExtraInfo(libraryItem.title)?.coverImage else null } catch (exc: Exception) { null } diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderViewModel.kt index a59bc22e..3307ee06 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/viewmodels/ReaderViewModel.kt @@ -34,8 +34,8 @@ import com.starry.myne.database.reader.ReaderDao import com.starry.myne.database.reader.ReaderData import com.starry.myne.epub.EpubParser import com.starry.myne.epub.models.EpubBook +import com.starry.myne.helpers.PreferenceUtil import com.starry.myne.ui.theme.figeronaFont -import com.starry.myne.utils.PreferenceUtil import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay 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 b8914c4d..d11e6f85 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 @@ -71,9 +71,9 @@ import coil.compose.AsyncImage import coil.request.ImageRequest import com.starry.myne.BuildConfig import com.starry.myne.R +import com.starry.myne.helpers.Constants import com.starry.myne.ui.common.CustomTopAppBar import com.starry.myne.ui.theme.figeronaFont -import com.starry.myne.utils.Constants @OptIn(ExperimentalMaterial3Api::class) diff --git a/app/src/main/java/com/starry/myne/ui/screens/settings/composables/SettingsScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/settings/composables/SettingsScreen.kt index f3fef5e1..6a2d32ab 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/settings/composables/SettingsScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/settings/composables/SettingsScreen.kt @@ -79,12 +79,12 @@ import androidx.navigation.compose.rememberNavController import com.starry.myne.BuildConfig import com.starry.myne.MainActivity import com.starry.myne.R +import com.starry.myne.helpers.getActivity import com.starry.myne.ui.common.CustomTopAppBar import com.starry.myne.ui.navigation.Screens 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.getActivity import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) diff --git a/app/src/main/java/com/starry/myne/ui/screens/settings/viewmodels/SettingsViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/settings/viewmodels/SettingsViewModel.kt index ecb0cd5b..54bb99b8 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/settings/viewmodels/SettingsViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/settings/viewmodels/SettingsViewModel.kt @@ -22,7 +22,7 @@ import androidx.compose.runtime.Composable import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import com.starry.myne.utils.PreferenceUtil +import com.starry.myne.helpers.PreferenceUtil import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject diff --git a/app/src/main/java/com/starry/myne/ui/screens/welcome/viewmodels/WelcomeViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/welcome/viewmodels/WelcomeViewModel.kt index c08b0968..c35c8534 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/welcome/viewmodels/WelcomeViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/welcome/viewmodels/WelcomeViewModel.kt @@ -19,7 +19,7 @@ package com.starry.myne.ui.screens.welcome.viewmodels import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.starry.myne.utils.PreferenceUtil +import com.starry.myne.helpers.PreferenceUtil import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/test/java/com/starry/myne/BookUtilsTest.kt b/app/src/test/java/com/starry/myne/BookUtilsTest.kt index 7f5d206e..3c6515b1 100644 --- a/app/src/test/java/com/starry/myne/BookUtilsTest.kt +++ b/app/src/test/java/com/starry/myne/BookUtilsTest.kt @@ -1,8 +1,8 @@ package com.starry.myne import com.google.common.truth.Truth.assertThat -import com.starry.myne.repo.models.Author -import com.starry.myne.utils.book.BookUtils +import com.starry.myne.api.models.Author +import com.starry.myne.helpers.book.BookUtils import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Test diff --git a/app/src/test/java/com/starry/myne/PaginatorTest.kt b/app/src/test/java/com/starry/myne/PaginatorTest.kt index a9439db9..db68d2ae 100644 --- a/app/src/test/java/com/starry/myne/PaginatorTest.kt +++ b/app/src/test/java/com/starry/myne/PaginatorTest.kt @@ -2,7 +2,7 @@ package com.starry.myne import com.google.common.truth.Truth.assertThat -import com.starry.myne.utils.Paginator +import com.starry.myne.helpers.Paginator import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Before diff --git a/app/src/test/java/com/starry/myne/UtilsTest.kt b/app/src/test/java/com/starry/myne/UtilsTest.kt index 4a107c43..a5740b56 100644 --- a/app/src/test/java/com/starry/myne/UtilsTest.kt +++ b/app/src/test/java/com/starry/myne/UtilsTest.kt @@ -1,6 +1,6 @@ package com.starry.myne -import com.starry.myne.utils.Utils.prettyCount +import com.starry.myne.helpers.Utils.prettyCount import junit.framework.TestCase.assertEquals import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest