Modern Apps git

← Modern-Apps.git

pdf: enable image selection

Commit
5f8ea906fb74c9ed7d962080b5e0db9ec3ddfd7a
Author
Vayun Mathur <[email protected]>
When
2026-04-13 16:47 UTC (7 months ago)
Parents
21baba8

Diff

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 2282ae6ed0..3874038bf5 100644--- a/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt+++ b/pdf/src/main/java/com/vayunmathur/pdf/MainActivity.kt@@ -13,16 +13,12 @@ import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.background-import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.size-import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.AlertDialog import androidx.compose.material3.BottomAppBar@@ -38,49 +34,34 @@ import androidx.compose.material3.SmallFloatingActionButton import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable-import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf-import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue-import androidx.compose.ui.Alignment 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.geometry.Rect import androidx.compose.ui.graphics.Color-import androidx.compose.ui.graphics.SolidColor-import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.painterResource-import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.unit.center-import androidx.compose.ui.unit.dp-import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.toOffset import androidx.core.util.forEach import androidx.pdf.EditablePdfDocument-import androidx.pdf.PdfDocument import androidx.pdf.PdfPasswordException import androidx.pdf.PdfPoint import androidx.pdf.PdfRect import androidx.pdf.SandboxedPdfLoader import androidx.pdf.compose.PdfViewer import androidx.pdf.compose.PdfViewerState-import androidx.pdf.models.FormEditInfo-import androidx.pdf.models.FormWidgetInfo-import androidx.pdf.models.FormWidgetInfo.Companion.WIDGET_TYPE_CHECKBOX import androidx.pdf.selection.model.ImageSelection import androidx.pdf.view.Highlight import com.vayunmathur.library.ui.DynamicTheme@@ -89,8 +70,6 @@ import com.vayunmathur.library.ui.IconSearch import com.vayunmathur.library.ui.IconShare import kotlinx.coroutines.delay import kotlinx.coroutines.launch-import java.util.concurrent.Executors-import kotlin.collections.forEach  class MainActivity : ComponentActivity() {     override fun onCreate(savedInstanceState: Bundle?) {@@ -308,15 +287,18 @@ fun PdfViewerScreen(pdfDocument: EditablePdfDocument) {                         center = coordinates.size.center.toOffset()                     },                     isFormFillingEnabled = true,-                    //isImageSelectionEnabled = true,+                    isImageSelectionEnabled = true,                     onFormWidgetInfoUpdated = { editInfo ->                         coroutineScope.launch {                             pdfDocument.applyEdit(editInfo)                             changesMade = true                         }                     },-//                    appendContextMenuComponents = {+                    appendContextMenuComponents = { //                        val selection = pdfState.currentSelection+//                        item("hjdfhdjsf", "Copy Image", null) {+//+//                        } //                        if (selection is ImageSelection) { //                            item("copy_image", "Copy Image", null) { //                                val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager@@ -324,7 +306,7 @@ fun PdfViewerScreen(pdfDocument: EditablePdfDocument) { //                                clipboard.setPrimaryClip(clip) //                            } //                        }-//                    }+                    }                 ) { uri ->                     val intent = Intent(Intent.ACTION_VIEW, uri)                     context.startActivity(intent)