Modern Apps git

← Modern-Apps.git

photos: fix all lint findings

Commit
caa077acb4f28deba51574e8986ace85a532e1cb
Author
Vayun Mathur <[email protected]>
When
2026-11-17 04:13 UTC (19 days ago)
Parents
bcb8e57
Clears every lint finding under photos/ (161 in-module findings
at the d687bc35a baseline: 159 warnings and 2 hints) down to
zero errors, zero warnings and zero hints, fixing code and
resources only. No lint configuration, baseline file or
check was disabled, and no @SuppressLint was added.

PackageStructure (34): the util/ tree moves to the canonical
roots - ViewModels, workers, backup agent, MediaStore/ML/
compositing helpers and the PhotosNative JNI bridge to
platform/, the pure edit helpers (MaskDab, PanoXmpParser,
UndoRedoManager) to domain/ (AdjustmentEditController and
MaskBrushPainer are PhotoEditViewModel extensions, so they
live in platform/ with it) - and glance/ moves to widget/.
The JNI entry points in the Rust bridge are renamed to the
new PhotosNative package. MainActivity.kt is split to its
contract: Route moves to Route.kt, Navigation to
Navigation.kt, NavigationBar and LocalColumnCount (with its
column-count constants) to ui/, the navigation entry effects
to ui/NavigationEntries.kt, and pushPhoto/shouldRelock/
viewerRouteFor to platform/NavigationHelpers.kt. Manifest
class references and all imports across main, test and
screenshotTest sources follow the moves.

OneComposablePerFile (15): AdvancedPanels' twelve panels
each get their own file (shared PanelColumn/SwitchRow/
ApplyButton become internal), PeopleScreen leaves
PeoplePage, VaultPhotoItem leaves SecureFolderPage (its
helpers become internal), and NavigationBar leaves
MainActivity.

UnsafeOptInUsageError (24 at baseline, 33 sites by the time
annotations propagated): media3 UnstableApi call sites in
VideoEditActivity, VideoEditNavigation, VideoEditPanels,
LiveWallpaperLauncher.apply and the VideoEditViewModel
factory now opt in at the exact function/class scope with
androidx.annotation.OptIn - the AndroidX annotation, since
kotlin.OptIn satisfied the compiler but not lint's
experimental-annotation check, which flagged the annotation
argument itself.

Resources: ExtraTranslation (48) entries with no default-
locale source are removed from every locale; unused default
strings (grant_storage_permission,
media_management_permission_required,
this_app_needs_permission_to_manage_medi, open_settings,
video_export_failed) are deleted everywhere after verifying
no code, manifest, test or dynamic lookup references them.
PluralsCandidate (3) strings become real plurals
(items_selected, photos_indexed_for_visual_search,
photos_indexed_for_text_search) with call sites and tests
switched to pluralStringResource/getQuantityString, full
per-locale quantity sets (ar zero/two/few/many, cs/pl
few/many, fr/it many; ja/zh drop the unused one), and
MissingQuantity (2) gains cs one/few and it one/many for
people_photo_count, which PeopleGrid now actually uses
instead of album_photo_count (also clearing its
UnusedResources entry). Typos (Gallerie, Liquify) and
TypographyEllipsis (ar/cs people_scanning) are corrected.

Remaining code fixes: ModifierParameter zoomModifier params
rename to modifier (call sites updated); StateFlow.value
reads in LoadedPagesEditingPass3Test hoist above setContent;
CheckResult test queries now assert (root existence, the
flatpano test tag, fetched clickable nodes); Autoboxing
hints switch to mutableIntStateOf; ClipEmbedder uses the
core-ktx Bitmap.scale; PhotoOcr's OcrBoxStore no longer
retains an OcrEngine (and its Context) in a static field -
engines are created per photo and closed after use; the
PhotoDao comment is reworded as prose so it no longer reads
as commented-out code; and the manifest declares
READ_MEDIA_VISUAL_USER_SELECTED for SelectedPhotoAccess.

Suppressions: none. No @SuppressLint and no false-positive
category had to be abandoned; every category was fixed in
code. Two CheckResult assertions first written as
assert-any-node checks failed against the real semantics
trees and were replaced with root/test-tag existence
assertions that verify the same rendering.

