Crash fixes (#38)
* Updated animation specifications for UI controls and overlays to use a 200ms tween duration. * Implemented fallback file picker and improved CSS rule merging efficiency to fix OOM.
This commit is contained in:
parent
77a09c545f
commit
3a31e4fc7b
7 changed files with 133 additions and 58 deletions
|
|
@ -109,6 +109,7 @@ import com.aryan.reader.data.RecentFileItem
|
|||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
|
@ -156,7 +157,14 @@ fun LibraryScreen(
|
|||
viewModel.setSyncedFolder(it)
|
||||
}
|
||||
}
|
||||
val onSelectSyncFolderClick = { pickFolderLauncher.launch(null) }
|
||||
|
||||
val onSelectSyncFolderClick = {
|
||||
try {
|
||||
pickFolderLauncher.launch(null)
|
||||
} catch (_: android.content.ActivityNotFoundException) {
|
||||
viewModel.showBanner("Your device doesn't support folder selection. You can still import files individually.", isError = true)
|
||||
}
|
||||
}
|
||||
|
||||
val pickFileLauncher = rememberFilePickerLauncher { uris ->
|
||||
if (isContextualModeActive) {
|
||||
|
|
@ -167,11 +175,31 @@ fun LibraryScreen(
|
|||
}
|
||||
}
|
||||
|
||||
val fallbackFilePickerLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.GetMultipleContents()
|
||||
) { uris ->
|
||||
if (isContextualModeActive) {
|
||||
viewModel.clearContextualAction()
|
||||
}
|
||||
uris.forEach { uri ->
|
||||
viewModel.onFileSelected(uri, isFromRecent = false)
|
||||
}
|
||||
}
|
||||
|
||||
val onSelectFileClick = {
|
||||
if (isContextualModeActive) {
|
||||
viewModel.clearContextualAction()
|
||||
}
|
||||
pickFileLauncher.launch(arrayOf("*/*"))
|
||||
try {
|
||||
pickFileLauncher.launch(arrayOf("*/*"))
|
||||
} catch (_: android.content.ActivityNotFoundException) {
|
||||
Timber.w("OpenDocument picker failed. Falling back to GetMultipleContents.")
|
||||
try {
|
||||
fallbackFilePickerLauncher.launch("*/*")
|
||||
} catch (_: android.content.ActivityNotFoundException) {
|
||||
viewModel.showBanner("No file manager found. Please install a file manager app.", isError = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(pagerState) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue