Skip to content

Commit

Permalink
Update librariesThis commit updates various libraries and dependencie…
Browse files Browse the repository at this point in the history
…s, including:- `reorderable`: v2.4.0 -> v2.4.2

- `accompanist`: v0.36.0 -> v0.37.0
- `zoomimageComposeGlide`: v1.0.2 -> v1.1.0It also includes code refactoring and adjustments, such as:- Removing unnecessary imports.
- Improving permission requests.
- Adding awaitAll for source population in GlobalSearchViewModel.
- Improving Glide async image loading in ReaderComposeImage.
- Replacing deprecated api in ImageLoaderSettings.
- Adding stacktrace to error output in DownloadViewerFragment.
  • Loading branch information
jacobrein committed Dec 13, 2024
1 parent 3d2cad0 commit b30c3bb
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalSharedTransitionApi
Expand Down Expand Up @@ -113,8 +115,6 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.google.accompanist.drawablepainter.rememberDrawablePainter
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberPermissionState
import com.programmersbox.extensionloader.SourceRepository
import com.programmersbox.favoritesdatabase.ItemDatabase
import com.programmersbox.favoritesdatabase.SourceOrder
Expand Down Expand Up @@ -387,7 +387,7 @@ abstract class BaseMainActivity : AppCompatActivity() {
Modifier.draggable(
orientation = Orientation.Vertical,
state =
rememberDraggableState { delta -> scrollBehavior.state.heightOffset -= delta },
rememberDraggableState { delta -> scrollBehavior.state.heightOffset -= delta },
onDragStopped = { velocity ->
settleAppBarBottom(
scrollBehavior.state,
Expand Down Expand Up @@ -713,12 +713,11 @@ abstract class BaseMainActivity : AppCompatActivity() {
)
}

@OptIn(ExperimentalPermissionsApi::class)
@Composable
fun AskForNotificationPermissions() {
if (Build.VERSION.SDK_INT >= 33) {
val permissions = rememberPermissionState(permission = Manifest.permission.POST_NOTIFICATIONS)
LaunchedEffect(Unit) { permissions.launchPermissionRequest() }
val permissionRequest = rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) {}
LaunchedEffect(Unit) { permissionRequest.launch(Manifest.permission.POST_NOTIFICATIONS) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class GlobalSearchViewModel(
isRefreshing = true
isSearching = true
searchListPublisher = emptyList()
//TODO: Add option to have live population or all at once
async {
sourceRepository.list
.apmap { a ->
Expand All @@ -61,21 +62,26 @@ class GlobalSearchViewModel(
.onCompletion { isRefreshing = false }
}
.forEach { launch { it.collect() } }

// this populates after it all finishes
/*combine(
info.searchList()
.apmap { a ->
a
.searchSourceList(searchText, list = emptyList())
.dispatchIoAndCatchList()
.map { SearchModel(a.serviceName, it) }
/*val d = awaitAll(
*sourceRepository
.list
.mapNotNull { a ->
async {
a
.apiService
.searchSourceList(searchText, list = emptyList())
.dispatchIoAndCatchList()
.map { SearchModel(a.apiService.serviceName, it) }
.filter { it.data.isNotEmpty() }
.firstOrNull()
}
}
) { it.toList().filter { s -> s.data.isNotEmpty() } }
.onStart { isRefreshing = true }
.onCompletion { isRefreshing = false }
.onEach { searchListPublisher = it }
.collect()
*/
.toTypedArray()
).filterNotNull()
searchListPublisher = d
isRefreshing = false*/
}.await()
isSearching = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,50 @@ package com.programmersbox.uiviews.utils.components
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import androidx.compose.foundation.layout.*
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.*
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastAll
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberMultiplePermissionsState
import com.google.accompanist.permissions.shouldShowRationale
import com.programmersbox.uiviews.R

@ExperimentalPermissionsApi
@Composable
fun PermissionRequest(permissionsList: List<String>, content: @Composable () -> Unit) {
val storagePermissions = rememberMultiplePermissionsState(permissionsList)
var hasStoragePermission by remember { mutableStateOf(false) }
val storage = rememberLauncherForActivityResult(
ActivityResultContracts.RequestMultiplePermissions()
) { hasStoragePermission = it.all { it.value } }
val context = LocalContext.current
SideEffect { storagePermissions.launchMultiplePermissionRequest() }
if (storagePermissions.allPermissionsGranted) {
SideEffect { storage.launch(permissionsList.toTypedArray()) }
if (hasStoragePermission) {
content()
} else {
if (storagePermissions.permissions.fastAll { it.status.shouldShowRationale }) {
NeedsPermissions { storagePermissions.launchMultiplePermissionRequest() }
} else {
NeedsPermissions {
context.startActivity(
Intent().apply {
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
data = Uri.fromParts("package", context.packageName, null)
}
)
}
NeedsPermissions {
context.startActivity(
Intent().apply {
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
data = Uri.fromParts("package", context.packageName, null)
}
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ import coil.compose.rememberAsyncImagePainter
import coil.decode.VideoFrameDecoder
import coil.request.ImageRequest
import coil.request.videoFramePercent
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.programmersbox.animeworld.MainActivity
import com.programmersbox.animeworld.R
import com.programmersbox.animeworld.SlideToDeleteDialog
Expand Down Expand Up @@ -97,7 +96,6 @@ import java.util.concurrent.TimeUnit
@OptIn(
ExperimentalMaterial3Api::class,
ExperimentalAnimationApi::class,
ExperimentalPermissionsApi::class
)
@Composable
fun ViewVideoScreen() {
Expand Down
11 changes: 5 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ glideVersion = "4.16.0"
pagecurl = "1.5.1"
pagingVersion = "3.3.5"
protobufGradlePlugin = "0.9.4"
reorderable = "2.4.0"
reorderable = "2.4.2"
roomVersion = "2.7.0-alpha12"
navVersion = "2.9.0-alpha04"
koin-bom = "4.0.0"
Expand All @@ -30,7 +30,7 @@ lifecycle = "2.9.0-alpha08"
jetpack = "1.6.0-alpha03"
jetpackCompiler = "1.5.11"
jetbrainsCompiler = "1.5.1"
accompanist = "0.36.0"
accompanist = "0.37.0"
okhttpVersion = "4.12.0"
ktorVersion = "3.0.2"
workVersion = "2.10.0"
Expand Down Expand Up @@ -61,7 +61,7 @@ benchmark-macro-junit4 = "1.3.0"
androidx-baselineprofile = "1.3.0"
profileinstaller = "1.3.1"
zoomableImageGlide = "0.14.0"
zoomimageComposeGlide = "1.0.2"
zoomimageComposeGlide = "1.1.0"

googleAndroidLibrariesMapsplatformSecretsGradlePlugin = "2.0.1"

Expand Down Expand Up @@ -139,7 +139,6 @@ material-kolor = { module = "com.materialkolor:material-kolor", version.ref = "m

#Accompanist
drawablePainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanist" }
permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" }
adaptive = { module = "com.google.accompanist:accompanist-adaptive", version.ref = "accompanist" }
okhttpLib = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttpVersion" }
okhttpDns = { module = "com.squareup.okhttp3:okhttp-dnsoverhttps", version.ref = "okhttpVersion" }
Expand Down Expand Up @@ -340,7 +339,7 @@ compose = [
"composeRuntimeLivedata",
"landscapist-bom", "landscapistGlide", "landscapistPalette", "landscapistPlaceholder",
"coilCompose",
"composeConstraintLayout", "permissions",
"composeConstraintLayout",
"drawablePainter", "uiUtil",
"materialYou", "materialYou-common",
"materialWindow",
Expand All @@ -354,7 +353,7 @@ composeTv = [
"composeRuntimeLivedata",
"landscapist-bom", "landscapistGlide", "landscapistPalette", "landscapistPlaceholder",
"coilCompose",
"composeConstraintLayout", "permissions",
"composeConstraintLayout",
"drawablePainter", "uiUtil",
"navCompose"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.toRoute
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.programmersbox.favoritesdatabase.DbModel
import com.programmersbox.gsonutils.toJson
import com.programmersbox.helpfulutils.downloadManager
Expand Down Expand Up @@ -262,7 +261,7 @@ class GenericManga(
}
}

@OptIn(ExperimentalPermissionsApi::class, ExperimentalAnimationApi::class)
@OptIn(ExperimentalAnimationApi::class)
override fun composeCustomPreferences(): ComposeSettingsDsl.() -> Unit = {

viewSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import androidx.compose.ui.util.fastForEach
import androidx.core.net.toUri
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.programmersbox.mangaworld.ChaptersGet
import com.programmersbox.mangaworld.DOWNLOAD_FILE_PATH
import com.programmersbox.mangaworld.MangaSettingsHandling
Expand All @@ -83,7 +82,6 @@ import androidx.compose.material3.MaterialTheme as M3MaterialTheme

@OptIn(
ExperimentalMaterial3Api::class,
ExperimentalPermissionsApi::class,
ExperimentalFoundationApi::class,
ExperimentalAnimationApi::class,
)
Expand Down Expand Up @@ -263,6 +261,7 @@ private fun ChapterItem(
}
emit(true)
} catch (e: Exception) {
e.printStackTrace()
emit(false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import coil.request.ImageRequest
import coil.size.Size
import com.bumptech.glide.load.model.GlideUrl
import com.github.panpf.zoomimage.GlideZoomAsyncImage
import com.github.panpf.zoomimage.compose.glide.internal.ExperimentalGlideComposeApi
import com.github.panpf.zoomimage.compose.glide.ExperimentalGlideComposeApi
import com.github.panpf.zoomimage.rememberGlideZoomState
import com.github.panpf.zoomimage.zoom.ReadMode
import com.programmersbox.mangasettings.ImageLoaderType
import com.programmersbox.mangaworld.R
Expand Down Expand Up @@ -182,14 +183,14 @@ internal fun Panpf(
.fillMaxWidth()
.clip(RectangleShape)
) {
val state = com.github.panpf.zoomimage.compose.rememberZoomState()
val state = rememberGlideZoomState()
LaunchedEffect(Unit) {
state.zoomable.readMode = ReadMode(ReadMode.SIZE_TYPE_VERTICAL, ReadMode.Decider.Default)
}

GlideZoomAsyncImage(
model = remember(painter) { GlideUrl(painter) { headers } },
state = state,
zoomState = state,
contentDescription = null,
contentScale = contentScale,
scrollBar = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private fun Coil(
)
}

@OptIn(com.github.panpf.zoomimage.compose.glide.internal.ExperimentalGlideComposeApi::class)
@OptIn(com.github.panpf.zoomimage.compose.glide.ExperimentalGlideComposeApi::class)
@Composable
private fun Panpf(
url: String,
Expand Down

0 comments on commit b30c3bb

Please sign in to comment.