Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.
Rust androiddocument-scannerdocximage-editorjetpack-composekotlinliquid-glassofflineopen-sourcepdfpdf-compressorpdf-editorpdf-mergerpdf-readerpdf-splitterpdf-toolspdf-viewerpptxspreadsheet-editorxlsx
feat: Extra Features in Preferences, with the status bar in documents (#24, #2)
Josh1efb657f008e
diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.ktindex 980c701..c63d494 100644--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/AppViewModel.kt@@ -812,6 +812,18 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {appPrefs.edit().putString("theme", t.name).apply()}+ /**+ * Extra Features ▸ the status bar in documents: shown with the viewer's bars, and the page uses the+ * whole screen when they hide (off: the reference's black band where the camera is).+ */+ var statusBarInDocuments by mutableStateOf(appPrefs.getBoolean("statusBarInDocuments", false))+ private set++ fun updateStatusBarInDocuments(on: Boolean) {+ statusBarInDocuments = on+ appPrefs.edit().putBoolean("statusBarInDocuments", on).apply()+ }+// ---- Reading the document ---------------------------------------------------------------suspend fun outline(doc: OpenDocument) = engine?.let { e -> runCatching { e.command { outline(doc.id) } }.getOrNull() }.orEmpty()diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.ktindex b237ccd..02ff6d9 100644--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/home/Tabs.kt@@ -383,6 +383,14 @@ private fun Preferences(vm: AppViewModel) {stringResource(R.string.home_keyboard_shortcuts_body),color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp),)+ SheetDivider()+ // what PdfCraft does differently from the reference, each by choice+ Section(stringResource(R.string.home_section_extra))+ Text(stringResource(R.string.home_extra_body), color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp))+ SheetRow(null, stringResource(R.string.home_status_bar_in_documents), { vm.updateStatusBarInDocuments(!vm.statusBarInDocuments) }) {+ PdfSwitch(vm.statusBarInDocuments, { vm.updateStatusBarInDocuments(it) })+ }+ Text(stringResource(R.string.home_status_bar_in_documents_body), color = c.textSecondary, fontSize = 13.sp, modifier = Modifier.padding(horizontal = 20.dp))Spacer(Modifier.height(24.dp))if (authorDialog) {var name by remember { mutableStateOf(vm.toolPrefs.author) }diff --git a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.ktindex 285aeee..8da34a0 100644--- a/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt+++ b/apps/pdfcraft-android/android/app/src/main/java/io/github/artcraftandroid/pdfcraft/ui/viewer/ViewerScreen.kt@@ -88,17 +88,20 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {val context = LocalContext.current// The system bars go with the viewer's bars.- DisposableEffect(ctl.barsVisible) {+ val statusBar = vm.statusBarInDocuments+ DisposableEffect(ctl.barsVisible, statusBar, c.dark) {val window = (context as? Activity)?.windowif (window != null) {val insets = WindowCompat.getInsetsController(window, view)insets.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE// the status bar stays hidden in the viewer (a black band where the camera is), as the- // reference's; the navigation bar comes and goes with the viewer's bars- insets.hide(WindowInsetsCompat.Type.statusBars())+ // reference's, unless Extra Features shows it with the bars; the navigation bar comes and+ // goes with the viewer's bars+ if (statusBar && ctl.barsVisible) insets.show(WindowInsetsCompat.Type.statusBars()) else insets.hide(WindowInsetsCompat.Type.statusBars())if (ctl.barsVisible) insets.show(WindowInsetsCompat.Type.navigationBars()) else insets.hide(WindowInsetsCompat.Type.navigationBars())- // light status icons on the black band, as the reference has in both themes- insets.isAppearanceLightStatusBars = false+ // light status icons on the black band, as the reference has in both themes; shown, they+ // sit on the top bar's colour+ insets.isAppearanceLightStatusBars = statusBar && !c.darkinsets.isAppearanceLightNavigationBars = !c.dark}onDispose {@@ -114,10 +117,11 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {var quickExtraPx by remember { mutableIntStateOf(0) }val bottomPx = with(density) { if (ctl.tool == ViewerTool.None) QuickBarHeight.toPx() + quickExtraPx else BottomBarHeight.toPx() }// keyed on the document too: one opened over another (Create, Combine) has a fresh page view- LaunchedEffect(doc, ctl.barsVisible, statusPx, navPx, ctl.searching, ctl.tool, vm.readingMode, bottomPx) {+ LaunchedEffect(doc, ctl.barsVisible, statusPx, navPx, ctl.searching, ctl.tool, vm.readingMode, bottomPx, statusBar) {val bottomShown = ctl.barsVisible && !ctl.searching && !vm.readingModedoc.viewer.setPadding(- top = if (ctl.barsVisible) statusPx + topPx else statusPx,+ // with the status bar in documents, the page goes up to the top edge once the bars hide+ top = if (ctl.barsVisible) statusPx + topPx else if (statusBar) 0f else statusPx,bottom = if (bottomShown) bottomPx + navPx else navPx,)}@@ -293,7 +297,10 @@ fun ViewerScreen(vm: AppViewModel, doc: OpenDocument) {// The bars.Column(Modifier.fillMaxWidth().align(Alignment.TopCenter)) {- Box(Modifier.fillMaxWidth().height(with(density) { statusPx.toDp() }).background(Color.Black))+ Box(+ Modifier.fillMaxWidth().height(with(density) { statusPx.toDp() })+ .background(if (!statusBar) Color.Black else if (ctl.barsVisible) c.surface else Color.Transparent),+ )AnimatedVisibility(ctl.barsVisible,enter = slideInVertically(tween(PdfMotion.BARS_MS)) { -it } + fadeIn(tween(PdfMotion.BARS_MS)),diff --git a/apps/pdfcraft-android/android/app/src/main/res/values-es/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values-es/strings.xmlindex 3c8b317..8364cfd 100644--- a/apps/pdfcraft-android/android/app/src/main/res/values-es/strings.xml+++ b/apps/pdfcraft-android/android/app/src/main/res/values-es/strings.xml@@ -225,6 +225,10 @@<string name="home_keyboard_shortcuts">Atajos de teclado</string><!-- N, P, Page Down, Page Up, Ctrl+P, Ctrl, + and − are keys on the keyboard --><string name="home_keyboard_shortcuts_body">Con un teclado conectado: N o Av Pág para la página siguiente, P o Re Pág para la anterior, las flechas para desplazarte, Ctrl+P para imprimir y Ctrl y + o − para ampliar.</string>+ <string name="home_section_extra">Funciones extra</string>+ <string name="home_extra_body">Cambios opcionales en el aspecto y el funcionamiento de PdfCraft.</string>+ <string name="home_status_bar_in_documents">Mostrar la barra de estado en los documentos</string>+ <string name="home_status_bar_in_documents_body">La barra de estado se muestra con las barras de herramientas. Al tocar para ocultarlas, la página ocupa toda la pantalla, también alrededor de la cámara.</string><!-- Settings: About PdfCraft --><string name="home_section_about">Acerca de</string>diff --git a/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml b/apps/pdfcraft-android/android/app/src/main/res/values/strings.xmlindex da2b221..b54b7f0 100644--- a/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml+++ b/apps/pdfcraft-android/android/app/src/main/res/values/strings.xml@@ -226,6 +226,10 @@<string name="home_keyboard_shortcuts">Keyboard shortcuts</string><!-- N, P, Page Down, Page Up, Ctrl+P, Ctrl, + and − are keys on the keyboard --><string name="home_keyboard_shortcuts_body">With a keyboard connected: N or Page Down for the next page, P or Page Up for the previous one, the arrow keys to scroll, Ctrl+P to print, Ctrl and + or − to zoom.</string>+ <string name="home_section_extra">Extra Features</string>+ <string name="home_extra_body">Optional changes to how PdfCraft looks and works.</string>+ <string name="home_status_bar_in_documents">Show the status bar in documents</string>+ <string name="home_status_bar_in_documents_body">The status bar shows with the toolbars. When you tap to hide them, the page uses the whole screen, around the camera too.</string><!-- Settings: About PdfCraft --><string name="home_section_about">About</string>