office: fix all lint findings
- Commit
bcb8e57cea350452dddcfa29452a62695eb6a6d4- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 03:52 UTC (19 days ago)
- Parents
bdaf962
Fixes every in-module finding in the :office lintDev report (baseline on origin/main d687bc35a: 179 in-module findings — 84 PackageStructure, 77 ExtraTranslation, 5 AutoboxingStateValueProperty, 4 OneComposablePerFile, 3 UnusedResources, 3 TypographyEllipsis, 1 TextConcatSpace, 1 AutoboxingStateCreation hint, 1 CommentedOutCode). The 61 remaining report entries are all in shared library modules (library/*) and are unchanged; they are the lead's job. PackageStructure (84): moved files to canonical roots with git mv and rewrote every import/reference in office/ (main, test, screenshotTest): - root document chrome/screens -> ui/ - odf/ importers/parsers/writers -> data/odf/ - util/OfficeViewModel* -> platform/ - util/OfficeSync + OfficeSyncCrypto -> sync/ - util/DocumentTreeCrdt -> domain/ - MainActivity.kt now contains only MainActivity; OfficeRoute was renamed to Route in a new Route.kt (sealed interface Route : NavKey, nested routes keep their names), the nav root moved to a new Navigation.kt (@Composable fun Navigation), themes and the dark-mode invert modifier moved to ui/OfficeTheme.kt, and DocumentScreen moved to ui/DocumentScreen.kt. - Test sources mirror the moves (odf -> data/odf, util -> platform). OneComposablePerFile (4): DocumentScreen out of MainActivity.kt (above); OdfImageView split out of OdfImageViews.kt; HomeScreen split out of OfficeHomeScreens.kt; OnlineTab split out of OfficeOnlineScreens.kt. FileLength (new Errors exposed by the ui/ move: ui limit is 350 lines, root-package limit was 800): split DocumentScreenShell.kt into DocumentScaffoldShell.kt/DocumentScaffoldBody.kt, OfficeDocumentOverlays.kt into DocumentOverlaySections.kt, and OfficeOnlineScreens.kt into ShareOnlineDialog.kt. A few formerly file-private helpers/constants were widened to internal so the split files can share them (one duplicate private ROTATE_QUARTER_TURNS constant deleted). ExtraTranslation (77): removed locale string entries that have no default-locale source string. UnusedResources (3): removed error_loading, insert_table_1 and speaker_notes_2 from the default and all locale string files after verifying there is no dynamic lookup (no getIdentifier/reflection or concatenated names) anywhere in office/. TypographyEllipsis (3): replaced "..." with the ellipsis character in values-ar and values-ru. TextConcatSpace (1): added the missing space in the shared-document error message in OfficeViewModelSyncB. Autoboxing (5 warnings + 1 hint + 1 test warning): read MutableIntState via intValue in OfficeDocumentMenuBar and Slice4MenusOverlaysTest, and use mutableFloatStateOf for the page-setup margin. CommentedOutCode (1): rewrote the code-like comment in OdfParserText as plain prose. Suppressions: none. No @SuppressLint added, no lint config or baseline touched. False positive / exception: util/OfficeNative.kt keeps its package. Its fully-qualified name is frozen by JNI — the Rust office_engine crate binds Java_com_vayunmathur_office_util_OfficeNative_* symbols — so it carries the rule's sanctioned verbatim marker "// PACKAGE STRUCTURE EXCEPTION (JNI)" with a justification comment instead of moving. This is the PackageStructure rule's own documented escape hatch, not a lint suppression. Verification: - :office:lintDev — in-module (files under office/) findings: 179 -> 0 errors, 0 warnings, 0 hints. Report total is now the 61 pre-existing shared-library findings only. - :office:testDevUnitTest — green, 1063 tests, 0 failures/errors. - :office:compileDevKotlin and :office:compileDevScreenshotTestKotlin also green. Lead integration: declared POST_NOTIFICATIONS in the manifest - the NotificationPermission finding arrived via library MaNotifications usage and the detector requires the posting app to hold the permission (same fix contacts/code applied).
Diff
office/src/main/AndroidManifest.xml
diff --git a/office/src/main/AndroidManifest.xml b/office/src/main/AndroidManifest.xmlindex 5f0155abf6..9a3e895228 100644--- a/office/src/main/AndroidManifest.xml+++ b/office/src/main/AndroidManifest.xml@@ -6,6 +6,7 @@ <!-- Sensors permission at install instead of auto-granting it. --> <uses-permission android:name="com.vayunmathur.permission.SENSORS_OPTOUT" /> + <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
office/src/main/java/com/vayunmathur/office/DocumentScreenShell.kt
diff --git a/office/src/main/java/com/vayunmathur/office/DocumentScreenShell.kt b/office/src/main/java/com/vayunmathur/office/DocumentScreenShell.ktdeleted file mode 100644index 60baa096ae..0000000000--- a/office/src/main/java/com/vayunmathur/office/DocumentScreenShell.kt+++ /dev/null@@ -1,527 +0,0 @@-package com.vayunmathur.office--import androidx.activity.ComponentActivity-import androidx.activity.compose.BackHandler-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Spacer-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.height-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.size-import androidx.compose.foundation.layout.width-import androidx.compose.foundation.lazy.LazyListState-import androidx.compose.runtime.Composable-import androidx.compose.runtime.LaunchedEffect-import androidx.compose.runtime.getValue-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.style.TextOverflow-import androidx.compose.ui.unit.dp-import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.CircularProgressIndicator-import com.vayunmathur.library.ui.DrawerState-import com.vayunmathur.library.ui.IconBack-import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.IconRedo-import com.vayunmathur.library.ui.IconSave-import com.vayunmathur.library.ui.IconSearch-import com.vayunmathur.library.ui.IconUndo-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.ModalDrawerSheet-import com.vayunmathur.library.ui.ModalNavigationDrawer-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TextButton-import com.vayunmathur.library.ui.appBarScrollBehavior-import com.vayunmathur.library.ui.isExpandedWidth-import com.vayunmathur.library.ui.odf.OdfDocument-import com.vayunmathur.office.ui.OfficeEditorWideLayout-import com.vayunmathur.office.util.OfficeViewModel-import com.vayunmathur.office.util.needsSaveAs-import com.vayunmathur.office.util.save-import kotlinx.coroutines.CoroutineScope--private val DrawerWidth = 280.dp-private val SavingSpinnerSize = 20.dp-private const val TIMER_TICK_MS = 1000L--/**- * Error body for a document that failed to load.- */-@Composable-internal fun MainActivity.EditorError(message: String, onOpenDocument: () -> Unit) {- ErrorBody(message, onOpenDocument)-}--/** Error body content. */-@Composable-internal fun ErrorBody(message: String, onOpenDocument: () -> Unit) {- Column(- modifier = Modifier.fillMaxSize().padding(24.dp),- verticalArrangement = Arrangement.Center,- horizontalAlignment = Alignment.CenterHorizontally) {- Text(message, style = MaterialTheme.typography.bodyLarge)- Spacer(Modifier.height(16.dp))- TextButton(onClick = onOpenDocument) {- Text(stringResource(R.string.open_document))- }- }-}--/** Timer + back-handler effects for [DocumentScreen]. */-@Composable-internal fun DocumentEffects(- s: DocumentScreenState,- chrome: DocumentChrome,- onBack: () -> Unit,- onShowUnsavedDialog: () -> Unit,-) {- // Presentation timer- LaunchedEffect(s.showTimer) {- if (s.showTimer) {- s.timerSeconds = 0- while (s.showTimer) { kotlinx.coroutines.delay(TIMER_TICK_MS); s.timerSeconds++ }- }- }-- // Always intercept back inside a document so it returns to the home screen instead of exiting- // the app. Online docs sync live (nothing to save); offline docs with edits prompt to save.- BackHandler(enabled = true) {- if (!chrome.isOnline && chrome.hasUnsavedChanges) onShowUnsavedDialog() else onBack()- }-}--/** Navigation drawer + scaffold shell for [DocumentScreen]. */-@Composable-internal fun DocumentDrawerShell(- s: DocumentScreenState,- document: OdfDocument,- viewModel: OfficeViewModel,- activity: ComponentActivity,- chrome: DocumentChrome,- launchers: DocumentLaunchers,- scope: CoroutineScope,- drawerState: DrawerState,- listState: LazyListState,- onToggleSearch: () -> Unit,- onShowUnsavedDialog: () -> Unit,- sel: ScreenSelection,- onRunSelectionChange: (Int, Int, Int, Int) -> Unit,- onCellFocus: (Int, Int, Int) -> Unit,- onCellSelected: (Int, Int, Int) -> Unit,- onSlideChange: (Int) -> Unit,- onSlideElementSelected: (Int, Int) -> Unit,- focusedPara: Int,- onBack: () -> Unit,- onBecameOnline: (String) -> Unit,-) {- ModalNavigationDrawer(- drawerState = drawerState,- gesturesEnabled = chrome.isTextDoc &&- (chrome.headings.isNotEmpty() || chrome.bookmarks.isNotEmpty()),- drawerContent = {- DrawerOutline(chrome, listState, drawerState, scope)- }- ) {- DocumentScaffoldShell(- s = s,- document = document,- viewModel = viewModel,- activity = activity,- chrome = chrome,- launchers = launchers,- scope = scope,- drawerState = drawerState,- listState = listState,- onToggleSearch = onToggleSearch,- onShowUnsavedDialog = onShowUnsavedDialog,- sel = sel,- onRunSelectionChange = onRunSelectionChange,- onCellFocus = onCellFocus,- onCellSelected = onCellSelected,- onSlideChange = onSlideChange,- onSlideElementSelected = onSlideElementSelected,- onBack = onBack,- )- DrawerScreenOverlays(- s = s,- document = document,- viewModel = viewModel,- chrome = chrome,- launchers = launchers,- scope = scope,- listState = listState,- focusedPara = focusedPara,- onBack = onBack,- onBecameOnline = onBecameOnline,- )- }-}--/** Outline drawer content. */-@Composable-internal fun DrawerOutline(- chrome: DocumentChrome,- listState: LazyListState,- drawerState: DrawerState,- scope: CoroutineScope,-) {- if (!chrome.isTextDoc) return- ModalDrawerSheet(Modifier.width(DrawerWidth)) {- OfficeOutlinePane(- chrome.bookmarks,- chrome.headings,- listState,- drawerState,- scope,- Modifier.fillMaxWidth())- }-}--/** Trailing overlays for the drawer shell. */-@Composable-internal fun DrawerScreenOverlays(- s: DocumentScreenState,- document: OdfDocument,- viewModel: OfficeViewModel,- chrome: DocumentChrome,- launchers: DocumentLaunchers,- scope: CoroutineScope,- listState: LazyListState,- focusedPara: Int,- onBack: () -> Unit,- onBecameOnline: (String) -> Unit,-) {- DocumentOverlays(- state = s,- document = document,- viewModel = viewModel,- isPresentation = chrome.isPresentation,- isOnline = chrome.isOnline,- focusedPara = focusedPara,- saveAsName = chrome.saveAsName,- activeCell = s.activeCellState,- activeSlide = s.activeSlideState,- activeSlideEl = s.activeSlideElState,- activeRunStart = s.activeRunStartState,- activeRunEnd = s.activeRunEndState,- selStart = s.selStartState,- selEnd = s.selEndState,- pendingReplace = s.pendingReplaceState,- listState = listState,- scope = scope,- launchers = launchers,- onBecameOnline = onBecameOnline,- onBack = onBack,- )- }--/** App-bar scaffold with actions + bottom bar. */-@Composable-internal fun DocumentScaffoldShell(- s: DocumentScreenState,- document: OdfDocument,- viewModel: OfficeViewModel,- activity: ComponentActivity,- chrome: DocumentChrome,- launchers: DocumentLaunchers,- scope: kotlinx.coroutines.CoroutineScope,- drawerState: com.vayunmathur.library.ui.DrawerState,- listState: androidx.compose.foundation.lazy.LazyListState,- onToggleSearch: () -> Unit,- onShowUnsavedDialog: () -> Unit,- sel: ScreenSelection,- onRunSelectionChange: (Int, Int, Int, Int) -> Unit,- onCellFocus: (Int, Int, Int) -> Unit,- onCellSelected: (Int, Int, Int) -> Unit,- onSlideChange: (Int) -> Unit,- onSlideElementSelected: (Int, Int) -> Unit,- onBack: () -> Unit,-) {- AppScaffold(- title = { Text(- document.title,- maxLines = 1,- overflow = TextOverflow.Ellipsis,- style = MaterialTheme.typography.titleSmall) },- navigationIcon = {- IconButton(onClick = {- if (!chrome.isOnline && chrome.hasUnsavedChanges) onShowUnsavedDialog() else onBack()- }) {- IconBack()- }- },- actions = {- DocumentScaffoldActions(- chrome = chrome,- viewModel = viewModel,- canEdit = chrome.canEdit,- saveAsName = chrome.saveAsName,- launchers = launchers,- onToggleSearch = onToggleSearch,- )- },- bottomBar = {- ScaffoldBottomBar(s, document, viewModel, chrome, launchers, sel)- },- scrollBehavior = appBarScrollBehavior(),- ) { paddingValues ->- DocumentScaffoldBody(- s = s,- document = document,- viewModel = viewModel,- activity = activity,- chrome = chrome,- launchers = launchers,- scope = scope,- drawerState = drawerState,- listState = listState,- contentPadding = paddingValues,- onRunSelectionChange = onRunSelectionChange,- onCellFocus = onCellFocus,- onCellSelected = onCellSelected,- onSlideChange = onSlideChange,- onSlideElementSelected = onSlideElementSelected,- )- }-}--/** Bottom bar for the document scaffold. */-@Composable-internal fun ScaffoldBottomBar(- s: DocumentScreenState,- document: OdfDocument,- viewModel: OfficeViewModel,- chrome: DocumentChrome,- launchers: DocumentLaunchers,- sel: ScreenSelection,-) {- DocumentBottomBarHost(- s, document, viewModel, chrome.canEdit, chrome.isTextDoc, chrome.isSpreadsheet, chrome.isPresentation,- sel.activeRunStart, sel.activeRunEnd, sel.selStart, sel.selEnd, sel.activeCell,- sel.activeSlide, sel.activeSlideEl, launchers,- sel.activeTableBlock, sel.activeTableRow, sel.activeTableCol)-}--/** Top-app-bar actions for [DocumentScreen]. */-@Composable-internal fun DocumentScaffoldActions(- chrome: DocumentChrome,- viewModel: OfficeViewModel,- canEdit: Boolean,- saveAsName: String,- launchers: DocumentLaunchers,- onToggleSearch: () -> Unit,-) {- if (canEdit) IconButton(onClick = { onToggleSearch() }) { IconSearch() }- IconButton(onClick = { viewModel.undo() }, enabled = chrome.canUndo) { IconUndo() }- IconButton(onClick = { viewModel.redo() }, enabled = chrome.canRedo) { IconRedo() }- if (!chrome.isOnline) {- SaveAction(viewModel, chrome, saveAsName, launchers)- }-}--/** Save / save-as action (offline only). */-@Composable-internal fun SaveAction(- viewModel: OfficeViewModel,- chrome: DocumentChrome,- saveAsName: String,- launchers: DocumentLaunchers,-) {- IconButton(- onClick = {- if (viewModel.needsSaveAs()) {- launchers.saveAs.launch(saveAsName)- } else {- viewModel.save()- }- },- enabled = chrome.hasUnsavedChanges && !chrome.isSaving,- ) {- if (chrome.isSaving) CircularProgressIndicator(Modifier.size(SavingSpinnerSize)) else IconSave()- }-}--/** Scaffold body: menu bar, find bars, and the editor pane. */-@Composable-internal fun DocumentScaffoldBody(- s: DocumentScreenState,- document: OdfDocument,- viewModel: OfficeViewModel,- activity: ComponentActivity,- chrome: DocumentChrome,- launchers: DocumentLaunchers,- scope: kotlinx.coroutines.CoroutineScope,- drawerState: com.vayunmathur.library.ui.DrawerState,- listState: androidx.compose.foundation.lazy.LazyListState,- contentPadding: androidx.compose.foundation.layout.PaddingValues,- onRunSelectionChange: (Int, Int, Int, Int) -> Unit,- onCellFocus: (Int, Int, Int) -> Unit,- onCellSelected: (Int, Int, Int) -> Unit,- onSlideChange: (Int) -> Unit,- onSlideElementSelected: (Int, Int) -> Unit,- modifier: Modifier = Modifier,-) {- Column(Modifier.fillMaxSize().padding(contentPadding)) {- ScaffoldMenuBars(- s = s, document = document, viewModel = viewModel,- activity = activity, chrome = chrome, launchers = launchers,- scope = scope, drawerState = drawerState, listState = listState)- // Timer/search/font/word bars: see DocumentFindBars (file-length split).- DocumentEditorPane(- s = s,- document = document,- viewModel = viewModel,- chrome = chrome,- listState = listState,- scope = scope,- drawerState = drawerState,- onRunSelectionChange = onRunSelectionChange,- onCellFocus = onCellFocus,- onCellSelected = onCellSelected,- onSlideChange = onSlideChange,- onSlideElementSelected = onSlideElementSelected,- modifier = modifier,- )- }-}--/** Menu + find bars for the scaffold body. */-@Composable-internal fun ScaffoldMenuBars(- s: DocumentScreenState,- document: OdfDocument,- viewModel: OfficeViewModel,- activity: ComponentActivity,- chrome: DocumentChrome,- launchers: DocumentLaunchers,- scope: kotlinx.coroutines.CoroutineScope,- drawerState: com.vayunmathur.library.ui.DrawerState,- listState: androidx.compose.foundation.lazy.LazyListState,-) {- DocumentMenuBar(- s = s,- document = document,- viewModel = viewModel,- activity = activity,- isTextDoc = chrome.isTextDoc,- isSpreadsheet = chrome.isSpreadsheet,- isPresentation = chrome.isPresentation,- isOnline = chrome.isOnline,- onlineEnabled = chrome.onlineEnabled,- hasUnsavedChanges = chrome.hasUnsavedChanges,- saveAsName = chrome.saveAsName,- wordCount = chrome.wordCount,- charCount = chrome.charCount,- readingTime = chrome.readingTime,- nightMode = chrome.nightMode,- documentDarkMode = chrome.documentDarkMode,- launchers = launchers,- scope = scope,- drawerState = drawerState,- )- DocumentFindBars(- s = s,- document = document,- viewModel = viewModel,- isTextDoc = chrome.isTextDoc,- isPresentation = chrome.isPresentation,- wordCount = chrome.wordCount,- charCount = chrome.charCount,- readingTime = chrome.readingTime,- scope = scope,- listState = listState,- )-}--/** Editor pane with the wide-layout outline branch. */-@Composable-internal fun DocumentEditorPane(- s: DocumentScreenState,- document: OdfDocument,- viewModel: OfficeViewModel,- chrome: DocumentChrome,- listState: androidx.compose.foundation.lazy.LazyListState,- scope: kotlinx.coroutines.CoroutineScope,- drawerState: com.vayunmathur.library.ui.DrawerState,- onRunSelectionChange: (Int, Int, Int, Int) -> Unit,- onCellFocus: (Int, Int, Int) -> Unit,- onCellSelected: (Int, Int, Int) -> Unit,- onSlideChange: (Int) -> Unit,- onSlideElementSelected: (Int, Int) -> Unit,- modifier: Modifier = Modifier,-) {- Column(modifier) {- val showOutline = isExpandedWidth() && chrome.isTextDoc &&- (chrome.headings.isNotEmpty() || chrome.bookmarks.isNotEmpty())- if (showOutline) {- OfficeEditorWideLayout(- outline = { OfficeOutlinePane(- chrome.bookmarks,- chrome.headings,- listState,- drawerState,- scope,- Modifier.fillMaxSize()) },- document = {- EditorDocumentPane(- s = s, document = document, viewModel = viewModel, chrome = chrome,- listState = listState, onRunSelectionChange = onRunSelectionChange,- onCellFocus = onCellFocus, onCellSelected = onCellSelected,- onSlideChange = onSlideChange, onSlideElementSelected = onSlideElementSelected,- modifier = Modifier.fillMaxSize())- },- )- } else {- EditorDocumentPane(- s = s, document = document, viewModel = viewModel, chrome = chrome,- listState = listState, onRunSelectionChange = onRunSelectionChange,- onCellFocus = onCellFocus, onCellSelected = onCellSelected,- onSlideChange = onSlideChange, onSlideElementSelected = onSlideElementSelected,- modifier = Modifier.fillMaxSize())- }- }-}--/** Single shared [OfficeDocumentPane] call (compact + wide layouts). */-@Composable-internal fun EditorDocumentPane(- s: DocumentScreenState,- document: OdfDocument,- viewModel: OfficeViewModel,- chrome: DocumentChrome,- listState: androidx.compose.foundation.lazy.LazyListState,- onRunSelectionChange: (Int, Int, Int, Int) -> Unit,- onCellFocus: (Int, Int, Int) -> Unit,- onCellSelected: (Int, Int, Int) -> Unit,- onSlideChange: (Int) -> Unit,- onSlideElementSelected: (Int, Int) -> Unit,- modifier: Modifier = Modifier,-) {- val activeSlideEl by s.activeSlideElState- OfficeDocumentPane(- document = document,- viewModel = viewModel,- documentDarkMode = chrome.documentDarkMode,- nightMode = chrome.nightMode,- searchQuery = s.searchQuery,- fontSizeMultiplier = s.fontSizeMultiplier,- listState = listState,- isEditMode = chrome.isEditMode,- activeSlideEl = activeSlideEl,- onRunSelectionChange = onRunSelectionChange,- onCellFocus = onCellFocus,- onCellSelected = onCellSelected,- onSlideChange = onSlideChange,- onSlideElementSelected = onSlideElementSelected,- onChartClick = { bi -> s.editingChartBlock = bi; s.showChartEditor = true },- onCropImage = { bi -> s.cropImageBlock = bi },- onCropSlide = { si, e -> s.cropSlideTarget = si to e },- onCropSheet = { si, e -> s.cropSheetTarget = si to e },- modifier = modifier,- )-}
office/src/main/java/com/vayunmathur/office/MainActivity.kt
diff --git a/office/src/main/java/com/vayunmathur/office/MainActivity.kt b/office/src/main/java/com/vayunmathur/office/MainActivity.ktindex d8fb88acd5..e8c33ba906 100644--- a/office/src/main/java/com/vayunmathur/office/MainActivity.kt+++ b/office/src/main/java/com/vayunmathur/office/MainActivity.kt@@ -2,137 +2,19 @@ package com.vayunmathur.office import android.content.Intent import android.net.Uri-import androidx.activity.ComponentActivity-import androidx.activity.compose.rememberLauncherForActivityResult-import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.lazy.rememberLazyListState 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.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.draw.drawWithContent-import androidx.compose.ui.geometry.Rect-import androidx.compose.ui.graphics.Color-import androidx.compose.ui.graphics.ColorFilter-import androidx.compose.ui.graphics.ColorMatrix-import androidx.compose.ui.graphics.Paint-import androidx.compose.ui.graphics.drawscope.drawIntoCanvas-import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.res.stringResource-import androidx.compose.ui.text.style.TextOverflow-import androidx.compose.ui.unit.dp import androidx.core.content.IntentCompat import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.library.network.TrustBundle import com.vayunmathur.library.ui.MaActivity-import com.vayunmathur.library.ui.CircularProgressIndicator-import com.vayunmathur.library.ui.DrawerValue-import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.IconButton-import com.vayunmathur.library.ui.IconClose-import com.vayunmathur.library.ui.IconDownload-import com.vayunmathur.library.ui.IconHome-import com.vayunmathur.library.ui.IconRedo-import com.vayunmathur.library.ui.IconRefresh-import com.vayunmathur.library.ui.IconSave-import com.vayunmathur.library.ui.IconSearch-import com.vayunmathur.library.ui.IconSettings-import com.vayunmathur.library.ui.IconShare-import com.vayunmathur.library.ui.IconUndo-import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.Typography-import com.vayunmathur.library.ui.dynamicDarkColorScheme-import com.vayunmathur.library.ui.dynamicLightColorScheme-import com.vayunmathur.library.ui.odf.OdfDocument-import com.vayunmathur.library.ui.rememberDrawerState import com.vayunmathur.library.util.AppMessages-import com.vayunmathur.library.util.MainNavigation-import com.vayunmathur.library.util.NavKey-import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.office.R-import com.vayunmathur.office.util.OfficeViewModel-import com.vayunmathur.office.util.clearDocument-import com.vayunmathur.office.util.initSync-import com.vayunmathur.office.util.loadDocument-import com.vayunmathur.office.util.openOnlineDocument-import com.vayunmathur.office.util.requestToJoin-import com.vayunmathur.office.util.runParagraphIndexAt-import kotlinx.serialization.Serializable+import com.vayunmathur.office.platform.OfficeViewModel+import com.vayunmathur.office.platform.requestToJoin+import com.vayunmathur.office.ui.OfficeAppTheme --// Public so `src/screenshotTest` can wrap a document exactly the way DocumentScreen does;-// without it the listing images would show the paper in the wrong scheme.-@Composable-fun OfficeLightTheme(content: @Composable () -> Unit) {- // Light scheme — used only for the rendered document (the "paper"), which stays light in dark mode.- val colorScheme = dynamicLightColorScheme(LocalContext.current)- MaterialTheme(colorScheme = colorScheme, typography = Typography(), content = content)-}--// Inverts luminance (white paper <-> black) while preserving hue, matching the-// "invert(1) hue-rotate(180deg)" trick used for document dark modes like Google Docs.-private val ErrorPadding = 16.dp-private val DrawerWidth = 280.dp-private val SavingSpinnerSize = 20.dp-private const val TIMER_TICK_MS = 1000L--private val DocumentDarkModeColorMatrix = ColorMatrix(- floatArrayOf(- 0.574f, -1.430f, -0.144f, 0f, 255f,- -0.426f, -0.430f, -0.144f, 0f, 255f,- -0.426f, -1.430f, 0.856f, 0f, 255f,- 0f, 0f, 0f, 1f, 0f,- ),-)--/**- * Renders the content into an offscreen layer and paints it back through a- * luminance-inverting color filter, so the displayed document appears dark- * without altering the underlying document colors. View-only (#479).- */-fun Modifier.documentDarkModeInvert(): Modifier = this.drawWithContent {- val paint = Paint().apply {- colorFilter = ColorFilter.colorMatrix(DocumentDarkModeColorMatrix)- }- drawIntoCanvas { canvas ->- canvas.saveLayer(Rect(0f, 0f, size.width, size.height), paint)- drawContent()- canvas.restore()- }-}--@Composable-private fun OfficeAppTheme(content: @Composable () -> Unit) {- // The app chrome (menus, toolbars, home) is dark; the document content re-wraps in the light theme.- val colorScheme = dynamicDarkColorScheme(LocalContext.current)- MaterialTheme(colorScheme = colorScheme, typography = Typography(), content = content)-}--/** Top-level navigation routes for the Office app (shared nav framework). */-@Serializable-sealed interface OfficeRoute : NavKey {- /** Offline home tab (sibling route, the start destination). */- @Serializable data object OfflineHome : OfficeRoute- /** Online cloud-docs home tab (sibling route). */- @Serializable data object OnlineHome : OfficeRoute- /** Editing a local/offline document (optionally identified by its source uri). */- @Serializable data class OfflineEditor(val uri: String? = null) : OfficeRoute- /** Editing a cloud-synced document, identified by its document id. */- @Serializable data class OnlineEditor(val docId: String) : OfficeRoute-}--/** Main Activity: a ma activity implementation for main activity. */+import com.vayunmathur.office.data.odf.DocumentImporter class MainActivity : MaActivity() { private val viewModel: OfficeViewModel by viewModels() private var intentDocumentUri: Uri? = null@@ -156,46 +38,7 @@ class MainActivity : MaActivity() { @Composable override fun Content() {- OfficeRoot(intentDocumentUri)- }-- /** Root content: nav graph over home + editor routes. */- @Composable- private fun OfficeRoot(intentUri: Uri?) {- val startedWithIntent = intentUri != null- var documentUri by rememberSaveable { mutableStateOf(intentUri) }- val state by viewModel.state.collectAsState()- val backStack = rememberNavBackStack<OfficeRoute>(- if (intentUri != null) OfficeRoute.OfflineEditor(intentUri.toString()) else OfficeRoute.OfflineHome- )-- LaunchedEffect(Unit) { viewModel.initSync() }-- if (documentUri != null && state is OfficeViewModel.ViewState.Empty) {- viewModel.loadDocument(documentUri!!, resolveDisplayName(this@MainActivity, documentUri!!))- }-- val filePickerLauncher = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->- uri?.let {- persistUriGrant(it)- documentUri = it- viewModel.loadDocument(it, resolveDisplayName(this@MainActivity, it))- backStack.add(OfficeRoute.OfflineEditor(it.toString()))- }- }-- fun leaveEditor() {- if (startedWithIntent) finish()- else {- documentUri = null- viewModel.clearDocument()- if (backStack.backStack.size > 1) backStack.pop()- }- }-- OfficeAppTheme {- OfficeNavGraph(state, filePickerLauncher, { leaveEditor() }, backStack)- }+ Navigation(viewModel, this, intentDocumentUri) } /**@@ -205,7 +48,7 @@ class MainActivity : MaActivity() { * OpenableColumns.DISPLAY_NAME first to keep extension-based routing working for * files opened via intents (falling back to the last path segment). */- private fun resolveDisplayName(context: android.content.Context, uri: Uri): String {+ internal fun resolveDisplayName(context: android.content.Context, uri: Uri): String { if (uri.scheme == "content") { runCatching { context.contentResolver.query(@@ -221,43 +64,8 @@ class MainActivity : MaActivity() { return uri.lastPathSegment?.substringAfterLast('/') ?: "document" } - /** Navigation graph for home + editor routes. */- @Composable- private fun OfficeNavGraph(- state: OfficeViewModel.ViewState,- filePickerLauncher: androidx.activity.result.ActivityResultLauncher<Array<String>>,- onLeaveEditor: () -> Unit,- backStack: com.vayunmathur.library.util.NavBackStack<OfficeRoute>,- ) {- val editorContent: @Composable () -> Unit = {- when (val s = state) {- is OfficeViewModel.ViewState.Loaded -> DocumentScreen(- document = s.document, viewModel = viewModel, activity = this@MainActivity,- onBack = { onLeaveEditor() },- // When an offline doc is shared it becomes a cloud doc — switch its route.- onBecameOnline = { id -> backStack.setLast(OfficeRoute.OnlineEditor(id)) }- )- is OfficeViewModel.ViewState.Error -> EditorError(s.message, onLeaveEditor)- else -> Box(- Modifier.fillMaxSize(),- contentAlignment = Alignment.Center) { CircularProgressIndicator() }- }- }- OfficeTabs(- backStack = backStack,- viewModel = viewModel,- onOpenDocument = { filePickerLauncher.launch(odfMimeTypes) },- onNavigateEditor = { backStack.add(OfficeRoute.OfflineEditor()) },- onOpenOnlineDoc = { meta ->- viewModel.openOnlineDocument(meta)- backStack.add(OfficeRoute.OnlineEditor(meta.docId))- },- editorContent = editorContent,- )- }- /** MIME types accepted by the document picker. */- private val odfMimeTypes = arrayOf(+ internal val odfMimeTypes = arrayOf( "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.presentation",@@ -278,7 +86,7 @@ class MainActivity : MaActivity() { * Holds on to the picker's grant so Save can still write back to the chosen document after the * transient grant expires. Falls back to a read-only grant for providers that refuse write. */- private fun persistUriGrant(uri: Uri) {+ internal fun persistUriGrant(uri: Uri) { val readWrite = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION if (runCatching { contentResolver.takePersistableUriPermission(uri, readWrite) }.isFailure) { runCatching { contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION) }@@ -323,65 +131,3 @@ class MainActivity : MaActivity() { else -> intent.data } }--/**- * Error body for a document that failed to load: see DocumentScreenShell.- */-@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun DocumentScreen(- document: OdfDocument,- viewModel: OfficeViewModel,- activity: ComponentActivity,- onBack: () -> Unit,- onBecameOnline: (String) -> Unit = {}) {- val s = rememberDocumentScreenState()- val sel = rememberScreenSelection(s)-- val onRunSelectionChange = rememberRunSelectionHandler(sel, viewModel)-- val chrome = rememberDocumentChrome(viewModel, document)- val focusedPara = if (sel.activeRunStart >= 0 && chrome.isTextDoc) viewModel.runParagraphIndexAt(- sel.activeRunStart,- sel.activeRunEnd,- sel.selStart) else -1-- DocumentEffects(s, chrome, onBack, { sel.showUnsavedDialog = true })-- val drawerState = rememberDrawerState(DrawerValue.Closed)- val scope = rememberCoroutineScope()- val listState = rememberLazyListState()-- val launchers = rememberDocumentLaunchers(- viewModel = viewModel,- holder = s,- onPickImageBytes = rememberImagePickerHandler(- document, viewModel, focusedPara, sel.activeSlide, sel.activeCell))-- DocumentDrawerShell(- s = s,- document = document,- viewModel = viewModel,- activity = activity,- chrome = chrome,- launchers = launchers,- scope = scope,- drawerState = drawerState,- listState = listState,- onToggleSearch = { sel.showSearch = !sel.showSearch },- onShowUnsavedDialog = { sel.showUnsavedDialog = true },- sel = ScreenSelection(- sel.activeRunStart, sel.activeRunEnd, sel.activeTableBlock, sel.activeTableRow, sel.activeTableCol,- sel.selStart, sel.selEnd, sel.activeCell, sel.activeSlide, sel.activeSlideEl),- onRunSelectionChange = onRunSelectionChange,- onCellFocus = { bi, r, c -> sel.activeTableBlock = bi; sel.activeTableRow = r; sel.activeTableCol = c },- onCellSelected = { si, r, c -> sel.activeCell = Triple(si, r, c) },- onSlideChange = { sel.activeSlide = it },- onSlideElementSelected = { si, e -> sel.activeSlide = si; sel.activeSlideEl = e },- focusedPara = focusedPara,- onBack = onBack,- onBecameOnline = onBecameOnline,- )-}--/** Run-selection + shell sections: see DocumentScreenChrome / DocumentScreenShell. */
office/src/main/java/com/vayunmathur/office/Navigation.kt
diff --git a/office/src/main/java/com/vayunmathur/office/Navigation.kt b/office/src/main/java/com/vayunmathur/office/Navigation.ktnew file mode 100644index 0000000000..40bc782187--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/Navigation.kt@@ -0,0 +1,90 @@+package com.vayunmathur.office++import android.net.Uri+import androidx.activity.compose.rememberLauncherForActivityResult+import androidx.activity.result.contract.ActivityResultContracts+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxSize+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.saveable.rememberSaveable+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.util.rememberNavBackStack+import com.vayunmathur.office.platform.OfficeViewModel+import com.vayunmathur.office.platform.clearDocument+import com.vayunmathur.office.platform.initSync+import com.vayunmathur.office.platform.loadDocument+import com.vayunmathur.office.platform.openOnlineDocument+import com.vayunmathur.office.ui.DocumentScreen+import com.vayunmathur.office.ui.EditorError+import com.vayunmathur.office.ui.OfficeAppTheme+import com.vayunmathur.office.ui.OfficeTabs++/** Root navigation graph: home tabs plus the document editor routes. */+@Composable+fun Navigation(viewModel: OfficeViewModel, activity: MainActivity, intentUri: Uri?) {+ val startedWithIntent = intentUri != null+ var documentUri by rememberSaveable { mutableStateOf(intentUri) }+ val state by viewModel.state.collectAsState()+ val backStack = rememberNavBackStack<Route>(+ if (intentUri != null) Route.OfflineEditor(intentUri.toString()) else Route.OfflineHome+ )++ LaunchedEffect(Unit) { viewModel.initSync() }++ if (documentUri != null && state is OfficeViewModel.ViewState.Empty) {+ viewModel.loadDocument(documentUri!!, activity.resolveDisplayName(activity, documentUri!!))+ }++ val filePickerLauncher = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->+ uri?.let {+ activity.persistUriGrant(it)+ documentUri = it+ viewModel.loadDocument(it, activity.resolveDisplayName(activity, it))+ backStack.add(Route.OfflineEditor(it.toString()))+ }+ }++ fun leaveEditor() {+ if (startedWithIntent) activity.finish()+ else {+ documentUri = null+ viewModel.clearDocument()+ if (backStack.backStack.size > 1) backStack.pop()+ }+ }++ OfficeAppTheme {+ val editorContent: @Composable () -> Unit = {+ when (val s = state) {+ is OfficeViewModel.ViewState.Loaded -> DocumentScreen(+ document = s.document, viewModel = viewModel, activity = activity,+ onBack = { leaveEditor() },+ // When an offline doc is shared it becomes a cloud doc — switch its route.+ onBecameOnline = { id -> backStack.setLast(Route.OnlineEditor(id)) }+ )+ is OfficeViewModel.ViewState.Error -> activity.EditorError(s.message, { leaveEditor() })+ else -> Box(+ Modifier.fillMaxSize(),+ contentAlignment = Alignment.Center) { CircularProgressIndicator() }+ }+ }+ OfficeTabs(+ backStack = backStack,+ viewModel = viewModel,+ onOpenDocument = { filePickerLauncher.launch(activity.odfMimeTypes) },+ onNavigateEditor = { backStack.add(Route.OfflineEditor()) },+ onOpenOnlineDoc = { meta ->+ viewModel.openOnlineDocument(meta)+ backStack.add(Route.OnlineEditor(meta.docId))+ },+ editorContent = editorContent,+ )+ }+}
office/src/main/java/com/vayunmathur/office/Route.kt
diff --git a/office/src/main/java/com/vayunmathur/office/Route.kt b/office/src/main/java/com/vayunmathur/office/Route.ktnew file mode 100644index 0000000000..af2f8135e9--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/Route.kt@@ -0,0 +1,17 @@+package com.vayunmathur.office++import com.vayunmathur.library.util.NavKey+import kotlinx.serialization.Serializable++/** Top-level navigation routes for the Office app (shared nav framework). */+@Serializable+sealed interface Route : NavKey {+ /** Offline home tab (sibling route, the start destination). */+ @Serializable data object OfflineHome : Route+ /** Online cloud-docs home tab (sibling route). */+ @Serializable data object OnlineHome : Route+ /** Editing a local/offline document (optionally identified by its source uri). */+ @Serializable data class OfflineEditor(val uri: String? = null) : Route+ /** Editing a cloud-synced document, identified by its document id. */+ @Serializable data class OnlineEditor(val docId: String) : Route+}
office/src/main/java/com/vayunmathur/office/data/odf/DocumentImporter.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/DocumentImporter.kt b/office/src/main/java/com/vayunmathur/office/data/odf/DocumentImporter.ktsimilarity index 98%rename from office/src/main/java/com/vayunmathur/office/odf/DocumentImporter.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/DocumentImporter.ktindex 6ec120b196..7075a6ef89 100644--- a/office/src/main/java/com/vayunmathur/office/odf/DocumentImporter.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/DocumentImporter.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import android.content.Context import android.net.Uri@@ -11,6 +11,7 @@ import com.vayunmathur.library.ui.odf.OdfSpan import com.vayunmathur.library.ui.odf.RtfOdfConverter import com.vayunmathur.library.ui.odf.numberUnnumberedListItems +import com.vayunmathur.office.platform.save /** * Routes an opened file to the right importer by extension, with a content sniff fallback: * ODF/flat-ODF -> [OdfParser.parse], OOXML -> [OoxmlImporter], CSV/TSV -> [OdfParser.parseCsv],
office/src/main/java/com/vayunmathur/office/data/odf/ExcelFormula.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/ExcelFormula.kt b/office/src/main/java/com/vayunmathur/office/data/odf/ExcelFormula.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/ExcelFormula.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/ExcelFormula.ktindex c8f894b9c3..ae6d048a63 100644--- a/office/src/main/java/com/vayunmathur/office/odf/ExcelFormula.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/ExcelFormula.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf /** * Best-effort translator between Excel A1-style formulas and ODF OpenFormula strings
office/src/main/java/com/vayunmathur/office/data/odf/ExcelNumFmt.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/ExcelNumFmt.kt b/office/src/main/java/com/vayunmathur/office/data/odf/ExcelNumFmt.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/ExcelNumFmt.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/ExcelNumFmt.ktindex 19824f5137..9729065360 100644--- a/office/src/main/java/com/vayunmathur/office/odf/ExcelNumFmt.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/ExcelNumFmt.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfNumberFormat import com.vayunmathur.library.ui.odf.OdfNumberToken
office/src/main/java/com/vayunmathur/office/data/odf/OdfMath.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfMath.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfMath.ktsimilarity index 95%rename from office/src/main/java/com/vayunmathur/office/odf/OdfMath.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfMath.ktindex 7d8e885c40..85d3654b25 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfMath.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfMath.kt@@ -1,14 +1,14 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf -import com.vayunmathur.office.odf.MathNode.Fenced-import com.vayunmathur.office.odf.MathNode.Frac-import com.vayunmathur.office.odf.MathNode.Root-import com.vayunmathur.office.odf.MathNode.Row-import com.vayunmathur.office.odf.MathNode.Sqrt-import com.vayunmathur.office.odf.MathNode.Sub-import com.vayunmathur.office.odf.MathNode.SubSup-import com.vayunmathur.office.odf.MathNode.Sup-import com.vayunmathur.office.odf.MathNode.Token+import com.vayunmathur.office.data.odf.MathNode.Fenced+import com.vayunmathur.office.data.odf.MathNode.Frac+import com.vayunmathur.office.data.odf.MathNode.Root+import com.vayunmathur.office.data.odf.MathNode.Row+import com.vayunmathur.office.data.odf.MathNode.Sqrt+import com.vayunmathur.office.data.odf.MathNode.Sub+import com.vayunmathur.office.data.odf.MathNode.SubSup+import com.vayunmathur.office.data.odf.MathNode.Sup+import com.vayunmathur.office.data.odf.MathNode.Token import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParserFactory
office/src/main/java/com/vayunmathur/office/data/odf/OdfParser.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParser.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParser.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParser.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParser.ktindex 8c3418b557..db24cd4884 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParser.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParser.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import android.content.Context import android.net.Uri@@ -10,6 +10,7 @@ import java.util.zip.ZipInputStream import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParserFactory +import com.vayunmathur.office.Route /** Singleton holding odf parser state and operations. */ object OdfParser {
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserChart.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserChart.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserChart.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserChart.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserChart.ktindex d37cd6cf42..5151c22214 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserChart.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserChart.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.ChartType import com.vayunmathur.library.ui.odf.OdfChart
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserCsv.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserCsv.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserCsv.ktsimilarity index 98%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserCsv.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserCsv.ktindex 2eb0da0148..2639c57b15 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserCsv.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserCsv.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfCell import com.vayunmathur.library.ui.odf.OdfDocument
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserDocMeta.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserDocMeta.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserDocMeta.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserDocMeta.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserDocMeta.ktindex b4aca20a1b..8050ccf017 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserDocMeta.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserDocMeta.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfMetadata import com.vayunmathur.library.ui.odf.OdfPageSetup
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserHeading.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserHeading.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserHeading.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserHeading.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserHeading.ktindex 063a6af930..75efd6a572 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserHeading.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserHeading.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfBookmark import com.vayunmathur.library.ui.odf.OdfChart
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserInline.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserInline.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserInline.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserInline.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserInline.ktindex f343a6c4bf..adff65c65f 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserInline.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserInline.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import android.util.Base64 import com.vayunmathur.library.ui.odf.OdfAnnotation
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserInlineMedia.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserInlineMedia.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserInlineMedia.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserInlineMedia.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserInlineMedia.ktindex ea6968e1e1..fb9ef13741 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserInlineMedia.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserInlineMedia.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import android.util.Base64 import com.vayunmathur.library.ui.odf.OdfImage
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserNumberStyles.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserNumberStyles.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserNumberStyles.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserNumberStyles.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserNumberStyles.ktindex a01f0cbbdd..1d8c59b761 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserNumberStyles.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserNumberStyles.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfNumberFormat import com.vayunmathur.library.ui.odf.OdfNumberToken
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserParagraph.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserParagraph.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserParagraph.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserParagraph.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserParagraph.ktindex ac4134a994..02ec460f7f 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserParagraph.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserParagraph.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfBookmark import com.vayunmathur.library.ui.odf.OdfChart
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserSheet.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserSheet.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserSheet.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserSheet.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserSheet.ktindex e44a51416f..985a567e3d 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserSheet.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserSheet.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfAnnotation import com.vayunmathur.library.ui.odf.OdfCell
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserSlides.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserSlides.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserSlides.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserSlides.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserSlides.ktindex 0f3b84413e..cfc104f47d 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserSlides.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserSlides.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import android.util.Base64 import com.vayunmathur.library.ui.odf.OdfChart
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserStyles.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserStyles.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserStyles.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserStyles.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserStyles.ktindex 6e8113891a..95d355d485 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserStyles.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserStyles.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import androidx.compose.ui.text.style.TextAlign import com.vayunmathur.library.ui.odf.OdfBorders
office/src/main/java/com/vayunmathur/office/data/odf/OdfParserText.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserText.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserText.ktsimilarity index 98%rename from office/src/main/java/com/vayunmathur/office/odf/OdfParserText.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfParserText.ktindex 82b9ab4266..32c7a43c93 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserText.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfParserText.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.LayoutDirection@@ -57,9 +57,9 @@ internal fun OdfParser.parseTextDocument( trackedDeletionText = emptyMap() val parser = newParser(xml) val acc = TextDocAcc(outlineStyle = listStyles["%outline%"])- // Word (and LibreOffice) export one <text:list> per item and chain them with- // text:continue-numbering / text:continue-list; without honoring those every item restarts- // at 1. Remember where each list left off, by nesting depth and by xml:id. (bugfix)+ // Word and LibreOffice export one list per item and chain the items together+ // with continuation attributes; without honoring those, every item restarts+ // at 1. Remember where each list left off, by nesting depth and by id. (bugfix) var eventType = parser.eventType val ctx = TextDocCtx(styles, images, listStyles, objectContents)
office/src/main/java/com/vayunmathur/office/data/odf/OdfWriter.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfWriter.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OdfWriter.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OdfWriter.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OdfWriter.ktindex 9e74af9c17..5ecbe80ea6 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfWriter.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OdfWriter.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import android.content.Context import android.net.Uri@@ -10,6 +10,7 @@ import java.util.zip.ZipEntry import java.util.zip.ZipInputStream import java.util.zip.ZipOutputStream +import com.vayunmathur.office.platform.save /** Singleton holding odf writer state and operations. */ object OdfWriter {
office/src/main/java/com/vayunmathur/office/data/odf/OmmlToMathml.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OmmlToMathml.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OmmlToMathml.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OmmlToMathml.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OmmlToMathml.ktindex 645d59a803..b637a0def9 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OmmlToMathml.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OmmlToMathml.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import org.xmlpull.v1.XmlPullParser
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlChart.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlChart.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlChart.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlChart.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlChart.ktindex 639fb6ae3a..fff11f3b56 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlChart.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlChart.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.ChartType import com.vayunmathur.library.ui.odf.OdfChart
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlColor.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlColor.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlColor.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlColor.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlColor.ktindex c332acb366..dc046f71c5 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlColor.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlColor.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import org.xmlpull.v1.XmlPullParser
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDiagram.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDiagram.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDiagram.ktsimilarity index 97%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlDiagram.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDiagram.ktindex ae5ed814b4..571bdcc4ab 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDiagram.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDiagram.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import org.xmlpull.v1.XmlPullParser
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocx.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDocx.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocx.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlDocx.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocx.ktindex aff042d557..4630e6b02f 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDocx.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocx.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.LayoutDirection
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxDrawings.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxDrawings.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxDrawings.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxDrawings.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxDrawings.ktindex 45bc46aa98..cdaafa2bae 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxDrawings.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxDrawings.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfContentBlock import com.vayunmathur.library.ui.odf.OdfImage
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxStyles.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxStyles.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxStyles.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxStyles.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxStyles.ktindex 79374fb014..2278141e74 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxStyles.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxStyles.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfBorders import com.vayunmathur.library.ui.odf.OdfTabStop
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxTables.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxTables.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxTables.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxTables.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxTables.ktindex 62c16447ec..7d1554fbd6 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlDocxTables.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlDocxTables.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfBorders import com.vayunmathur.library.ui.odf.OdfContentBlock
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlImporter.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlImporter.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlImporter.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlImporter.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlImporter.ktindex 79464ce3c9..f502a74dc6 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlImporter.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlImporter.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.log.Log import com.vayunmathur.library.ui.odf.OdfDocument
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlMetadata.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlMetadata.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlMetadata.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlMetadata.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlMetadata.ktindex 083aaa4b2a..a0729d5399 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlMetadata.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlMetadata.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfMetadata import org.xmlpull.v1.XmlPullParser
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPackage.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPackage.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPackage.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlPackage.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPackage.ktindex cce4646a11..cdc0520eb7 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPackage.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPackage.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import org.xmlpull.v1.XmlPullParser import java.util.zip.ZipInputStream
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptx.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPptx.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptx.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlPptx.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptx.ktindex 6a9bb62e8c..5889e391fd 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPptx.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptx.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import androidx.compose.ui.text.style.TextAlign import com.vayunmathur.library.ui.odf.ListType
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxGroups.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxGroups.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxGroups.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxGroups.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxGroups.ktindex c809ba54e4..362c82fa68 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxGroups.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxGroups.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfSlideElement import org.xmlpull.v1.XmlPullParser
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxPlaceholders.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxPlaceholders.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxPlaceholders.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxPlaceholders.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxPlaceholders.ktindex 8d80de011a..82ff2fe856 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxPlaceholders.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxPlaceholders.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfParagraph import com.vayunmathur.library.ui.odf.OdfSpan
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxText.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxText.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxText.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxText.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxText.ktindex 3983935a10..08fd9df6f7 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPptxText.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlPptxText.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import androidx.compose.ui.text.style.TextAlign import com.vayunmathur.library.ui.odf.ListType
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlTheme.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlTheme.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlTheme.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlTheme.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlTheme.ktindex 6ae4e2604d..c654f0ebda 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlTheme.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlTheme.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import org.xmlpull.v1.XmlPullParser
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlUnits.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlUnits.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlUnits.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlUnits.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlUnits.ktindex c785f0d178..2ab4e4a4f7 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlUnits.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlUnits.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf /** * Central unit conversions and color parsing for OOXML (Phase 0D). All screen lengths in the ODF
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsx.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsx.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsx.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsx.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsx.ktindex e67cfe93b0..58c3dfbd81 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsx.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsx.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import androidx.compose.ui.text.style.TextAlign import com.vayunmathur.library.ui.odf.OdfBorders
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxHelper.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxHelper.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxHelper.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxHelper.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxHelper.ktindex 238063e6aa..de012c87df 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxHelper.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxHelper.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfFrame import com.vayunmathur.library.ui.odf.OdfImage
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxPost.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxPost.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxPost.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxPost.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxPost.ktindex 78885e69b3..bc8380df7a 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxPost.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxPost.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfAnnotation import com.vayunmathur.library.ui.odf.OdfCell
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxStyles.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxStyles.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxStyles.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxStyles.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxStyles.ktindex 16567af49c..16ad264820 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXlsxStyles.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXlsxStyles.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import com.vayunmathur.library.ui.odf.OdfBorders import com.vayunmathur.library.ui.odf.OdfNumberFormat
office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXml.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXml.kt b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXml.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/odf/OoxmlXml.ktrename to office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXml.ktindex 2dd0e7c7df..65ea1de22f 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlXml.kt+++ b/office/src/main/java/com/vayunmathur/office/data/odf/OoxmlXml.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.odf+package com.vayunmathur.office.data.odf import org.xmlpull.v1.XmlPullParser import org.xmlpull.v1.XmlPullParserFactory
office/src/main/java/com/vayunmathur/office/domain/DocumentTreeCrdt.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/DocumentTreeCrdt.kt b/office/src/main/java/com/vayunmathur/office/domain/DocumentTreeCrdt.ktsimilarity index 93%rename from office/src/main/java/com/vayunmathur/office/util/DocumentTreeCrdt.ktrename to office/src/main/java/com/vayunmathur/office/domain/DocumentTreeCrdt.ktindex d4b9f21b6e..de7116e86f 100644--- a/office/src/main/java/com/vayunmathur/office/util/DocumentTreeCrdt.kt+++ b/office/src/main/java/com/vayunmathur/office/domain/DocumentTreeCrdt.kt@@ -1,5 +1,6 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.domain +import com.vayunmathur.office.util.OfficeNative /** * Thin handle wrapper over the native `office_engine` document-tree CRDT. *
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModel.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModel.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModel.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModel.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModel.ktindex 5d809efa20..4c8bb1ef5a 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModel.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModel.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context@@ -34,6 +34,8 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json +import com.vayunmathur.office.domain.DocumentTreeCrdt+import com.vayunmathur.office.sync.OfficeSync /** Local metadata for a document in the online folder (title/key stay client-side; never sent in the clear). */ internal const val MAX_UNDO = 30 internal const val MAX_RECENT = 20
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelDocuments.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelDocuments.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelDocuments.ktsimilarity index 97%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelDocuments.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelDocuments.ktindex d2321b3141..9d1b885214 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelDocuments.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelDocuments.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context@@ -21,13 +21,14 @@ import com.vayunmathur.library.ui.odf.OdfSpan import com.vayunmathur.library.ui.odf.ParagraphStyle import com.vayunmathur.library.util.AppMessages import com.vayunmathur.office.R-import com.vayunmathur.office.odf.DocumentImporter-import com.vayunmathur.office.odf.OdfWriter-import com.vayunmathur.office.util.MAX_RECENT-import com.vayunmathur.office.util.OfficeViewModel.ViewState+import com.vayunmathur.office.data.odf.DocumentImporter+import com.vayunmathur.office.data.odf.OdfWriter+import com.vayunmathur.office.platform.MAX_RECENT+import com.vayunmathur.office.platform.OfficeViewModel.ViewState import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import com.vayunmathur.office.sync.OfficeSync fun OfficeViewModel.addToRecent(context: Context, uri: Uri, name: String) { val prefs = context.getSharedPreferences("office_recent", Context.MODE_PRIVATE) val existing = getRecentFiles(context).toMutableList()
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelExport.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelExport.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelExport.ktsimilarity index 98%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelExport.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelExport.ktindex 0856dd339b..09748ac4b2 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelExport.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelExport.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context@@ -22,7 +22,7 @@ import com.vayunmathur.library.ui.odf.RtfOdfConverter import com.vayunmathur.library.util.AppMessages import com.vayunmathur.library.util.DataStoreUtils import com.vayunmathur.office.R-import com.vayunmathur.office.odf.OdfMath+import com.vayunmathur.office.data.odf.OdfMath import kotlin.io.encoding.Base64 import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelFields.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelFields.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelFields.ktsimilarity index 98%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelFields.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelFields.ktindex 0acc833c09..53eacddb0a 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelFields.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelFields.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import com.vayunmathur.library.ui.odf.OdfContentBlock import com.vayunmathur.library.ui.odf.OdfDocument
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelImageOps.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelImageOps.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelImageOps.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelImageOps.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelImageOps.ktindex 04fd242cd5..882bd3a2b3 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelImageOps.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelImageOps.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import com.vayunmathur.library.ui.odf.OdfContentBlock import com.vayunmathur.library.ui.odf.OdfDocument
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelLinks.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelLinks.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelLinks.ktsimilarity index 98%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelLinks.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelLinks.ktindex 7a526cc516..f7ee932d34 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelLinks.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelLinks.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import com.vayunmathur.library.ui.odf.OdfContentBlock import com.vayunmathur.library.ui.odf.OdfDocument
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSheet.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSheet.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSheet.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSheet.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSheet.ktindex ff52b2b0d9..bc7d64d726 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSheet.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSheet.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context@@ -15,7 +15,7 @@ import com.vayunmathur.library.ui.odf.OdfRow import com.vayunmathur.library.ui.odf.OdfSheet import com.vayunmathur.library.util.AppMessages import com.vayunmathur.library.util.DataStoreUtils-import com.vayunmathur.office.odf.ExcelFormula+import com.vayunmathur.office.data.odf.ExcelFormula import com.vayunmathur.office.R import kotlin.io.encoding.Base64 import kotlinx.coroutines.Dispatchers
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSheetFloating.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSheetFloating.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSheetFloating.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSheetFloating.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSheetFloating.ktindex 5ec8f079fa..ca9e03e6ae 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSheetFloating.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSheetFloating.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import com.vayunmathur.library.ui.odf.OdfAnnotation import com.vayunmathur.library.ui.odf.OdfChart
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSlides.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSlides.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSlides.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSlides.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSlides.ktindex 1719b1b0c3..1cf3b09cb9 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSlides.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSlides.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncA.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncA.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncA.ktsimilarity index 97%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncA.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncA.ktindex 943ef57e5c..173865fafd 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncA.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncA.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context@@ -26,6 +26,11 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json +import com.vayunmathur.office.domain.DocumentTreeCrdt+import com.vayunmathur.office.sync.OfficeSync+import com.vayunmathur.office.sync.decrypt+import com.vayunmathur.office.sync.sign+import com.vayunmathur.office.sync.verify // --- Sync A: identity + presence + live channel (split from OfficeViewModel.kt for file length) --- /** True if this device's PQC keys and id are already stored (i.e. online sharing was enabled before). */
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncB.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncB.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncB.ktsimilarity index 97%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncB.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncB.ktindex 13451972ee..2872f8e191 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncB.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncB.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context@@ -12,8 +12,8 @@ import com.vayunmathur.library.ui.odf.OdfDocument import com.vayunmathur.library.util.AppMessages import com.vayunmathur.library.util.DataStoreUtils import com.vayunmathur.office.R-import com.vayunmathur.office.odf.DocumentImporter-import com.vayunmathur.office.util.OfficeViewModel.ViewState+import com.vayunmathur.office.data.odf.DocumentImporter+import com.vayunmathur.office.platform.OfficeViewModel.ViewState import kotlin.io.encoding.Base64 import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job@@ -29,6 +29,13 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json +import com.vayunmathur.office.domain.DocumentTreeCrdt+import com.vayunmathur.office.sync.OfficeSync+import com.vayunmathur.office.sync.decrypt+import com.vayunmathur.office.sync.seal+import com.vayunmathur.office.sync.securityCode+import com.vayunmathur.office.sync.sign+import com.vayunmathur.office.sync.verify // --- Sync B: device/index/inbox/join-requests/trees/share/open (split from OfficeViewModel.kt for file length) --- /** Registers this device, loads the local online index, and pulls any new invites. */@@ -432,7 +439,7 @@ fun OfficeViewModel.openOnlineDocument(meta: OfficeDocMeta) { crdt.close() // never adopted as currentTree; free its native handle withContext(Dispatchers.Main) { stateMutable.value =- ViewState.Error("This shared document has no readable content. It was likely created" ++ ViewState.Error("This shared document has no readable content. It was likely created " + "with an older version — ask the owner to re-share a new copy.") } return@runCatching
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncC.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncC.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncC.ktsimilarity index 97%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncC.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncC.ktindex 1284525cc9..ec83392be9 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelSyncC.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelSyncC.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context@@ -12,7 +12,7 @@ import com.vayunmathur.library.ui.odf.OdfDocument import com.vayunmathur.library.util.AppMessages import com.vayunmathur.library.util.DataStoreUtils import com.vayunmathur.office.R-import com.vayunmathur.office.util.OfficeViewModel.ViewState+import com.vayunmathur.office.platform.OfficeViewModel.ViewState import kotlin.io.encoding.Base64 import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job@@ -28,6 +28,14 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json +import com.vayunmathur.office.sync.OfficeSync+import com.vayunmathur.office.sync.appendRaw+import com.vayunmathur.office.sync.decrypt+import com.vayunmathur.office.sync.pullRaw+import com.vayunmathur.office.sync.seal+import com.vayunmathur.office.sync.sign+import com.vayunmathur.office.sync.unseal+import com.vayunmathur.office.sync.verify // --- Sync C: members / key epochs / ownership / titles (split from OfficeViewModel.kt for file length) --- /** This device's role in the open document (owner/editor/viewer). */
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTables.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTables.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTables.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTables.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTables.ktindex 9a6e35f0ed..f37421e0c4 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTables.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTables.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context@@ -52,6 +52,7 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json +import com.vayunmathur.office.ui.replaceAll // --- Track changes / tables / paragraph ops (split from OfficeViewModel.kt for file length) --- fun OfficeViewModel.insertChart(blockIndex: Int, chart: OdfChart) {
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelText.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelText.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelText.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelText.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelText.ktindex d76606f96d..a7eadf3bfe 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelText.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelText.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import android.app.Application import android.content.Context
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTextTables.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTextTables.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTextTables.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTextTables.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTextTables.ktindex ac9867e093..377acade64 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTextTables.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTextTables.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import com.vayunmathur.library.ui.odf.OdfChart import com.vayunmathur.library.ui.odf.OdfContentBlock
office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTracked.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTracked.kt b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTracked.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTracked.ktrename to office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTracked.ktindex cc23406609..3b98db675e 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeViewModelTracked.kt+++ b/office/src/main/java/com/vayunmathur/office/platform/OfficeViewModelTracked.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.platform import com.vayunmathur.library.ui.odf.OdfAnnotation import com.vayunmathur.library.ui.odf.OdfBookmark
office/src/main/java/com/vayunmathur/office/sync/OfficeSync.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeSync.kt b/office/src/main/java/com/vayunmathur/office/sync/OfficeSync.ktsimilarity index 99%rename from office/src/main/java/com/vayunmathur/office/util/OfficeSync.ktrename to office/src/main/java/com/vayunmathur/office/sync/OfficeSync.ktindex 6ba2f51f8e..4268975d8a 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeSync.kt+++ b/office/src/main/java/com/vayunmathur/office/sync/OfficeSync.kt@@ -1,6 +1,6 @@ @file:OptIn(kotlin.uuid.ExperimentalUuidApi::class) -package com.vayunmathur.office.util+package com.vayunmathur.office.sync import kotlin.uuid.Uuid import android.content.Context@@ -28,6 +28,7 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json import kotlin.io.encoding.Base64 +import com.vayunmathur.office.platform.startLive /** Singleton holding office sync state and operations. */ object OfficeSync { // Cloudflare-fronted; covered by the FIRST_PARTY pins.
office/src/main/java/com/vayunmathur/office/sync/OfficeSyncCrypto.kt
diff --git a/office/src/main/java/com/vayunmathur/office/util/OfficeSyncCrypto.kt b/office/src/main/java/com/vayunmathur/office/sync/OfficeSyncCrypto.ktsimilarity index 97%rename from office/src/main/java/com/vayunmathur/office/util/OfficeSyncCrypto.ktrename to office/src/main/java/com/vayunmathur/office/sync/OfficeSyncCrypto.ktindex 9c5a6456ec..32fe9758cd 100644--- a/office/src/main/java/com/vayunmathur/office/util/OfficeSyncCrypto.kt+++ b/office/src/main/java/com/vayunmathur/office/sync/OfficeSyncCrypto.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office.util+package com.vayunmathur.office.sync import com.vayunmathur.e2ee.E2ee import com.vayunmathur.e2ee.Pqc
office/src/main/java/com/vayunmathur/office/ui/DocumentOverlaySections.kt
diff --git a/office/src/main/java/com/vayunmathur/office/OfficeDocumentOverlays.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentOverlaySections.ktsimilarity index 51%rename from office/src/main/java/com/vayunmathur/office/OfficeDocumentOverlays.ktrename to office/src/main/java/com/vayunmathur/office/ui/DocumentOverlaySections.ktindex e3da9e031a..6afe038d91 100644--- a/office/src/main/java/com/vayunmathur/office/OfficeDocumentOverlays.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentOverlaySections.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office+package com.vayunmathur.office.ui import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row@@ -47,204 +47,72 @@ import com.vayunmathur.office.ui.InsertHyperlinkDialog import com.vayunmathur.office.ui.InsertTableDialog import com.vayunmathur.office.ui.SettingsDialog import com.vayunmathur.office.ui.SpecialCharsDialog-import com.vayunmathur.office.util.OfficeViewModel-import com.vayunmathur.office.util.save-import com.vayunmathur.office.util.needsSaveAs-import com.vayunmathur.office.util.acceptAllChanges-import com.vayunmathur.office.util.acceptChange-import com.vayunmathur.office.util.addBookmark-import com.vayunmathur.office.util.applyRunSpanStyle-import com.vayunmathur.office.util.cellCommentText-import com.vayunmathur.office.util.currentDocRole-import com.vayunmathur.office.util.currentOnlineDocId-import com.vayunmathur.office.util.documentMembers-import com.vayunmathur.office.util.enableOnlineSharing-import com.vayunmathur.office.util.initSync-import com.vayunmathur.office.util.insertChart-import com.vayunmathur.office.util.insertChartIntoSheet-import com.vayunmathur.office.util.insertChartIntoSlide-import com.vayunmathur.office.util.insertComment-import com.vayunmathur.office.util.insertFootnote-import com.vayunmathur.office.util.insertHyperlink-import com.vayunmathur.office.util.insertTable-import com.vayunmathur.office.util.insertTextInRun-import com.vayunmathur.office.util.rejectAllChanges-import com.vayunmathur.office.util.rejectChange-import com.vayunmathur.office.util.renameDocument-import com.vayunmathur.office.util.replaceSheetImage-import com.vayunmathur.office.util.replaceSlideImage-import com.vayunmathur.office.util.replaceTextImage-import com.vayunmathur.office.util.resolveComment-import com.vayunmathur.office.util.rotateSheetImage-import com.vayunmathur.office.util.rotateSlideImage-import com.vayunmathur.office.util.rotateTextImage-import com.vayunmathur.office.util.securityCodeWith-import com.vayunmathur.office.util.setCellBgColor-import com.vayunmathur.office.util.setCellBorder-import com.vayunmathur.office.util.setCellColor-import com.vayunmathur.office.util.setCellComment-import com.vayunmathur.office.util.setColumnWidth-import com.vayunmathur.office.util.setFooterText-import com.vayunmathur.office.util.setHeaderText-import com.vayunmathur.office.util.setImageCrop-import com.vayunmathur.office.util.setMemberRole-import com.vayunmathur.office.util.setPageSetup-import com.vayunmathur.office.util.setRowHeight-import com.vayunmathur.office.util.setSheetImageCrop-import com.vayunmathur.office.util.setSlideBackgroundColor-import com.vayunmathur.office.util.setSlideElementColor-import com.vayunmathur.office.util.setSlideElementFill-import com.vayunmathur.office.util.setSlideElementStroke-import com.vayunmathur.office.util.setSlideImageCrop-import com.vayunmathur.office.util.setSlideNotes-import com.vayunmathur.office.util.setSlideTransition-import com.vayunmathur.office.util.shareCurrentDocument-import com.vayunmathur.office.util.shareLinkFor-import com.vayunmathur.office.util.slideNotesText-import com.vayunmathur.office.util.transferOwnership-import com.vayunmathur.office.util.updateChart-import com.vayunmathur.office.util.updateMetadata+import com.vayunmathur.office.platform.OfficeViewModel+import com.vayunmathur.office.platform.save+import com.vayunmathur.office.platform.needsSaveAs+import com.vayunmathur.office.platform.acceptAllChanges+import com.vayunmathur.office.platform.acceptChange+import com.vayunmathur.office.platform.addBookmark+import com.vayunmathur.office.platform.applyRunSpanStyle+import com.vayunmathur.office.platform.cellCommentText+import com.vayunmathur.office.platform.currentDocRole+import com.vayunmathur.office.platform.currentOnlineDocId+import com.vayunmathur.office.platform.documentMembers+import com.vayunmathur.office.platform.enableOnlineSharing+import com.vayunmathur.office.platform.initSync+import com.vayunmathur.office.platform.insertChart+import com.vayunmathur.office.platform.insertChartIntoSheet+import com.vayunmathur.office.platform.insertChartIntoSlide+import com.vayunmathur.office.platform.insertComment+import com.vayunmathur.office.platform.insertFootnote+import com.vayunmathur.office.platform.insertHyperlink+import com.vayunmathur.office.platform.insertTable+import com.vayunmathur.office.platform.insertTextInRun+import com.vayunmathur.office.platform.replaceSheetImage+import com.vayunmathur.office.platform.replaceSlideImage+import com.vayunmathur.office.platform.replaceTextImage+import com.vayunmathur.office.platform.rotateSheetImage+import com.vayunmathur.office.platform.rotateSlideImage+import com.vayunmathur.office.platform.rotateTextImage+import com.vayunmathur.office.platform.securityCodeWith+import com.vayunmathur.office.platform.setCellBgColor+import com.vayunmathur.office.platform.setCellBorder+import com.vayunmathur.office.platform.setCellColor+import com.vayunmathur.office.platform.setCellComment+import com.vayunmathur.office.platform.setColumnWidth+import com.vayunmathur.office.platform.setFooterText+import com.vayunmathur.office.platform.setHeaderText+import com.vayunmathur.office.platform.setImageCrop+import com.vayunmathur.office.platform.setMemberRole+import com.vayunmathur.office.platform.setPageSetup+import com.vayunmathur.office.platform.setRowHeight+import com.vayunmathur.office.platform.setSheetImageCrop+import com.vayunmathur.office.platform.setSlideBackgroundColor+import com.vayunmathur.office.platform.setSlideElementColor+import com.vayunmathur.office.platform.setSlideElementFill+import com.vayunmathur.office.platform.setSlideElementStroke+import com.vayunmathur.office.platform.setSlideImageCrop+import com.vayunmathur.office.platform.setSlideNotes+import com.vayunmathur.office.platform.setSlideTransition+import com.vayunmathur.office.platform.shareCurrentDocument+import com.vayunmathur.office.platform.shareLinkFor+import com.vayunmathur.office.platform.slideNotesText+import com.vayunmathur.office.platform.updateChart+import com.vayunmathur.office.platform.updateMetadata import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch--/**- * Dialog/show flags owned by [DocumentScreen].- *- * Plain holder with snapshot-state delegates, kept across recompositions via- * [rememberDocumentOverlayState]; identical semantics to the `var x by remember {}`- * declarations it replaces (split for file length, behavior identical).- *- * Subclassed by [DocumentScreenState], which adds the selection and chrome state.- */-open class DocumentOverlayState {- var showMetadata by mutableStateOf(false)- var showShareDialog by mutableStateOf(false)- var showEnableOnlineDialog by mutableStateOf(false)- val showUnsavedDialogState = mutableStateOf(false)- var showUnsavedDialog by showUnsavedDialogState- var showSettings by mutableStateOf(false)- val showColorPickerState = mutableStateOf(false)- var showColorPicker by showColorPickerState- val showFontSizePickerState = mutableStateOf(false)- var showFontSizePicker by showFontSizePickerState- val showInsertTableState = mutableStateOf(false)- var showInsertTable by showInsertTableState- var showInsertLink by mutableStateOf(false)- var showAddBookmark by mutableStateOf(false)- var showSpecialChars by mutableStateOf(false)- var showFootnote by mutableStateOf(false)- var showComment by mutableStateOf(false)- var showComments by mutableStateOf(false)- var showChanges by mutableStateOf(false)- var showPageSetup by mutableStateOf(false)- var showHeaderFooter by mutableStateOf(false)- val showCellTextColorState = mutableStateOf(false)- var showCellTextColor by showCellTextColorState- val showCellBgColorState = mutableStateOf(false)- var showCellBgColor by showCellBgColorState- val showCellBorderColorState = mutableStateOf(false)- var showCellBorderColor by showCellBorderColorState- val showSlideTextColorState = mutableStateOf(false)- var showSlideTextColor by showSlideTextColorState- val showSlideFillColorState = mutableStateOf(false)- var showSlideFillColor by showSlideFillColorState- val showSlideStrokeColorState = mutableStateOf(false)- var showSlideStrokeColor by showSlideStrokeColorState- val showCellCommentState = mutableStateOf(false)- var showCellComment by showCellCommentState- val showCellResizeState = mutableStateOf(false)- var showCellResize by showCellResizeState- val showSlideNotesState = mutableStateOf(false)- var showSlideNotes by showSlideNotesState- val showSlideBackgroundState = mutableStateOf(false)- var showSlideBackground by showSlideBackgroundState- val showSlideTransitionState = mutableStateOf(false)- var showSlideTransition by showSlideTransitionState- val showChartEditorState = mutableStateOf(false)- var showChartEditor by showChartEditorState- val editingChartBlockState = mutableIntStateOf(-1)- var editingChartBlock by editingChartBlockState- val chartForSlideState = mutableStateOf(false)- var chartForSlide by chartForSlideState- val chartForSheetState = mutableStateOf(false)- var chartForSheet by chartForSheetState- val cropImageBlockState = mutableIntStateOf(-1)- var cropImageBlock by cropImageBlockState- val cropSlideTargetState: MutableState<Pair<Int, Int>?> = mutableStateOf(null)- var cropSlideTarget by cropSlideTargetState- val cropSheetTargetState: MutableState<Pair<Int, Int>?> = mutableStateOf(null)- var cropSheetTarget by cropSheetTargetState- var exportWarning by mutableStateOf<(() -> Unit)?>(null)-}--@Composable-internal fun rememberDocumentOverlayState(): DocumentOverlayState = remember { DocumentOverlayState() }--internal const val MARGIN_NARROW_CM = 1.27f-internal const val MARGIN_NARROW_MAX = 1.5f-internal const val MARGIN_NORMAL_CM = 2f-internal const val MARGIN_WIDE_MIN = 2.3f-internal const val MARGIN_WIDE_CM = 2.54f-private val CommentFieldHeight = 120.dp-private val ChartPickerHeight = 160.dp-private val DialogSpacing = 8.dp-private const val DATE_PREFIX_LENGTH = 10--internal const val SHARED_DATE_PREFIX_LENGTH = 10-private const val ROTATE_QUARTER_TURNS = 90f--/**- * All trailing `if (showX)` dialogs of [DocumentScreen], hoisted verbatim.- *- * Dialog flags live in [DocumentOverlayState] (via [DocumentScreenState]); selection state- * shared with the scaffold body arrives as [MutableState] params. Behavior identical.- */-@Composable-fun DocumentOverlays(- state: DocumentOverlayState,- document: OdfDocument,- viewModel: OfficeViewModel,- isPresentation: Boolean,- isOnline: Boolean,- focusedPara: Int,- saveAsName: String,- activeCell: MutableState<Triple<Int, Int, Int>?>,- activeSlide: MutableState<Int>,- activeSlideEl: MutableState<Int>,- activeRunStart: MutableState<Int>,- activeRunEnd: MutableState<Int>,- selStart: MutableState<Int>,- selEnd: MutableState<Int>,- pendingReplace: MutableState<((String, ByteArray) -> Unit)?>,- listState: LazyListState,- scope: CoroutineScope,- launchers: DocumentLaunchers,- onBecameOnline: (String) -> Unit,- onBack: () -> Unit,-) {- val context = LocalContext.current- if (state.showMetadata) MetadataDialog(- metadata = document.metadata,- onSave = { m -> viewModel.updateMetadata { m } },- onDismiss = { state.showMetadata = false })- LaunchedEffect(Unit) { viewModel.initSync() }- ShareOverlays(- state, document, viewModel, isOnline, saveAsName, launchers, onBecameOnline, onBack)- SettingsOverlay(state, viewModel, context)- RunStyleOverlays(state, viewModel, activeRunStart, activeRunEnd, selStart, selEnd)- InsertOverlays(state, viewModel, focusedPara, activeRunStart, activeRunEnd, selStart)- CommentOverlaysHost(state, document, viewModel, focusedPara, listState, scope)- CellOverlays(state, viewModel, activeCell, activeSlide, activeSlideEl)- SlideOverlays(- state, document, viewModel, isPresentation, activeCell, activeSlide,- pendingReplace, launchers, focusedPara)- SlideCropOverlay(state, document, viewModel, pendingReplace, launchers)- SheetCropOverlay(state, document, viewModel, pendingReplace, launchers)-}+import com.vayunmathur.office.platform.OfficeMember+import com.vayunmathur.office.platform.OfficeRoles+import com.vayunmathur.office.R+import com.vayunmathur.office.platform.rejectAllChanges+import com.vayunmathur.office.platform.rejectChange+import com.vayunmathur.office.platform.renameDocument+import com.vayunmathur.office.platform.resolveComment+import com.vayunmathur.office.platform.transferOwnership /** Slide floating-image crop dialog. */ @Composable-private fun SlideCropOverlay(+internal fun SlideCropOverlay( state: DocumentOverlayState, document: OdfDocument, viewModel: OfficeViewModel,@@ -272,7 +140,7 @@ private fun SlideCropOverlay( /** Sheet floating-image crop dialog. */ @Composable-private fun SheetCropOverlay(+internal fun SheetCropOverlay( state: DocumentOverlayState, document: OdfDocument, viewModel: OfficeViewModel,@@ -300,7 +168,7 @@ private fun SheetCropOverlay( /** Share / unsaved-changes / export-warning overlays. */ @Composable-private fun ShareOverlays(+internal fun ShareOverlays( state: DocumentOverlayState, document: OdfDocument, viewModel: OfficeViewModel,@@ -348,18 +216,18 @@ private fun ShareOverlays( /** Share dialog with live roster. */ @Composable-private fun ShareDialogBody(+internal fun ShareDialogBody( state: DocumentOverlayState, document: OdfDocument, viewModel: OfficeViewModel, isOnline: Boolean, onBecameOnline: (String) -> Unit, ) {- var members by remember { mutableStateOf<List<com.vayunmathur.office.util.OfficeMember>>(emptyList()) }+ var members by remember { mutableStateOf<List<com.vayunmathur.office.platform.OfficeMember>>(emptyList()) } LaunchedEffect(state.showShareDialog) { viewModel.documentMembers { members = it } } ShareOnlineDialog( deviceId = viewModel.syncDeviceId,- isOwner = viewModel.currentDocRole() == com.vayunmathur.office.util.OfficeRoles.OWNER,+ isOwner = viewModel.currentDocRole() == com.vayunmathur.office.platform.OfficeRoles.OWNER, isOnline = isOnline, initialName = document.title, myRole = viewModel.currentDocRole(),@@ -390,7 +258,7 @@ private fun ShareDialogBody( /** Settings dialog overlay. */ @Composable-private fun SettingsOverlay(+internal fun SettingsOverlay( state: DocumentOverlayState, viewModel: OfficeViewModel, context: android.content.Context,@@ -408,7 +276,7 @@ private fun SettingsOverlay( /** Run text-color / font-size overlays. */ @Composable-private fun RunStyleOverlays(+internal fun RunStyleOverlays( state: DocumentOverlayState, viewModel: OfficeViewModel, activeRunStart: MutableState<Int>,@@ -447,7 +315,7 @@ private fun RunStyleOverlays( /** Table / link / bookmark / chars / footnote insert overlays. */ @Composable-private fun InsertOverlays(+internal fun InsertOverlays( state: DocumentOverlayState, viewModel: OfficeViewModel, focusedPara: Int,@@ -467,29 +335,4 @@ private fun InsertOverlays( CharFootnoteOverlays(state, viewModel, activeRunStart, activeRunEnd, selStart) } -/** Special-chars + footnote overlays. */-@Composable-private fun CharFootnoteOverlays(- state: DocumentOverlayState,- viewModel: OfficeViewModel,- activeRunStart: MutableState<Int>,- activeRunEnd: MutableState<Int>,- selStart: MutableState<Int>,-) {- if (state.showSpecialChars) SpecialCharsDialog(- onPick = { ch ->- if (activeRunStart.value >= 0) {- viewModel.insertTextInRun(activeRunStart.value, activeRunEnd.value, selStart.value, ch)- }- },- onDismiss = { state.showSpecialChars = false },- )- if (state.showFootnote) FootnoteDialog(- onAdd = { body ->- if (activeRunStart.value >= 0) {- viewModel.insertFootnote(activeRunStart.value, activeRunEnd.value, selStart.value, body)- }- },- onDismiss = { state.showFootnote = false },- )-}+
office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.ktnew file mode 100644index 0000000000..2baf10856e--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldBody.kt@@ -0,0 +1,229 @@+package com.vayunmathur.office.ui++import androidx.activity.ComponentActivity+import androidx.activity.compose.BackHandler+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyListState+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+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.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.DrawerState+import com.vayunmathur.library.ui.IconBack+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconRedo+import com.vayunmathur.library.ui.IconSave+import com.vayunmathur.library.ui.IconSearch+import com.vayunmathur.library.ui.IconUndo+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.ModalDrawerSheet+import com.vayunmathur.library.ui.ModalNavigationDrawer+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.ui.isExpandedWidth+import com.vayunmathur.library.ui.odf.OdfDocument+import com.vayunmathur.office.ui.OfficeEditorWideLayout+import com.vayunmathur.office.platform.OfficeViewModel+import com.vayunmathur.office.platform.needsSaveAs+import com.vayunmathur.office.platform.save+import kotlinx.coroutines.CoroutineScope+import com.vayunmathur.office.MainActivity+import com.vayunmathur.office.Navigation+import com.vayunmathur.office.R++/** Scaffold body: menu bar, find bars, and the editor pane. */+@Composable+internal fun DocumentScaffoldBody(+ s: DocumentScreenState,+ document: OdfDocument,+ viewModel: OfficeViewModel,+ activity: ComponentActivity,+ chrome: DocumentChrome,+ launchers: DocumentLaunchers,+ scope: kotlinx.coroutines.CoroutineScope,+ drawerState: com.vayunmathur.library.ui.DrawerState,+ listState: androidx.compose.foundation.lazy.LazyListState,+ contentPadding: androidx.compose.foundation.layout.PaddingValues,+ onRunSelectionChange: (Int, Int, Int, Int) -> Unit,+ onCellFocus: (Int, Int, Int) -> Unit,+ onCellSelected: (Int, Int, Int) -> Unit,+ onSlideChange: (Int) -> Unit,+ onSlideElementSelected: (Int, Int) -> Unit,+ modifier: Modifier = Modifier,+) {+ Column(Modifier.fillMaxSize().padding(contentPadding)) {+ ScaffoldMenuBars(+ s = s, document = document, viewModel = viewModel,+ activity = activity, chrome = chrome, launchers = launchers,+ scope = scope, drawerState = drawerState, listState = listState)+ // Timer/search/font/word bars: see DocumentFindBars (file-length split).+ DocumentEditorPane(+ s = s,+ document = document,+ viewModel = viewModel,+ chrome = chrome,+ listState = listState,+ scope = scope,+ drawerState = drawerState,+ onRunSelectionChange = onRunSelectionChange,+ onCellFocus = onCellFocus,+ onCellSelected = onCellSelected,+ onSlideChange = onSlideChange,+ onSlideElementSelected = onSlideElementSelected,+ modifier = modifier,+ )+ }+}++/** Menu + find bars for the scaffold body. */+@Composable+internal fun ScaffoldMenuBars(+ s: DocumentScreenState,+ document: OdfDocument,+ viewModel: OfficeViewModel,+ activity: ComponentActivity,+ chrome: DocumentChrome,+ launchers: DocumentLaunchers,+ scope: kotlinx.coroutines.CoroutineScope,+ drawerState: com.vayunmathur.library.ui.DrawerState,+ listState: androidx.compose.foundation.lazy.LazyListState,+) {+ DocumentMenuBar(+ s = s,+ document = document,+ viewModel = viewModel,+ activity = activity,+ isTextDoc = chrome.isTextDoc,+ isSpreadsheet = chrome.isSpreadsheet,+ isPresentation = chrome.isPresentation,+ isOnline = chrome.isOnline,+ onlineEnabled = chrome.onlineEnabled,+ hasUnsavedChanges = chrome.hasUnsavedChanges,+ saveAsName = chrome.saveAsName,+ wordCount = chrome.wordCount,+ charCount = chrome.charCount,+ readingTime = chrome.readingTime,+ nightMode = chrome.nightMode,+ documentDarkMode = chrome.documentDarkMode,+ launchers = launchers,+ scope = scope,+ drawerState = drawerState,+ )+ DocumentFindBars(+ s = s,+ document = document,+ viewModel = viewModel,+ isTextDoc = chrome.isTextDoc,+ isPresentation = chrome.isPresentation,+ wordCount = chrome.wordCount,+ charCount = chrome.charCount,+ readingTime = chrome.readingTime,+ scope = scope,+ listState = listState,+ )+}++/** Editor pane with the wide-layout outline branch. */+@Composable+internal fun DocumentEditorPane(+ s: DocumentScreenState,+ document: OdfDocument,+ viewModel: OfficeViewModel,+ chrome: DocumentChrome,+ listState: androidx.compose.foundation.lazy.LazyListState,+ scope: kotlinx.coroutines.CoroutineScope,+ drawerState: com.vayunmathur.library.ui.DrawerState,+ onRunSelectionChange: (Int, Int, Int, Int) -> Unit,+ onCellFocus: (Int, Int, Int) -> Unit,+ onCellSelected: (Int, Int, Int) -> Unit,+ onSlideChange: (Int) -> Unit,+ onSlideElementSelected: (Int, Int) -> Unit,+ modifier: Modifier = Modifier,+) {+ Column(modifier) {+ val showOutline = isExpandedWidth() && chrome.isTextDoc &&+ (chrome.headings.isNotEmpty() || chrome.bookmarks.isNotEmpty())+ if (showOutline) {+ OfficeEditorWideLayout(+ outline = { OfficeOutlinePane(+ chrome.bookmarks,+ chrome.headings,+ listState,+ drawerState,+ scope,+ Modifier.fillMaxSize()) },+ document = {+ EditorDocumentPane(+ s = s, document = document, viewModel = viewModel, chrome = chrome,+ listState = listState, onRunSelectionChange = onRunSelectionChange,+ onCellFocus = onCellFocus, onCellSelected = onCellSelected,+ onSlideChange = onSlideChange, onSlideElementSelected = onSlideElementSelected,+ modifier = Modifier.fillMaxSize())+ },+ )+ } else {+ EditorDocumentPane(+ s = s, document = document, viewModel = viewModel, chrome = chrome,+ listState = listState, onRunSelectionChange = onRunSelectionChange,+ onCellFocus = onCellFocus, onCellSelected = onCellSelected,+ onSlideChange = onSlideChange, onSlideElementSelected = onSlideElementSelected,+ modifier = Modifier.fillMaxSize())+ }+ }+}++/** Single shared [OfficeDocumentPane] call (compact + wide layouts). */+@Composable+internal fun EditorDocumentPane(+ s: DocumentScreenState,+ document: OdfDocument,+ viewModel: OfficeViewModel,+ chrome: DocumentChrome,+ listState: androidx.compose.foundation.lazy.LazyListState,+ onRunSelectionChange: (Int, Int, Int, Int) -> Unit,+ onCellFocus: (Int, Int, Int) -> Unit,+ onCellSelected: (Int, Int, Int) -> Unit,+ onSlideChange: (Int) -> Unit,+ onSlideElementSelected: (Int, Int) -> Unit,+ modifier: Modifier = Modifier,+) {+ val activeSlideEl by s.activeSlideElState+ OfficeDocumentPane(+ document = document,+ viewModel = viewModel,+ documentDarkMode = chrome.documentDarkMode,+ nightMode = chrome.nightMode,+ searchQuery = s.searchQuery,+ fontSizeMultiplier = s.fontSizeMultiplier,+ listState = listState,+ isEditMode = chrome.isEditMode,+ activeSlideEl = activeSlideEl,+ onRunSelectionChange = onRunSelectionChange,+ onCellFocus = onCellFocus,+ onCellSelected = onCellSelected,+ onSlideChange = onSlideChange,+ onSlideElementSelected = onSlideElementSelected,+ onChartClick = { bi -> s.editingChartBlock = bi; s.showChartEditor = true },+ onCropImage = { bi -> s.cropImageBlock = bi },+ onCropSlide = { si, e -> s.cropSlideTarget = si to e },+ onCropSheet = { si, e -> s.cropSheetTarget = si to e },+ modifier = modifier,+ )+}+
office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.ktnew file mode 100644index 0000000000..848a91da8f--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScaffoldShell.kt@@ -0,0 +1,176 @@+package com.vayunmathur.office.ui++import androidx.activity.ComponentActivity+import androidx.activity.compose.BackHandler+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyListState+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+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.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.DrawerState+import com.vayunmathur.library.ui.IconBack+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconRedo+import com.vayunmathur.library.ui.IconSave+import com.vayunmathur.library.ui.IconSearch+import com.vayunmathur.library.ui.IconUndo+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.ModalDrawerSheet+import com.vayunmathur.library.ui.ModalNavigationDrawer+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton+import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.library.ui.isExpandedWidth+import com.vayunmathur.library.ui.odf.OdfDocument+import com.vayunmathur.office.ui.OfficeEditorWideLayout+import com.vayunmathur.office.platform.OfficeViewModel+import com.vayunmathur.office.platform.needsSaveAs+import com.vayunmathur.office.platform.save+import kotlinx.coroutines.CoroutineScope+import com.vayunmathur.office.MainActivity+import com.vayunmathur.office.Navigation+import com.vayunmathur.office.R++/** App-bar scaffold with actions + bottom bar. */+@Composable+internal fun DocumentScaffoldShell(+ s: DocumentScreenState,+ document: OdfDocument,+ viewModel: OfficeViewModel,+ activity: ComponentActivity,+ chrome: DocumentChrome,+ launchers: DocumentLaunchers,+ scope: kotlinx.coroutines.CoroutineScope,+ drawerState: com.vayunmathur.library.ui.DrawerState,+ listState: androidx.compose.foundation.lazy.LazyListState,+ onToggleSearch: () -> Unit,+ onShowUnsavedDialog: () -> Unit,+ sel: ScreenSelection,+ onRunSelectionChange: (Int, Int, Int, Int) -> Unit,+ onCellFocus: (Int, Int, Int) -> Unit,+ onCellSelected: (Int, Int, Int) -> Unit,+ onSlideChange: (Int) -> Unit,+ onSlideElementSelected: (Int, Int) -> Unit,+ onBack: () -> Unit,+) {+ AppScaffold(+ title = { Text(+ document.title,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ style = MaterialTheme.typography.titleSmall) },+ navigationIcon = {+ IconButton(onClick = {+ if (!chrome.isOnline && chrome.hasUnsavedChanges) onShowUnsavedDialog() else onBack()+ }) {+ IconBack()+ }+ },+ actions = {+ DocumentScaffoldActions(+ chrome = chrome,+ viewModel = viewModel,+ canEdit = chrome.canEdit,+ saveAsName = chrome.saveAsName,+ launchers = launchers,+ onToggleSearch = onToggleSearch,+ )+ },+ bottomBar = {+ ScaffoldBottomBar(s, document, viewModel, chrome, launchers, sel)+ },+ scrollBehavior = appBarScrollBehavior(),+ ) { paddingValues ->+ DocumentScaffoldBody(+ s = s,+ document = document,+ viewModel = viewModel,+ activity = activity,+ chrome = chrome,+ launchers = launchers,+ scope = scope,+ drawerState = drawerState,+ listState = listState,+ contentPadding = paddingValues,+ onRunSelectionChange = onRunSelectionChange,+ onCellFocus = onCellFocus,+ onCellSelected = onCellSelected,+ onSlideChange = onSlideChange,+ onSlideElementSelected = onSlideElementSelected,+ )+ }+}++/** Bottom bar for the document scaffold. */+@Composable+internal fun ScaffoldBottomBar(+ s: DocumentScreenState,+ document: OdfDocument,+ viewModel: OfficeViewModel,+ chrome: DocumentChrome,+ launchers: DocumentLaunchers,+ sel: ScreenSelection,+) {+ DocumentBottomBarHost(+ s, document, viewModel, chrome.canEdit, chrome.isTextDoc, chrome.isSpreadsheet, chrome.isPresentation,+ sel.activeRunStart, sel.activeRunEnd, sel.selStart, sel.selEnd, sel.activeCell,+ sel.activeSlide, sel.activeSlideEl, launchers,+ sel.activeTableBlock, sel.activeTableRow, sel.activeTableCol)+}++/** Top-app-bar actions for [DocumentScreen]. */+@Composable+internal fun DocumentScaffoldActions(+ chrome: DocumentChrome,+ viewModel: OfficeViewModel,+ canEdit: Boolean,+ saveAsName: String,+ launchers: DocumentLaunchers,+ onToggleSearch: () -> Unit,+) {+ if (canEdit) IconButton(onClick = { onToggleSearch() }) { IconSearch() }+ IconButton(onClick = { viewModel.undo() }, enabled = chrome.canUndo) { IconUndo() }+ IconButton(onClick = { viewModel.redo() }, enabled = chrome.canRedo) { IconRedo() }+ if (!chrome.isOnline) {+ SaveAction(viewModel, chrome, saveAsName, launchers)+ }+}++/** Save / save-as action (offline only). */+@Composable+internal fun SaveAction(+ viewModel: OfficeViewModel,+ chrome: DocumentChrome,+ saveAsName: String,+ launchers: DocumentLaunchers,+) {+ IconButton(+ onClick = {+ if (viewModel.needsSaveAs()) {+ launchers.saveAs.launch(saveAsName)+ } else {+ viewModel.save()+ }+ },+ enabled = chrome.hasUnsavedChanges && !chrome.isSaving,+ ) {+ if (chrome.isSaving) CircularProgressIndicator(Modifier.size(SavingSpinnerSize)) else IconSave()+ }+}+
office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.ktnew file mode 100644index 0000000000..aa94efd7ee--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreen.kt@@ -0,0 +1,74 @@+package com.vayunmathur.office.ui++import androidx.activity.ComponentActivity+import androidx.compose.foundation.lazy.rememberLazyListState+import androidx.compose.runtime.Composable+import androidx.compose.runtime.rememberCoroutineScope+import com.vayunmathur.library.ui.DrawerValue+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.odf.OdfDocument+import com.vayunmathur.library.ui.rememberDrawerState+import com.vayunmathur.office.platform.OfficeViewModel+import com.vayunmathur.office.platform.runParagraphIndexAt++/**+ * Error body for a document that failed to load: see DocumentScreenShell.+ */+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun DocumentScreen(+ document: OdfDocument,+ viewModel: OfficeViewModel,+ activity: ComponentActivity,+ onBack: () -> Unit,+ onBecameOnline: (String) -> Unit = {}) {+ val s = rememberDocumentScreenState()+ val sel = rememberScreenSelection(s)++ val onRunSelectionChange = rememberRunSelectionHandler(sel, viewModel)++ val chrome = rememberDocumentChrome(viewModel, document)+ val focusedPara = if (sel.activeRunStart >= 0 && chrome.isTextDoc) viewModel.runParagraphIndexAt(+ sel.activeRunStart,+ sel.activeRunEnd,+ sel.selStart) else -1++ DocumentEffects(s, chrome, onBack, { sel.showUnsavedDialog = true })++ val drawerState = rememberDrawerState(DrawerValue.Closed)+ val scope = rememberCoroutineScope()+ val listState = rememberLazyListState()++ val launchers = rememberDocumentLaunchers(+ viewModel = viewModel,+ holder = s,+ onPickImageBytes = rememberImagePickerHandler(+ document, viewModel, focusedPara, sel.activeSlide, sel.activeCell))++ DocumentDrawerShell(+ s = s,+ document = document,+ viewModel = viewModel,+ activity = activity,+ chrome = chrome,+ launchers = launchers,+ scope = scope,+ drawerState = drawerState,+ listState = listState,+ onToggleSearch = { sel.showSearch = !sel.showSearch },+ onShowUnsavedDialog = { sel.showUnsavedDialog = true },+ sel = ScreenSelection(+ sel.activeRunStart, sel.activeRunEnd, sel.activeTableBlock, sel.activeTableRow, sel.activeTableCol,+ sel.selStart, sel.selEnd, sel.activeCell, sel.activeSlide, sel.activeSlideEl),+ onRunSelectionChange = onRunSelectionChange,+ onCellFocus = { bi, r, c -> sel.activeTableBlock = bi; sel.activeTableRow = r; sel.activeTableCol = c },+ onCellSelected = { si, r, c -> sel.activeCell = Triple(si, r, c) },+ onSlideChange = { sel.activeSlide = it },+ onSlideElementSelected = { si, e -> sel.activeSlide = si; sel.activeSlideEl = e },+ focusedPara = focusedPara,+ onBack = onBack,+ onBecameOnline = onBecameOnline,+ )+}++/** Run-selection + shell sections: see DocumentScreenChrome / DocumentScreenShell. */
office/src/main/java/com/vayunmathur/office/ui/DocumentScreenChrome.kt
diff --git a/office/src/main/java/com/vayunmathur/office/DocumentScreenChrome.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenChrome.ktsimilarity index 95%rename from office/src/main/java/com/vayunmathur/office/DocumentScreenChrome.ktrename to office/src/main/java/com/vayunmathur/office/ui/DocumentScreenChrome.ktindex 3ed2e31319..513e4343f0 100644--- a/office/src/main/java/com/vayunmathur/office/DocumentScreenChrome.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenChrome.kt@@ -1,4 +1,4 @@-package com.vayunmathur.office+package com.vayunmathur.office.ui import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.Composable@@ -11,11 +11,11 @@ import com.vayunmathur.office.ui.countChars import com.vayunmathur.office.ui.countWords import com.vayunmathur.office.ui.extractHeadings import com.vayunmathur.office.ui.readingTimeMinutes-import com.vayunmathur.office.util.OfficeViewModel-import com.vayunmathur.office.util.insertImage-import com.vayunmathur.office.util.insertImageIntoSheet-import com.vayunmathur.office.util.insertImageIntoSlide-import com.vayunmathur.office.util.setLocalCaret+import com.vayunmathur.office.platform.OfficeViewModel+import com.vayunmathur.office.platform.insertImage+import com.vayunmathur.office.platform.insertImageIntoSheet+import com.vayunmathur.office.platform.insertImageIntoSlide+import com.vayunmathur.office.platform.setLocalCaret /** Value snapshot of the hoisted selection (avoids 9-param plumbing). */ internal class ScreenSelection(
office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.kt b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.ktnew file mode 100644index 0000000000..3f4fe0c2b1--- /dev/null+++ b/office/src/main/java/com/vayunmathur/office/ui/DocumentScreenShell.kt@@ -0,0 +1,231 @@+package com.vayunmathur.office.ui++import androidx.activity.ComponentActivity+import androidx.activity.compose.BackHandler+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyListState+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+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.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.DrawerState+import com.vayunmathur.library.ui.IconBack+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconRedo+import com.vayunmathur.library.ui.IconSave+import com.vayunmathur.library.ui.IconSearch+import com.vayunmathur.library.ui.IconUndo+import com.vay
Diff truncated.