v1.0.47 (#279)
* Add performance and stylus debugging logs * Refactor and decouple UI models from `MainViewModel` * Refactor library state management and projection logic * Implement desktop shell using Compose Multiplatform * Implement desktop shell using Compose Multiplatform * Implement desktop shell using Compose Multiplatform * Introduce ReaderEngine and enhance EPUB reader features in windows app * Move core paginated reader logic to a Kotlin Multiplatform `shared` module and introduce experimental desktop support. * Implement PDF rendering and text extraction for desktop using Pdfium * Add `NonReaderScreens.kt` and UI dependencies * Refactor and centralize library state management and models to improve cross-platform consistency * Implement JSON persistence for desktop library and enhance library management features including shelf CRUD, tagging, and metadata editing * Implement PDF annotation system and enhanced zoom controls for the desktop viewer * Implement WebView-based EPUB rendering for desktop using CEF and embedded resources * Optimize UI state projection, navigation state handling, and main screen pager performance * Implement Bring Your Own Key (BYOK) support for AI features in OSS version * Support Gemini-based Cloud TTS with BYOK support for OSS builds * Refactor table cell image sizing in `PaginatedReader` and improve `MobiParser` native library loading and error handling. * crash fixes * Enhance navigation stability with lifecycle-aware safety checks and update `navigation-compose` to 2.9.6 * Implement dynamic bottom padding for the page info bar to account for device rounded corners * Implement bidirectional jump history navigation and replace the jump-back pill with a dedicated `PdfJumpHistoryBar` * Optimize PDF tiling performance and refine pan-and-fling gesture handling * Implement customizable toolbars with drag-and-drop reordering and placement for PDF and EPUB readers * Updated UI for customize toolbar * Refine drag-and-drop reordering and section assignment for PDF and EPUB reader controls * restructure PDF viewer UI component hierarchy to fix verifier crash * Implement separate text dimming factors for light and dark themes * Synchronize Pdfium access and improve resource lifecycle safety across Kotlin and native layers * Enhance image alignment in paginated and EPUB readers through anchor detection and style-based positioning * Centralize file type resolution logic and implement HTML sanitization during import * Introduce vertical margin customization and configurable progress bar positioning * texture support in epub reader * Enhance TTS session management, progress tracking, and diagnostic logging * Optimize library state projection and folder synchronization performance by refactoring collection lookups and refining metadata extraction logic. * Refine TTS page mapping for PDF and overhaul TTS control UI * Implement natural session completion logic in `TtsPlaybackManager` for cloud tts * Replace Snackbar with `CustomTopBanner` for notifications in `PdfViewerScreen` * Refine TTS playback continuity across PDF pages and improve state management for session transitions * Implement global texture transparency and enhance textured theme support across PDF and EPUB readers. * Update reader themes and improve texture rendering in page animations, EPUB UI, and immersive mode * Add Support Project screen * Optimize library performance via projection caching, batch database updates, and scoped folder synchronization. * Enhance folder synchronization with fallback query mechanisms and refactor annotation sidecar importing logic * Bump version to 1.0.47 (51)
This commit is contained in:
parent
f42de6b462
commit
d7a9cae9e1
126 changed files with 15287 additions and 3154 deletions
|
|
@ -43,13 +43,18 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.media3.common.util.UnstableApi
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import com.aryan.reader.epubreader.EpubReaderScreen
|
||||
import com.aryan.reader.feedback.FeedbackScreen
|
||||
import com.aryan.reader.feedback.SupportProjectScreen
|
||||
import com.aryan.reader.pdf.PdfViewerScreen
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
object AppDestinations {
|
||||
const val MAIN_ROUTE = "main"
|
||||
|
|
@ -57,19 +62,74 @@ object AppDestinations {
|
|||
const val EPUB_READER_ROUTE = "epub_reader"
|
||||
const val PRO_SCREEN_ROUTE = "pro_screen"
|
||||
const val FEEDBACK_SCREEN_ROUTE = "feedback_screen_route"
|
||||
const val SUPPORT_PROJECT_SCREEN_ROUTE = "support_project_screen_route"
|
||||
const val FONTS_SCREEN_ROUTE = "fonts_screen_route"
|
||||
const val AI_SETTINGS_SCREEN_ROUTE = "ai_settings_screen_route"
|
||||
}
|
||||
|
||||
private fun NavHostController.isReadyForBackStackChange(): Boolean {
|
||||
return currentBackStackEntry?.lifecycle?.currentState == Lifecycle.State.RESUMED
|
||||
}
|
||||
|
||||
private suspend fun NavHostController.awaitReadyForBackStackChange() {
|
||||
while (!isReadyForBackStackChange()) {
|
||||
delay(32)
|
||||
}
|
||||
}
|
||||
|
||||
private fun NavHostController.navigateSingleTopTo(route: String) {
|
||||
navigate(route) {
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
popUpTo(graph.startDestinationId) {
|
||||
saveState = true
|
||||
if (!isReadyForBackStackChange()) {
|
||||
Timber.d("Skipping navigation to $route because the current entry is not resumed yet.")
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
navigate(route) {
|
||||
launchSingleTop = true
|
||||
popUpTo(graph.startDestinationId) {
|
||||
saveState = false
|
||||
}
|
||||
}
|
||||
} catch (e: IllegalStateException) {
|
||||
Timber.w(e, "Navigation to $route ignored because the back stack is mid-transition.")
|
||||
}
|
||||
}
|
||||
|
||||
private fun NavHostController.navigateToMain() {
|
||||
navigateSingleTopTo(AppDestinations.MAIN_ROUTE)
|
||||
}
|
||||
|
||||
private fun NavHostController.navigateIfReady(route: String) {
|
||||
if (currentDestination?.route == route) return
|
||||
navigateSingleTopTo(route)
|
||||
}
|
||||
|
||||
private fun NavHostController.popBackStackIfReady(): Boolean {
|
||||
if (!isReadyForBackStackChange()) {
|
||||
Timber.d("Skipping popBackStack because the current entry is not resumed yet.")
|
||||
return false
|
||||
}
|
||||
|
||||
return try {
|
||||
popBackStack()
|
||||
} catch (e: IllegalStateException) {
|
||||
Timber.w(e, "popBackStack ignored because the back stack is mid-transition.")
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun NavHostController.syncRouteTo(route: String) {
|
||||
awaitReadyForBackStackChange()
|
||||
if (currentDestination?.route != route) {
|
||||
if (route == AppDestinations.MAIN_ROUTE) {
|
||||
navigateToMain()
|
||||
} else {
|
||||
navigateSingleTopTo(route)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@androidx.annotation.OptIn(UnstableApi::class)
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
|
||||
@Composable
|
||||
|
|
@ -80,34 +140,31 @@ fun AppNavigation(
|
|||
) {
|
||||
Timber.d("AppNavigation composable invoked.")
|
||||
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
val currentBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = currentBackStackEntry?.destination?.route
|
||||
|
||||
LaunchedEffect(uiState.selectedFileType, uiState.isLoading, uiState.selectedEpubBook, uiState.selectedPdfUri) {
|
||||
LaunchedEffect(currentRoute, uiState.selectedFileType, uiState.isLoading, uiState.selectedEpubBook, uiState.selectedPdfUri) {
|
||||
if (!uiState.isLoading) {
|
||||
try {
|
||||
when (uiState.selectedFileType) {
|
||||
FileType.PDF, FileType.CBZ, FileType.CBR, FileType.CB7 -> {
|
||||
if (uiState.selectedPdfUri != null) {
|
||||
if (navController.currentDestination?.route != AppDestinations.PDF_VIEWER_ROUTE) {
|
||||
navController.navigateSingleTopTo(AppDestinations.PDF_VIEWER_ROUTE)
|
||||
}
|
||||
}
|
||||
}
|
||||
FileType.EPUB, FileType.MOBI, FileType.MD, FileType.TXT, FileType.HTML, FileType.FB2, FileType.DOCX, FileType.ODT, FileType.FODT -> {
|
||||
if (uiState.selectedEpubBook != null) {
|
||||
if (navController.currentDestination?.route != AppDestinations.EPUB_READER_ROUTE) {
|
||||
navController.navigateSingleTopTo(AppDestinations.EPUB_READER_ROUTE)
|
||||
}
|
||||
}
|
||||
}
|
||||
null -> {
|
||||
val currentRoute = navController.currentBackStackEntry?.destination?.route
|
||||
if (currentRoute != null && currentRoute != AppDestinations.MAIN_ROUTE) {
|
||||
navController.navigateSingleTopTo(AppDestinations.MAIN_ROUTE)
|
||||
when (uiState.selectedFileType) {
|
||||
FileType.PDF, FileType.CBZ, FileType.CBR, FileType.CB7 -> {
|
||||
if (uiState.selectedPdfUri != null) {
|
||||
if (currentRoute != AppDestinations.PDF_VIEWER_ROUTE) {
|
||||
navController.syncRouteTo(AppDestinations.PDF_VIEWER_ROUTE)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: IllegalStateException) {
|
||||
Timber.w(e, "Navigation transition already in progress, ignoring.")
|
||||
FileType.EPUB, FileType.MOBI, FileType.MD, FileType.TXT, FileType.HTML, FileType.FB2, FileType.DOCX, FileType.ODT, FileType.FODT -> {
|
||||
if (uiState.selectedEpubBook != null) {
|
||||
if (currentRoute != AppDestinations.EPUB_READER_ROUTE) {
|
||||
navController.syncRouteTo(AppDestinations.EPUB_READER_ROUTE)
|
||||
}
|
||||
}
|
||||
}
|
||||
null -> {
|
||||
if (currentRoute == AppDestinations.PDF_VIEWER_ROUTE || currentRoute == AppDestinations.EPUB_READER_ROUTE) {
|
||||
navController.syncRouteTo(AppDestinations.MAIN_ROUTE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -153,7 +210,7 @@ fun AppNavigation(
|
|||
}
|
||||
},
|
||||
onNavigateToPro = {
|
||||
navController.navigate(AppDestinations.PRO_SCREEN_ROUTE)
|
||||
navController.navigateIfReady(AppDestinations.PRO_SCREEN_ROUTE)
|
||||
},
|
||||
viewModel = viewModel
|
||||
)
|
||||
|
|
@ -226,7 +283,7 @@ fun AppNavigation(
|
|||
}
|
||||
},
|
||||
onNavigateToPro = {
|
||||
navController.navigate(AppDestinations.PRO_SCREEN_ROUTE)
|
||||
navController.navigateIfReady(AppDestinations.PRO_SCREEN_ROUTE)
|
||||
},
|
||||
onRenderModeChange = viewModel::setRenderMode,
|
||||
customFonts = customFonts,
|
||||
|
|
@ -276,7 +333,7 @@ fun AppNavigation(
|
|||
composable(route = AppDestinations.PRO_SCREEN_ROUTE) {
|
||||
ProScreen(
|
||||
viewModel = viewModel,
|
||||
onNavigateBack = { navController.popBackStack() }
|
||||
onNavigateBack = { navController.popBackStackIfReady() }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -286,10 +343,22 @@ fun AppNavigation(
|
|||
)
|
||||
}
|
||||
|
||||
composable(route = AppDestinations.SUPPORT_PROJECT_SCREEN_ROUTE) {
|
||||
SupportProjectScreen(
|
||||
navController = navController
|
||||
)
|
||||
}
|
||||
|
||||
composable(route = AppDestinations.FONTS_SCREEN_ROUTE) {
|
||||
FontsScreen(
|
||||
viewModel = viewModel,
|
||||
onBackClick = { navController.popBackStack() }
|
||||
onBackClick = { navController.popBackStackIfReady() }
|
||||
)
|
||||
}
|
||||
|
||||
composable(route = AppDestinations.AI_SETTINGS_SCREEN_ROUTE) {
|
||||
AiSettingsScreen(
|
||||
onBackClick = { navController.popBackStackIfReady() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue