feat: 拼图功能增加自动导入最后N张照片功能

- 选择2x2模式时显示「自动导入最后4张照片」提示
- 选择3x3模式时显示「自动导入最后9张照片」提示
- 点击提示文字后自动从相册导入对应数量的最新照片
This commit is contained in:
2026-03-11 19:28:16 +08:00
parent 1d0cac0d1a
commit 6165baa4c7
97 changed files with 71 additions and 5 deletions

Binary file not shown.

View File

@@ -1,4 +1,4 @@
#Sat Mar 07 00:02:01 CST 2026 #Wed Mar 11 19:27:43 CST 2026
path.4=14/classes.dex path.4=14/classes.dex
path.3=12/classes.dex path.3=12/classes.dex
path.2=10/classes.dex path.2=10/classes.dex

View File

@@ -1 +1 @@
τ8ξ)ϊ*ψ'ί&θ%ή!ψω#ϋ#η#η#η#η#η#α# τ8ξ)ϊ*ψ'ί&θ%ή!ψω#ϋ#η#η#η#η#η#α#α#

View File

@@ -1 +1 @@
ëXè¾ú¹Ñ~Ì>Åô­ï`ý¿ÄJùÉïNÔî×úbå4å²×?Í#àÀ2èjÓ*ú3ð²ÀÚëð2ã;Ñþñ/Éæ†À0ÉÅ€î*ËüíØ&üËÅÉ$æñ‘Â"Ë ëXè¾ú¹Ñ~Ì>Åô­ï`ý¿ÄJùÉïNÔî×úbå4å²×?Í#àÀ2èjÓ*ú3ð²ÀÚëð2ã;Ñþñ/Éæ†À0ÉÅ€î*ËüíØ&üËÅÉ$æñ‘Â"ËÓnÕ%ð ó/

View File

@@ -2,6 +2,7 @@ package com.inspection.camera.ui.merge
import android.graphics.Bitmap import android.graphics.Bitmap
import android.net.Uri import android.net.Uri
import android.provider.MediaStore
// java.io.File and FileOutputStream will be referenced with fully qualified names to avoid ambiguity // java.io.File and FileOutputStream will be referenced with fully qualified names to avoid ambiguity
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
@@ -126,6 +127,52 @@ fun MergeScreen(
} }
} }
// 获取相册中最后N张照片
suspend fun getLatestImages(count: Int): List<Uri> {
return withContext(Dispatchers.IO) {
val images = mutableListOf<Uri>()
val projection = arrayOf(MediaStore.Images.Media._ID)
val sortOrder = "${MediaStore.Images.Media.DATE_ADDED} DESC"
context.contentResolver.query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection,
null,
null,
sortOrder
)?.use { cursor ->
val idColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID)
var loadedCount = 0
while (cursor.moveToNext() && loadedCount < count) {
val id = cursor.getLong(idColumn)
val uri = Uri.withAppendedPath(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
id.toString()
)
images.add(uri)
loadedCount++
}
}
images
}
}
// 自动导入最后N张照片
fun autoImportLatestImages(count: Int) {
scope.launch {
val latestUris = getLatestImages(count)
if (latestUris.isNotEmpty()) {
images.clear()
latestUris.forEach { uri ->
val path = copyImageToCache(uri)
if (path != null) {
images.add(ImageWithCache(uri, path))
}
}
}
}
}
// 图片选择器 // 图片选择器
val imagePickerLauncher = rememberLauncherForActivityResult( val imagePickerLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.GetMultipleContents() contract = ActivityResultContracts.GetMultipleContents()
@@ -242,6 +289,25 @@ fun MergeScreen(
} }
} }
// 自动导入提示
val autoImportText = when (layoutType) {
MergeLayoutType.Grid2x2 -> "自动导入最后4张照片"
MergeLayoutType.Grid3x3 -> "自动导入最后9张照片"
}
Text(
text = autoImportText,
style = MaterialTheme.typography.bodyMedium,
color = Primary,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
.clickable {
autoImportLatestImages(layoutType.maxImages)
}
)
Spacer(modifier = Modifier.height(8.dp))
// 质量选择 // 质量选择
Row( Row(
modifier = Modifier modifier = Modifier