Modern Apps git

← Modern-Apps.git

pdf: remove unsafe PDF route

Commit
62bf998a75916a287a25d7e183e1d70ad1c170bc
Author
Vayun Mathur <[email protected]>
When
2026-07-16 18:10 UTC (4 months ago)
Parents
a8b4fb5

Diff

pdf/build.gradle.kts
diff --git a/pdf/build.gradle.kts b/pdf/build.gradle.ktsindex c448d25619..bd99134f43 100644--- a/pdf/build.gradle.kts+++ b/pdf/build.gradle.kts@@ -104,11 +104,6 @@ tasks.matching { it.name == "preBuild" }.configureEach { }  dependencies {-    // pdf-    implementation(libs.androidx.pdf.viewer)-    implementation(libs.androidx.pdf.compose)-    implementation(libs.androidx.pdf.document.service)-     implementation(libs.androidx.camera.core)     implementation(libs.androidx.camera.camera2)     implementation(libs.androidx.camera.lifecycle)
pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt
diff --git a/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt b/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.ktindex 738c8a5a72..cc8791ed29 100644--- a/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt+++ b/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt@@ -5,7 +5,6 @@ import android.os.Build import android.os.Bundle import android.os.ext.SdkExtensions import androidx.activity.ComponentActivity-import androidx.activity.compose.BackHandler import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge@@ -16,17 +15,12 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.text.KeyboardOptions-import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme-import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember@@ -35,13 +29,10 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource-import androidx.compose.ui.text.input.KeyboardType-import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.DynamicTheme import com.vayunmathur.pdf.ui.CapturePdfScreen import com.vayunmathur.pdf.ui.CutGlueScreen-import com.vayunmathur.pdf.ui.PdfViewerScreen import com.vayunmathur.pdf.ui.SafePdfViewerScreen import com.vayunmathur.pdf.util.PdfViewModel @@ -69,50 +60,21 @@ class MainActivity : ComponentActivity() {          setContent {             val startedWithIntent = remember { intentData != null }-            var data by rememberSaveable { mutableStateOf(intentData) }-            var safeData: Uri? by rememberSaveable { mutableStateOf(null) }-            var password: String? by rememberSaveable { mutableStateOf(null) }+            var data: Uri? by rememberSaveable { mutableStateOf(intentData) }             var isCapturing by rememberSaveable { mutableStateOf(false) }             var isCutGlue by rememberSaveable { mutableStateOf(false) } -            val pdfDocument by pdfViewModel.pdfDocument.collectAsState()-            val passwordRequired by pdfViewModel.passwordRequired.collectAsState()-            val passwordError by pdfViewModel.passwordError.collectAsState()-             val filePickerLauncher = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->                 uri?.let { data = it }             } -            val safeFilePickerLauncher = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->-                uri?.let { safeData = it }-            }--            LaunchedEffect(data, password) {-                val uri = data-                if (uri != null) {-                    pdfViewModel.loadDocument(uri, password)-                }-            }-             DynamicTheme {                 Surface(                     modifier = Modifier.fillMaxSize(),                     color = MaterialTheme.colorScheme.background                 ) {-                    if (safeData != null) {-                        SafePdfViewerScreen(-                            uri = safeData!!,-                            onBack = { safeData = null }-                        )-                    } else if (isCutGlue) {+                    if (isCutGlue) {                         CutGlueScreen(onBack = { isCutGlue = false })-                    } else if (data == null && !isCapturing) {-                        InitialScreen(-                            onOpenPdf = { filePickerLauncher.launch(arrayOf("application/pdf")) },-                            onOpenPdfSafe = { safeFilePickerLauncher.launch(arrayOf("application/pdf")) },-                            onCapturePdf = { isCapturing = true },-                            onCutGlue = { isCutGlue = true }-                        )                     } else if (isCapturing) {                         CapturePdfScreen(                             viewModel = pdfViewModel,@@ -122,34 +84,18 @@ class MainActivity : ComponentActivity() {                                 isCapturing = false                             }                         )-                    } else {-                        val onBack = {-                            if (startedWithIntent) {-                                finish()-                            } else {-                                data = null-                                password = null-                                pdfViewModel.clearDocument()+                    } else if (data != null) {+                        SafePdfViewerScreen(+                            uri = data!!,+                            onBack = {+                                if (startedWithIntent) finish() else data = null                             }-                        }--                        pdfDocument?.let {-                            PdfViewerScreen(-                                pdfDocument = it,-                                pdfName = data?.lastPathSegment ?: "pdf",-                                viewModel = pdfViewModel,-                                onBack = onBack-                            )-                        } ?: run {-                            BackHandler { onBack() }-                            Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background))-                        }-                    }--                    if (passwordRequired) {-                        PasswordDialog(-                            errorMessage = passwordError,-                            onPasswordEntered = { password = it }+                        )+                    } else {+                        InitialScreen(+                            onOpenPdf = { filePickerLauncher.launch(arrayOf("application/pdf")) },+                            onCapturePdf = { isCapturing = true },+                            onCutGlue = { isCutGlue = true }                         )                     }                 }@@ -159,15 +105,12 @@ class MainActivity : ComponentActivity() { }  @Composable-fun InitialScreen(onOpenPdf: () -> Unit, onOpenPdfSafe: () -> Unit, onCapturePdf: () -> Unit, onCutGlue: () -> Unit) {+fun InitialScreen(onOpenPdf: () -> Unit, onCapturePdf: () -> Unit, onCutGlue: () -> Unit) {     Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background), contentAlignment = Alignment.Center) {         Column(horizontalAlignment = Alignment.CenterHorizontally) {             Button(onClick = onOpenPdf, Modifier.padding(16.dp)) {                 Text(stringResource(R.string.open_pdf))             }-            Button(onClick = onOpenPdfSafe, Modifier.padding(16.dp)) {-                Text(stringResource(R.string.open_pdf_safe))-            }             Button(onClick = onCapturePdf, Modifier.padding(16.dp)) {                 Text(stringResource(R.string.capture_pdf))             }@@ -178,42 +121,6 @@ fun InitialScreen(onOpenPdf: () -> Unit, onOpenPdfSafe: () -> Unit, onCapturePdf     } } -@Composable-fun PasswordDialog(-    onPasswordEntered: (String) -> Unit,-    errorMessage: String? = null-) {-    var password by rememberSaveable { mutableStateOf("") }--    AlertDialog(-        onDismissRequest = {},-        title = { Text(stringResource(R.string.password_dialog_title)) },-        text = {-            Column {-                Text(stringResource(R.string.password_dialog_message))-                if (errorMessage != null) {-                    Text(errorMessage, color = MaterialTheme.colorScheme.error)-                }-                OutlinedTextField(-                    value = password,-                    onValueChange = { password = it },-                    label = { Text(stringResource(R.string.password_label)) },-                    singleLine = true,-                    isError = errorMessage != null,-                    visualTransformation = PasswordVisualTransformation(),-                    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password)-                )-            }-        },-        confirmButton = {-            Button(onClick = { onPasswordEntered(password) }) {-                Text(stringResource(R.string.ok))-            }-        },-        dismissButton = null-    )-}- fun isAdvancedPdfSupported(): Boolean {     return Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM ||         SdkExtensions.getExtensionVersion(Build.VERSION_CODES.R) >= 13
pdf/src/main/java/com/vayunmathur/pdf/ui/PdfViewerScreen.kt
diff --git a/pdf/src/main/java/com/vayunmathur/pdf/ui/PdfViewerScreen.kt b/pdf/src/main/java/com/vayunmathur/pdf/ui/PdfViewerScreen.ktdeleted file mode 100644index 51e6310be7..0000000000--- a/pdf/src/main/java/com/vayunmathur/pdf/ui/PdfViewerScreen.kt+++ /dev/null@@ -1,404 +0,0 @@-package com.vayunmathur.pdf.ui--import android.content.Intent-import android.util.Log-import android.widget.Toast-import androidx.activity.compose.BackHandler-import androidx.activity.compose.rememberLauncherForActivityResult-import androidx.activity.result.contract.ActivityResultContracts-import androidx.compose.foundation.clickable-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.WindowInsets-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.width-import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.itemsIndexed-import androidx.compose.foundation.text.KeyboardOptions-import androidx.compose.material3.DropdownMenu-import androidx.compose.material3.DropdownMenuItem-import androidx.compose.material3.ExperimentalMaterial3Api-import androidx.compose.material3.HorizontalDivider-import androidx.compose.material3.Icon-import androidx.compose.material3.IconButton-import androidx.compose.material3.MaterialTheme-import androidx.compose.material3.ModalDrawerSheet-import androidx.compose.material3.ModalNavigationDrawer-import androidx.compose.material3.Scaffold-import androidx.compose.material3.SmallFloatingActionButton-import androidx.compose.material3.Text-import androidx.compose.material3.TextField-import androidx.compose.material3.TextFieldDefaults-import androidx.compose.material3.TopAppBar-import androidx.compose.material3.rememberDrawerState-import androidx.compose.material3.DrawerValue-import androidx.compose.runtime.Composable-import androidx.compose.runtime.DisposableEffect-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableIntStateOf-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.rememberCoroutineScope-import androidx.compose.runtime.setValue-import androidx.compose.ui.Modifier-import androidx.compose.ui.focus.FocusRequester-import androidx.compose.ui.focus.focusRequester-import androidx.compose.ui.geometry.Offset-import androidx.compose.ui.graphics.Color-import androidx.compose.ui.graphics.toArgb-import androidx.compose.ui.layout.onGloballyPositioned-import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.platform.LocalResources-import androidx.compose.ui.res.painterResource-import androidx.compose.ui.res.stringResource-import androidx.compose.ui.text.input.ImeAction-import androidx.compose.ui.unit.center-import androidx.compose.ui.unit.dp-import androidx.compose.ui.unit.toOffset-import androidx.core.util.forEach-import androidx.pdf.EditablePdfDocument-import androidx.pdf.PdfPoint-import androidx.pdf.PdfRect-import androidx.pdf.compose.FastScrollConfiguration-import androidx.pdf.compose.PdfViewer-import androidx.pdf.compose.PdfViewerState-import androidx.pdf.Highlight-import com.vayunmathur.library.ui.IconMenu-import com.vayunmathur.library.ui.IconNavigation-import com.vayunmathur.library.ui.IconSave-import com.vayunmathur.library.ui.IconSearch-import com.vayunmathur.library.ui.IconShare-import com.vayunmathur.pdf.R-import com.vayunmathur.pdf.ui.components.AnnotationOverlay-import com.vayunmathur.pdf.util.PaddleOcrProvider-import com.vayunmathur.pdf.util.PdfStateStore-import com.vayunmathur.pdf.util.PdfViewModel-import kotlinx.coroutines.delay-import kotlinx.coroutines.launch--@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun PdfViewerScreen(-    pdfDocument: EditablePdfDocument,-    pdfName: String,-    viewModel: PdfViewModel,-    onBack: () -> Unit,-) {-    val pdfState = remember { PdfViewerState() }-    val context = LocalContext.current-    val resources = LocalResources.current-    val coroutineScope = rememberCoroutineScope()-    val linkDestinations by viewModel.linkDestinations.collectAsState()-    val outlineEntries by viewModel.outlineEntries.collectAsState()--    // On-device OCR provider (shared :library:ocr / PaddleOCR). Handed to the-    // PdfViewer so text selection + search work natively on scanned pages.-    val ocrProvider = remember(context) { PaddleOcrProvider(context) }-    DisposableEffect(ocrProvider) {-        onDispose { ocrProvider.close() }-    }--    val drawerState = rememberDrawerState(DrawerValue.Closed)--    LaunchedEffect(pdfDocument) {-        viewModel.buildLinkIndex(pdfDocument)-        viewModel.buildOutline(pdfDocument)-    }--    val pdfSavedMessage = stringResource(R.string.pdf_saved)-    val pdfSaveErrorMessage = stringResource(R.string.pdf_save_error)-    val downloadLauncher = rememberLauncherForActivityResult(-        ActivityResultContracts.CreateDocument("application/pdf")-    ) { uri ->-        uri?.let {-            viewModel.saveDocumentChanges(pdfDocument, it)-        }-    }--    LaunchedEffect(pdfDocument) {-        viewModel.pdfWriteResults.collect { result ->-            val msg = if (result.success) pdfSavedMessage else pdfSaveErrorMessage-            Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()-        }-    }--    var showSearchBar by remember { mutableStateOf(false) }-    var searchResults by remember { mutableStateOf(emptyList<PdfRect>()) }-    var searchIndex by remember(searchResults) { mutableIntStateOf(0) }-    var searchText by remember { mutableStateOf("") }-    var showSaveMenu by remember { mutableStateOf(false) }-    var viewerLaidOut by remember { mutableStateOf(false) }-    var centerOffset by remember { mutableStateOf(Offset.Zero) }--    BackHandler {-        when {-            drawerState.isOpen -> coroutineScope.launch { drawerState.close() }-            showSearchBar -> {-                showSearchBar = false-                searchResults = emptyList()-            }-            else -> onBack()-        }-    }--    LaunchedEffect(pdfDocument.uri, viewerLaidOut) {-        if (!viewerLaidOut) return@LaunchedEffect-        PdfStateStore.restore(context, pdfDocument.uri)?.invoke(pdfState)-    }--    LaunchedEffect(Unit) {-        while (true) {-            delay(2000)-            PdfStateStore.save(context, pdfDocument.uri, centerOffset, pdfState)-        }-    }--    LaunchedEffect(searchText) {-        if (searchText.isBlank()) {-            searchResults = emptyList()-            return@LaunchedEffect-        }-        delay(300)-        val results = pdfDocument.searchDocument(searchText, 0 until pdfDocument.pageCount)-        val resultsFinal = mutableListOf<PdfRect>()-        results.forEach { page, result ->-            resultsFinal.addAll(-                result.mapNotNull {-                    it.bounds.firstOrNull()?.let { rect -> PdfRect(page, rect) }-                })-        }-        searchResults = resultsFinal-    }--    LaunchedEffect(searchResults, searchIndex) {-        val allHighlights = searchResults.mapIndexed { idx, it ->-            Highlight(-                it, if (idx == searchIndex) 0xFFFFA500.toInt() else Color.Yellow.toArgb()-            )-        }-        pdfState.setHighlights(allHighlights)-        if (searchResults.isNotEmpty()) {-            pdfState.scrollToPosition(-                searchResults[searchIndex].let { PdfPoint(it.pageNum, it.left, it.top) })-        }-    }--    val focusRequestor = remember { FocusRequester() }-    LaunchedEffect(showSearchBar) {-        if (showSearchBar) {-            focusRequestor.requestFocus()-        } else {-            searchResults = emptyList()-        }-    }--    val shareAction = {-        val intent = Intent(Intent.ACTION_SEND).apply {-            type = "application/pdf"-            putExtra(Intent.EXTRA_STREAM, pdfDocument.uri)-            addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)-        }-        context.startActivity(-            Intent.createChooser(intent, resources.getString(R.string.share_pdf))-        )-    }--    ModalNavigationDrawer(-        drawerState = drawerState,-        drawerContent = {-            ModalDrawerSheet(Modifier.width(300.dp)) {-                Text(-                    "Outline",-                    style = MaterialTheme.typography.titleMedium,-                    modifier = Modifier.padding(16.dp)-                )-                HorizontalDivider()-                LazyColumn {-                    itemsIndexed(outlineEntries) { _, entry ->-                        Text(-                            text = entry.label,-                            modifier = Modifier-                                .fillMaxWidth()-                                .clickable {-                                    coroutineScope.launch {-                                        pdfState.scrollToPage(entry.pageNum)-                                        drawerState.close()-                                    }-                                }-                                .padding(horizontal = 16.dp, vertical = 12.dp),-                            style = MaterialTheme.typography.bodyMedium-                        )-                    }-                }-            }-        }-    ) {-        Scaffold(-            modifier = Modifier.fillMaxSize(),-            topBar = {-                TopAppBar(-                    title = {-                        if (showSearchBar) {-                            TextField(-                                value = searchText,-                                onValueChange = { searchText = it },-                                modifier = Modifier-                                    .fillMaxWidth()-                                    .focusRequester(focusRequestor),-                                placeholder = { Text(stringResource(R.string.search_label)) },-                                singleLine = true,-                                keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),-                                colors = TextFieldDefaults.colors(-                                    focusedContainerColor = Color.Transparent,-                                    unfocusedContainerColor = Color.Transparent,-                                    disabledContainerColor = Color.Transparent,-                                    focusedIndicatorColor = Color.Transparent,-                                    unfocusedIndicatorColor = Color.Transparent,-                                )-                            )-                        } else {-                            Text(stringResource(R.string.pdf_viewer_title))-                        }-                    },-                    navigationIcon = {-                        if (showSearchBar) {-                            IconNavigation {-                                showSearchBar = false-                                searchResults = emptyList()-                            }-                        } else {-                            IconButton({ coroutineScope.launch { drawerState.open() } }) {-                                IconMenu()-                            }-                        }-                    },-                    actions = {-                        if (!showSearchBar) {-                            IconButton({ showSearchBar = true }) { IconSearch() }-                            Box {-                                IconButton(onClick = { showSaveMenu = true }) {-                                    IconSave()-                                }-                                DropdownMenu(-                                    expanded = showSaveMenu,-                                    onDismissRequest = { showSaveMenu = false }-                                ) {-                                    DropdownMenuItem(-                                        text = { Text(stringResource(R.string.pdf_save)) },-                                        onClick = {-                                            showSaveMenu = false-                                            viewModel.saveDocumentChanges(pdfDocument, pdfDocument.uri)-                                        }-                                    )-                                    DropdownMenuItem(-                                        text = { Text(stringResource(R.string.pdf_save_as_copy)) },-                                        onClick = {-                                            showSaveMenu = false-                                            downloadLauncher.launch(pdfName)-                                        }-                                    )-                                }-                            }-                            IconButton({ shareAction() }) { IconShare() }-                        } else {-                            if (searchResults.isNotEmpty()) {-                                Text(-                                    stringResource(-                                        R.string.search_result_counter,-                                        searchIndex + 1,-                                        searchResults.size-                                    ), modifier = Modifier.padding(end = 12.dp)-                                )-                            }-                        }-                    })-            },-            floatingActionButton = {-                if (showSearchBar) {-                    Column {-                        SmallFloatingActionButton({ if (searchIndex > 0) searchIndex-- }) {-                            Icon(painterResource(R.drawable.keyboard_arrow_up_24px), null)-                        }-                        SmallFloatingActionButton({-                            if (searchIndex < searchResults.size - 1) searchIndex++-                        }) { Icon(painterResource(R.drawable.keyboard_arrow_down_24px), null) }-                    }-                }-            },-            contentWindowInsets = WindowInsets(0)-        ) { innerPadding ->-            Box(-                Modifier-                    .padding(innerPadding)-                    .fillMaxSize()-            ) {-                PdfViewer(-                    pdfDocument = pdfDocument,-                    state = pdfState,-                    ocrProvider = ocrProvider,-                    modifier = Modifier.onGloballyPositioned { coordinates ->-                        centerOffset = coordinates.size.center.toOffset()-                        viewerLaidOut = true-                    },-                    fastScrollConfig = FastScrollConfiguration.withDrawableIdsAndDp(-                        fastScrollPageIndicatorBackgroundDrawableRes = R.drawable.pdf_page_indicator_background,-                        fastScrollVerticalThumbDrawableRes = R.drawable.pdf_fast_scroll_thumb,-                        fastScrollPageIndicatorMarginEnd = 42.dp,-                        fastScrollVerticalThumbMarginEnd = 0.dp,-                    ),-                    isFormFillingEnabled = true,-                    isImageSelectionEnabled = true,-                    onFormWidgetInfoUpdated = { editInfo ->-                        coroutineScope.launch {-                            pdfDocument.applyEdit(editInfo)-                        }-                    },-                ) { uri ->-                    Log.d("PdfViewer", "Link clicked: uri=$uri scheme=${uri.scheme} fragment=${uri.fragment}")-                    if (uri.scheme == "file") {-                        val destPage = linkDestinations[uri.toString()]-                        if (destPage != null) {-                            Log.d("PdfViewer", "Resolved via index: page $destPage")-                            coroutineScope.launch { pdfState.scrollToPage(destPage) }-                            return@PdfViewer true-                        }-                        val pathOnly = uri.buildUpon().fragment(null).build().toString()-                        val fallback = linkDestinations.entries-                            .firstOrNull { it.key.startsWith(pathOnly) }?.value-                        if (fallback != null) {-                            Log.d("PdfViewer", "Resolved via path match: page $fallback")-                            coroutineScope.launch { pdfState.scrollToPage(fallback) }-                            return@PdfViewer true-                        }-                        Log.d("PdfViewer", "Unresolved internal link: $uri")-                        return@PdfViewer true-                    }-                    val fragment = uri.fragment-                    if (fragment != null) {-                        val page = Regex("page=(\\d+)").find(fragment)-                            ?.groupValues?.get(1)?.toIntOrNull()-                            ?: fragment.toIntOrNull()-                        if (page != null && page in 1..pdfDocument.pageCount) {-                            coroutineScope.launch { pdfState.scrollToPage(page - 1) }-                            return@PdfViewer true-                        }-                    }-                    if (uri.scheme == "http" || uri.scheme == "https" || uri.scheme == "mailto") {-                        val intent = Intent(Intent.ACTION_VIEW, uri)-                        context.startActivity(intent)-                    }-                    true-                }-                AnnotationOverlay(-                    pdfDocument = pdfDocument,-                    pdfState = pdfState,-                    modifier = Modifier.matchParentSize(),-                )-            }-        }-    }-}
pdf/src/main/java/com/vayunmathur/pdf/ui/components/AnnotationOverlay.kt
diff --git a/pdf/src/main/java/com/vayunmathur/pdf/ui/components/AnnotationOverlay.kt b/pdf/src/main/java/com/vayunmathur/pdf/ui/components/AnnotationOverlay.ktdeleted file mode 100644index 1ceb42b84c..0000000000--- a/pdf/src/main/java/com/vayunmathur/pdf/ui/components/AnnotationOverlay.kt+++ /dev/null@@ -1,82 +0,0 @@-package com.vayunmathur.pdf.ui.components--import android.graphics.RectF-import android.util.SparseArray-import androidx.compose.runtime.Composable-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue-import androidx.compose.ui.Modifier-import androidx.compose.ui.viewinterop.AndroidView-import androidx.pdf.PdfDocument-import androidx.pdf.annotation.AnnotationsView-import androidx.pdf.annotation.PdfViewportState-import androidx.pdf.annotation.content.KeyedPdfAnnotation-import androidx.pdf.compose.PdfViewerState--/**- * Overlays an [AnnotationsView] on top of the Compose [androidx.pdf.compose.PdfViewer] so that- * annotations embedded in the document (ink, highlights, stamps) render and can be selected/edited- * by the library. The overlay mirrors the viewer's viewport (visible pages, per-page bounds and- * zoom) and feeds the annotations for the visible pages via [AnnotationsView.updateDisplayState].- */-@Composable-fun AnnotationOverlay(-    pdfDocument: PdfDocument,-    pdfState: PdfViewerState,-    modifier: Modifier = Modifier,-) {-    val pageSizes = remember(pdfDocument) { mutableMapOf<Int, PdfDocument.PageInfo>() }-    val pageAnnotationCache = remember(pdfDocument) { mutableMapOf<Int, List<KeyedPdfAnnotation>>() }-    var annotationsView by remember { mutableStateOf<AnnotationsView?>(null) }--    AndroidView(-        modifier = modifier,-        factory = { context ->-            AnnotationsView(context).apply {-                interactionMode = AnnotationsView.AnnotationMode.Select-                annotationsView = this-            }-        },-    )--    val firstVisiblePage = pdfState.firstVisiblePage-    val visiblePagesCount = pdfState.visiblePagesCount-    val zoom = pdfState.zoom-    // firstVisiblePageOffset is snapshot state; reading it makes this recompute while scrolling.-    val scrollOffset = pdfState.firstVisiblePageOffset--    LaunchedEffect(annotationsView, firstVisiblePage, visiblePagesCount, zoom, scrollOffset) {-        val view = annotationsView ?: return@LaunchedEffect-        if (visiblePagesCount <= 0) return@LaunchedEffect--        val pageBounds = SparseArray<RectF>()-        val pageAnnotations = SparseArray<List<KeyedPdfAnnotation>>()--        for (page in firstVisiblePage until firstVisiblePage + visiblePagesCount) {-            val offset = pdfState.getVisiblePageOffset(page) ?: continue--            val info = pageSizes.getOrPut(page) { pdfDocument.getPageInfo(page) }-            pageBounds.put(-                page,-                RectF(-                    offset.x,-                    offset.y,-                    offset.x + info.width * zoom,-                    offset.y + info.height * zoom,-                ),-            )-            pageAnnotations.put(-                page,-                pageAnnotationCache.getOrPut(page) { pdfDocument.getAnnotationsForPage(page) },-            )-        }--        view.updateDisplayState(-            PdfViewportState(firstVisiblePage, visiblePagesCount, pageBounds, zoom),-            pageAnnotations,-        )-    }-}
pdf/src/main/java/com/vayunmathur/pdf/util/PaddleOcrProvider.kt
diff --git a/pdf/src/main/java/com/vayunmathur/pdf/util/PaddleOcrProvider.kt b/pdf/src/main/java/com/vayunmathur/pdf/util/PaddleOcrProvider.ktdeleted file mode 100644index be2491e1af..0000000000--- a/pdf/src/main/java/com/vayunmathur/pdf/util/PaddleOcrProvider.kt+++ /dev/null@@ -1,141 +0,0 @@-package com.vayunmathur.pdf.util--import android.content.Context-import android.graphics.Bitmap-import android.graphics.Rect-import androidx.pdf.ocr.OcrProvider-import androidx.pdf.ocr.OcrResult-import androidx.pdf.ocr.OcrText-import com.vayunmathur.library.ocr.OcrEngine--/**- * [OcrProvider] backed by the shared [OcrEngine] (PaddleOCR PP-OCR mobile on- * ONNX Runtime, from the `:library:ocr` module). Passing this into the AndroidX- * [androidx.pdf.compose.PdfViewer] lets the library natively use our on-device- * OCR for text selection and search on scanned / image-only PDF pages.- *- * PaddleOCR detects text at the *line* level. The AndroidX PDF viewer, however,- * works in terms of words (selection, tap-to-select, search). We therefore split- * each recognised line into words and estimate each word's bounding [Rect] by- * proportionally dividing the line box across the line's characters — good enough- * for selection and search highlighting.- *- * Coordinate space: [OcrEngine.recognizeDetailed] already returns its boxes in- * the pixel space of the bitmap passed to it (it maps the detector's internally- * downscaled probability-map coordinates back up to the source bitmap), so the- * rects here are in the same space as the [recognizeText] input bitmap and need- * no further rescaling.- */-class PaddleOcrProvider(context: Context) : OcrProvider {--    // Cheap to construct; the ONNX sessions load lazily on first recognizeText.-    private val engine = OcrEngine(context.applicationContext)--    override suspend fun recognizeText(image: Bitmap): OcrResult {-        val detailed = engine.recognizeDetailed(image)-        val words = ArrayList<Word>()-        for (line in detailed.boxes) {-            words += splitLineIntoWords(line)-        }-        return PaddleOcrResult(words)-    }--    override fun close() {-        engine.close()-    }--    /** A single word with its estimated bounding box, in input-bitmap pixels. */-    private class Word(val text: String, val rect: Rect)--    /**-     * Split a detected line into words, estimating each word's rect by dividing-     * the line box width evenly across the line's characters (spaces included).-     */-    private fun splitLineIntoWords(line: OcrEngine.TextBox): List<Word> {-        val text = line.text-        if (text.isBlank()) return emptyList()-        val left = minOf(line.left, line.right)-        val right = maxOf(line.left, line.right)-        val top = minOf(line.top, line.bottom)-        val bottom = maxOf(line.top, line.bottom)-        val totalChars = text.length.coerceAtLeast(1)-        val charWidth = (right - left).toFloat() / totalChars--        val result = ArrayList<Word>()-        val matcher = Regex("\\S+")-        for (m in matcher.findAll(text)) {-            val startChar = m.range.first-            val endChar = m.range.last + 1 // exclusive-            val wl = (left + startChar * charWidth).toInt()-            val wr = (left + endChar * charWidth).toInt().coerceAtLeast(wl + 1)-            result += Word(m.value, Rect(wl, top, wr, bottom))-        }-        return result-    }--    /** [OcrResult] over a flat, reading-order list of [Word]s. */-    private class PaddleOcrResult(private val words: List<Word>) : OcrResult {--        override fun getAllText(): OcrText =-            OcrText(words.joinToString(" ") { it.text }, words.map { it.rect })--        override fun getText(startX: Int, startY: Int, endX: Int, endY: Int): OcrText {-            val query = Rect(minOf(startX, endX), minOf(startY, endY), maxOf(startX, endX), maxOf(startY, endY))-            val hits = words.filter { Rect.intersects(it.rect, query) }-            return OcrText(hits.joinToString(" ") { it.text }, hits.map { it.rect })-        }--        override fun getWordAt(x: Int, y: Int): OcrText {-            val word = words.firstOrNull { it.rect.contains(x, y) }-            return if (word != null) OcrText(word.text, listOf(word.rect)) else EMPTY-        }--        override fun getSearchBounds(searchTerm: String, ignoreCase: Boolean): List<List<Rect>> {-            if (searchTerm.isBlank() || words.isEmpty()) return emptyList()--            // Build the concatenated text with a single space between words, and a-            // map from each character position back to its word index (-1 for the-            // separator spaces). This lets a match span multiple words.-            val sb = StringBuilder()-            val charToWord = ArrayList<Int>()-            for ((i, word) in words.withIndex()) {-                if (i > 0) {-                    sb.append(' ')-                    charToWord.add(-1)-                }-                for (c in word.text) {-                    sb.append(c)-                    charToWord.add(i)-                }-            }--            val haystack = sb.toString()-            val matches = ArrayList<List<Rect>>()--            var from = 0-            while (true) {-                val idx = haystack.indexOf(searchTerm, from, ignoreCase)-                if (idx < 0) break-                val end = idx + searchTerm.length-                from = end.coerceAtLeast(idx + 1)--                // Collect the distinct words this occurrence spans, in order.-                val rects = ArrayList<Rect>()-                var lastWord = -1-                for (p in idx until end) {-                    val w = charToWord[p]-                    if (w >= 0 && w != lastWord) {-                        rects.add(words[w].rect)-                        lastWord = w-                    }-                }-                if (rects.isNotEmpty()) matches.add(rects)-            }-            return matches-        }--        companion object {-            private val EMPTY = OcrText("", emptyList())-        }-    }-}
pdf/src/main/java/com/vayunmathur/pdf/util/PdfStateStore.kt
diff --git a/pdf/src/main/java/com/vayunmathur/pdf/util/PdfStateStore.kt b/pdf/src/main/java/com/vayunmathur/pdf/util/PdfStateStore.ktindex a2fe607488..b014be3339 100644--- a/pdf/src/main/java/com/vayunmathur/pdf/util/PdfStateStore.kt+++ b/pdf/src/main/java/com/vayunmathur/pdf/util/PdfStateStore.kt@@ -1,43 +1,11 @@ package com.vayunmathur.pdf.util import android.content.Context import android.net.Uri-import androidx.compose.ui.geometry.Offset import androidx.core.content.edit-import androidx.pdf.PdfPoint-import androidx.pdf.compose.PdfViewerState  object PdfStateStore {     private const val PREFS_NAME = "pdf_viewer_state" -    // Save state as a simple comma-separated string: "page,left,top"-    fun save(context: Context, uri: Uri, centerOffset: Offset, state: PdfViewerState) {-        val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)-        val key = uri.toString()-        val pdfPoint = state.visibleOffsetToPdfPoint(centerOffset) ?: return-        val value = "${state.zoom},${pdfPoint.pageNum},${pdfPoint.x},${pdfPoint.y}"-        prefs.edit { putString(key, value) }-    }--    fun restore(context: Context, uri: Uri): (suspend (PdfViewerState) -> Unit)? {-        val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)-        val key = uri.toString()-        val value = try {-            prefs.getString(key, null)-        } catch (_: ClassCastException) {-            prefs.edit { remove(key) }-            null-        } ?: return null-        val parts = value.split(',')-        if (parts.size < 3) return null-        val page = parts[1].toIntOrNull() ?: 0-        val left = parts[2].toFloatOrNull() ?: 0f-        val top = parts[3].toFloatOrNull() ?: 0f-        return {-            it.scrollToPage(page)-            it.scrollToPosition(PdfPoint(page, left, top))-        }-    }-     // --- Safe (Rust) viewer: remember the first-visible page per document. ---      fun saveSafePage(context: Context, uri: Uri, page: Int) {
pdf/src/main/java/com/vayunmathur/pdf/util/PdfViewModel.kt
diff --git a/pdf/src/main/java/com/vayunmathur/pdf/util/PdfViewModel.kt b/pdf/src/main/java/com/vayunmathur/pdf/util/PdfViewModel.ktindex 2abcc2d83b..e9c389f8c6 100644--- a/pdf/src/main/java/com/vayunmathur/pdf/util/PdfViewModel.kt+++ b/pdf/src/main/java/com/vayunmathur/pdf/util/PdfViewModel.kt@@ -2,17 +2,10 @@ package com.vayunmathur.pdf.util  import android.app.Application import android.net.Uri-import android.util.Log import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.viewModelScope-import androidx.pdf.EditablePdfDocument-import androidx.pdf.PdfDocument-import androidx.pdf.PdfPasswordException-import androidx.pdf.SandboxedPdfLoader-import com.vayunmathur.pdf.R import com.vayunmathur.pdf.model.CapturedImage import com.vayunmathur.pdf.model.Quadrilateral-import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow@@ -20,14 +13,9 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch-import kotlinx.coroutines.withContext--data class OutlineEntry(val label: String, val pageNum: Int)  class PdfViewModel(application: Application) : AndroidViewModel(application) { -    private val pdfLoader = SandboxedPdfLoader(application)-     // --- Captured images / cropping ----------------------------------------      private val _capturedImages = MutableStateFlow<List<CapturedImage>>(emptyList())@@ -79,133 +67,7 @@ class PdfViewModel(application: Application) : AndroidViewModel(application) {         }     } -    fun saveDocumentChanges(document: EditablePdfDocument, targetUri: Uri) {-        val ctx = getApplication<Application>()-        viewModelScope.launch {-            val ok = withContext(Dispatchers.IO) {-                try {-                    ctx.contentResolver.openFileDescriptor(targetUri, "w")?.use { pfd ->-                        document.createWriteHandle().writeTo(pfd)-                    }-                    true-                } catch (e: Exception) {-                    Log.e(TAG, "Error saving PDF to $targetUri", e)-                    false-                }-            }-            _pdfWriteResults.emit(PdfWriteResult(targetUri, ok))-        }-    }-     fun clearCapturedImages() {         _capturedImages.value = emptyList()     }--    // --- Document loading -----------------------------------------------------    private val _pdfDocument = MutableStateFlow<EditablePdfDocument?>(null)-    val pdfDocument: StateFlow<EditablePdfDocument?> = _pdfDocument.asStateFlow()--    private val _passwordRequired = MutableStateFlow(false)-    val passwordRequired: StateFlow<Boolean> = _passwordRequired.asStateFlow()--    private val _passwordError = MutableStateFlow<String?>(null)-    val passwordError: StateFlow<String?> = _passwordError.asStateFlow()--    fun loadDocument(uri: Uri, password: String?) {-        val ctx = getApplication<Application>()-        _passwordError.value = null-        viewModelScope.launch {-            try {-                val doc = pdfLoader.openDocument(uri, password) as EditablePdfDocument-                _pdfDocument.value = doc-                _passwordRequired.value = false-                _passwordError.value = null-            } catch (_: PdfPasswordException) {-                if (password != null) {-                    _passwordError.value = ctx.getString(R.string.incorrect_password)-                }-                _passwordRequired.value = true-            } catch (e: Exception) {-                Log.e(TAG, "Failed to open PDF $uri", e)-            }-        }-    }--    fun clearDocument() {-        _pdfDocument.value = null-        _passwordRequired.value = false-        _passwordError.value = null-        _linkDestinations.value = emptyMap()-        _outlineEntries.value = emptyList()-    }--    // --- Internal link resolution ---------------------------------------------    private val _linkDestinations = MutableStateFlow<Map<String, Int>>(emptyMap())-    val linkDestinations: StateFlow<Map<String, Int>> = _linkDestinations.asStateFlow()--    fun buildLinkIndex(document: EditablePdfDocument) {-        viewModelScope.launch(Dispatchers.Default) {-            val map = mutableMapOf<String, Int>()-            for (page in 0 until document.pageCount) {-                val links = try {-                    document.getPageLinks(page)-                } catch (e: Exception) {-                    continue-                }-                val gotos = links.gotoLinks.filter { it.bounds.isNotEmpty() }-                val externals = links.externalLinks.filter {-                    it.bounds.isNotEmpty() && it.uri.scheme == "file"-                }-                if (gotos.isEmpty() || externals.isEmpty()) continue--                for (ext in externals) {-                    val extY = ext.bounds.first().centerY()-                    val match = gotos.minByOrNull {-                        kotlin.math.abs(it.bounds.first().centerY() - extY)-                    } ?: continue-                    if (kotlin.math.abs(match.bounds.first().centerY() - extY) < 20f) {-                        map[ext.uri.toString()] = match.destination.pageNumber-                    }-                }-            }-            Log.d(TAG, "Link index: ${map.size} entries")-            for ((uri, dest) in map) {-                Log.d(TAG, "  $uri -> page $dest")-            }-            _linkDestinations.value = map-        }-    }--    // --- Outline --------------------------------------------------------------    private val _outlineEntries = MutableStateFlow<List<OutlineEntry>>(emptyList())-    val outlineEntries: StateFlow<List<OutlineEntry>> = _outlineEntries.asStateFlow()--    fun buildOutline(document: PdfDocument) {-        viewModelScope.launch(Dispatchers.Default) {-            val entries = mutableListOf<OutlineEntry>()-            for (page in 0 until document.pageCount) {-                try {-                    val content = document.getPageContent(page)-                    val firstText = content?.textContents?.firstOrNull()?.text-                    val firstLine = firstText?.lineSequence()?.firstOrNull { it.isNotBlank() }?.trim()-                    val label = if (!firstLine.isNullOrEmpty()) {-                        firstLine.take(80)-                    } else {-                        "Page ${page + 1}"-                    }-                    entries.add(OutlineEntry(label, page))-                } catch (e: Exception) {-                    entries.add(OutlineEntry("Page ${page + 1}", page))-                }-            }-            _outlineEntries.value = entries-        }-    }--    companion object {-        private const val TAG = "PdfViewModel"-    } }
pdf/src/main/res/values-cs/strings.xml
diff --git a/pdf/src/main/res/values-cs/strings.xml b/pdf/src/main/res/values-cs/strings.xmlindex 6b8dd30843..bc0993b329 100644--- a/pdf/src/main/res/values-cs/strings.xml+++ b/pdf/src/main/res/values-cs/strings.xml@@ -1,21 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <resources>-    <string name="ok">OK</string>     <string name="app_name">PDF</string>     <string name="search_label">Najít</string>-    <string name="search_result_counter">%1$d z %2$d</string>-    <string name="password_dialog_message">Toto PDF je zabezpečeno heslem. Prosím vložte heslo.</string>-    <string name="password_label">Heslo</string>-    <string name="incorrect_password">Nesprávné heslo. Zkuste to prosím znovu.</string>     <string name="open_pdf">Otevřít PDF</string>     <string name="upload_image">Nahrát obrázek</string>     <string name="pdf_saved">PDF úspěšně uloženo</string>     <string name="share_pdf">Sdílet PDF</string>     <string name="crop_image">Oříznout obrázek</string>     <string name="continue_label">Pokračovat</string>-    <string name="pdf_viewer_title">Prohlížeč PDF</string>-    <string name="password_dialog_title">Požadováno helso</string>-    <string name="open_pdf_safe">Otevřít PDF (bezpečný)</string>     <string name="safe_pdf_viewer_title">Prohlížeč PDF (bezpečný)</string>     <string name="safe_pdf_error">Toto PDF nešlo otevřít v bezpečném prohlížeči. Může být šifrovaný nebo používat nepodporované funkce.</string>     <string name="capture_pdf">Zachytit PDF</string>
pdf/src/main/res/values-de/strings.xml
diff --git a/pdf/src/main/res/values-de/strings.xml b/pdf/src/main/res/values-de/strings.xmlindex dc6b73b970..b67381d2ef 100644--- a/pdf/src/main/res/values-de/strings.xml+++ b/pdf/src/main/res/values-de/strings.xml@@ -1,14 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources>-    <string name="ok">Ok</string>     <string name="app_name">PDF</string>-    <string name="pdf_viewer_title">PDF Viewer</string>     <string name="search_label">Suchen</string>-    <string name="search_result_counter">%1$d von %2$d</string>-    <string name="password_dialog_title">Passwort erforderlich</string>-    <string name="password_dialog_message">Dieses PDF ist passwortgeschützt. Bitte geben Sie das Passwort ein.</string>-    <string name="password_label">Passwort</string>-    <string name="incorrect_password">Falsches Passwort. Bitte versuchen Sie es erneut.</string>     <string name="open_pdf">PDF öffnen</string>     <string name="capture_pdf">PDF erfassen</string>     <string name="capture_pdf_title">PDF erfassen</string>
pdf/src/main/res/values-es/strings.xml
diff --git a/pdf/src/main/res/values-es/strings.xml b/pdf/src/main/res/values-es/strings.xmlindex edf057b3a6..045e125f3d 100644--- a/pdf/src/main/res/values-es/strings.xml+++ b/pdf/src/main/res/values-es/strings.xml@@ -1,4 +1,3 @@ <?xml version="1.0" encoding="utf-8"?> <resources>-    <string name="ok">Ok</string> </resources>
pdf/src/main/res/values-et/strings.xml
diff --git a/pdf/src/main/res/values-et/strings.xml b/pdf/src/main/res/values-et/strings.xmlindex cd12930f47..eb7d919c84 100644--- a/pdf/src/main/res/values-et/strings.xml+++ b/pdf/src/main/res/values-et/strings.xml@@ -1,14 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources>     <string name="app_name">PDF</string>-    <string name="ok">Sobib</string>-    <string name="pdf_viewer_title">PDF-failide näitaja</string>     <string name="search_label">Otsi</string>-    <string name="search_result_counter">%1$d / %2$d</string>-    <string name="password_dialog_title">Salasõna on vajalik</string>-    <string name="password_dialog_message">See PDF-fail on kaitstud salasõnaga. Palun sisesta salasõna.</string>-    <string name="password_label">Salasõna</string>-    <string name="incorrect_password">Salasõna pole õige. Palun proovi uuesti.</string>     <string name="open_pdf">Ava PDF-fail</string>     <string name="capture_pdf">Hõiva sisu PDF-failina</string>     <string name="capture_pdf_title">Hõiva sisu PDF-failina</string>@@ -23,7 +16,6 @@     <string name="auto_detect">Tuvasta automatselt</string>     <string name="pdf_save">Salvesta</string>     <string name="pdf_save_as_copy">Salvesta koopiana</string>-    <string name="open_pdf_safe">Ava PDF-fail (ohutult)</string>     <string name="safe_pdf_viewer_title">PDF-failide kuvaja (ohutult)</string>     <string name="safe_pdf_error">Selle PDF-faili avamine ohutus režiimis polnud võimalik. Ta võib olla krüptitud või on kasutusel mõni mittetoetatud funktsionaalsus.</string> </resources>
pdf/src/main/res/values-fr/strings.xml
diff --git a/pdf/src/main/res/values-fr/strings.xml b/pdf/src/main/res/values-fr/strings.xmlindex 604de5c2f1..3a37616e7d 100644--- a/pdf/src/main/res/values-fr/strings.xml+++ b/pdf/src/main/res/values-fr/strings.xml@@ -1,5 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <resources>     <string name="app_name">PDF</string>-    <string name="ok">Ok</string> </resources>
pdf/src/main/res/values-it/strings.xml
diff --git a/pdf/src/main/res/values-it/strings.xml b/pdf/src/main/res/values-it/strings.xmlindex 19c17d18b2..dba3d793b8 100644--- a/pdf/src/main/res/values-it/strings.xml+++ b/pdf/src/main/res/values-it/strings.xml@@ -1,14 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources>-    <string name="ok">OK</string>     <string name="app_name">PDF</string>-    <string name="pdf_viewer_title">Visualizzatore PDF</string>     <string name="search_label">Trova</string>-    <string name="search_result_counter">%1$d di %2$d</string>-    <string name="password_dialog_title">Password necessaria</string>-    <string name="password_dialog_message">Questo PDF è protetto tramite password. Inserisci la password.</string>-    <string name="password_label">Password</string>-    <string name="incorrect_password">Password errata. Riprova.</string>     <string name="open_pdf">Apri PDF</string>     <string name="capture_pdf">Acquisisci PDF</string>     <string name="capture_pdf_title">Acquisizione PDF</string>@@ -23,7 +16,6 @@     <string name="auto_detect">Rilevamento automatico</string>     <string name="pdf_save">Salva</string>     <string name="pdf_save_as_copy">Salva come copia</string>-    <string name="open_pdf_safe">Apri PDF (sicuro)</string>     <string name="safe_pdf_viewer_title">Visualizzatore PDF (sicuro)</string>     <string name="safe_pdf_error">Impossibile aprire questo PDF con il visualizzatore sicuro. Potrebbe essere crittografato o utilizzare funzionalità non supportate.</string> </resources>
pdf/src/main/res/values-iw/strings.xml
diff --git a/pdf/src/main/res/values-iw/strings.xml b/pdf/src/main/res/values-iw/strings.xmlindex 62071254b6..045e125f3d 100644--- a/pdf/src/main/res/values-iw/strings.xml+++ b/pdf/src/main/res/values-iw/strings.xml@@ -1,4 +1,3 @@ <?xml version="1.0" encoding="utf-8"?> <resources>-    <string name="ok">אישור</string> </resources>
pdf/src/main/res/values-pl/strings.xml
diff --git a/pdf/src/main/res/values-pl/strings.xml b/pdf/src/main/res/values-pl/strings.xmlindex 900fb7a175..ad069e35bf 100644--- a/pdf/src/main/res/values-pl/strings.xml+++ b/pdf/src/main/res/values-pl/strings.xml@@ -1,14 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources>-    <string name="ok">OK</string>     <string name="app_name">PDF</string>-    <string name="pdf_viewer_title">Przeglądarka plików PDF</string>     <string name="search_label">Znajdź</string>-    <string name="search_result_counter">%1$d z %2$d</string>-    <string name="password_dialog_title">Wymagane hasło</string>-    <string name="password_dialog_message">Ten plik PDF jest chroniony hasłem. Proszę wprowadzić hasło.</string>-    <string name="password_label">Hasło</string>-    <string name="incorrect_password">Nieprawidłowe hasło. Spróbuj ponownie.</string>     <string name="open_pdf">Otwórz plik PDF</string>     <string name="capture_pdf">Zapisz jako PDF</string>     <string name="capture_pdf_title">Zapisz PDF</string>@@ -23,7 +16,6 @@     <string name="pdf_save">Zapisz</string>     <string name="pdf_save_as_copy">Zapisz kopię</string>     <string name="auto_detect">Automatyczne wykrywanie</string>-    <string name="open_pdf_safe">Otwórz PDF (bezpieczny)</string>     <string name="safe_pdf_viewer_title">Przeglądarka PDF (bezpieczna)</string>     <string name="safe_pdf_error">Tego pliku PDF nie można otworzyć za pomocą bezpiecznej przeglądarki. Możliwe, że jest zaszyfrowany lub korzysta z nieobsługiwanych funkcji.</string> </resources>
pdf/src/main/res/values-pt/strings.xml
diff --git a/pdf/src/main/res/values-pt/strings.xml b/pdf/src/main/res/values-pt/strings.xmlindex edf057b3a6..045e125f3d 100644--- a/pdf/src/main/res/values-pt/strings.xml+++ b/pdf/src/main/res/values-pt/strings.xml@@ -1,4 +1,3 @@ <?xml version="1.0" encoding="utf-8"?> <resources>-    <string name="ok">Ok</string> </resources>
pdf/src/main/res/values-zh-rCN/strings.xml
diff --git a/pdf/src/main/res/values-zh-rCN/strings.xml b/pdf/src/main/res/values-zh-rCN/strings.xmlindex 2038bbc238..3cdfee6444 100644--- a/pdf/src/main/res/values-zh-rCN/strings.xml+++ b/pdf/src/main/res/values-zh-rCN/strings.xml@@ -1,14 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources>     <string name="app_name">PDF</string>-    <string name="pdf_viewer_title">PDF 查看器</string>     <string name="search_label">查找</string>-    <string name="search_result_counter">%1$d / %2$d</string>-    <string name="password_dialog_title">需要密码</string>-    <string name="password_dialog_message">此 PDF 受密码保护。请输入密码。</string>-    <string name="password_label">密码</string>-    <string name="ok">确定</string>-    <string name="incorrect_password">密码错误,请重试。</string>     <string name="open_pdf">打开 PDF</string>     <string name="capture_pdf">捕获 PDF</string>     <string name="capture_pdf_title">捕获 PDF</string>@@ -24,6 +17,5 @@     <string name="pdf_save">保存</string>     <string name="pdf_save_as_copy">另存为副本</string>     <string name="safe_pdf_error">安全查看器无法打开此 PDF。它可能已加密或使用不支持的功能。</string>-    <string name="open_pdf_safe">打开 PDF(安全)</string>     <string name="safe_pdf_viewer_title">PDF 查看器(安全)</string> </resources>
pdf/src/main/res/values/strings.xml
diff --git a/pdf/src/main/res/values/strings.xml b/pdf/src/main/res/values/strings.xmlindex 831d7d67e8..4fd40d83db 100644--- a/pdf/src/main/res/values/strings.xml+++ b/pdf/src/main/res/values/strings.xml@@ -1,15 +1,7 @@ <resources>     <string name="app_name">PDF</string>-    <string name="pdf_viewer_title">PDF Viewer</string>     <string name="search_label">Find</string>-    <string name="search_result_counter">%1$d of %2$d</string>-    <string name="password_dialog_title">Password Required</string>-    <string name="password_dialog_message">This PDF is password protected. Please enter the password.</string>-    <string name="password_label">Password</string>-    <string name="ok">OK</string>-    <string name="incorrect_password">Incorrect password. Please try again.</string>     <string name="open_pdf">Open PDF</string>-    <string name="open_pdf_safe">Open PDF (safe)</string>     <string name="safe_pdf_viewer_title">PDF Viewer (safe)</string>     <string name="safe_pdf_error">This PDF could not be opened by the safe viewer. It may be encrypted or use unsupported features.</string>     <string name="capture_pdf">Capture PDF</string>