diff --git a/app/src/main/java/com/melonhead/mangadexfollower/App.kt b/app/src/main/java/com/melonhead/mangadexfollower/App.kt index 6fda57a..ad16849 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/App.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/App.kt @@ -56,7 +56,7 @@ class App: Application() { override fun onStop(owner: LifecycleOwner) { super.onStop(owner) inForeground = false - com.melonhead.lib_logging.Clog.i("onStop: Creating background task") + Clog.i("onStop: Creating background task") val refreshWorkRequest = PeriodicWorkRequestBuilder(15.minutes.toJavaDuration()).build() WorkManager.getInstance(this@App).enqueueUniquePeriodicWork("refresh-task", ExistingPeriodicWorkPolicy.KEEP, refreshWorkRequest) } diff --git a/app/src/main/java/com/melonhead/mangadexfollower/extensions/HttpClientExtensions.kt b/app/src/main/java/com/melonhead/mangadexfollower/extensions/HttpClientExtensions.kt index fa5276a..5db9e6a 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/extensions/HttpClientExtensions.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/extensions/HttpClientExtensions.kt @@ -8,7 +8,7 @@ import io.ktor.client.statement.* import kotlin.random.Random suspend inline fun HttpClient.catching(logMessage: String, function: HttpClient.() -> HttpResponse): T? { - com.melonhead.lib_logging.Clog.i(logMessage) + Clog.i(logMessage) var response: HttpResponse? = null return try { response = function() @@ -21,14 +21,14 @@ suspend inline fun HttpClient.catching(logMessage: String, function: App.authFailed() } } else { - com.melonhead.lib_logging.Clog.e("$logMessage: ${response?.bodyAsText() ?: ""}", e) + Clog.e("$logMessage: ${response?.bodyAsText() ?: ""}", e) } null } } suspend inline fun HttpClient.catchingSuccess(logMessage: String, function: HttpClient.() -> HttpResponse): Boolean { - com.melonhead.lib_logging.Clog.i(logMessage) + Clog.i(logMessage) var response: HttpResponse? = null return try { response = function() @@ -41,7 +41,7 @@ suspend inline fun HttpClient.catchingSuccess(logMessage: String, function: Http App.authFailed() } } else { - com.melonhead.lib_logging.Clog.e("$logMessage: ${response?.bodyAsText() ?: ""}", e) + Clog.e("$logMessage: ${response?.bodyAsText() ?: ""}", e) } false } diff --git a/app/src/main/java/com/melonhead/mangadexfollower/models/shared/PaginatedResponse.kt b/app/src/main/java/com/melonhead/mangadexfollower/models/shared/PaginatedResponse.kt index 90afca1..dcc08a5 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/models/shared/PaginatedResponse.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/models/shared/PaginatedResponse.kt @@ -21,7 +21,7 @@ suspend inline fun handlePagination( if (fetchAll) total = response.total response.data } catch (e: Exception) { - com.melonhead.lib_logging.Clog.e("handlePagination: ${result.bodyAsText()}", e) + Clog.e("handlePagination: ${result.bodyAsText()}", e) break } allItems.addAll(items) diff --git a/app/src/main/java/com/melonhead/mangadexfollower/notifications/AuthFailedNotification.kt b/app/src/main/java/com/melonhead/mangadexfollower/notifications/AuthFailedNotification.kt index 0bd45a3..bc1ddd9 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/notifications/AuthFailedNotification.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/notifications/AuthFailedNotification.kt @@ -48,7 +48,7 @@ object AuthFailedNotification { val notificationManager = NotificationManagerCompat.from(context) - com.melonhead.lib_logging.Clog.i("postAuthFailed: Auth failed") + Clog.i("postAuthFailed: Auth failed") val notification = buildNotification(context) notificationManager.notify(Random.nextInt(), notification) } diff --git a/app/src/main/java/com/melonhead/mangadexfollower/notifications/NewChapterNotification.kt b/app/src/main/java/com/melonhead/mangadexfollower/notifications/NewChapterNotification.kt index d53a495..9c01f3a 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/notifications/NewChapterNotification.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/notifications/NewChapterNotification.kt @@ -64,7 +64,7 @@ object NewChapterNotification { val notificationManager = NotificationManagerCompat.from(context) - com.melonhead.lib_logging.Clog.i("post: New chapters for ${series.count()} manga") + Clog.i("post: New chapters for ${series.count()} manga") series.forEach { manga -> manga.chapters.filter { it.createdDate >= installDateSeconds }.forEach chapters@{ uiChapter -> val pendingIntent = pendingIntent(context, manga, uiChapter) ?: return@chapters diff --git a/app/src/main/java/com/melonhead/mangadexfollower/repositories/AuthRepository.kt b/app/src/main/java/com/melonhead/mangadexfollower/repositories/AuthRepository.kt index c457a0b..00694e8 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/repositories/AuthRepository.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/repositories/AuthRepository.kt @@ -34,7 +34,7 @@ class AuthRepository( suspend fun refreshToken(logoutOnFail: Boolean = false): AuthToken? { suspend fun signOut() { - com.melonhead.lib_logging.Clog.e("Signing out, refresh failed", Exception()) + Clog.e("Signing out, refresh failed", Exception()) mutableIsLoggedIn.value = LoginStatus.LoggedOut if ((appContext as App).inForeground) return val notificationManager = NotificationManagerCompat.from(appContext) @@ -56,14 +56,14 @@ class AuthRepository( val userResponse = userService.getInfo(newToken) val userId = userResponse?.data?.id if (userId == null) { - com.melonhead.lib_logging.Clog.e("User info returned null", RuntimeException()) + Clog.e("User info returned null", RuntimeException()) } appDataService.updateUserId(userId ?: "") } return newToken } suspend fun authenticate(email: String, password: String) { - com.melonhead.lib_logging.Clog.i("authenticate") + Clog.i("authenticate") mutableIsLoggedIn.value = LoginStatus.LoggingIn val token = loginService.authenticate(email, password) appDataService.updateToken(token) diff --git a/app/src/main/java/com/melonhead/mangadexfollower/repositories/MangaRepository.kt b/app/src/main/java/com/melonhead/mangadexfollower/repositories/MangaRepository.kt index 8fadcbf..c67e0ad 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/repositories/MangaRepository.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/repositories/MangaRepository.kt @@ -87,11 +87,11 @@ class MangaRepository( // refresh auth val token = authRepository.refreshToken() if (token == null) { - com.melonhead.lib_logging.Clog.i("Failed to refresh token") + Clog.i("Failed to refresh token") return@launch } - com.melonhead.lib_logging.Clog.i("refreshManga") + Clog.i("refreshManga") mutableRefreshStatus.value = Following // fetch chapters from server @@ -99,7 +99,7 @@ class MangaRepository( val chapterEntities = chaptersResponse.map { ChapterEntity.from(it) } val newChapters = chapterEntities.filter { !chapterDb.containsChapter(it.id) } - com.melonhead.lib_logging.Clog.i("New chapters: ${newChapters.count()}") + Clog.i("New chapters: ${newChapters.count()}") if (newChapters.isNotEmpty()) { mutableRefreshStatus.value = MangaSeries @@ -111,7 +111,7 @@ class MangaRepository( // fetch manga series val newMangaIds = mangaIds.filter { !mangaDb.containsManga(it) } - com.melonhead.lib_logging.Clog.i("New manga: ${newMangaIds.count()}") + Clog.i("New manga: ${newMangaIds.count()}") if (newMangaIds.isNotEmpty()) { val newMangaSeries = mangaService.getManga(token, newMangaIds.toList()) @@ -135,7 +135,7 @@ class MangaRepository( val notificationManager = NotificationManagerCompat.from(appContext) if (!notificationManager.areNotificationsEnabled()) return val installDateSeconds = appDataService.installDateSeconds.firstOrNull() ?: 0L - com.melonhead.lib_logging.Clog.i("notifyOfNewChapters") + Clog.i("notifyOfNewChapters") val newChapters = chapterDb.getAllSync().filter { readMarkerDb.isRead(it.mangaId, it.chapter) != true } val manga = mangaDb.getAllSync() @@ -146,7 +146,7 @@ class MangaRepository( private suspend fun refreshReadStatus() { // make sure we have a token val token = appDataService.token.firstOrNull() ?: return - com.melonhead.lib_logging.Clog.i("refreshReadStatus") + Clog.i("refreshReadStatus") val manga = mangaDb.getAllSync() val chapters = chapterDb.getAllSync() diff --git a/app/src/main/java/com/melonhead/mangadexfollower/services/AtHomeService.kt b/app/src/main/java/com/melonhead/mangadexfollower/services/AtHomeService.kt index e6c8343..d338b8f 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/services/AtHomeService.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/services/AtHomeService.kt @@ -23,7 +23,7 @@ class AtHomeServiceImpl( authToken: AuthToken, chapterId: String ): AtHomeChapterResponse? { - com.melonhead.lib_logging.Clog.i("getChapterData: $chapterId") + Clog.i("getChapterData: $chapterId") return client.catching("getChapterData") { client.get(CHAPTER_DATA_URL + chapterId) { headers { diff --git a/app/src/main/java/com/melonhead/mangadexfollower/services/LoginService.kt b/app/src/main/java/com/melonhead/mangadexfollower/services/LoginService.kt index c6ac2f2..942ad16 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/services/LoginService.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/services/LoginService.kt @@ -45,7 +45,7 @@ class LoginServiceImpl( val response: AuthResponse? = result.body() if (response?.result == "ok") response.token else null } catch (e: Exception) { - com.melonhead.lib_logging.Clog.w(e.localizedMessage ?: "Unknown error") + Clog.w(e.localizedMessage ?: "Unknown error") if (logoutOnFail) null else token } } diff --git a/app/src/main/java/com/melonhead/mangadexfollower/services/MangaService.kt b/app/src/main/java/com/melonhead/mangadexfollower/services/MangaService.kt index 8d08768..58b8973 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/services/MangaService.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/services/MangaService.kt @@ -29,7 +29,7 @@ class MangaServiceImpl( private val client: HttpClient, ): MangaService { override suspend fun getManga(token: AuthToken, mangaIds: List): List { - com.melonhead.lib_logging.Clog.i("getManga: ${mangaIds.count()}") + Clog.i("getManga: ${mangaIds.count()}") val result: List = handlePagination(mangaIds.count()) { offset -> client.catching("getManga") { client.get(MANGA_URL) { @@ -50,10 +50,10 @@ class MangaServiceImpl( } override suspend fun getReadChapters(token: AuthToken, mangaIds: List): List { - com.melonhead.lib_logging.Clog.i("getReadChapters: total ${mangaIds.count()}") + Clog.i("getReadChapters: total ${mangaIds.count()}") val allChapters = mutableListOf() mangaIds.chunked(100).map { list -> - com.melonhead.lib_logging.Clog.i("getReadChapters: chunked ${list.count()}") + Clog.i("getReadChapters: chunked ${list.count()}") val result: MangaReadMarkersResponse? = client.catching("getReadChapters") { client.get(MANGA_READ_MARKERS_URL) { headers { @@ -74,7 +74,7 @@ class MangaServiceImpl( } override suspend fun changeReadStatus(token: AuthToken, uiManga: UIManga, uiChapter: UIChapter, readStatus: Boolean) { - com.melonhead.lib_logging.Clog.i("changeReadStatus: chapter ${uiChapter.title} readStatus $readStatus") + Clog.i("changeReadStatus: chapter ${uiChapter.title} readStatus $readStatus") client.catchingSuccess("changeReadStatus") { client.post(MANGA_READ_CHAPTER_MARKERS_URL.replace(ID_PLACEHOLDER, uiManga.id)) { headers { diff --git a/app/src/main/java/com/melonhead/mangadexfollower/services/UserService.kt b/app/src/main/java/com/melonhead/mangadexfollower/services/UserService.kt index 79fd89b..dd5b4de 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/services/UserService.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/services/UserService.kt @@ -21,7 +21,7 @@ class UserServiceImpl( private val client: HttpClient ): UserService { override suspend fun getFollowedChapters(token: AuthToken): List { - com.melonhead.lib_logging.Clog.i("getFollowedChapters") + Clog.i("getFollowedChapters") return handlePagination(50, fetchAll = false) { offset -> client.catching("getFollowedChapters") { client.get(HttpRoutes.USER_FOLLOW_CHAPTERS_URL) { @@ -41,7 +41,7 @@ class UserServiceImpl( } override suspend fun getInfo(token: AuthToken): UserResponse? { - com.melonhead.lib_logging.Clog.i("Get user") + Clog.i("Get user") return client.catching("getInfo") { client.get(HttpRoutes.USER_ME_URL) { headers { diff --git a/app/src/main/java/com/melonhead/mangadexfollower/ui/scenes/chapter_reader/native_chapter_reader/ChapterScreen.kt b/app/src/main/java/com/melonhead/mangadexfollower/ui/scenes/chapter_reader/native_chapter_reader/ChapterScreen.kt index 52ed7cd..5cfc599 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/ui/scenes/chapter_reader/native_chapter_reader/ChapterScreen.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/ui/scenes/chapter_reader/native_chapter_reader/ChapterScreen.kt @@ -50,7 +50,7 @@ internal fun ChapterScreen( LaunchedEffect(key1 = allPages) { val preloadPages = 2 - com.melonhead.lib_logging.Clog.i("First page - Preloading pages 1 - ${1 + preloadPages}") + Clog.i("First page - Preloading pages 1 - ${1 + preloadPages}") allPages.slice(min(1, allPages.count() - 1)..min((1 + preloadPages), allPages.count() - 1)).forEach { page -> preloadImage(page, allPages.indexOf(page)) } @@ -67,7 +67,7 @@ internal fun ChapterScreen( val nextPreloadIndex = currentPageIndex + 2 val start = min(nextPreloadIndex, totalPages - 1) val end = min(totalPages - 1, nextPreloadIndex + 1) - com.melonhead.lib_logging.Clog.i("Next page - Current Page $currentPageIndex, moving to ${currentPageIndex + 1} Preloading pages $start - $end") + Clog.i("Next page - Current Page $currentPageIndex, moving to ${currentPageIndex + 1} Preloading pages $start - $end") allPages.slice(start..end).forEach { preloadImage(it, allPages.indexOf(it)) } @@ -157,7 +157,7 @@ private fun ChapterView( val (width, height) = getWidthHeight() SubcomposeAsyncImage( model = currentPageUrl.preloadImageRequest(pageIndex = currentPageIndex, LocalContext.current, width, height, retryHash) { - com.melonhead.lib_logging.Clog.i("Retrying due to load failure") + Clog.i("Retrying due to load failure") retryHash = !retryHash }, loading = { @@ -193,17 +193,17 @@ private fun String.preloadImageRequest(pageIndex: Int, context: Context, width: .crossfade(true) .listener( onStart = { - com.melonhead.lib_logging.Clog.i("Image Load start: page $pageIndex") + Clog.i("Image Load start: page $pageIndex") }, onCancel = { - com.melonhead.lib_logging.Clog.i("Image Load cancel: page $pageIndex") + Clog.i("Image Load cancel: page $pageIndex") }, onSuccess = { _, result -> - com.melonhead.lib_logging.Clog.i("Image Load success: Source ${result.dataSource.name}, page $pageIndex") + Clog.i("Image Load success: Source ${result.dataSource.name}, page $pageIndex") }, onError = { _, result -> - com.melonhead.lib_logging.Clog.i("Image Load failed: page $pageIndex") - com.melonhead.lib_logging.Clog.e("Image Load failed", result.throwable) + Clog.i("Image Load failed: page $pageIndex") + Clog.e("Image Load failed", result.throwable) onError() } ) diff --git a/app/src/main/java/com/melonhead/mangadexfollower/ui/viewmodels/ChapterViewModel.kt b/app/src/main/java/com/melonhead/mangadexfollower/ui/viewmodels/ChapterViewModel.kt index 4ab2d24..5253082 100644 --- a/app/src/main/java/com/melonhead/mangadexfollower/ui/viewmodels/ChapterViewModel.kt +++ b/app/src/main/java/com/melonhead/mangadexfollower/ui/viewmodels/ChapterViewModel.kt @@ -44,7 +44,7 @@ class ChapterViewModel( if (!manga.useWebview) { mangaRepository.setUseWebview(manga, true) } - com.melonhead.lib_logging.Clog.i("Falling back to webview") + Clog.i("Falling back to webview") // fallback to secondary render style val intent = WebViewActivity.newIntent(activity, chapter, manga) activity.finish()