Verified with the module Gradle recipe:
:photos:lintDev reports 0 errors, 0 warnings and 0 hints
for photos/ (the 77 findings that remain in the report all
live in library/* and belong to the shared-library fix).
:photos:testDevUnitTest runs 790 tests; the two
CheckResult-affected tests pass, and the full suite is
green apart from VaultViewerPageRealTest.
viewerDecryptsAndShowsVaultPhoto, which failed once under
full-suite parallel load, passes in isolation and passed
in the first full run - a pre-existing timing flake in its
async decrypt await, untouched by this change.

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

photos/src/main/AndroidManifest.xml
diff --git a/photos/src/main/AndroidManifest.xml b/photos/src/main/AndroidManifest.xmlindex 5b104a6176..1f85ac91fa 100644--- a/photos/src/main/AndroidManifest.xml+++ b/photos/src/main/AndroidManifest.xml@@ -16,19 +16,21 @@      <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />     <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />+    <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />     <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />     <uses-permission android:name="android.permission.MANAGE_MEDIA" />      <uses-permission android:name="android.permission.SET_WALLPAPER" />     <uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" /> +    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />     <uses-permission android:name="android.permission.INTERNET" />     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />     <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />     <application         android:allowBackup="true"-        android:backupAgent=".util.AppBackupAgent"+        android:backupAgent=".platform.AppBackupAgent"         android:dataExtractionRules="@xml/data_extraction_rules"         android:icon="@mipmap/ic_launcher"         android:label="@string/app_name"@@ -75,7 +77,7 @@             </intent-filter>         </activity>         <receiver-            android:name=".glance.PhotoGlanceWidgetReceiver"+            android:name=".widget.PhotoGlanceWidgetReceiver"             android:exported="false">             <intent-filter>                 <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
photos/src/main/java/com/vayunmathur/photos/MainActivity.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/MainActivity.kt b/photos/src/main/java/com/vayunmathur/photos/MainActivity.ktindex 42d30380c4..c1eeec6445 100644--- a/photos/src/main/java/com/vayunmathur/photos/MainActivity.kt+++ b/photos/src/main/java/com/vayunmathur/photos/MainActivity.kt@@ -50,37 +50,31 @@ import com.vayunmathur.library.util.NavKey import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.library.widgets.updateWidgetPreviews import com.vayunmathur.photos.data.Photo+import com.vayunmathur.photos.ui.COLUMN_COUNT_KEY+import com.vayunmathur.photos.ui.LocalColumnCount+import com.vayunmathur.photos.ui.MAX_COLUMN_COUNT+import com.vayunmathur.photos.ui.MIN_COLUMN_COUNT import com.vayunmathur.photos.data.PhotosRepository-import com.vayunmathur.photos.glance.PhotoGlanceWidgetReceiver+import com.vayunmathur.photos.widget.PhotoGlanceWidgetReceiver import com.vayunmathur.photos.ui.AlbumDetailPage import com.vayunmathur.photos.ui.FavoritesPage import com.vayunmathur.photos.ui.AlbumsPage-import com.vayunmathur.photos.ui.GalleryPage import com.vayunmathur.photos.ui.MapPage import com.vayunmathur.photos.ui.PeoplePage-import com.vayunmathur.photos.ui.PhotoPage import com.vayunmathur.photos.ui.SecureFolderPage-import com.vayunmathur.photos.ui.TrashPage import com.vayunmathur.photos.ui.VaultViewerPage import com.vayunmathur.photos.ui.WallpaperPage-import com.vayunmathur.photos.util.GalleryViewModel-import com.vayunmathur.photos.util.GalleryViewModelFactory-import com.vayunmathur.photos.util.ImageLoader-import com.vayunmathur.photos.util.PhotoMapViewModel-import com.vayunmathur.photos.util.PhotoMapViewModelFactory-import com.vayunmathur.photos.util.SecureFolderViewModel-import com.vayunmathur.photos.util.SecureFolderViewModelFactory+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.GalleryViewModelFactory+import com.vayunmathur.photos.platform.ImageLoader+import com.vayunmathur.photos.platform.PhotoMapViewModel+import com.vayunmathur.photos.platform.PhotoMapViewModelFactory+import com.vayunmathur.photos.platform.SecureFolderViewModel+import com.vayunmathur.photos.platform.SecureFolderViewModelFactory import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.serialization.Serializable import kotlin.math.roundToInt -private const val COLUMN_COUNT_KEY = "photos_column_count"-private const val MIN_COLUMN_COUNT = 2-private const val MAX_COLUMN_COUNT = 8--val LocalColumnCount = staticCompositionLocalOf<MutableFloatState> {-    error("No LocalColumnCount provided")-}  /** Main Activity: a ma fragment activity implementation for main activity. */ class MainActivity : MaFragmentActivity() {@@ -146,270 +140,3 @@ class MainActivity : MaFragmentActivity() {         }     } }--/** Contract for route. */-@Serializable-sealed interface Route: NavKey {-    /** Singleton holding gallery state and operations. */-    @Serializable-    data object Gallery: Route--    /** Immutable value describing photo page; carries id, overridePhotosList, pendingUri. */-    @Serializable-    data class PhotoPage(val id: Long, val overridePhotosList: List<Photo>?, val pendingUri: String? = null): Route--    /** Singleton holding map state and operations. */-    @Serializable-    data object Map: Route--    /** Singleton holding people state and operations. */-    @Serializable-    data object People: Route--    /** Singleton holding albums state and operations. */-    @Serializable-    data object Albums: Route--    /** Immutable value describing album detail; carries albumName. */-    @Serializable-    data class AlbumDetail(val albumName: String): Route--    /** The Favorites album: every MediaStore favorite, opened from its Albums tile. */-    @Serializable-    data object Favorites: Route--    /** Singleton holding trash state and operations. */-    @Serializable-    data object Trash: Route--    /** Singleton holding secure folder state and operations. */-    @Serializable-    data object SecureFolder: Route--    /** Immutable value describing vault viewer; carries vaultId. */-    @Serializable-    data class VaultViewer(val vaultId: Long): Route--    /** Immutable value describing wallpaper; carries id, uri. */-    @Serializable-    data class Wallpaper(val id: Long, val uri: String? = null) : Route-}--/**- * Re-tapping a photo (or swiping to another) replaces the viewer instead of stacking it.- *- * On a two-pane layout the grid stays visible beside the viewer, so opening a second photo- * would otherwise pile PhotoPage on PhotoPage; back would then step through stale viewers- * instead of returning to the grid.- */-internal fun NavBackStack<Route>.pushPhoto(route: Route.PhotoPage) {-    if (last() is Route.PhotoPage) setLast(route) else add(route)-}--/** Whether leaving [topRoute] should re-lock the vault (opt-in, off by default). */-private fun shouldRelock(-    relockOnExit: Boolean,-    topRoute: Route?,-    vaultPhotoDao: com.vayunmathur.photos.data.VaultPhotoDao?,-): Boolean {-    if (!relockOnExit || topRoute == null || vaultPhotoDao == null) return false-    // The vault viewer counts as inside the folder.-    return topRoute !is Route.SecureFolder && topRoute !is Route.VaultViewer-}--@Composable-fun Navigation(-    galleryViewModel: GalleryViewModel,-    photoMapViewModel: PhotoMapViewModel,-    secureFolderViewModel: SecureFolderViewModel,-    viewUri: Uri? = null,-) {-    // Opened via ACTION_VIEW from another app (e.g. the camera): that one photo is the whole app-    // for this launch, so it is the root of the stack and the gallery is not underneath it. Back-    // then belongs to the system, which finishes this Activity straight back to whoever fired the-    // intent - the same task they started us in - and runs the cross-activity predictive back-    // animation itself. An in-app back handler would swallow that gesture, animate nothing, and-    // land the user on a home screen they never asked for.-    //-    // The MediaStore _id in a content URI equals Photo.id, so the page can be named up front and-    // render the incoming URI directly while the background index writes the row and the full sync-    // populates the rest of the library for swiping. PhotoPage reconciles to the DB-backed pager.-    val viewerRoute = remember(viewUri) { viewerRouteFor(viewUri) }--    val backStack = rememberNavBackStack<Route>(viewerRoute ?: Route.Gallery)-    val vaultPhotoDao by secureFolderViewModel.vaultPhotoDao.collectAsState()-    val vaultPassword by secureFolderViewModel.vaultPassword.collectAsState()-    val relockOnExit by secureFolderViewModel.relockOnExit.collectAsState()--    RelockEffect(backStack, relockOnExit, vaultPhotoDao, secureFolderViewModel)-    IndexViewUriEffect(viewUri, galleryViewModel)--    // PhotoPage pops itself when its last remaining photo is deleted. With the viewer as the root-    // there is nothing under it to pop to, and leaving the viewer here means leaving the app: hand-    // back to whoever sent us rather than hand NavDisplay an empty stack, which it rejects.-    val activity = LocalActivity.current-    if (backStack.backStack.isEmpty()) {-        LaunchedEffect(Unit) { activity?.finish() }-        return-    }--    MainNavigation(backStack) {-        // List role for the gallery so medium widths pair it with the viewer; Sibling motion-        // kept so switching bottom-nav tabs still crossfades instead of sliding.-        entry<Route.Gallery>(metadata = ListPage() + SiblingPage()) {-            GalleryPage(backStack, galleryViewModel, secureFolderViewModel)-        }--        entry<Route.Map>(metadata = SiblingPage()) {-            MapPage(backStack, galleryViewModel, photoMapViewModel)-        }--        entry<Route.People>(metadata = SiblingPage()) {-            PeoplePage(backStack, galleryViewModel)-        }--        entry<Route.Albums>(metadata = SiblingPage()) {-            AlbumsPage(backStack, galleryViewModel, secureFolderViewModel)-        }--        entry<Route.AlbumDetail> {-            AlbumDetailPage(backStack, galleryViewModel, it.albumName)-        }--        entry<Route.PhotoPage>(metadata = ListDetailPage() + MorphPage()) {-            PhotoPage(galleryViewModel, photoMapViewModel, it.id, it.overridePhotosList, it.pendingUri, backStack)-        }--        entry<Route.Wallpaper>(metadata = ListDetailPage()) {-            WallpaperPage(backStack, it.uri)-        }--        // Built-in collections, opened from the Albums grid's default tiles-        // (Favorites, Trash, Secure Folder). Detail pages: they push over Albums-        // and show a back arrow instead of the bottom bar.-        entry<Route.Favorites> {-            FavoritesPage(backStack, galleryViewModel, secureFolderViewModel)-        }--        entry<Route.Trash> {-            TrashPage(backStack, galleryViewModel)-        }--        entry<Route.SecureFolder> {-            SecureFolderEntry(backStack, secureFolderViewModel, vaultPhotoDao != null, vaultPassword)-        }--        entry<Route.VaultViewer>(metadata = ListDetailPage()) {-            VaultViewerEntry(backStack, it.vaultId, vaultPassword, secureFolderViewModel)-        }-    }-}--/** The viewer root for an ACTION_VIEW launch, or null for the normal gallery root. */-private fun viewerRouteFor(viewUri: Uri?): Route.PhotoPage? {-    viewUri ?: return null-    return Route.PhotoPage(-        runCatching { ContentUris.parseId(viewUri) }.getOrNull() ?: -1L,-        null,-        viewUri.toString(),-    )-}--/**- * Opt-in re-lock: leaving the Secure Folder (any route other than the- * folder itself or the vault viewer, which counts as inside) locks the- * vault so the next open requires unlock again. Off by default, which- * preserves the current stay-unlocked behaviour.- */-@Composable-private fun RelockEffect(-    backStack: NavBackStack<Route>,-    relockOnExit: Boolean,-    vaultPhotoDao: com.vayunmathur.photos.data.VaultPhotoDao?,-    secureFolderViewModel: SecureFolderViewModel,-) {-    val topRoute = backStack.backStack.lastOrNull()-    LaunchedEffect(topRoute, relockOnExit) {-        if (shouldRelock(relockOnExit, topRoute, vaultPhotoDao)) {-            secureFolderViewModel.lock()-        }-    }-}--/** Index one incoming URI once per launch (survives configuration change). */-@Composable-private fun IndexViewUriEffect(viewUri: Uri?, galleryViewModel: GalleryViewModel) {-    var indexedViewUri by rememberSaveable { mutableStateOf(false) }-    LaunchedEffect(viewUri) {-        if (viewUri == null || indexedViewUri) return@LaunchedEffect-        indexedViewUri = true-        galleryViewModel.resolveAndIndex(viewUri) {}-    }-}--@Composable-private fun VaultViewerEntry(-    backStack: NavBackStack<Route>,-    vaultId: Long,-    vaultPassword: String?,-    secureFolderViewModel: SecureFolderViewModel,-) {-    val password = vaultPassword-    if (password != null) {-        VaultViewerPage(backStack, vaultId, password, secureFolderViewModel)-    } else {-        SecureFolderEntry(backStack, secureFolderViewModel, false, null)-    }-}--@Composable-private fun SecureFolderEntry(-    backStack: NavBackStack<Route>,-    secureFolderViewModel: SecureFolderViewModel,-    isUnlocked: Boolean,-    vaultPassword: String?,-) {-    val activity = LocalActivity.current as FragmentActivity-    if (!isUnlocked) {-        LaunchedEffect(Unit) {-            secureFolderViewModel.unlock(-                activity,-                onSuccess = { _, _ -> },-                onFailure = { message ->-                    if (message != null) {-                        AppMessages.show(message)-                    }-                    backStack.pop()-                },-            )-        }-        Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {-            LoadingIndicator()-        }-    } else {-        SecureFolderPage(backStack, vaultPassword!!, secureFolderViewModel)-    }-}--private enum class MainRoute(val route: Route, @StringRes val titleRes: Int, val icon: @Composable () -> Unit) {-    Gallery(Route.Gallery, R.string.label_gallery, { IconPhotoLibrary() }),-    Map(Route.Map, R.string.label_map, { IconMap() }),-    People(Route.People, R.string.label_people, { IconGroup() }),-    Albums(Route.Albums, R.string.label_albums, { IconAlbum() }),-}--@Composable-fun NavigationBar(currentRoute: Route, backStack: NavBackStack<Route>) {-    BottomNavBar {-        MainRoute.entries.forEach {-            BottomNavBarItem(-                selected = it.route == currentRoute,-                // Photos pushes rather than resetting, so back returns to the-                // previous tab instead of leaving the app.-                onClick = { backStack.add(it.route) },-                icon = { it.icon() },-                label = stringResource(it.titleRes),-            )-        }-    }-}
photos/src/main/java/com/vayunmathur/photos/Navigation.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/Navigation.kt b/photos/src/main/java/com/vayunmathur/photos/Navigation.ktnew file mode 100644index 0000000000..4cb4049b3a--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/Navigation.kt@@ -0,0 +1,120 @@+package com.vayunmathur.photos+import com.vayunmathur.photos.ui.TrashPage+import com.vayunmathur.photos.ui.PhotoPage+import com.vayunmathur.photos.ui.GalleryPage++import android.net.Uri+import androidx.activity.compose.LocalActivity+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import com.vayunmathur.library.util.ListDetailPage+import com.vayunmathur.library.util.ListPage+import com.vayunmathur.library.util.MainNavigation+import com.vayunmathur.library.util.MorphPage+import com.vayunmathur.library.util.SiblingPage+import com.vayunmathur.library.util.rememberNavBackStack+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.PhotoMapViewModel+import com.vayunmathur.photos.platform.SecureFolderViewModel+import com.vayunmathur.photos.platform.viewerRouteFor+import com.vayunmathur.photos.ui.AlbumDetailPage+import com.vayunmathur.photos.ui.AlbumsPage+import com.vayunmathur.photos.ui.FavoritesPage+import com.vayunmathur.photos.ui.IndexViewUriEffect+import com.vayunmathur.photos.ui.MapPage+import com.vayunmathur.photos.ui.PeoplePage+import com.vayunmathur.photos.ui.RelockEffect+import com.vayunmathur.photos.ui.SecureFolderEntry+import com.vayunmathur.photos.ui.VaultViewerEntry+import com.vayunmathur.photos.ui.WallpaperPage++@Composable+fun Navigation(+    galleryViewModel: GalleryViewModel,+    photoMapViewModel: PhotoMapViewModel,+    secureFolderViewModel: SecureFolderViewModel,+    viewUri: Uri? = null,+) {+    // Opened via ACTION_VIEW from another app (e.g. the camera): that one photo is the whole app+    // for this launch, so it is the root of the stack and the gallery is not underneath it. Back+    // then belongs to the system, which finishes this Activity straight back to whoever fired the+    // intent - the same task they started us in - and runs the cross-activity predictive back+    // animation itself. An in-app back handler would swallow that gesture, animate nothing, and+    // land the user on a home screen they never asked for.+    //+    // The MediaStore _id in a content URI equals Photo.id, so the page can be named up front and+    // render the incoming URI directly while the background index writes the row and the full sync+    // populates the rest of the library for swiping. PhotoPage reconciles to the DB-backed pager.+    val viewerRoute = remember(viewUri) { viewerRouteFor(viewUri) }++    val backStack = rememberNavBackStack<Route>(viewerRoute ?: Route.Gallery)+    val vaultPhotoDao by secureFolderViewModel.vaultPhotoDao.collectAsState()+    val vaultPassword by secureFolderViewModel.vaultPassword.collectAsState()+    val relockOnExit by secureFolderViewModel.relockOnExit.collectAsState()++    RelockEffect(backStack, relockOnExit, vaultPhotoDao, secureFolderViewModel)+    IndexViewUriEffect(viewUri, galleryViewModel)++    // PhotoPage pops itself when its last remaining photo is deleted. With the viewer as the root+    // there is nothing under it to pop to, and leaving the viewer here means leaving the app: hand+    // back to whoever sent us rather than hand NavDisplay an empty stack, which it rejects.+    val activity = LocalActivity.current+    if (backStack.backStack.isEmpty()) {+        LaunchedEffect(Unit) { activity?.finish() }+        return+    }++    MainNavigation(backStack) {+        // List role for the gallery so medium widths pair it with the viewer; Sibling motion+        // kept so switching bottom-nav tabs still crossfades instead of sliding.+        entry<Route.Gallery>(metadata = ListPage() + SiblingPage()) {+            GalleryPage(backStack, galleryViewModel, secureFolderViewModel)+        }++        entry<Route.Map>(metadata = SiblingPage()) {+            MapPage(backStack, galleryViewModel, photoMapViewModel)+        }++        entry<Route.People>(metadata = SiblingPage()) {+            PeoplePage(backStack, galleryViewModel)+        }++        entry<Route.Albums>(metadata = SiblingPage()) {+            AlbumsPage(backStack, galleryViewModel, secureFolderViewModel)+        }++        entry<Route.AlbumDetail> {+            AlbumDetailPage(backStack, galleryViewModel, it.albumName)+        }++        entry<Route.PhotoPage>(metadata = ListDetailPage() + MorphPage()) {+            PhotoPage(galleryViewModel, photoMapViewModel, it.id, it.overridePhotosList, it.pendingUri, backStack)+        }++        entry<Route.Wallpaper>(metadata = ListDetailPage()) {+            WallpaperPage(backStack, it.uri)+        }++        // Built-in collections, opened from the Albums grid's default tiles+        // (Favorites, Trash, Secure Folder). Detail pages: they push over Albums+        // and show a back arrow instead of the bottom bar.+        entry<Route.Favorites> {+            FavoritesPage(backStack, galleryViewModel, secureFolderViewModel)+        }++        entry<Route.Trash> {+            TrashPage(backStack, galleryViewModel)+        }++        entry<Route.SecureFolder> {+            SecureFolderEntry(backStack, secureFolderViewModel, vaultPhotoDao != null, vaultPassword)+        }++        entry<Route.VaultViewer>(metadata = ListDetailPage()) {+            VaultViewerEntry(backStack, it.vaultId, vaultPassword, secureFolderViewModel)+        }+    }+}
photos/src/main/java/com/vayunmathur/photos/Route.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/Route.kt b/photos/src/main/java/com/vayunmathur/photos/Route.ktnew file mode 100644index 0000000000..ee7bf324cc--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/Route.kt@@ -0,0 +1,53 @@+package com.vayunmathur.photos++import com.vayunmathur.library.util.NavKey+import com.vayunmathur.photos.data.Photo+import kotlinx.serialization.Serializable++/** Contract for route. */+@Serializable+sealed interface Route: NavKey {+    /** Singleton holding gallery state and operations. */+    @Serializable+    data object Gallery: Route++    /** Immutable value describing photo page; carries id, overridePhotosList, pendingUri. */+    @Serializable+    data class PhotoPage(val id: Long, val overridePhotosList: List<Photo>?, val pendingUri: String? = null): Route++    /** Singleton holding map state and operations. */+    @Serializable+    data object Map: Route++    /** Singleton holding people state and operations. */+    @Serializable+    data object People: Route++    /** Singleton holding albums state and operations. */+    @Serializable+    data object Albums: Route++    /** Immutable value describing album detail; carries albumName. */+    @Serializable+    data class AlbumDetail(val albumName: String): Route++    /** The Favorites album: every MediaStore favorite, opened from its Albums tile. */+    @Serializable+    data object Favorites: Route++    /** Singleton holding trash state and operations. */+    @Serializable+    data object Trash: Route++    /** Singleton holding secure folder state and operations. */+    @Serializable+    data object SecureFolder: Route++    /** Immutable value describing vault viewer; carries vaultId. */+    @Serializable+    data class VaultViewer(val vaultId: Long): Route++    /** Immutable value describing wallpaper; carries id, uri. */+    @Serializable+    data class Wallpaper(val id: Long, val uri: String? = null) : Route+}
photos/src/main/java/com/vayunmathur/photos/data/BlurData.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/BlurData.kt b/photos/src/main/java/com/vayunmathur/photos/data/BlurData.ktindex ee11e26ad0..80dccc2832 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/BlurData.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/BlurData.kt@@ -2,7 +2,7 @@ package com.vayunmathur.photos.data  import android.graphics.Bitmap import androidx.core.graphics.createBitmap-import com.vayunmathur.photos.util.PhotosNative+import com.vayunmathur.photos.platform.PhotosNative  /** Kinds of blur mode. */ enum class BlurMode { Radial, Linear, Lens }
photos/src/main/java/com/vayunmathur/photos/data/ContentAwareData.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/ContentAwareData.kt b/photos/src/main/java/com/vayunmathur/photos/data/ContentAwareData.ktindex 73213f55a4..e0d86a2c48 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/ContentAwareData.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/ContentAwareData.kt@@ -1,7 +1,7 @@ package com.vayunmathur.photos.data  import android.graphics.Bitmap-import com.vayunmathur.photos.util.PhotosNative+import com.vayunmathur.photos.platform.PhotosNative  /**  * Content-aware fill: removes the region marked by [holeMask] (normalized, at
photos/src/main/java/com/vayunmathur/photos/data/LiquifyData.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/LiquifyData.kt b/photos/src/main/java/com/vayunmathur/photos/data/LiquifyData.ktindex d7ef9fd74e..1846ec56b1 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/LiquifyData.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/LiquifyData.kt@@ -2,7 +2,7 @@ package com.vayunmathur.photos.data  import android.graphics.Bitmap import androidx.core.graphics.createBitmap-import com.vayunmathur.photos.util.PhotosNative+import com.vayunmathur.photos.platform.PhotosNative  private const val OP_STRIDE = 6 private const val OP_X = 0
photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.kt b/photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.ktindex 000ee4e584..7706ba91c6 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/PhotoDatabase.kt@@ -17,12 +17,13 @@ interface PhotoDao {     // Excludes the heavy clipEmbedding BLOB, ocrText and ocrBoxes, which the     // gallery/photo UI never reads, so the first emission on cold start is fast     // (loading those for a large library is what left the grid blank). Semantic-    // search reads embeddings via getClipEmbeddings(); OCR text is read via-    // getAll(); the viewer's selectable-text overlay reads geometry by id via-    // getOcrBoxes(), because Photos from this flow always have ocrBoxes == null.+    // search reads embeddings through its own dedicated query; OCR text is+    // read through the full-row query; and the viewer's selectable-text+    // overlay reads geometry by id through its own by-id query, because+    // Photos from this flow always have ocrBoxes == null.     //-    // ORDER BY date DESC is served by index_Photo_date, so SQLite returns rows-    // newest-first on its own background executor. Every consumer (gallery grid,+    // Rows arrive newest-first: the date index lets SQLite emit them in+    // order on its own background executor. Every consumer (gallery grid,     // trash, people) groups/sorts by date descending anyway, so the composition     // pass now groups pre-ordered rows instead of sorting the whole library on     // the main thread — cutting first-load jank without changing what's shown.
photos/src/main/java/com/vayunmathur/photos/data/SharpenData.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/SharpenData.kt b/photos/src/main/java/com/vayunmathur/photos/data/SharpenData.ktindex 66a381d7f4..42d1e824bb 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/SharpenData.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/SharpenData.kt@@ -2,7 +2,7 @@ package com.vayunmathur.photos.data  import android.graphics.Bitmap import androidx.core.graphics.createBitmap-import com.vayunmathur.photos.util.PhotosNative+import com.vayunmathur.photos.platform.PhotosNative  /** Immutable value describing unsharp mask. */ data class UnsharpMask(
photos/src/main/java/com/vayunmathur/photos/data/StylizeData.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/StylizeData.kt b/photos/src/main/java/com/vayunmathur/photos/data/StylizeData.ktindex 117b55c31c..90be760954 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/StylizeData.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/StylizeData.kt@@ -2,7 +2,7 @@ package com.vayunmathur.photos.data  import android.graphics.Bitmap import androidx.core.graphics.createBitmap-import com.vayunmathur.photos.util.PhotosNative+import com.vayunmathur.photos.platform.PhotosNative  /** Kinds of stylize mode. */ enum class StylizeMode { None, FindEdges, Emboss }
photos/src/main/java/com/vayunmathur/photos/data/VideoEditState.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/data/VideoEditState.kt b/photos/src/main/java/com/vayunmathur/photos/data/VideoEditState.ktindex 325567d99f..e9aae1c828 100644--- a/photos/src/main/java/com/vayunmathur/photos/data/VideoEditState.kt+++ b/photos/src/main/java/com/vayunmathur/photos/data/VideoEditState.kt@@ -5,7 +5,7 @@ enum class VideoTool { Trim, CropRotate, Audio, Filters }  /**  * One-tap color looks for video. Each maps to a small set of color effects in- * [com.vayunmathur.photos.util.VideoEditViewModel.buildVideoEffects]; the+ * [com.vayunmathur.photos.platform.VideoEditViewModel.buildVideoEffects]; the  * per-slider brightness/contrast/saturation are applied on top.  */ enum class VideoFilterPreset { None, Mono, Warm, Cool, Vivid }
photos/src/main/java/com/vayunmathur/photos/domain/MaskDab.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/MaskDab.kt b/photos/src/main/java/com/vayunmathur/photos/domain/MaskDab.ktsimilarity index 94%rename from photos/src/main/java/com/vayunmathur/photos/util/MaskDab.ktrename to photos/src/main/java/com/vayunmathur/photos/domain/MaskDab.ktindex d893e01760..bb9c97e97d 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/MaskDab.kt+++ b/photos/src/main/java/com/vayunmathur/photos/domain/MaskDab.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.domain  /**  * One circular mask dab: paints [paintValue] into [data] for the pixels whose
photos/src/main/java/com/vayunmathur/photos/domain/PanoXmpParser.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/PanoXmpParser.kt b/photos/src/main/java/com/vayunmathur/photos/domain/PanoXmpParser.ktsimilarity index 98%rename from photos/src/main/java/com/vayunmathur/photos/util/PanoXmpParser.ktrename to photos/src/main/java/com/vayunmathur/photos/domain/PanoXmpParser.ktindex 60ef794362..9ef08c3f87 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/PanoXmpParser.kt+++ b/photos/src/main/java/com/vayunmathur/photos/domain/PanoXmpParser.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.domain  import com.vayunmathur.photos.data.PanoData 
photos/src/main/java/com/vayunmathur/photos/domain/PhotoOcr.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/domain/PhotoOcr.kt b/photos/src/main/java/com/vayunmathur/photos/domain/PhotoOcr.ktindex c9405fd205..8c414bfcf1 100644--- a/photos/src/main/java/com/vayunmathur/photos/domain/PhotoOcr.kt+++ b/photos/src/main/java/com/vayunmathur/photos/domain/PhotoOcr.kt@@ -69,7 +69,6 @@ object OcrBoxStore {     private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)     private val lock = Mutex()     private val inFlight = mutableMapOf<Long, Deferred<OcrLayout?>>()-    private var engine: OcrEngine? = null      suspend fun layoutFor(context: Context, photo: Photo): OcrLayout? {         if (photo.videoData != null) return null@@ -107,13 +106,9 @@ object OcrBoxStore {         return job.await()     } -    /** Forget a finished job and, once nothing else is queued, free the models. */+    /** Forget a finished job; engines are per-call and already closed. */     private suspend fun release(photoId: Long) = lock.withLock {         inFlight -= photoId-        if (inFlight.isEmpty()) {-            engine?.close()-            engine = null-        }     }      private suspend fun recognizeAndStore(@@ -121,9 +116,24 @@ object OcrBoxStore {         photo: Photo,         scanRepository: PhotoScanRepository,     ): OcrLayout? {-        val ocr = lock.withLock { engine ?: OcrEngine(context).also { engine = it } }-        if (!ocr.isAvailable()) return null+        // A fresh engine per photo: retaining one in this singleton would+        // statically hold its Context (StaticFieldLeak). Creation is cheap+        // relative to decode + recognition, and close() frees the models.+        val ocr = OcrEngine(context)+        try {+            if (!ocr.isAvailable()) return null+            return recognizeWith(ocr, context, photo, scanRepository)+        } finally {+            ocr.close()+        }+    } +    private suspend fun recognizeWith(+        ocr: OcrEngine,+        context: Context,+        photo: Photo,+        scanRepository: PhotoScanRepository,+    ): OcrLayout? {         val bitmap = decodeForOcr(context, photo.uri.toUri()) ?: return null         // The stored geometry is relative to this bitmap, so its dimensions have         // to be read before it's recycled.
photos/src/main/java/com/vayunmathur/photos/domain/UndoRedoManager.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/UndoRedoManager.kt b/photos/src/main/java/com/vayunmathur/photos/domain/UndoRedoManager.ktsimilarity index 97%rename from photos/src/main/java/com/vayunmathur/photos/util/UndoRedoManager.ktrename to photos/src/main/java/com/vayunmathur/photos/domain/UndoRedoManager.ktindex e820fbb878..1790123725 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/UndoRedoManager.kt+++ b/photos/src/main/java/com/vayunmathur/photos/domain/UndoRedoManager.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.domain  /**  * Generic, bounded undo/redo history. The caller owns the "current" state; this
photos/src/main/java/com/vayunmathur/photos/platform/AdjustmentEditController.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/AdjustmentEditController.kt b/photos/src/main/java/com/vayunmathur/photos/platform/AdjustmentEditController.ktsimilarity index 97%rename from photos/src/main/java/com/vayunmathur/photos/util/AdjustmentEditController.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/AdjustmentEditController.ktindex 3d381f17f4..b583e35afa 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/AdjustmentEditController.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/AdjustmentEditController.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import com.vayunmathur.photos.data.AdjustmentLayer import com.vayunmathur.photos.data.LayerAdjustment
photos/src/main/java/com/vayunmathur/photos/platform/AlbumMediaStore.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/AlbumMediaStore.kt b/photos/src/main/java/com/vayunmathur/photos/platform/AlbumMediaStore.ktsimilarity index 98%rename from photos/src/main/java/com/vayunmathur/photos/util/AlbumMediaStore.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/AlbumMediaStore.ktindex 0820f19e47..10b6af0387 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/AlbumMediaStore.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/AlbumMediaStore.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.content.ContentValues import android.content.Context
photos/src/main/java/com/vayunmathur/photos/platform/AppBackupAgent.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/AppBackupAgent.kt b/photos/src/main/java/com/vayunmathur/photos/platform/AppBackupAgent.ktsimilarity index 95%rename from photos/src/main/java/com/vayunmathur/photos/util/AppBackupAgent.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/AppBackupAgent.ktindex dcc57043b6..5c837a9ee5 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/AppBackupAgent.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/AppBackupAgent.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import com.vayunmathur.library.room.SqlCipherDbCodec import com.vayunmathur.library.util.BaseBackupAgent
photos/src/main/java/com/vayunmathur/photos/platform/ClipEmbedder.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/ClipEmbedder.kt b/photos/src/main/java/com/vayunmathur/photos/platform/ClipEmbedder.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/ClipEmbedder.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/ClipEmbedder.ktindex 39454f98bd..8a4c5e9cc8 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/ClipEmbedder.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/ClipEmbedder.kt@@ -1,9 +1,10 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.content.Context import android.graphics.Bitmap import android.graphics.BitmapFactory import android.net.Uri+import androidx.core.graphics.scale import com.vayunmathur.library.log.Log import com.vayunmathur.library.ml.ClipHandle import java.io.IOException@@ -235,7 +236,7 @@ object ClipEmbedder {         val ratio = IMAGE_SIZE.toFloat() / minOf(safe.width, safe.height)         val rw = (safe.width * ratio).roundToInt().coerceAtLeast(IMAGE_SIZE)         val rh = (safe.height * ratio).roundToInt().coerceAtLeast(IMAGE_SIZE)-        val scaled = Bitmap.createScaledBitmap(safe, rw, rh, true)+        val scaled = safe.scale(rw, rh)         val left = (rw - IMAGE_SIZE) / 2         val top = (rh - IMAGE_SIZE) / 2 
photos/src/main/java/com/vayunmathur/photos/platform/ClipTokenizer.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/ClipTokenizer.kt b/photos/src/main/java/com/vayunmathur/photos/platform/ClipTokenizer.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/ClipTokenizer.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/ClipTokenizer.ktindex a7db5de361..5542681ccb 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/ClipTokenizer.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/ClipTokenizer.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.content.Context 
photos/src/main/java/com/vayunmathur/photos/platform/FaceCropTransformation.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/FaceCropTransformation.kt b/photos/src/main/java/com/vayunmathur/photos/platform/FaceCropTransformation.ktsimilarity index 97%rename from photos/src/main/java/com/vayunmathur/photos/util/FaceCropTransformation.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/FaceCropTransformation.ktindex 151413cbca..5214a7c866 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/FaceCropTransformation.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/FaceCropTransformation.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.graphics.Bitmap import com.vayunmathur.library.image.Size
photos/src/main/java/com/vayunmathur/photos/platform/FaceRecognizer.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/FaceRecognizer.kt b/photos/src/main/java/com/vayunmathur/photos/platform/FaceRecognizer.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/FaceRecognizer.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/FaceRecognizer.ktindex 43e57cd244..af96d30be9 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/FaceRecognizer.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/FaceRecognizer.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.content.Context import android.graphics.Bitmap
photos/src/main/java/com/vayunmathur/photos/platform/FaceWorker.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/FaceWorker.kt b/photos/src/main/java/com/vayunmathur/photos/platform/FaceWorker.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/FaceWorker.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/FaceWorker.ktindex fd1b168c86..065a270080 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/FaceWorker.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/FaceWorker.kt@@ -1,5 +1,4 @@-package com.vayunmathur.photos.util-import com.vayunmathur.photos.R+package com.vayunmathur.photos.platform  import android.app.NotificationChannel import android.app.NotificationManager
photos/src/main/java/com/vayunmathur/photos/platform/GalleryUiContract.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/GalleryUiContract.kt b/photos/src/main/java/com/vayunmathur/photos/platform/GalleryUiContract.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/GalleryUiContract.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/GalleryUiContract.ktindex 0dfda92f20..196693fc80 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/GalleryUiContract.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/GalleryUiContract.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import com.vayunmathur.photos.data.Photo 
photos/src/main/java/com/vayunmathur/photos/platform/GalleryViewModel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/GalleryViewModel.kt b/photos/src/main/java/com/vayunmathur/photos/platform/GalleryViewModel.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/GalleryViewModel.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/GalleryViewModel.ktindex 3f5703cb36..8a21330778 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/GalleryViewModel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/GalleryViewModel.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import com.vayunmathur.photos.domain.FaceClusterConfig import android.app.Application
photos/src/main/java/com/vayunmathur/photos/platform/ImageLoader.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/ImageLoader.kt b/photos/src/main/java/com/vayunmathur/photos/platform/ImageLoader.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/ImageLoader.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/ImageLoader.ktindex 3f0e96c4d0..0752827088 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/ImageLoader.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/ImageLoader.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform import android.content.Context import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background
photos/src/main/java/com/vayunmathur/photos/platform/LayerCompositor.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/LayerCompositor.kt b/photos/src/main/java/com/vayunmathur/photos/platform/LayerCompositor.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/LayerCompositor.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/LayerCompositor.ktindex 1c9517738d..91e6958f4b 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/LayerCompositor.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/LayerCompositor.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.graphics.Bitmap import android.graphics.Canvas
photos/src/main/java/com/vayunmathur/photos/platform/LayerEditController.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/LayerEditController.kt b/photos/src/main/java/com/vayunmathur/photos/platform/LayerEditController.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/LayerEditController.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/LayerEditController.ktindex 22403a747b..a3f1c2ae00 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/LayerEditController.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/LayerEditController.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import androidx.core.graphics.createBitmap import com.vayunmathur.library.ink.SerializedStroke
photos/src/main/java/com/vayunmathur/photos/platform/LiveWallpaperLauncher.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/LiveWallpaperLauncher.kt b/photos/src/main/java/com/vayunmathur/photos/platform/LiveWallpaperLauncher.ktsimilarity index 93%rename from photos/src/main/java/com/vayunmathur/photos/util/LiveWallpaperLauncher.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/LiveWallpaperLauncher.ktindex 4a2889190f..668a3aa2e4 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/LiveWallpaperLauncher.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/LiveWallpaperLauncher.kt@@ -1,4 +1,6 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform+import androidx.annotation.OptIn+import androidx.media3.common.util.UnstableApi  import android.app.WallpaperManager import android.content.ActivityNotFoundException@@ -17,6 +19,7 @@ import com.vayunmathur.photos.service.LiveWallpaperService  */ object LiveWallpaperLauncher { +    @OptIn(UnstableApi::class)     suspend fun apply(context: Context, uri: String, isVideo: Boolean) {         val ds = DataStoreUtils.getInstance(context.applicationContext)         ds.setString(LiveWallpaperService.KEY_WALLPAPER_URI, uri)
photos/src/main/java/com/vayunmathur/photos/platform/MaskBrushPainer.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/MaskBrushPainer.kt b/photos/src/main/java/com/vayunmathur/photos/platform/MaskBrushPainer.ktsimilarity index 97%rename from photos/src/main/java/com/vayunmathur/photos/util/MaskBrushPainer.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/MaskBrushPainer.ktindex b7485534ef..9fc05efcff 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/MaskBrushPainer.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/MaskBrushPainer.kt@@ -1,4 +1,5 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform+import com.vayunmathur.photos.domain.MaskDab  import com.vayunmathur.photos.data.EditDocument import com.vayunmathur.photos.data.Layer
photos/src/main/java/com/vayunmathur/photos/platform/MlSegmentation.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/MlSegmentation.kt b/photos/src/main/java/com/vayunmathur/photos/platform/MlSegmentation.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/MlSegmentation.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/MlSegmentation.ktindex 9cdbd2b727..1beb90c416 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/MlSegmentation.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/MlSegmentation.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.content.Context import android.graphics.Bitmap
photos/src/main/java/com/vayunmathur/photos/platform/NavigationHelpers.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/platform/NavigationHelpers.kt b/photos/src/main/java/com/vayunmathur/photos/platform/NavigationHelpers.ktnew file mode 100644index 0000000000..1ad57aaf6f--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/platform/NavigationHelpers.kt@@ -0,0 +1,39 @@+package com.vayunmathur.photos.platform++import android.content.ContentUris+import android.net.Uri+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.photos.Route+import com.vayunmathur.photos.data.VaultPhotoDao++/**+ * Re-tapping a photo (or swiping to another) replaces the viewer instead of stacking it.+ *+ * On a two-pane layout the grid stays visible beside the viewer, so opening a second photo+ * would otherwise pile PhotoPage on PhotoPage; back would then step through stale viewers+ * instead of returning to the grid.+ */+internal fun NavBackStack<Route>.pushPhoto(route: Route.PhotoPage) {+    if (last() is Route.PhotoPage) setLast(route) else add(route)+}++/** Whether leaving [topRoute] should re-lock the vault (opt-in, off by default). */+internal fun shouldRelock(+    relockOnExit: Boolean,+    topRoute: Route?,+    vaultPhotoDao: com.vayunmathur.photos.data.VaultPhotoDao?,+): Boolean {+    if (!relockOnExit || topRoute == null || vaultPhotoDao == null) return false+    // The vault viewer counts as inside the folder.+    return topRoute !is Route.SecureFolder && topRoute !is Route.VaultViewer+}++/** The viewer root for an ACTION_VIEW launch, or null for the normal gallery root. */+internal fun viewerRouteFor(viewUri: Uri?): Route.PhotoPage? {+    viewUri ?: return null+    return Route.PhotoPage(+        runCatching { ContentUris.parseId(viewUri) }.getOrNull() ?: -1L,+        null,+        viewUri.toString(),+    )+}
photos/src/main/java/com/vayunmathur/photos/platform/OverlayRendering.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/OverlayRendering.kt b/photos/src/main/java/com/vayunmathur/photos/platform/OverlayRendering.ktsimilarity index 98%rename from photos/src/main/java/com/vayunmathur/photos/util/OverlayRendering.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/OverlayRendering.ktindex 3cc3b1bd8b..6bc3b12839 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/OverlayRendering.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/OverlayRendering.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.graphics.Canvas import android.graphics.Matrix
photos/src/main/java/com/vayunmathur/photos/platform/PhotoEditSaver.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/PhotoEditSaver.kt b/photos/src/main/java/com/vayunmathur/photos/platform/PhotoEditSaver.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/PhotoEditSaver.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/PhotoEditSaver.ktindex 24e415d861..2a07f918f3 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/PhotoEditSaver.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/PhotoEditSaver.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.content.ContentValues import android.content.Context
photos/src/main/java/com/vayunmathur/photos/platform/PhotoEditViewModel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/PhotoEditViewModel.kt b/photos/src/main/java/com/vayunmathur/photos/platform/PhotoEditViewModel.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/PhotoEditViewModel.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/PhotoEditViewModel.ktindex ab7b3be453..d45ff5e5f5 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/PhotoEditViewModel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/PhotoEditViewModel.kt@@ -1,4 +1,5 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform+import com.vayunmathur.photos.domain.UndoRedoManager  import android.app.Application import android.content.Context
photos/src/main/java/com/vayunmathur/photos/platform/PhotoMapViewModel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/PhotoMapViewModel.kt b/photos/src/main/java/com/vayunmathur/photos/platform/PhotoMapViewModel.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/PhotoMapViewModel.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/PhotoMapViewModel.ktindex c085865e08..f97b18e5df 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/PhotoMapViewModel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/PhotoMapViewModel.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.app.Application import android.location.Geocoder
photos/src/main/java/com/vayunmathur/photos/platform/PhotosNative.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/PhotosNative.kt b/photos/src/main/java/com/vayunmathur/photos/platform/PhotosNative.ktsimilarity index 98%rename from photos/src/main/java/com/vayunmathur/photos/util/PhotosNative.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/PhotosNative.ktindex 6d9491d4cb..d7822f849e 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/PhotosNative.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/PhotosNative.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  /**  * JNI bridge to the native `photos_fx` Rust library: performance-critical
photos/src/main/java/com/vayunmathur/photos/platform/PixelEditController.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/PixelEditController.kt b/photos/src/main/java/com/vayunmathur/photos/platform/PixelEditController.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/PixelEditController.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/PixelEditController.ktindex 0bfec2b05e..29e3c6fc12 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/PixelEditController.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/PixelEditController.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.graphics.Bitmap import android.graphics.Matrix
photos/src/main/java/com/vayunmathur/photos/platform/SecureFolderManager.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/SecureFolderManager.kt b/photos/src/main/java/com/vayunmathur/photos/platform/SecureFolderManager.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/SecureFolderManager.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/SecureFolderManager.ktindex 1b72b24950..75289a7101 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/SecureFolderManager.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/SecureFolderManager.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.content.ContentValues import android.content.Context
photos/src/main/java/com/vayunmathur/photos/platform/SecureFolderViewModel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/SecureFolderViewModel.kt b/photos/src/main/java/com/vayunmathur/photos/platform/SecureFolderViewModel.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/SecureFolderViewModel.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/SecureFolderViewModel.ktindex 0835636963..921211dd87 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/SecureFolderViewModel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/SecureFolderViewModel.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.app.Application import android.graphics.Bitmap
photos/src/main/java/com/vayunmathur/photos/platform/SyncWorker.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/SyncWorker.kt b/photos/src/main/java/com/vayunmathur/photos/platform/SyncWorker.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/SyncWorker.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/SyncWorker.ktindex 9284c395a6..34a84e5f8b 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/SyncWorker.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/SyncWorker.kt@@ -1,5 +1,5 @@-package com.vayunmathur.photos.util-import com.vayunmathur.photos.R+package com.vayunmathur.photos.platform+import com.vayunmathur.photos.domain.PanoXmpParser  import android.app.NotificationChannel import android.app.NotificationManager
photos/src/main/java/com/vayunmathur/photos/platform/SyncWorkerHelper.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/SyncWorkerHelper.kt b/photos/src/main/java/com/vayunmathur/photos/platform/SyncWorkerHelper.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/SyncWorkerHelper.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/SyncWorkerHelper.ktindex b9d58d6153..df2ae8f9eb 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/SyncWorkerHelper.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/SyncWorkerHelper.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.content.Context import com.vayunmathur.library.log.Log
photos/src/main/java/com/vayunmathur/photos/platform/VideoEditViewModel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/VideoEditViewModel.kt b/photos/src/main/java/com/vayunmathur/photos/platform/VideoEditViewModel.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/VideoEditViewModel.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/VideoEditViewModel.ktindex 336fd61eca..b95c1acd0d 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/VideoEditViewModel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/VideoEditViewModel.kt@@ -1,4 +1,5 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform+import androidx.annotation.OptIn  import android.app.Application import android.content.ContentValues@@ -468,6 +469,7 @@ class VideoEditViewModel(     } } +@OptIn(UnstableApi::class) @Suppress("FunctionName") fun VideoEditViewModelFactory(     application: Application,
photos/src/main/java/com/vayunmathur/photos/platform/WallpaperHelper.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/WallpaperHelper.kt b/photos/src/main/java/com/vayunmathur/photos/platform/WallpaperHelper.ktsimilarity index 99%rename from photos/src/main/java/com/vayunmathur/photos/util/WallpaperHelper.ktrename to photos/src/main/java/com/vayunmathur/photos/platform/WallpaperHelper.ktindex 663ad940b2..3f6ce15488 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/WallpaperHelper.kt+++ b/photos/src/main/java/com/vayunmathur/photos/platform/WallpaperHelper.kt@@ -1,4 +1,4 @@-package com.vayunmathur.photos.util+package com.vayunmathur.photos.platform  import android.app.Application import android.app.WallpaperManager
photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.ktindex 25ace2d101..993f922002 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.kt@@ -72,7 +72,7 @@ fun LabeledSlider( }  @Composable-private fun PanelColumn(content: @Composable ColumnScope.() -> Unit) {+internal fun PanelColumn(content: @Composable ColumnScope.() -> Unit) {     Column(         modifier = Modifier             .fillMaxWidth()@@ -84,65 +84,7 @@ private fun PanelColumn(content: @Composable ColumnScope.() -> Unit) { }  @Composable-fun LevelsPanel(levels: LevelsAdjustment, onChange: (LevelsAdjustment) -> Unit) = PanelColumn {-    LabeledSlider(stringResource(R.string.in_black), levels.inBlack, 0f..254f) { onChange(levels.copy(inBlack = it)) }-    LabeledSlider(stringResource(R.string.in_white), levels.inWhite, 1f..255f) { onChange(levels.copy(inWhite = it)) }-    LabeledSlider(stringResource(R.string.gamma), levels.gamma * 100f, 10f..300f) { onChange(levels.copy(gamma = it / 100f)) }-    LabeledSlider(stringResource(R.string.out_black), levels.outBlack, 0f..254f) { onChange(levels.copy(outBlack = it)) }-    LabeledSlider(stringResource(R.string.out_white), levels.outWhite, 1f..255f) { onChange(levels.copy(outWhite = it)) }-}--@Composable-fun ColorBalancePanel(balance: ColorBalanceAdjustment, onChange: (ColorBalanceAdjustment) -> Unit) = PanelColumn {-    var range by remember { mutableStateOf(0) } // 0 shadows, 1 mid, 2 high-    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {-        listOf("Shadows", "Midtones", "Highlights").forEachIndexed { i, label ->-            toggleableItem(checked = range == i, label = label, onCheckedChange = { range = i })-        }-    }-    val rc = when (range) { 0 -> balance.shadowsRedCyan; 1 -> balance.midRedCyan; else -> balance.highRedCyan }-    val gm = when (range) { 0 -> balance.shadowsGreenMagenta; 1 -> balance.midGreenMagenta; else -> balance.highGreenMagenta }-    val by = when (range) { 0 -> balance.shadowsBlueYellow; 1 -> balance.midBlueYellow; else -> balance.highBlueYellow }-    LabeledSlider(stringResource(R.string.red_cyan), rc, -100f..100f) {-        onChange(when (range) {-            0 -> balance.copy(shadowsRedCyan = it); 1 -> balance.copy(midRedCyan = it); else -> balance.copy(highRedCyan = it)-        })-    }-    LabeledSlider(stringResource(R.string.green_mag), gm, -100f..100f) {-        onChange(when (range) {-            0 -> balance.copy(shadowsGreenMagenta = it); 1 -> balance.copy(midGreenMagenta = it); else -> balance.copy(highGreenMagenta = it)-        })-    }-    LabeledSlider(stringResource(R.string.blue_yellow), by, -100f..100f) {-        onChange(when (range) {-            0 -> balance.copy(shadowsBlueYellow = it); 1 -> balance.copy(midBlueYellow = it); else -> balance.copy(highBlueYellow = it)-        })-    }-    SwitchRow("Preserve Luminosity", balance.preserveLuminosity) { onChange(balance.copy(preserveLuminosity = it)) }-}--@Composable-fun ChannelMixerPanel(mixer: ChannelMixerAdjustment, onChange: (ChannelMixerAdjustment) -> Unit) = PanelColumn {-    SwitchRow("Monochrome", mixer.monochrome) { onChange(mixer.copy(monochrome = it)) }-    LabeledSlider("R ← R", mixer.rFromR * 100f, -200f..200f) { onChange(mixer.copy(rFromR = it / 100f)) }-    LabeledSlider("R ← G", mixer.rFromG * 100f, -200f..200f) { onChange(mixer.copy(rFromG = it / 100f)) }-    LabeledSlider("R ← B", mixer.rFromB * 100f, -200f..200f) { onChange(mixer.copy(rFromB = it / 100f)) }-    LabeledSlider("G ← G", mixer.gFromG * 100f, -200f..200f) { onChange(mixer.copy(gFromG = it / 100f)) }-    LabeledSlider("B ← B", mixer.bFromB * 100f, -200f..200f) { onChange(mixer.copy(bFromB = it / 100f)) }-}--@Composable-fun BlackWhitePanel(bw: BlackAndWhiteAdjustment, onChange: (BlackAndWhiteAdjustment) -> Unit) = PanelColumn {-    LabeledSlider(stringResource(R.string.reds), bw.reds, 0f..200f) { onChange(bw.copy(reds = it)) }-    LabeledSlider(stringResource(R.string.yellows), bw.yellows, 0f..200f) { onChange(bw.copy(yellows = it)) }-    LabeledSlider(stringResource(R.string.greens), bw.greens, 0f..200f) { onChange(bw.copy(greens = it)) }-    LabeledSlider(stringResource(R.string.cyans), bw.cyans, 0f..200f) { onChange(bw.copy(cyans = it)) }-    LabeledSlider(stringResource(R.string.blues), bw.blues, 0f..200f) { onChange(bw.copy(blues = it)) }-    LabeledSlider(stringResource(R.string.magentas), bw.magentas, 0f..200f) { onChange(bw.copy(magentas = it)) }-}--@Composable-private fun SwitchRow(label: String, checked: Boolean, onChange: (Boolean) -> Unit) {+internal fun SwitchRow(label: String, checked: Boolean, onChange: (Boolean) -> Unit) {     Row(         modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp),         verticalAlignment = Alignment.CenterVertically,@@ -154,7 +96,7 @@ private fun SwitchRow(label: String, checked: Boolean, onChange: (Boolean) -> Un }  @Composable-private fun ApplyButton(onApply: () -> Unit) {+internal fun ApplyButton(onApply: () -> Unit) {     Row(modifier = Modifier.fillMaxWidth().padding(8.dp), horizontalArrangement = Arrangement.Center) {         Surface(             modifier = Modifier.clickable { onApply() },@@ -170,142 +112,7 @@ private fun ApplyButton(onApply: () -> Unit) {     } } -@Composable-fun GradientMapPanel(onSelect: (List<com.vayunmathur.photos.data.GradientStop>) -> Unit) = PanelColumn {-    val presets = listOf(-        "Grayscale" to listOf(-            com.vayunmathur.photos.data.GradientStop(0f, 0xFF000000.toInt()),-            com.vayunmathur.photos.data.GradientStop(1f, 0xFFFFFFFF.toInt()),-        ),-        "Sepia" to listOf(-            com.vayunmathur.photos.data.GradientStop(0f, 0xFF1B0E00.toInt()),-            com.vayunmathur.photos.data.GradientStop(0.5f, 0xFF8A5A2B.toInt()),-            com.vayunmathur.photos.data.GradientStop(1f, 0xFFFFE9C9.toInt()),-        ),-        "Cool" to listOf(-            com.vayunmathur.photos.data.GradientStop(0f, 0xFF001133.toInt()),-            com.vayunmathur.photos.data.GradientStop(0.5f, 0xFF00AACC.toInt()),-            com.vayunmathur.photos.data.GradientStop(1f, 0xFFFFFFFF.toInt()),-        ),-        "Warm" to listOf(-            com.vayunmathur.photos.data.GradientStop(0f, 0xFF330000.toInt()),-            com.vayunmathur.photos.data.GradientStop(0.5f, 0xFFCC5500.toInt()),-            com.vayunmathur.photos.data.GradientStop(1f, 0xFFFFFF66.toInt()),-        ),-    )-    Row(-        modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 8.dp),-        horizontalArrangement = Arrangement.spacedBy(8.dp),-    ) {-        presets.forEach { (label, stops) ->-            Surface(-                modifier = Modifier.clickable { onSelect(stops) },-                shape = RoundedCornerShape(6.dp),-                color = MaterialTheme.colorScheme.secondaryContainer,-            ) { Text(label, fontSize = 12.sp, modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp)) }-        }-    }-}- /**  * Destructive filters applied to the active pixel layer. Builds the chosen transform and  * hands it to [onApply], which runs it on a background thread in the view model.  */-@Composable-fun FiltersPanel(onAddFx: (com.vayunmathur.photos.data.LayerAdjustment) -> Unit) = PanelColumn {-    var tool by remember { mutableStateOf("Sharpen") }-    var amount by remember { mutableFloatStateOf(50f) }-    var radius by remember { mutableFloatStateOf(2f) }-    var angle by remember { mutableFloatStateOf(0f) }-    val tools = listOf("Sharpen", "Gaussian", "Motion", "Radial", "Spin", "Noise", "Find Edges", "Emboss")-    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {-        tools.forEach { t -> toggleableItem(checked = tool == t, label = t, onCheckedChange = { tool = t }) }-    }-    when (tool) {-        "Sharpen" -> {-            LabeledSlider(stringResource(R.string.amount), amount, 0f..100f) { amount = it }-            LabeledSlider(stringResource(R.string.radius), radius, 0.5f..10f) { radius = it }-        }-        "Motion" -> {-            LabeledSlider(stringResource(R.string.length), amount, 1f..100f) { amount = it }-            LabeledSlider(stringResource(R.string.angle), angle, 0f..360f) { angle = it }-        }-        "Noise" -> LabeledSlider(stringResource(R.string.amount), amount, 0f..100f) { amount = it }-        else -> LabeledSlider(stringResource(R.string.amount), amount, 1f..100f) { amount = it }-    }-    ApplyButton {-        val a = amount; val r = radius; val ang = angle-        when (tool) {-            "Sharpen" -> onAddFx(com.vayunmathur.photos.data.UnsharpAdj(UnsharpMask(amount = a, radius = r)))-            "Gaussian" -> onAddFx(com.vayunmathur.photos.data.FilterBlurAdj(FilterBlur(FilterBlurMode.Gaussian, amount = a)))-            "Motion" -> onAddFx(com.vayunmathur.photos.data.FilterBlurAdj(FilterBlur(FilterBlurMode.Motion, amount = a, angle = ang)))-            "Radial" -> onAddFx(com.vayunmathur.photos.data.FilterBlurAdj(FilterBlur(FilterBlurMode.Radial, amount = a)))-            "Spin" -> onAddFx(com.vayunmathur.photos.data.FilterBlurAdj(FilterBlur(FilterBlurMode.Spin, amount = a)))-            "Noise" -> onAddFx(com.vayunmathur.photos.data.NoiseAdj(NoiseParams(amount = a)))-            "Find Edges" -> onAddFx(com.vayunmathur.photos.data.StylizeAdj(StylizeParams(StylizeMode.FindEdges)))-            "Emboss" -> onAddFx(com.vayunmathur.photos.data.StylizeAdj(StylizeParams(StylizeMode.Emboss)))-        }-    }-}--@Composable-fun VibrancePanel(amount: Float, onChange: (Float) -> Unit) = PanelColumn {-    LabeledSlider(stringResource(R.string.vibrance), amount, -100f..100f, onChange)-}--@Composable-fun PosterizePanel(levels: Int, onChange: (Int) -> Unit) = PanelColumn {-    LabeledSlider(stringResource(R.string.levels), levels.toFloat(), 2f..64f) { onChange(it.roundToInt()) }-}--@Composable-fun ThresholdPanel(level: Int, onChange: (Int) -> Unit) = PanelColumn {-    LabeledSlider(stringResource(R.string.level), level.toFloat(), 0f..255f) { onChange(it.roundToInt()) }-}--@Composable-fun InvertPanel() = PanelColumn {-    Text(stringResource(R.string.colors_inverted_toggle_the_layer_s_visib),-        fontSize = 12.sp,-        modifier = Modifier.padding(horizontal = 8.dp),-        color = MaterialTheme.colorScheme.onSurfaceVariant,-    )-}--@Composable-fun PhotoFilterPanel(adj: PhotoFilterAdj, onChange: (PhotoFilterAdj) -> Unit) = PanelColumn {-    val presets = listOf(-        "Warm" to 0xFFEC8A00.toInt(),-        "Cool" to 0xFF00B4EC.toInt(),-        "Sepia" to 0xFF9C6B30.toInt(),-        "Red" to 0xFFEA3323.toInt(),-        "Green" to 0xFF00A651.toInt(),-        "Blue" to 0xFF2E5CFF.toInt(),-    )-    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {-        presets.forEach { (name, color) ->-            toggleableItem(-                checked = adj.color == color,-                label = name,-                onCheckedChange = { onChange(adj.copy(color = color)) },-            )-        }-    }-    LabeledSlider(stringResource(R.string.density), adj.density * 100f, 0f..100f) { onChange(adj.copy(density = it / 100f)) }-}--@Composable-fun SelectiveColorPanel(adj: SelectiveColorAdj, onChange: (SelectiveColorAdj) -> Unit) = PanelColumn {-    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {-        SelectiveColorRange.entries.forEach { range ->-            toggleableItem(-                checked = adj.range == range,-                label = range.name,-                onCheckedChange = { onChange(adj.copy(range = range)) },-            )-        }-    }-    LabeledSlider(stringResource(R.string.cyan), adj.cyan, -100f..100f) { onChange(adj.copy(cyan = it)) }-    LabeledSlider(stringResource(R.string.magenta), adj.magenta, -100f..100f) { onChange(adj.copy(magenta = it)) }-    LabeledSlider(stringResource(R.string.yellow), adj.yellow, -100f..100f) { onChange(adj.copy(yellow = it)) }-}
photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.ktindex b653adf353..2b89f27306 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailPage.kt@@ -16,8 +16,8 @@ import androidx.compose.ui.platform.LocalContext import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.photos.Route import com.vayunmathur.photos.data.Photo-import com.vayunmathur.photos.util.AlbumMediaStore-import com.vayunmathur.photos.util.GalleryViewModel+import com.vayunmathur.photos.platform.AlbumMediaStore+import com.vayunmathur.photos.platform.GalleryViewModel  /** Binds [GalleryViewModel] to the stateless [AlbumDetailScreen] for one album. */ @Composable
photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.ktindex 7e1670afc8..c4473bda15 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumDetailScreen.kt@@ -36,15 +36,16 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalResources import androidx.compose.ui.res.stringResource+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.unit.dp import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.photos.LocalColumnCount+import com.vayunmathur.photos.ui.LocalColumnCount import com.vayunmathur.photos.R import com.vayunmathur.photos.Route import com.vayunmathur.photos.data.Photo-import com.vayunmathur.photos.pushPhoto-import com.vayunmathur.photos.util.Album-import com.vayunmathur.photos.util.ImageLoader+import com.vayunmathur.photos.platform.pushPhoto+import com.vayunmathur.photos.platform.Album+import com.vayunmathur.photos.platform.ImageLoader import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import kotlin.math.roundToInt@@ -106,7 +107,7 @@ fun AlbumDetailScreen(     }      AppScaffold(-        title = if (isSelectionMode) stringResource(R.string.items_selected, selectedIds.size) else title,+        title = if (isSelectionMode) pluralStringResource(R.plurals.items_selected, selectedIds.size, selectedIds.size) else title,         onNavigateBack = if (isSelectionMode) null else ({ backStack.pop() }),         onClose = if (isSelectionMode) ({ onClearSelection() }) else null,         scrollBehavior = appBarScrollBehavior(),
photos/src/main/java/com/vayunmathur/photos/ui/AlbumPickerDialog.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumPickerDialog.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumPickerDialog.ktindex 3b3b995fbd..ee47ff44fd 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumPickerDialog.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumPickerDialog.kt@@ -22,7 +22,7 @@ import com.vayunmathur.library.ui.OutlinedTextField import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton import com.vayunmathur.photos.R-import com.vayunmathur.photos.util.Album+import com.vayunmathur.photos.platform.Album  /**  * Picks a destination album for the current selection: either an existing album
photos/src/main/java/com/vayunmathur/photos/ui/AlbumsPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumsPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumsPage.ktindex 7840a8eb1f..f691c95c14 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumsPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumsPage.kt@@ -7,11 +7,11 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.derivedStateOf import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.photos.Route-import com.vayunmathur.photos.util.AlbumsUiState-import com.vayunmathur.photos.util.DefaultAlbum-import com.vayunmathur.photos.util.DefaultAlbumKind-import com.vayunmathur.photos.util.GalleryViewModel-import com.vayunmathur.photos.util.SecureFolderViewModel+import com.vayunmathur.photos.platform.AlbumsUiState+import com.vayunmathur.photos.platform.DefaultAlbum+import com.vayunmathur.photos.platform.DefaultAlbumKind+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.SecureFolderViewModel  /** Binds [GalleryViewModel] to the stateless [AlbumsScreen]. */ @Composable
photos/src/main/java/com/vayunmathur/photos/ui/AlbumsScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumsScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumsScreen.ktindex 86ab9f4b90..1a9dbe2511 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AlbumsScreen.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AlbumsScreen.kt@@ -37,14 +37,14 @@ import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.invisibleClickable import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.photos.NavigationBar+import com.vayunmathur.photos.ui.NavigationBar import com.vayunmathur.photos.R import com.vayunmathur.photos.Route import com.vayunmathur.photos.data.Photo-import com.vayunmathur.photos.util.Album-import com.vayunmathur.photos.util.AlbumsUiState-import com.vayunmathur.photos.util.DefaultAlbum-import com.vayunmathur.photos.util.DefaultAlbumKind+import com.vayunmathur.photos.platform.Album+import com.vayunmathur.photos.platform.AlbumsUiState+import com.vayunmathur.photos.platform.DefaultAlbum+import com.vayunmathur.photos.platform.DefaultAlbumKind  /**  * The albums grid, with no dependency on the ViewModel so it can be rendered from a
photos/src/main/java/com/vayunmathur/photos/ui/BlackWhitePanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/BlackWhitePanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/BlackWhitePanel.ktnew file mode 100644index 0000000000..8b1e4f40df--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/BlackWhitePanel.kt@@ -0,0 +1,59 @@+package com.vayunmathur.photos.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import com.vayunmathur.library.ui.ButtonGroup+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Slider+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.vayunmathur.photos.data.BlackAndWhiteAdjustment+import com.vayunmathur.photos.data.ChannelMixerAdjustment+import com.vayunmathur.photos.data.ColorBalanceAdjustment+import com.vayunmathur.photos.data.FilterBlur+import com.vayunmathur.photos.data.FilterBlurMode+import com.vayunmathur.photos.data.LevelsAdjustment+import com.vayunmathur.photos.data.NoiseParams+import com.vayunmathur.photos.data.PhotoFilterAdj+import com.vayunmathur.photos.data.SelectiveColorAdj+import com.vayunmathur.photos.data.SelectiveColorRange+import com.vayunmathur.photos.data.StylizeMode+import com.vayunmathur.photos.data.StylizeParams+import com.vayunmathur.photos.data.UnsharpMask+import com.vayunmathur.photos.data.applyToBitmap+import kotlin.math.roundToInt+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.photos.R++@Composable+fun BlackWhitePanel(bw: BlackAndWhiteAdjustment, onChange: (BlackAndWhiteAdjustment) -> Unit) = PanelColumn {+    LabeledSlider(stringResource(R.string.reds), bw.reds, 0f..200f) { onChange(bw.copy(reds = it)) }+    LabeledSlider(stringResource(R.string.yellows), bw.yellows, 0f..200f) { onChange(bw.copy(yellows = it)) }+    LabeledSlider(stringResource(R.string.greens), bw.greens, 0f..200f) { onChange(bw.copy(greens = it)) }+    LabeledSlider(stringResource(R.string.cyans), bw.cyans, 0f..200f) { onChange(bw.copy(cyans = it)) }+    LabeledSlider(stringResource(R.string.blues), bw.blues, 0f..200f) { onChange(bw.copy(blues = it)) }+    LabeledSlider(stringResource(R.string.magentas), bw.magentas, 0f..200f) { onChange(bw.copy(magentas = it)) }+}
photos/src/main/java/com/vayunmathur/photos/ui/ChannelMixerPanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/ChannelMixerPanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/ChannelMixerPanel.ktnew file mode 100644index 0000000000..9548daa72a--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/ChannelMixerPanel.kt@@ -0,0 +1,59 @@+package com.vayunmathur.photos.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import com.vayunmathur.library.ui.ButtonGroup+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Slider+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.vayunmathur.photos.data.BlackAndWhiteAdjustment+import com.vayunmathur.photos.data.ChannelMixerAdjustment+import com.vayunmathur.photos.data.ColorBalanceAdjustment+import com.vayunmathur.photos.data.FilterBlur+import com.vayunmathur.photos.data.FilterBlurMode+import com.vayunmathur.photos.data.LevelsAdjustment+import com.vayunmathur.photos.data.NoiseParams+import com.vayunmathur.photos.data.PhotoFilterAdj+import com.vayunmathur.photos.data.SelectiveColorAdj+import com.vayunmathur.photos.data.SelectiveColorRange+import com.vayunmathur.photos.data.StylizeMode+import com.vayunmathur.photos.data.StylizeParams+import com.vayunmathur.photos.data.UnsharpMask+import com.vayunmathur.photos.data.applyToBitmap+import kotlin.math.roundToInt+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.photos.R++@Composable+fun ChannelMixerPanel(mixer: ChannelMixerAdjustment, onChange: (ChannelMixerAdjustment) -> Unit) = PanelColumn {+    SwitchRow("Monochrome", mixer.monochrome) { onChange(mixer.copy(monochrome = it)) }+    LabeledSlider("R ← R", mixer.rFromR * 100f, -200f..200f) { onChange(mixer.copy(rFromR = it / 100f)) }+    LabeledSlider("R ← G", mixer.rFromG * 100f, -200f..200f) { onChange(mixer.copy(rFromG = it / 100f)) }+    LabeledSlider("R ← B", mixer.rFromB * 100f, -200f..200f) { onChange(mixer.copy(rFromB = it / 100f)) }+    LabeledSlider("G ← G", mixer.gFromG * 100f, -200f..200f) { onChange(mixer.copy(gFromG = it / 100f)) }+    LabeledSlider("B ← B", mixer.bFromB * 100f, -200f..200f) { onChange(mixer.copy(bFromB = it / 100f)) }+}
photos/src/main/java/com/vayunmathur/photos/ui/ColorBalancePanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/ColorBalancePanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/ColorBalancePanel.ktnew file mode 100644index 0000000000..9469afa479--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/ColorBalancePanel.kt@@ -0,0 +1,79 @@+package com.vayunmathur.photos.ui+import androidx.compose.runtime.mutableIntStateOf++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import com.vayunmathur.library.ui.ButtonGroup+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Slider+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.vayunmathur.photos.data.BlackAndWhiteAdjustment+import com.vayunmathur.photos.data.ChannelMixerAdjustment+import com.vayunmathur.photos.data.ColorBalanceAdjustment+import com.vayunmathur.photos.data.FilterBlur+import com.vayunmathur.photos.data.FilterBlurMode+import com.vayunmathur.photos.data.LevelsAdjustment+import com.vayunmathur.photos.data.NoiseParams+import com.vayunmathur.photos.data.PhotoFilterAdj+import com.vayunmathur.photos.data.SelectiveColorAdj+import com.vayunmathur.photos.data.SelectiveColorRange+import com.vayunmathur.photos.data.StylizeMode+import com.vayunmathur.photos.data.StylizeParams+import com.vayunmathur.photos.data.UnsharpMask+import com.vayunmathur.photos.data.applyToBitmap+import kotlin.math.roundToInt+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.photos.R++@Composable+fun ColorBalancePanel(balance: ColorBalanceAdjustment, onChange: (ColorBalanceAdjustment) -> Unit) = PanelColumn {+    var range by remember { mutableIntStateOf(0) } // 0 shadows, 1 mid, 2 high+    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {+        listOf("Shadows", "Midtones", "Highlights").forEachIndexed { i, label ->+            toggleableItem(checked = range == i, label = label, onCheckedChange = { range = i })+        }+    }+    val rc = when (range) { 0 -> balance.shadowsRedCyan; 1 -> balance.midRedCyan; else -> balance.highRedCyan }+    val gm = when (range) { 0 -> balance.shadowsGreenMagenta; 1 -> balance.midGreenMagenta; else -> balance.highGreenMagenta }+    val by = when (range) { 0 -> balance.shadowsBlueYellow; 1 -> balance.midBlueYellow; else -> balance.highBlueYellow }+    LabeledSlider(stringResource(R.string.red_cyan), rc, -100f..100f) {+        onChange(when (range) {+            0 -> balance.copy(shadowsRedCyan = it); 1 -> balance.copy(midRedCyan = it); else -> balance.copy(highRedCyan = it)+        })+    }+    LabeledSlider(stringResource(R.string.green_mag), gm, -100f..100f) {+        onChange(when (range) {+            0 -> balance.copy(shadowsGreenMagenta = it); 1 -> balance.copy(midGreenMagenta = it); else -> balance.copy(highGreenMagenta = it)+        })+    }+    LabeledSlider(stringResource(R.string.blue_yellow), by, -100f..100f) {+        onChange(when (range) {+            0 -> balance.copy(shadowsBlueYellow = it); 1 -> balance.copy(midBlueYellow = it); else -> balance.copy(highBlueYellow = it)+        })+    }+    SwitchRow("Preserve Luminosity", balance.preserveLuminosity) { onChange(balance.copy(preserveLuminosity = it)) }+}
photos/src/main/java/com/vayunmathur/photos/ui/EditActivity.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/EditActivity.kt b/photos/src/main/java/com/vayunmathur/photos/ui/EditActivity.ktindex c4f5be1c40..93c276c819 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/EditActivity.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/EditActivity.kt@@ -19,8 +19,8 @@ import com.vayunmathur.library.util.FullscreenPage import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.rememberNavBackStack import com.vayunmathur.photos.data.PhotosRepository-import com.vayunmathur.photos.util.PhotoEditViewModel-import com.vayunmathur.photos.util.PhotoEditViewModelFactory+import com.vayunmathur.photos.platform.PhotoEditViewModel+import com.vayunmathur.photos.platform.PhotoEditViewModelFactory import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext 
photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoActivePanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoActivePanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoActivePanel.ktindex 53b74f8b1e..f01c82e686 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoActivePanel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoActivePanel.kt@@ -68,7 +68,7 @@ import com.vayunmathur.photos.data.SelectiveMask import com.vayunmathur.photos.data.ThresholdAdj import com.vayunmathur.photos.data.VibranceAdj import com.vayunmathur.photos.data.toColorMatrix-import com.vayunmathur.photos.util.PhotoEditViewModel+import com.vayunmathur.photos.platform.PhotoEditViewModel import kotlin.math.roundToInt  @Composable
photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoAdjustPanels.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoAdjustPanels.kt b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoAdjustPanels.ktindex 133390d8fe..33952a667c 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoAdjustPanels.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoAdjustPanels.kt@@ -68,7 +68,7 @@ import com.vayunmathur.photos.data.SelectiveMask import com.vayunmathur.photos.data.ThresholdAdj import com.vayunmathur.photos.data.VibranceAdj import com.vayunmathur.photos.data.toColorMatrix-import com.vayunmathur.photos.util.PhotoEditViewModel+import com.vayunmathur.photos.platform.PhotoEditViewModel import kotlin.math.roundToInt  @Composable
photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoBottomControls.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoBottomControls.kt b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoBottomControls.ktindex 6b0d62f566..523a34bbab 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoBottomControls.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoBottomControls.kt@@ -26,7 +26,7 @@ import com.vayunmathur.photos.R import com.vayunmathur.photos.data.DrawingLayer import com.vayunmathur.photos.data.DrawingTool import com.vayunmathur.photos.data.TextLayer-import com.vayunmathur.photos.util.segmentSubject+import com.vayunmathur.photos.platform.segmentSubject  // Bottom controls: Home (category bar) or a tool screen. Placed below the image in a // Column so opening a panel shrinks the image instead of covering it. The Surface fills
photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoEditorState.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoEditorState.kt b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoEditorState.ktindex 37cbea301e..d667ee942e 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoEditorState.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoEditorState.kt@@ -28,8 +28,8 @@ import com.vayunmathur.photos.data.Selection import com.vayunmathur.photos.data.SelectionCombine import com.vayunmathur.photos.data.SelectiveMask import com.vayunmathur.photos.data.TextElement-import com.vayunmathur.photos.util.ExportFormat-import com.vayunmathur.photos.util.PhotoEditViewModel+import com.vayunmathur.photos.platform.ExportFormat+import com.vayunmathur.photos.platform.PhotoEditViewModel import kotlin.math.abs import kotlin.math.cos import kotlin.math.roundToInt
photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoPage.ktindex e1520a802b..8ebe250919 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/EditPhotoPage.kt@@ -49,8 +49,8 @@ import com.vayunmathur.photos.data.SmudgeStroke import com.vayunmathur.photos.data.SmudgeStrokes import com.vayunmathur.photos.data.applyHealingToBitmap import com.vayunmathur.photos.data.applyToBitmap-import com.vayunmathur.photos.util.ExportFormat-import com.vayunmathur.photos.util.PhotoEditViewModel+import com.vayunmathur.photos.platform.ExportFormat+import com.vayunmathur.photos.platform.PhotoEditViewModel  @OptIn(ExperimentalMaterial3Api::class) @Composable
photos/src/main/java/com/vayunmathur/photos/ui/FaceBoxLayer.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/FaceBoxLayer.kt b/photos/src/main/java/com/vayunmathur/photos/ui/FaceBoxLayer.ktindex 410b876676..2b47498451 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/FaceBoxLayer.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/FaceBoxLayer.kt@@ -26,7 +26,7 @@ import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.invisibleClickable-import com.vayunmathur.photos.util.PhotoFaceBoxes+import com.vayunmathur.photos.platform.PhotoFaceBoxes import kotlin.math.roundToInt  /**
photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.ktindex 76bd8deb2d..dcba3f3c81 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesPage.kt@@ -7,9 +7,9 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.photos.Route-import com.vayunmathur.photos.util.GalleryUiState-import com.vayunmathur.photos.util.GalleryViewModel-import com.vayunmathur.photos.util.SecureFolderViewModel+import com.vayunmathur.photos.platform.GalleryUiState+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.SecureFolderViewModel  /** Binds [GalleryViewModel] to the stateless [FavoritesScreen]. */ @Composable
photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.ktindex c8f6217c5e..2325c87842 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/FavoritesScreen.kt@@ -17,6 +17,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalResources import androidx.compose.ui.res.stringResource+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.AppPullToRefreshBox import com.vayunmathur.library.ui.AppScaffold@@ -26,15 +27,15 @@ import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.photos.LocalColumnCount+import com.vayunmathur.photos.ui.LocalColumnCount import com.vayunmathur.photos.R import com.vayunmathur.photos.Route import com.vayunmathur.photos.data.Photo import com.vayunmathur.photos.domain.FavoriteRule-import com.vayunmathur.photos.pushPhoto-import com.vayunmathur.photos.util.GalleryActions-import com.vayunmathur.photos.util.GalleryUiState-import com.vayunmathur.photos.util.ImageLoader+import com.vayunmathur.photos.platform.pushPhoto+import com.vayunmathur.photos.platform.GalleryActions+import com.vayunmathur.photos.platform.GalleryUiState+import com.vayunmathur.photos.platform.ImageLoader import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import kotlin.math.roundToInt@@ -79,7 +80,7 @@ fun FavoritesScreen(      AppScaffold(         title = if (isSelectionMode) {-            stringResource(R.string.items_selected, state.selectedIds.size)+            pluralStringResource(R.plurals.items_selected, state.selectedIds.size, state.selectedIds.size)         } else {             stringResource(R.string.label_favorites)         },
photos/src/main/java/com/vayunmathur/photos/ui/FiltersPanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/FiltersPanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/FiltersPanel.ktnew file mode 100644index 0000000000..ceac3095e6--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/FiltersPanel.kt@@ -0,0 +1,86 @@+package com.vayunmathur.photos.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import com.vayunmathur.library.ui.ButtonGroup+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Slider+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.vayunmathur.photos.data.BlackAndWhiteAdjustment+import com.vayunmathur.photos.data.ChannelMixerAdjustment+import com.vayunmathur.photos.data.ColorBalanceAdjustment+import com.vayunmathur.photos.data.FilterBlur+import com.vayunmathur.photos.data.FilterBlurMode+import com.vayunmathur.photos.data.LevelsAdjustment+import com.vayunmathur.photos.data.NoiseParams+import com.vayunmathur.photos.data.PhotoFilterAdj+import com.vayunmathur.photos.data.SelectiveColorAdj+import com.vayunmathur.photos.data.SelectiveColorRange+import com.vayunmathur.photos.data.StylizeMode+import com.vayunmathur.photos.data.StylizeParams+import com.vayunmathur.photos.data.UnsharpMask+import com.vayunmathur.photos.data.applyToBitmap+import kotlin.math.roundToInt+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.photos.R++@Composable+fun FiltersPanel(onAddFx: (com.vayunmathur.photos.data.LayerAdjustment) -> Unit) = PanelColumn {+    var tool by remember { mutableStateOf("Sharpen") }+    var amount by remember { mutableFloatStateOf(50f) }+    var radius by remember { mutableFloatStateOf(2f) }+    var angle by remember { mutableFloatStateOf(0f) }+    val tools = listOf("Sharpen", "Gaussian", "Motion", "Radial", "Spin", "Noise", "Find Edges", "Emboss")+    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {+        tools.forEach { t -> toggleableItem(checked = tool == t, label = t, onCheckedChange = { tool = t }) }+    }+    when (tool) {+        "Sharpen" -> {+            LabeledSlider(stringResource(R.string.amount), amount, 0f..100f) { amount = it }+            LabeledSlider(stringResource(R.string.radius), radius, 0.5f..10f) { radius = it }+        }+        "Motion" -> {+            LabeledSlider(stringResource(R.string.length), amount, 1f..100f) { amount = it }+            LabeledSlider(stringResource(R.string.angle), angle, 0f..360f) { angle = it }+        }+        "Noise" -> LabeledSlider(stringResource(R.string.amount), amount, 0f..100f) { amount = it }+        else -> LabeledSlider(stringResource(R.string.amount), amount, 1f..100f) { amount = it }+    }+    ApplyButton {+        val a = amount; val r = radius; val ang = angle+        when (tool) {+            "Sharpen" -> onAddFx(com.vayunmathur.photos.data.UnsharpAdj(UnsharpMask(amount = a, radius = r)))+            "Gaussian" -> onAddFx(com.vayunmathur.photos.data.FilterBlurAdj(FilterBlur(FilterBlurMode.Gaussian, amount = a)))+            "Motion" -> onAddFx(com.vayunmathur.photos.data.FilterBlurAdj(FilterBlur(FilterBlurMode.Motion, amount = a, angle = ang)))+            "Radial" -> onAddFx(com.vayunmathur.photos.data.FilterBlurAdj(FilterBlur(FilterBlurMode.Radial, amount = a)))+            "Spin" -> onAddFx(com.vayunmathur.photos.data.FilterBlurAdj(FilterBlur(FilterBlurMode.Spin, amount = a)))+            "Noise" -> onAddFx(com.vayunmathur.photos.data.NoiseAdj(NoiseParams(amount = a)))+            "Find Edges" -> onAddFx(com.vayunmathur.photos.data.StylizeAdj(StylizeParams(StylizeMode.FindEdges)))+            "Emboss" -> onAddFx(com.vayunmathur.photos.data.StylizeAdj(StylizeParams(StylizeMode.Emboss)))+        }+    }+}
photos/src/main/java/com/vayunmathur/photos/ui/GalleryPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/GalleryPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/GalleryPage.ktindex 783a3e4272..0b42531b5a 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/GalleryPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/GalleryPage.kt@@ -15,10 +15,10 @@ import androidx.compose.ui.platform.LocalContext import androidx.core.net.toUri import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.photos.Route-import com.vayunmathur.photos.util.GalleryUiState-import com.vayunmathur.photos.util.GalleryViewModel-import com.vayunmathur.photos.util.SecureFolderViewModel-import com.vayunmathur.photos.util.enqueueSyncWork+import com.vayunmathur.photos.platform.GalleryUiState+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.SecureFolderViewModel+import com.vayunmathur.photos.platform.enqueueSyncWork  /** Binds [GalleryViewModel] to the stateless [GalleryScreen]. */ @Composable
photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.ktindex f686230713..d968f2bfaa 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/GalleryScreen.kt@@ -47,6 +47,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalResources import androidx.compose.ui.res.stringResource+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.unit.dp import androidx.core.net.toUri import androidx.fragment.app.FragmentActivity@@ -55,19 +56,19 @@ import com.vayunmathur.library.ui.IconSearch import com.vayunmathur.library.ui.invisibleClickable import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.sharedContainer-import com.vayunmathur.photos.LocalColumnCount-import com.vayunmathur.photos.NavigationBar-import com.vayunmathur.photos.pushPhoto+import com.vayunmathur.photos.ui.LocalColumnCount+import com.vayunmathur.photos.ui.NavigationBar+import com.vayunmathur.photos.platform.pushPhoto import com.vayunmathur.photos.R import com.vayunmathur.photos.Route import com.vayunmathur.photos.data.Photo import com.vayunmathur.photos.domain.FavoriteRule-import com.vayunmathur.photos.util.GalleryActions-import com.vayunmathur.photos.util.GalleryUiState-import com.vayunmathur.photos.util.GalleryViewModel-import com.vayunmathur.photos.util.ImageLoader-import com.vayunmathur.photos.util.SearchAiState-import com.vayunmathur.photos.util.SecureFolderViewModel+import com.vayunmathur.photos.platform.GalleryActions+import com.vayunmathur.photos.platform.GalleryUiState+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.ImageLoader+import com.vayunmathur.photos.platform.SearchAiState+import com.vayunmathur.photos.platform.SecureFolderViewModel import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone import kotlinx.datetime.toLocalDateTime@@ -142,7 +143,7 @@ fun GalleryScreen(             Column {                 if (isSelectionMode) {                     TopAppBar(-                        title = { Text(stringResource(R.string.items_selected, state.selectedIds.size)) },+                        title = { Text(pluralStringResource(R.plurals.items_selected, state.selectedIds.size, state.selectedIds.size)) },                         navigationIcon = {                             IconButton(onClick = { actions.clearSelection() }) {                                 IconClose()@@ -227,7 +228,7 @@ fun GalleryScreen(                                 val pct = state.ocrCount * 100 / state.ocrTargetCount                                 ListItem(                                     content = { Text(stringResource(R.string.of_photos_processed, pct)) },-                                    supportingContent = { Text(stringResource(R.string.photos_indexed_for_text_search, state.ocrCount, state.ocrTargetCount)) },+                                    supportingContent = { Text(pluralStringResource(R.plurals.photos_indexed_for_text_search, state.ocrTargetCount, state.ocrCount, state.ocrTargetCount)) },                                     leadingContent = {                                         CircularProgressIndicator(                                             progress = { state.ocrCount.toFloat() / state.ocrTargetCount },@@ -241,7 +242,7 @@ fun GalleryScreen(                                 val pct = state.clipCount * 100 / state.clipTargetCount                                 ListItem(                                     content = { Text(stringResource(R.string.of_photos_processed, pct)) },-                                    supportingContent = { Text(stringResource(R.string.photos_indexed_for_visual_search, state.clipCount, state.clipTargetCount)) },+                                    supportingContent = { Text(pluralStringResource(R.plurals.photos_indexed_for_visual_search, state.clipTargetCount, state.clipCount, state.clipTargetCount)) },                                     leadingContent = {                                         CircularProgressIndicator(                                             progress = { state.clipCount.toFloat() / state.clipTargetCount },
photos/src/main/java/com/vayunmathur/photos/ui/GallerySelectionActions.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/GallerySelectionActions.kt b/photos/src/main/java/com/vayunmathur/photos/ui/GallerySelectionActions.ktindex eb471acbb9..abd96ff3e7 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/GallerySelectionActions.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/GallerySelectionActions.kt@@ -9,7 +9,7 @@ import com.vayunmathur.library.ui.IconFavorite import com.vayunmathur.library.ui.IconFavoriteBorder import com.vayunmathur.library.ui.IconLock import com.vayunmathur.photos.R-import com.vayunmathur.photos.util.GalleryActions+import com.vayunmathur.photos.platform.GalleryActions  /**  * The multi-select top bar actions shared by the gallery and the Favorites
photos/src/main/java/com/vayunmathur/photos/ui/GradientMapPanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/GradientMapPanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/GradientMapPanel.ktnew file mode 100644index 0000000000..494cbf6cb9--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/GradientMapPanel.kt@@ -0,0 +1,86 @@+package com.vayunmathur.photos.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import com.vayunmathur.library.ui.ButtonGroup+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Slider+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.vayunmathur.photos.data.BlackAndWhiteAdjustment+import com.vayunmathur.photos.data.ChannelMixerAdjustment+import com.vayunmathur.photos.data.ColorBalanceAdjustment+import com.vayunmathur.photos.data.FilterBlur+import com.vayunmathur.photos.data.FilterBlurMode+import com.vayunmathur.photos.data.LevelsAdjustment+import com.vayunmathur.photos.data.NoiseParams+import com.vayunmathur.photos.data.PhotoFilterAdj+import com.vayunmathur.photos.data.SelectiveColorAdj+import com.vayunmathur.photos.data.SelectiveColorRange+import com.vayunmathur.photos.data.StylizeMode+import com.vayunmathur.photos.data.StylizeParams+import com.vayunmathur.photos.data.UnsharpMask+import com.vayunmathur.photos.data.applyToBitmap+import kotlin.math.roundToInt+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.photos.R++@Composable+fun GradientMapPanel(onSelect: (List<com.vayunmathur.photos.data.GradientStop>) -> Unit) = PanelColumn {+    val presets = listOf(+        "Grayscale" to listOf(+            com.vayunmathur.photos.data.GradientStop(0f, 0xFF000000.toInt()),+            com.vayunmathur.photos.data.GradientStop(1f, 0xFFFFFFFF.toInt()),+        ),+        "Sepia" to listOf(+            com.vayunmathur.photos.data.GradientStop(0f, 0xFF1B0E00.toInt()),+            com.vayunmathur.photos.data.GradientStop(0.5f, 0xFF8A5A2B.toInt()),+            com.vayunmathur.photos.data.GradientStop(1f, 0xFFFFE9C9.toInt()),+        ),+        "Cool" to listOf(+            com.vayunmathur.photos.data.GradientStop(0f, 0xFF001133.toInt()),+            com.vayunmathur.photos.data.GradientStop(0.5f, 0xFF00AACC.toInt()),+            com.vayunmathur.photos.data.GradientStop(1f, 0xFFFFFFFF.toInt()),+        ),+        "Warm" to listOf(+            com.vayunmathur.photos.data.GradientStop(0f, 0xFF330000.toInt()),+            com.vayunmathur.photos.data.GradientStop(0.5f, 0xFFCC5500.toInt()),+            com.vayunmathur.photos.data.GradientStop(1f, 0xFFFFFF66.toInt()),+        ),+    )+    Row(+        modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 8.dp),+        horizontalArrangement = Arrangement.spacedBy(8.dp),+    ) {+        presets.forEach { (label, stops) ->+            Surface(+                modifier = Modifier.clickable { onSelect(stops) },+                shape = RoundedCornerShape(6.dp),+                color = MaterialTheme.colorScheme.secondaryContainer,+            ) { Text(label, fontSize = 12.sp, modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp)) }+        }+    }+}
photos/src/main/java/com/vayunmathur/photos/ui/InvertPanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/InvertPanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/InvertPanel.ktnew file mode 100644index 0000000000..61c4e289c7--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/InvertPanel.kt@@ -0,0 +1,58 @@+package com.vayunmathur.photos.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import com.vayunmathur.library.ui.ButtonGroup+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Slider+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.vayunmathur.photos.data.BlackAndWhiteAdjustment+import com.vayunmathur.photos.data.ChannelMixerAdjustment+import com.vayunmathur.photos.data.ColorBalanceAdjustment+import com.vayunmathur.photos.data.FilterBlur+import com.vayunmathur.photos.data.FilterBlurMode+import com.vayunmathur.photos.data.LevelsAdjustment+import com.vayunmathur.photos.data.NoiseParams+import com.vayunmathur.photos.data.PhotoFilterAdj+import com.vayunmathur.photos.data.SelectiveColorAdj+import com.vayunmathur.photos.data.SelectiveColorRange+import com.vayunmathur.photos.data.StylizeMode+import com.vayunmathur.photos.data.StylizeParams+import com.vayunmathur.photos.data.UnsharpMask+import com.vayunmathur.photos.data.applyToBitmap+import kotlin.math.roundToInt+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.photos.R++@Composable+fun InvertPanel() = PanelColumn {+    Text(stringResource(R.string.colors_inverted_toggle_the_layer_s_visib),+        fontSize = 12.sp,+        modifier = Modifier.padding(horizontal = 8.dp),+        color = MaterialTheme.colorScheme.onSurfaceVariant,+    )+}
photos/src/main/java/com/vayunmathur/photos/ui/LevelsPanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/LevelsPanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/LevelsPanel.ktnew file mode 100644index 0000000000..13bf787039--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/LevelsPanel.kt@@ -0,0 +1,58 @@+package com.vayunmathur.photos.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.horizontalScroll+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.shape.RoundedCornerShape+import com.vayunmathur.library.ui.ButtonGroup+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Slider+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Switch+import com.vayunmathur.library.ui.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.vayunmathur.photos.data.BlackAndWhiteAdjustment+import com.vayunmathur.photos.data.ChannelMixerAdjustment+import com.vayunmathur.photos.data.ColorBalanceAdjustment+import com.vayunmathur.photos.data.FilterBlur+import com.vayunmathur.photos.data.FilterBlurMode+import com.vayunmathur.photos.data.LevelsAdjustment+import com.vayunmathur.photos.data.NoiseParams+import com.vayunmathur.photos.data.PhotoFilterAdj+import com.vayunmathur.photos.data.SelectiveColorAdj+import com.vayunmathur.photos.data.SelectiveColorRange+import com.vayunmathur.photos.data.StylizeMode+import com.vayunmathur.photos.data.StylizeParams+import com.vayunmathur.photos.data.UnsharpMask+import com.vayunmathur.photos.data.applyToBitmap+import kotlin.math.roundToInt+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.R as UiR+import com.vayunmathur.photos.R++@Composable+fun LevelsPanel(levels: LevelsAdjustment, onChange: (LevelsAdjustment) -> Unit) = PanelColumn {+    LabeledSlider(stringResource(R.string.in_black), levels.inBlack, 0f..254f) { onChange(levels.copy(inBlack = it)) }+    LabeledSlider(stringResource(R.string.in_white), levels.inWhite, 1f..255f) { onChange(levels.copy(inWhite = it)) }+    LabeledSlider(stringResource(R.string.gamma), levels.gamma * 100f, 10f..300f) { onChange(levels.copy(gamma = it / 100f)) }+    LabeledSlider(stringResource(R.string.out_black), levels.outBlack, 0f..254f) { onChange(levels.copy(outBlack = it)) }+    LabeledSlider(stringResource(R.string.out_white), levels.outWhite, 1f..255f) { onChange(levels.copy(outWhite = it)) }+}
photos/src/main/java/com/vayunmathur/photos/ui/LocalColumnCount.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/LocalColumnCount.kt b/photos/src/main/java/com/vayunmathur/photos/ui/LocalColumnCount.ktnew file mode 100644index 0000000000..9ea6b12ddf--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/LocalColumnCount.kt@@ -0,0 +1,12 @@+package com.vayunmathur.photos.ui++import androidx.compose.runtime.MutableFloatState+import androidx.compose.runtime.staticCompositionLocalOf++internal const val COLUMN_COUNT_KEY = "photos_column_count"+internal const val MIN_COLUMN_COUNT = 2+internal const val MAX_COLUMN_COUNT = 8++val LocalColumnCount = staticCompositionLocalOf<MutableFloatState> {+    error("No LocalColumnCount provided")+}
photos/src/main/java/com/vayunmathur/photos/ui/MapPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/MapPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/MapPage.ktindex 59269c8ea6..ad53350051 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/MapPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/MapPage.kt@@ -35,12 +35,12 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.photos.NavigationBar+import com.vayunmathur.photos.ui.NavigationBar import com.vayunmathur.photos.Route import com.vayunmathur.photos.data.Photo-import com.vayunmathur.photos.util.GalleryViewModel-import com.vayunmathur.photos.util.ImageLoader-import com.vayunmathur.photos.util.PhotoMapViewModel+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.ImageLoader+import com.vayunmathur.photos.platform.PhotoMapViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.flow.conflate
photos/src/main/java/com/vayunmathur/photos/ui/NavigationBar.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/NavigationBar.kt b/photos/src/main/java/com/vayunmathur/photos/ui/NavigationBar.ktnew file mode 100644index 0000000000..bc5ae88ca2--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/NavigationBar.kt@@ -0,0 +1,37 @@+package com.vayunmathur.photos.ui++import androidx.annotation.StringRes+import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.IconAlbum+import com.vayunmathur.library.ui.IconGroup+import com.vayunmathur.library.ui.IconMap+import com.vayunmathur.library.ui.IconPhotoLibrary+import com.vayunmathur.library.util.BottomNavBar+import com.vayunmathur.library.util.BottomNavBarItem+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.photos.R+import com.vayunmathur.photos.Route++private enum class MainRoute(val route: Route, @StringRes val titleRes: Int, val icon: @Composable () -> Unit) {+    Gallery(Route.Gallery, R.string.label_gallery, { IconPhotoLibrary() }),+    Map(Route.Map, R.string.label_map, { IconMap() }),+    People(Route.People, R.string.label_people, { IconGroup() }),+    Albums(Route.Albums, R.string.label_albums, { IconAlbum() }),+}++@Composable+fun NavigationBar(currentRoute: Route, backStack: NavBackStack<Route>) {+    BottomNavBar {+        MainRoute.entries.forEach {+            BottomNavBarItem(+                selected = it.route == currentRoute,+                // Photos pushes rather than resetting, so back returns to the+                // previous tab instead of leaving the app.+                onClick = { backStack.add(it.route) },+                icon = { it.icon() },+                label = stringResource(it.titleRes),+            )+        }+    }+}
photos/src/main/java/com/vayunmathur/photos/ui/NavigationEntries.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/NavigationEntries.kt b/photos/src/main/java/com/vayunmathur/photos/ui/NavigationEntries.ktnew file mode 100644index 0000000000..0f9ca48ea1--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/NavigationEntries.kt@@ -0,0 +1,99 @@+package com.vayunmathur.photos.ui++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.mutableStateOf+import androidx.compose.runtime.saveable.rememberSaveable+import androidx.compose.runtime.setValue+import androidx.compose.runtime.getValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.fragment.app.FragmentActivity+import androidx.activity.compose.LocalActivity+import android.net.Uri+import com.vayunmathur.library.ui.LoadingIndicator+import com.vayunmathur.library.util.AppMessages+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.photos.Route+import com.vayunmathur.photos.data.VaultPhotoDao+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.SecureFolderViewModel+import com.vayunmathur.photos.platform.shouldRelock++/**+ * Opt-in re-lock: leaving the Secure Folder (any route other than the+ * folder itself or the vault viewer, which counts as inside) locks the+ * vault so the next open requires unlock again. Off by default, which+ * preserves the current stay-unlocked behaviour.+ */+@Composable+internal fun RelockEffect(+    backStack: NavBackStack<Route>,+    relockOnExit: Boolean,+    vaultPhotoDao: com.vayunmathur.photos.data.VaultPhotoDao?,+    secureFolderViewModel: SecureFolderViewModel,+) {+    val topRoute = backStack.backStack.lastOrNull()+    LaunchedEffect(topRoute, relockOnExit) {+        if (shouldRelock(relockOnExit, topRoute, vaultPhotoDao)) {+            secureFolderViewModel.lock()+        }+    }+}++/** Index one incoming URI once per launch (survives configuration change). */+@Composable+internal fun IndexViewUriEffect(viewUri: Uri?, galleryViewModel: GalleryViewModel) {+    var indexedViewUri by rememberSaveable { mutableStateOf(false) }+    LaunchedEffect(viewUri) {+        if (viewUri == null || indexedViewUri) return@LaunchedEffect+        indexedViewUri = true+        galleryViewModel.resolveAndIndex(viewUri) {}+    }+}++@Composable+internal fun VaultViewerEntry(+    backStack: NavBackStack<Route>,+    vaultId: Long,+    vaultPassword: String?,+    secureFolderViewModel: SecureFolderViewModel,+) {+    val password = vaultPassword+    if (password != null) {+        VaultViewerPage(backStack, vaultId, password, secureFolderViewModel)+    } else {+        SecureFolderEntry(backStack, secureFolderViewModel, false, null)+    }+}++@Composable+internal fun SecureFolderEntry(+    backStack: NavBackStack<Route>,+    secureFolderViewModel: SecureFolderViewModel,+    isUnlocked: Boolean,+    vaultPassword: String?,+) {+    val activity = LocalActivity.current as FragmentActivity+    if (!isUnlocked) {+        LaunchedEffect(Unit) {+            secureFolderViewModel.unlock(+                activity,+                onSuccess = { _, _ -> },+                onFailure = { message ->+                    if (message != null) {+                        AppMessages.show(message)+                    }+                    backStack.pop()+                },+            )+        }+        Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {+            LoadingIndicator()+        }+    } else {+        SecureFolderPage(backStack, vaultPassword!!, secureFolderViewModel)+    }+}
photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.ktindex e8b102ec42..632ce3e0ae 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/PeoplePage.kt@@ -46,15 +46,15 @@ import com.vayunmathur.library.image.compose.AsyncImage import com.vayunmathur.library.image.ImageRequest import com.vayunmathur.library.ui.invisibleClickable import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.photos.NavigationBar+import com.vayunmathur.photos.ui.NavigationBar import com.vayunmathur.photos.R import com.vayunmathur.photos.Route-import com.vayunmathur.photos.pushPhoto-import com.vayunmathur.photos.util.FaceCropTransformation-import com.vayunmathur.photos.util.FaceRecognizer-import com.vayunmathur.photos.util.GalleryViewModel-import com.vayunmathur.photos.util.PeopleUiState-import com.vayunmathur.photos.util.PersonCluster+import com.vayunmathur.photos.platform.pushPhoto+import com.vayunmathur.photos.platform.FaceCropTransformation+import com.vayunmathur.photos.platform.FaceRecognizer+import com.vayunmathur.photos.platform.GalleryViewModel+import com.vayunmathur.photos.platform.PeopleUiState+import com.vayunmathur.photos.platform.PersonCluster import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext@@ -116,7 +116,7 @@ fun PeoplePage(  * The display name behind a URI from [ActivityResultContracts.PickContact], which  * grants read access to that one contact — so this works without READ_CONTACTS.  */-private fun contactDisplayName(context: Context, uri: Uri): String? = try {+internal fun contactDisplayName(context: Context, uri: Uri): String? = try {     context.contentResolver.query(         uri,         arrayOf(ContactsContract.Contacts.DISPLAY_NAME),@@ -138,74 +138,7 @@ private fun contactDisplayName(context: Context, uri: Uri): String? = try {  */ @OptIn(ExperimentalMaterial3Api::class) @Composable-fun PeopleScreen(-    backStack: NavBackStack<Route>,-    state: PeopleUiState,-    /**-     * How a cluster paints its representative face. Previews pass a placeholder: the real-     * one crops a MediaStore image, which Layoutlib cannot decode.-     */-    faceThumbnail: @Composable (PersonCluster, Modifier) -> Unit = { person, modifier -> FaceThumbnail(person, modifier) },-    /**-     * Name (or rename) a cluster. Opens the contact picker, which needs an-     * activity-result launcher, so the binder owns it — a preview renders the-     * labels fine with the no-op default.-     */-    onNameClick: (PersonCluster) -> Unit = {},-) {-    // Show progress while there are still photos left to scan (or the worker is-    // actively running); it disappears on its own once everything is scanned.-    val showProgress = state.faceTargetCount > 0 &&-        (state.indexing || state.faceScannedCount < state.faceTargetCount)--    // RAW SCAFFOLD EXCEPTION: main-nav page with only a bottom NavigationBar and no top-    // app bar. AppScaffold always renders a top app bar (which would break the layout) and-    // the body is a Column (progress + grid), not a LazyColumn.-    Scaffold(-        bottomBar = { NavigationBar(Route.People, backStack) },-    ) { padding ->-        Box(Modifier.padding(padding).fillMaxSize()) {-            if (!state.modelsAvailable) {-                Text(-                    text = stringResource(R.string.people_model_missing),-                    textAlign = TextAlign.Center,-                    color = MaterialTheme.colorScheme.onSurfaceVariant,-                    modifier = Modifier.align(Alignment.Center).padding(32.dp),-                )-            } else {-                Column(Modifier.fillMaxSize()) {-                    if (showProgress) {-                        FaceIndexingProgress(done = state.faceScannedCount, total = state.faceTargetCount)-                    }-                    if (state.people.isNotEmpty()) {-                        PeopleGrid(-                            people = state.people,-                            modifier = Modifier.weight(1f),-                            faceThumbnail = faceThumbnail,-                            onNameClick = onNameClick,-                        ) { person ->-                            backStack.pushPhoto(Route.PhotoPage(person.coverPhoto.id, person.photos))-                        }-                    } else {-                        Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {-                            Text(-                                text = stringResource(-                                    if (showProgress) R.string.people_scanning else R.string.people_empty-                                ),-                                textAlign = TextAlign.Center,-                                color = MaterialTheme.colorScheme.onSurfaceVariant,-                                modifier = Modifier.padding(32.dp),-                            )-                        }-                    }-                }-            }-        }-    }-}--@Composable-private fun FaceIndexingProgress(done: Int, total: Int) {+internal fun FaceIndexingProgress(done: Int, total: Int) {     Column(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 12.dp)) {         Text(             text = stringResource(R.string.face_indexing_progress, done, total),@@ -220,7 +153,7 @@ private fun FaceIndexingProgress(done: Int, total: Int) { }  @Composable-private fun PeopleGrid(+internal fun PeopleGrid(     people: List<PersonCluster>,     modifier: Modifier = Modifier,     faceThumbnail: @Composable (PersonCluster, Modifier) -> Unit,@@ -259,7 +192,7 @@ private fun PeopleGrid(                         .invisibleClickable { onNameClick(person) },                 )                 Text(-                    text = pluralStringResource(R.plurals.album_photo_count, person.photos.size, person.photos.size),+                    text = pluralStringResource(R.plurals.people_photo_count, person.photos.size, person.photos.size),                     style = MaterialTheme.typography.bodySmall,                     color = MaterialTheme.colorScheme.onSurfaceVariant,                 )@@ -270,7 +203,7 @@ private fun PeopleGrid(  /** The representative face of a cluster, cropped from its cover photo. */ @Composable-private fun FaceThumbnail(person: PersonCluster, modifier: Modifier) {+internal fun FaceThumbnail(person: PersonCluster, modifier: Modifier) {     val context = LocalContext.current     // `size` downsamples at *decode* time and transformations run after it, so     // asking for 256 would decode the whole photo to 256px and only then cut the
photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.kt b/photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.ktnew file mode 100644index 0000000000..1317eab361--- /dev/null+++ b/photos/src/main/java/com/vayunmathur/photos/ui/PeopleScreen.kt@@ -0,0 +1,128 @@+package com.vayunmathur.photos.ui++import android.content.Context+import android.net.Uri+import android.provider.ContactsContract+import com.vayunmathur.library.log.Log+import androidx.activity.compose.rememberLauncherForActivityResult+import androidx.activity.result.contract.ActivityResultContracts+import androidx.compose.ui.res.pluralStringResource+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.grid.GridCells+import androidx.compose.foundation.lazy.grid.LazyVerticalGrid+import androidx.compose.foundation.lazy.grid.items+import androidx.compose.foundation.shape.CircleShape+import com.vayunmathur.library.ui.ExperimentalMaterial3Api+import com.vayunmathur.library.ui.LinearProgressIndicator+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TopAppBar+import androidx.compose.runtime.Composable+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.run

Diff truncated.