diff --git a/UIViews/src/main/java/com/programmersbox/uiviews/recent/RecentFragment.kt b/UIViews/src/main/java/com/programmersbox/uiviews/recent/RecentFragment.kt index a44a62e0f..8d56fd818 100644 --- a/UIViews/src/main/java/com/programmersbox/uiviews/recent/RecentFragment.kt +++ b/UIViews/src/main/java/com/programmersbox/uiviews/recent/RecentFragment.kt @@ -33,6 +33,7 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.ListItem import androidx.compose.material3.ListItemDefaults import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.SnackbarHost import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState @@ -70,7 +71,6 @@ import com.programmersbox.uiviews.utils.LocalSourcesRepository import com.programmersbox.uiviews.utils.OtakuBannerBox import com.programmersbox.uiviews.utils.PreviewTheme import com.programmersbox.uiviews.utils.PreviewThemeColorsSizes -import com.programmersbox.uiviews.utils.ToasterItemsSetup import com.programmersbox.uiviews.utils.components.InfiniteListHandler import com.programmersbox.uiviews.utils.components.NoSourcesInstalled import com.programmersbox.uiviews.utils.components.OtakuHazeScaffold @@ -182,7 +182,8 @@ fun RecentView( blurTopBar = showBlur, topBarBlur = { progressive = HazeProgressive.verticalGradient(startIntensity = 1f, endIntensity = 0f, preferPerformance = true) - } + }, + snackbarHost = { SnackbarHost(recentVm.snackbarHostState) } ) { p -> var showBanner by remember { mutableStateOf(false) } OtakuBannerBox( @@ -250,12 +251,6 @@ fun RecentView( } } } - - ToasterItemsSetup( - toastItems = recentVm, - alignment = Alignment.TopCenter, - modifier = Modifier.padding(p) - ) } } diff --git a/UIViews/src/main/java/com/programmersbox/uiviews/recent/RecentViewModel.kt b/UIViews/src/main/java/com/programmersbox/uiviews/recent/RecentViewModel.kt index f5a0c1718..7e97a37a2 100644 --- a/UIViews/src/main/java/com/programmersbox/uiviews/recent/RecentViewModel.kt +++ b/UIViews/src/main/java/com/programmersbox/uiviews/recent/RecentViewModel.kt @@ -1,6 +1,7 @@ package com.programmersbox.uiviews.recent import androidx.compose.foundation.lazy.grid.LazyGridState +import androidx.compose.material3.SnackbarHostState import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateListOf @@ -18,8 +19,6 @@ import com.programmersbox.models.ItemModel import com.programmersbox.models.SourceInformation import com.programmersbox.sharedutils.FirebaseDb import com.programmersbox.uiviews.CurrentSourceRepository -import com.programmersbox.uiviews.utils.DefaultToastItems -import com.programmersbox.uiviews.utils.ToastItems import com.programmersbox.uiviews.utils.combineSources import com.programmersbox.uiviews.utils.dispatchIo import com.programmersbox.uiviews.utils.recordFirebaseException @@ -33,13 +32,14 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onStart +import kotlinx.coroutines.withContext import ru.beryukhov.reactivenetwork.ReactiveNetwork class RecentViewModel( dao: ItemDao, sourceRepository: SourceRepository, currentSourceRepository: CurrentSourceRepository, -) : ViewModel(), ToastItems by DefaultToastItems() { +) : ViewModel() { var isRefreshing by mutableStateOf(false) private val sourceList = mutableStateListOf() @@ -61,6 +61,8 @@ class RecentViewModel( val sources = mutableStateListOf() + val snackbarHostState = SnackbarHostState() + init { combineSources(sourceRepository, dao) .onEach { @@ -118,7 +120,12 @@ class RecentViewModel( ?.dispatchIo() ?.catch { it.printStackTrace() - showError() + withContext(Dispatchers.Main) { + snackbarHostState.showSnackbar( + "Something went wrong", + withDismissAction = true + ) + } emit(emptyList()) recordFirebaseException(it) } diff --git a/UIViews/src/main/java/com/programmersbox/uiviews/utils/ToasterUtils.kt b/UIViews/src/main/java/com/programmersbox/uiviews/utils/ToasterUtils.kt index 1f6c982ca..3af2fffa3 100644 --- a/UIViews/src/main/java/com/programmersbox/uiviews/utils/ToasterUtils.kt +++ b/UIViews/src/main/java/com/programmersbox/uiviews/utils/ToasterUtils.kt @@ -92,11 +92,11 @@ class DefaultToastItems : ToastItems { @Composable fun ToasterItemsSetup( toastItems: ToastItems, + modifier: Modifier = Modifier, scope: CoroutineScope = rememberCoroutineScope(), toaster: ToasterState = rememberToasterState( onToastDismissed = { scope.launch { toastItems.removeError() } } ), - modifier: Modifier = Modifier, alignment: Alignment = Alignment.BottomEnd, ) { LaunchedEffect(toaster, toastItems) { diff --git a/anime_sources/src/main/java/com/programmersbox/anime_sources/utilities/AnimeUtils.kt b/anime_sources/src/main/java/com/programmersbox/anime_sources/utilities/AnimeUtils.kt index 3a735b311..0816e04c2 100644 --- a/anime_sources/src/main/java/com/programmersbox/anime_sources/utilities/AnimeUtils.kt +++ b/anime_sources/src/main/java/com/programmersbox/anime_sources/utilities/AnimeUtils.kt @@ -3,13 +3,22 @@ package com.programmersbox.anime_sources.utilities import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.programmersbox.anime_sources.ShowApi -import okhttp3.* +import okhttp3.CacheControl +import okhttp3.FormBody +import okhttp3.Headers import okhttp3.Headers.Companion.toHeaders +import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrlOrNull +import okhttp3.Interceptor +import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.RequestBody +import okhttp3.Response import okio.BufferedSink import java.net.URI -import java.util.* +import java.util.Locale import java.util.concurrent.TimeUnit import java.util.regex.Pattern import javax.crypto.Cipher @@ -269,8 +278,9 @@ class M3u8Helper { } private fun getParentLink(uri: String): String { - val split = uri.split("/").toMutableList() - split.removeLast() + val split = uri.split("/") + .dropLast(1) + .toMutableList() return split.joinToString("/") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f541ffba1..3a33d10ed 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -35,7 +35,7 @@ okhttpVersion = "4.12.0" ktorVersion = "3.0.1" workVersion = "2.10.0" ziplineVersion = "1.1.0" -landscapist = "2.4.2" +landscapist = "2.4.3" protobufVersion = "4.26.1" sketchVersion = "3.3.2" activity = "1.10.0-beta01" @@ -52,7 +52,7 @@ piasy = "1.8.1" ### AnimeWorld autoBinding = "1.1-beta04" -media3Version = "1.4.1" +media3Version = "1.5.0" junit = "1.2.1" espresso-core = "3.6.1" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 66cd5a0e4..c1d5e0185 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/compose/ReaderCompose.kt b/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/compose/ReaderCompose.kt index 920b197fb..ac88de1ce 100644 --- a/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/compose/ReaderCompose.kt +++ b/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/compose/ReaderCompose.kt @@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.foundation.lazy.LazyListState @@ -31,6 +30,8 @@ import androidx.compose.material3.ModalBottomSheet import androidx.compose.material3.ModalDrawerSheet import androidx.compose.material3.ModalNavigationDrawer import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.rememberDrawerState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -50,9 +51,6 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel -import com.dokar.sonner.ToastType -import com.dokar.sonner.ToasterDefaults -import com.dokar.sonner.rememberToasterState import com.programmersbox.favoritesdatabase.ItemDao import com.programmersbox.mangasettings.ImageLoaderType import com.programmersbox.mangasettings.ReaderType @@ -64,7 +62,6 @@ import com.programmersbox.uiviews.utils.HideSystemBarsWhileOnScreen import com.programmersbox.uiviews.utils.LocalGenericInfo import com.programmersbox.uiviews.utils.LocalItemDao import com.programmersbox.uiviews.utils.LocalSettingsHandling -import com.programmersbox.uiviews.utils.ToasterSetup import com.programmersbox.uiviews.utils.components.OtakuPullToRefreshBox import dev.chrisbanes.haze.HazeProgressive import dev.chrisbanes.haze.HazeState @@ -104,7 +101,7 @@ fun ReadView( ) { HideSystemBarsWhileOnScreen() - val toaster = rememberToasterState() + val snackbarHostState = remember { SnackbarHostState() } val scope = rememberCoroutineScope() @@ -146,12 +143,10 @@ fun ReadView( var middleAction by mangaSettingsHandling.rememberPlayingMiddleAction() fun showToast() { - toaster.show( - message = context.getString(R.string.addedChapterItem), - icon = R.mipmap.ic_launcher, - type = ToastType.Success, - duration = ToasterDefaults.DurationShort - ) + scope.launch { + snackbarHostState.currentSnackbarData?.dismiss() + snackbarHostState.showSnackbar(context.getString(R.string.addedChapterItem)) + } } val listShowItems by remember { derivedStateOf { listState.isScrolledToTheEnd() && readerType == ReaderType.List } } @@ -333,6 +328,7 @@ fun ReadView( } } }, + snackbarHost = { SnackbarHost(hostState = snackbarHostState) } ) { p -> Box( modifier = if (showBlur) @@ -392,10 +388,6 @@ fun ReadView( } } } - ToasterSetup( - toaster = toaster, - modifier = Modifier.padding(p) - ) } } }