feat: enhance video deletion handling and refine gallery UI
This commit is contained in:
1 parent
f4f4947245
commit
5ab62b9727
16 files changed
+78
-26
No files matched your search
@@ -578,7 +578,10 @@ fun NavigationHost(
|
||||
onPhotoClick = { tab, index ->
|
||||
navController.navigate(Routes.photoDetail(tab, index))
|
||||
},
|
||||
onNavigateToEdit = {
|
||||
onNavigateToEdit = { photoId ->
|
||||
if (photoId != null) {
|
||||
navController.navigate(Routes.photoDetail(galleryViewModel.selectedTab, 0, photoId))
|
||||
}
|
||||
navController.navigate(Routes.PHOTO_EDIT)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2246,7 +2246,7 @@ object GalleryManager {
|
||||
val exportedUris = buildList {
|
||||
addAll(metadata?.exportedUris ?: emptyList())
|
||||
val sourceUri = metadata?.sourceUri
|
||||
if (metadata?.mediaType == MediaType.VIDEO && !sourceUri.isNullOrBlank()) {
|
||||
if (metadata?.mediaType == MediaType.VIDEO && metadata.isImported != true && !sourceUri.isNullOrBlank()) {
|
||||
add(sourceUri)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +590,14 @@ fun GalleryDetailScreen(
|
||||
|
||||
// 删除确认对话框
|
||||
if (showDeleteDialog) {
|
||||
val exportedPhotosCount = remember(currentPhoto) { currentPhoto?.metadata?.exportedUris?.size ?: 0 }
|
||||
val exportedPhotosCount = remember(currentPhoto, currentPhoto?.metadata, currentPhoto?.metadata?.exportedUris) {
|
||||
val baseCount = currentPhoto?.metadata?.exportedUris?.size ?: 0
|
||||
val sourceUri = currentPhoto?.metadata?.sourceUri
|
||||
val isVideoAndCaptured = currentPhoto?.isVideo == true &&
|
||||
currentPhoto.metadata?.isImported != true &&
|
||||
!sourceUri.isNullOrBlank()
|
||||
baseCount + (if (isVideoAndCaptured) 1 else 0)
|
||||
}
|
||||
var deleteExportedState by remember(showDeleteDialog) { mutableStateOf(deleteExportedPref) }
|
||||
|
||||
AlertDialog(
|
||||
@@ -619,7 +626,11 @@ fun GalleryDetailScreen(
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.delete_exported_photos_count, exportedPhotosCount),
|
||||
text = if (currentPhoto?.isVideo == true) {
|
||||
stringResource(R.string.delete_exported_videos_count, exportedPhotosCount)
|
||||
} else {
|
||||
stringResource(R.string.delete_exported_photos_count, exportedPhotosCount)
|
||||
},
|
||||
color = Color.White,
|
||||
fontSize = 14.sp
|
||||
)
|
||||
|
||||
@@ -90,7 +90,7 @@ fun GalleryScreen(
|
||||
viewModel: GalleryViewModel,
|
||||
onBack: () -> Unit,
|
||||
onPhotoClick: (GalleryTab, Int) -> Unit,
|
||||
onNavigateToEdit: () -> Unit = {},
|
||||
onNavigateToEdit: (String?) -> Unit = {},
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val photos by viewModel.currentPhotos.collectAsState()
|
||||
@@ -164,7 +164,7 @@ fun GalleryScreen(
|
||||
val newPhotoId = importedIds.first()
|
||||
viewModel.setCurrentPhotoById(newPhotoId)
|
||||
viewModel.enterEditMode()
|
||||
onNavigateToEdit()
|
||||
onNavigateToEdit(newPhotoId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -510,7 +510,19 @@ fun GalleryScreen(
|
||||
|
||||
// 删除确认对话框
|
||||
if (showDeleteDialog) {
|
||||
val exportedPhotosCount = remember(selectedPhotos) { selectedPhotos.sumOf { it.metadata?.exportedUris?.size ?: 0 } }
|
||||
val exportedPhotosCount = remember(selectedPhotos) {
|
||||
selectedPhotos.sumOf { photo ->
|
||||
val baseCount = photo.metadata?.exportedUris?.size ?: 0
|
||||
val sourceUri = photo.metadata?.sourceUri
|
||||
val isVideoAndCaptured = photo.isVideo &&
|
||||
photo.metadata?.isImported != true &&
|
||||
!sourceUri.isNullOrBlank()
|
||||
baseCount + (if (isVideoAndCaptured) 1 else 0)
|
||||
}
|
||||
}
|
||||
val selectedOnlyVideos = remember(selectedPhotos) {
|
||||
selectedPhotos.isNotEmpty() && selectedPhotos.all { it.isVideo }
|
||||
}
|
||||
var deleteExportedState by remember(showDeleteDialog) { mutableStateOf(deleteExportedPref) }
|
||||
|
||||
AlertDialog(
|
||||
@@ -541,7 +553,11 @@ fun GalleryScreen(
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.delete_exported_photos_count, exportedPhotosCount),
|
||||
text = if (selectedOnlyVideos) {
|
||||
stringResource(R.string.delete_exported_videos_count, exportedPhotosCount)
|
||||
} else {
|
||||
stringResource(R.string.delete_exported_photos_count, exportedPhotosCount)
|
||||
},
|
||||
color = Color.White,
|
||||
fontSize = 14.sp
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.hinnka.mycamera.frame.FrameInfo
|
||||
import com.hinnka.mycamera.gallery.GalleryManager
|
||||
import com.hinnka.mycamera.gallery.MediaData
|
||||
import com.hinnka.mycamera.gallery.MediaMetadata
|
||||
import com.hinnka.mycamera.gallery.MediaType
|
||||
import com.hinnka.mycamera.hdr.HdrGainmapStrength
|
||||
import com.hinnka.mycamera.hdr.UnifiedGainmapProducer
|
||||
import com.hinnka.mycamera.lut.creator.AiPhotoEvaluation
|
||||
@@ -1393,6 +1394,14 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
PLog.e(TAG, "Invalid URI: $uriString", e)
|
||||
}
|
||||
}
|
||||
val sourceUri = metadata?.sourceUri
|
||||
if (metadata?.mediaType == MediaType.VIDEO && metadata.isImported != true && !sourceUri.isNullOrBlank()) {
|
||||
try {
|
||||
allExportedUris.add(sourceUri.toUri())
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Invalid sourceUri: $sourceUri", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2582,11 +2591,12 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
)
|
||||
|
||||
// 记录导出 URI 到元数据
|
||||
// 记录导出 URI 到元数据并更新 UI 状态
|
||||
if (resultUri != null) {
|
||||
GalleryManager.updateMetadata(context, photo.id) { current ->
|
||||
updatePhotoMetadata(photo.id) { current ->
|
||||
current.copy(exportedUris = current.exportedUris + resultUri.toString())
|
||||
}
|
||||
photoRefreshKeys[photo.id] = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
onComplete(resultUri != null, resultUri)
|
||||
|
||||
@@ -41,16 +41,16 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gallery_photo_motion_icon"
|
||||
android:layout_width="13dp"
|
||||
android:layout_height="13dp"
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:src="@drawable/ic_live_photo"
|
||||
android:tint="#FFFFFFFF"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gallery_photo_burst_icon"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:src="@drawable/ic_gallery_burst"
|
||||
android:tint="#FFFFFFFF"
|
||||
@@ -64,23 +64,23 @@
|
||||
android:layout_gravity="bottom|start"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:gravity="bottom"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/gallery_photo_video_badge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_gallery_badge_pill"
|
||||
android:background="@drawable/bg_gallery_badge_rect"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="6dp"
|
||||
android:paddingVertical="4dp"
|
||||
android:paddingHorizontal="4dp"
|
||||
android:paddingVertical="2dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:src="@drawable/ic_gallery_play"
|
||||
android:tint="#FFFFFFFF" />
|
||||
|
||||
@@ -91,9 +91,8 @@
|
||||
android:layout_marginStart="2dp"
|
||||
android:fontFamily="sans"
|
||||
android:includeFontPadding="false"
|
||||
android:lineHeight="14sp"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="10sp"
|
||||
android:textSize="8sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
@@ -115,8 +114,8 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/gallery_photo_related_badge"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
@@ -125,8 +124,8 @@
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/auto_awesome"
|
||||
android:tint="#FFFFFFFF" />
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<string name="delete_confirm">Dieses Foto löschen?</string>
|
||||
<string name="delete_multiple_confirm">%d Fotos löschen?</string>
|
||||
<string name="delete_exported_photos">Auch aus der Systemgalerie löschen</string>
|
||||
<string name="delete_exported_videos_count">Auch %d exportierte Videos löschen</string>
|
||||
<string name="no_photos">Noch keine Fotos</string>
|
||||
<string name="photo_info">Foto-Info</string>
|
||||
<string name="filter">LUT</string>
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<string name="delete_confirm">Supprimer cette photo ?</string>
|
||||
<string name="delete_multiple_confirm">Supprimer %d photos ?</string>
|
||||
<string name="delete_exported_photos">Supprimer également de la galerie système</string>
|
||||
<string name="delete_exported_videos_count">Supprimer également %d vidéos exportées</string>
|
||||
<string name="no_photos">Aucune photo pour le moment</string>
|
||||
<string name="photo_info">Infos photo</string>
|
||||
<string name="filter">LUT</string>
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<string name="delete_confirm">Hapus foto ini?</string>
|
||||
<string name="delete_multiple_confirm">Hapus %d foto?</string>
|
||||
<string name="delete_exported_photos">Hapus juga dari galeri sistem</string>
|
||||
<string name="delete_exported_videos_count">Hapus juga %d video yang diekspor</string>
|
||||
<string name="no_photos">Belum ada foto</string>
|
||||
<string name="photo_info">Info Foto</string>
|
||||
<string name="filter">LUT</string>
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<string name="delete_confirm">この写真を削除しますか?</string>
|
||||
<string name="delete_multiple_confirm">%d枚の写真を削除しますか?</string>
|
||||
<string name="delete_exported_photos">システムギャラリーからも削除する</string>
|
||||
<string name="delete_exported_videos_count">エクスポートされた%d個の動画も削除する</string>
|
||||
<string name="no_photos">写真がありません</string>
|
||||
<string name="photo_info">写真情報</string>
|
||||
<string name="filter">LUT</string>
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
<string name="delete_confirm">이 사진을 삭제하시겠습니까?</string>
|
||||
<string name="delete_multiple_confirm">%d개의 사진을 삭제하시겠습니까?</string>
|
||||
<string name="delete_exported_photos">시스템 갤러리에서도 삭제</string>
|
||||
<string name="delete_exported_photos_count">내보낸 사진 %d개도 삭제</string>
|
||||
<string name="delete_exported_videos_count">내보낸 동영상 %d개도 삭제</string>
|
||||
<string name="no_photos">사진이 없습니다</string>
|
||||
<string name="photo_info">사진 정보</string>
|
||||
<string name="filter">LUT</string>
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
<string name="delete_confirm">Excluir esta foto?</string>
|
||||
<string name="delete_multiple_confirm">Excluir %d fotos?</string>
|
||||
<string name="delete_exported_photos">Também excluir da galeria do sistema</string>
|
||||
<string name="delete_exported_photos_count">Também excluir %d fotos exportadas</string>
|
||||
<string name="delete_exported_videos_count">Também excluir %d vídeos exportados</string>
|
||||
<string name="no_photos">Nenhuma foto ainda</string>
|
||||
<string name="photo_info">Informações da Foto</string>
|
||||
<string name="filter">LUT</string>
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
<string name="delete_confirm">ลบรูปภาพนี้หรือไม่?</string>
|
||||
<string name="delete_multiple_confirm">ลบรูปภาพ %d รูปหรือไม่?</string>
|
||||
<string name="delete_exported_photos">ลบออกจากแกลเลอรีระบบด้วย</string>
|
||||
<string name="delete_exported_photos_count">ลบ %d รูปภาพที่ส่งออกด้วย</string>
|
||||
<string name="delete_exported_videos_count">ลบ %d วิดีโอที่ส่งออกด้วย</string>
|
||||
<string name="no_photos">ยังไม่มีรูปภาพ</string>
|
||||
<string name="photo_info">ข้อมูลรูปภาพ</string>
|
||||
<string name="filter">LUT</string>
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
<string name="delete_multiple_confirm">删除 %d 张照片吗?</string>
|
||||
<string name="delete_exported_photos">同时删除系统相册中的导出图</string>
|
||||
<string name="delete_exported_photos_count">同时删除 %d 张已导出照片</string>
|
||||
<string name="delete_exported_videos_count">同时删除 %d 个已导出视频</string>
|
||||
<string name="delete_system_warning">注意:此操作将同步删除已导出至系统相册的照片。系统会弹出删除确认,即使拒绝也不影响删除 App 内的照片。</string>
|
||||
<string name="no_photos">暂无照片</string>
|
||||
<string name="photo_info">照片信息</string>
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<string name="delete_multiple_confirm">刪除 %d 張照片嗎?</string>
|
||||
<string name="delete_exported_photos">同時刪除系統相冊中的導出圖</string>
|
||||
<string name="delete_exported_photos_count">同時刪除 %d 張已導出照片</string>
|
||||
<string name="delete_exported_videos_count">同時刪除 %d 個已導出視頻</string>
|
||||
<string name="delete_system_warning">注意:此操作將同步刪除已匯出至系統相簿的照片。系統會彈出刪除確認,即使拒絕也不影響刪除 App 內的相片。</string>
|
||||
|
||||
<string name="no_photos">暫無相片</string>
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
<string name="delete_multiple_confirm">Delete %d photos?</string>
|
||||
<string name="delete_exported_photos">Also delete from system gallery</string>
|
||||
<string name="delete_exported_photos_count">Also delete %d exported photos</string>
|
||||
<string name="delete_exported_videos_count">Also delete %d exported videos</string>
|
||||
<string name="delete_system_warning">Note: Exported photos in the system gallery will also be removed. A system prompt will appear; declining it will only cancel the system deletion, while the app version will still be deleted.</string>
|
||||
<string name="no_photos">No photos yet</string>
|
||||
<string name="photo_info">Photo Info</string>
|
||||
|
||||
Reference in new issue
Block a user