From d23d72be91522e8dbcd5358158c0f1659d4a6fe6 Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Thu, 15 Aug 2024 22:00:03 +0900 Subject: [PATCH 01/12] =?UTF-8?q?[fix/#83]=20=EC=BB=A4=EC=8A=A4=ED=85=80?= =?UTF-8?q?=20=EA=B0=A4=EB=9F=AC=EB=A6=AC=20=EA=B5=AC=ED=98=84=EC=A4=91..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 + buildSrc/build/kotlin/buildSrcjar-classes.txt | 2 +- .../compileKotlin/cacheable/last-build.bin | Bin 18 -> 18 bytes .../local-state/build-history.bin | Bin 31 -> 31 bytes buildSrc/build/libs/buildSrc.jar | Bin 12602 -> 12602 bytes presentation/build.gradle.kts | 1 + .../presentation/gallery/GalleryActivity.kt | 24 ++ .../presentation/gallery/GalleryScreen.kt | 210 ++++++++++++++++++ .../presentation/home/HomeActivity.kt | 6 + .../src/main/res/layout/activity_gallery.xml | 16 ++ 10 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 presentation/src/main/java/com/depromeet/presentation/gallery/GalleryActivity.kt create mode 100644 presentation/src/main/java/com/depromeet/presentation/gallery/GalleryScreen.kt create mode 100644 presentation/src/main/res/layout/activity_gallery.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6cec1d27..51283ae5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -105,6 +105,10 @@ android:exported="false" android:screenOrientation="portrait"/> + + n+a literal 18 YcmZ4UmVvdLhk=1{qS1VbPzE3X05FvU@&Et; diff --git a/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin b/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin index 5ae2f43b13f169e387ed53f0d10db8899fffd922..6a9f6c12c1ad8fa9930f2f2629cbd7d80d90c326 100644 GIT binary patch literal 31 ccmZ4UmVvcgk^ur385kHRh7{jah4L8~09@DvhX4Qo literal 31 ccmZ4UmVvcgk^ur385kHR8qJpoh4L8~09L~U00000 diff --git a/buildSrc/build/libs/buildSrc.jar b/buildSrc/build/libs/buildSrc.jar index 011f4d7f5835b4c1e8f7f35b4031ab9790613812..87f3dc180263d8cc7b6524ec25d08fa58dca860e 100644 GIT binary patch delta 523 zcmdm$v@3}>z?+#xgn@yBgJDJ?|3qFj<|A7^Pc-vl2J$w)=X%TxX85SxV&g_qw>e5W zl?g1vD|`dOIH=IU3KE%oNH!5H^O^l8M5bNh0+_L}`3ehIMon%8MCOI)90((dbsB_m zl~0$2myt{s9`bl6SI+d4usQoa zHuYu$&AGwMz#xWV&KBj#iTWyFMJ@f?j;8_@O~gz?+#xgn@yBgF%*sb0V)A^Q)qd6V1GsfxONBGFMo@j0Cl5OkhTX*iSHH zWAkHXu)t3ZT^4R66E<(-y#Y~rPazhC6Apv91ZoO_Q^9?LkT=-_@69ESnrFBRlz=J`Y%At${R?FYDxdH3^*n zZxqduHTPd1JkG?xu!DtxL7V{rmNY(NpPa9+3f8|ySDNV&*W{DBvS98%C`*9crvP+u( + ActivityGalleryBinding::inflate +) { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + initView() + } + + private fun initView() { + binding.cvGallery.setContent { + MaterialTheme { + GalleryScreen() + } + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/depromeet/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/depromeet/presentation/gallery/GalleryScreen.kt new file mode 100644 index 00000000..c09d7957 --- /dev/null +++ b/presentation/src/main/java/com/depromeet/presentation/gallery/GalleryScreen.kt @@ -0,0 +1,210 @@ +package com.depromeet.presentation.gallery + +import android.Manifest +import android.content.ContentUris +import android.content.Context +import android.content.pm.PackageManager +import android.net.Uri +import android.provider.MediaStore +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.Image +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.wrapContentSize +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 androidx.compose.material.Button +import androidx.compose.material.Surface +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +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.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.dp +import androidx.core.content.ContextCompat +import coil.compose.rememberImagePainter + +data class GalleryImage(val id: Long, val uri: Uri) + +@Composable +fun GalleryScreen( + +) { + CustomGallery() +} + + +@Composable +fun CustomGallery() { + val context = LocalContext.current + var showGallery by remember { mutableStateOf(false) } + var selectedImages by remember { mutableStateOf(listOf()) } + var galleryImages by remember { mutableStateOf(listOf()) } + + val permissions = remember { + listOf( + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE + ) + } + + var permissionsGranted by remember { + mutableStateOf( + permissions.all { + ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED + } + ) + } + + val launcher = rememberLauncherForActivityResult( + ActivityResultContracts.RequestMultiplePermissions() + ) { permissionsMap -> + permissionsGranted = permissionsMap.values.all { it } + if (permissionsGranted) { + showGallery = true + galleryImages = loadGalleryImages(context) + } + } + + LaunchedEffect(permissionsGranted) { + if (permissionsGranted) { + showGallery = true + galleryImages = loadGalleryImages(context) + } + } + + Column { + Button(onClick = { + if (!permissionsGranted) { + launcher.launch(permissions.toTypedArray()) + } else { + showGallery = true + galleryImages = loadGalleryImages(context) + } + }) { + Text("Open Gallery") + } + + if (permissionsGranted && showGallery) { + GalleryGrid( + images = galleryImages, + selectedImages = selectedImages, + onImageSelected = { image -> + selectedImages = when { + selectedImages.contains(image) -> selectedImages - image + selectedImages.size < 3 -> selectedImages + image + else -> selectedImages + } + } + ) + } else if (!permissionsGranted) { + // 권한 없음 + } + } +} + +@Composable +fun GalleryGrid( + images: List, + selectedImages: List, + onImageSelected: (GalleryImage) -> Unit +) { + LazyVerticalGrid( + columns = GridCells.Fixed(3), + contentPadding = PaddingValues(4.dp) + ) { + items(images) { image -> + GalleryItem( + image = image, + isSelected = selectedImages.contains(image), + selectionOrder = selectedImages.indexOf(image) + 1, + onImageSelected = onImageSelected + ) + } + } +} + +@Composable +fun GalleryItem( + image: GalleryImage, + isSelected: Boolean, + selectionOrder: Int, + onImageSelected: (GalleryImage) -> Unit +) { + Box( + modifier = Modifier + .padding(4.dp) + .aspectRatio(1f) + .clickable { onImageSelected(image) } + ) { + Image( + painter = rememberImagePainter(data = image.uri), + contentDescription = null, + modifier = Modifier.fillMaxSize(), + contentScale = ContentScale.Crop + ) + + Surface( + color = if (isSelected) Color.Blue else Color.White, + shape = CircleShape, + modifier = Modifier + .size(24.dp) + .align(Alignment.TopEnd) + .padding(4.dp) + ) { + if (isSelected) { + Text( + text = selectionOrder.toString(), + color = Color.White, + modifier = Modifier.wrapContentSize(Alignment.Center) + ) + } + } + } +} + +fun loadGalleryImages(context: Context): List { + val images = mutableListOf() + val projection = arrayOf( + MediaStore.Images.Media._ID, + MediaStore.Images.Media.BUCKET_DISPLAY_NAME, + MediaStore.Images.Media.DATE_TAKEN + ) + val sortOrder = "${MediaStore.Images.Media.DATE_TAKEN} 내림차순" + + context.contentResolver.query( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + projection, + null, + null, + sortOrder + )?.use { cursor -> + val idColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID) + + while (cursor.moveToNext()) { + val id = cursor.getLong(idColumn) + val contentUri = ContentUris.withAppendedId( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + id + ) + images.add(GalleryImage(id, contentUri)) + } + } + return images +} \ No newline at end of file diff --git a/presentation/src/main/java/com/depromeet/presentation/home/HomeActivity.kt b/presentation/src/main/java/com/depromeet/presentation/home/HomeActivity.kt index 49886c0a..27b91383 100644 --- a/presentation/src/main/java/com/depromeet/presentation/home/HomeActivity.kt +++ b/presentation/src/main/java/com/depromeet/presentation/home/HomeActivity.kt @@ -13,6 +13,7 @@ import com.depromeet.domain.entity.response.home.ResponseHomeFeed import com.depromeet.domain.entity.response.viewfinder.ResponseStadiums import com.depromeet.presentation.databinding.ActivityHomeBinding import com.depromeet.presentation.extension.dpToPx +import com.depromeet.presentation.gallery.GalleryActivity import com.depromeet.presentation.home.adapter.StadiumAdapter import com.depromeet.presentation.home.viewmodel.HomeGuiViewModel import com.depromeet.presentation.seatreview.ReviewActivity @@ -56,6 +57,11 @@ class HomeActivity : BaseActivity( } private fun initEvent() = with(binding) { + ivHomeAppBar.setOnClickListener { + Intent(this@HomeActivity, GalleryActivity::class.java).apply { + startActivity(this) + } + } clHomeArchiving.setOnClickListener { startSeatRecordActivity() } ivHomeInfo.setOnClickListener { showLevelDescriptionDialog() } clHomeScrap.setOnClickListener { diff --git a/presentation/src/main/res/layout/activity_gallery.xml b/presentation/src/main/res/layout/activity_gallery.xml new file mode 100644 index 00000000..e76bc39a --- /dev/null +++ b/presentation/src/main/res/layout/activity_gallery.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file From 1dd79c31b53184eb00400d135747d17adfcff2fe Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Sat, 17 Aug 2024 14:19:57 +0900 Subject: [PATCH 02/12] =?UTF-8?q?[feat/#83]=20=EC=BB=A4=EC=8A=A4=ED=85=80?= =?UTF-8?q?=20=EA=B0=A4=EB=9F=AC=EB=A6=AC=20=EC=A7=84=ED=96=89=EC=A4=91..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compileKotlin/cacheable/last-build.bin | Bin 18 -> 18 bytes .../local-state/build-history.bin | Bin 31 -> 31 bytes buildSrc/build/libs/buildSrc.jar | Bin 12602 -> 12602 bytes .../presentation/gallery/GalleryScreen.kt | 244 +++++++++--------- 4 files changed, 128 insertions(+), 116 deletions(-) diff --git a/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin b/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin index d85a0a8b7d20c4c2d51e0c7615db44b7fd7c8e5a..64bb1d8328739262f284098252836c5dfe0aa2a5 100644 GIT binary patch literal 18 YcmZ4UmVvdLhk=1{Vzi-kE&~t%05By3=l}o! literal 18 YcmZ4UmVvdLhk=1{Vo32#RR$mc05k^#c>n+a diff --git a/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin b/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin index 6a9f6c12c1ad8fa9930f2f2629cbd7d80d90c326..fd0219317fe6725b0562e44e8855eb3344e3a76c 100644 GIT binary patch literal 31 ccmZ4UmVvcgk^ur385kHRMjKk^Lir2~09GLb_5c6? literal 31 ccmZ4UmVvcgk^ur385kHRh7{jah4L8~09@DvhX4Qo diff --git a/buildSrc/build/libs/buildSrc.jar b/buildSrc/build/libs/buildSrc.jar index 87f3dc180263d8cc7b6524ec25d08fa58dca860e..5b52b416389f855b6f300d84aa6179fe19aa5b32 100644 GIT binary patch delta 248 zcmdm$v@3}>z?+#xgn@yBgJJC&fr-4u%xl&NY;1na%nami&SZJS24?tir!s*V+jwt4 z7!w6LSV1C_WyBJ}G7VxsnLwI1*GOJ~DDjuM!UC33Q=9=2IjB4b!bnh?24VcvFbAud zY^+-b(mi>Nt`*qWm%5f*Oc(39g6Z9Q?qHf#-wR9!={te-P1kn@^Y7|I)TtUc Pg87+HdM%XxXy6F|CgWOI delta 248 zcmdm$v@3}>z?+#xgn@yBgJDJ?|3uzmW+1h(`7twy-kizuhz-o}<4$D)Gq&;GfG{Qs zbg+U%Cd-H=f@K=SenMnwBriZ1{xVlsz*1_8Gaw=dmFGYh32M_IjGr3jU^SDCb<4oU zt>(emptyList()) } + val selectedItems = remember { mutableStateListOf() } + var isLoading by remember { mutableStateOf(false) } val context = LocalContext.current - var showGallery by remember { mutableStateOf(false) } - var selectedImages by remember { mutableStateOf(listOf()) } - var galleryImages by remember { mutableStateOf(listOf()) } - - val permissions = remember { - listOf( - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE - ) - } - var permissionsGranted by remember { - mutableStateOf( - permissions.all { - ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED + val permissionLauncher = rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted -> + if (isGranted) { + isLoading = true + loadImages(context) { items -> + galleryItems = items + isLoading = false } - ) + } else { + Toast.makeText(context, "Permission denied", Toast.LENGTH_SHORT).show() + } } - val launcher = rememberLauncherForActivityResult( - ActivityResultContracts.RequestMultiplePermissions() - ) { permissionsMap -> - permissionsGranted = permissionsMap.values.all { it } - if (permissionsGranted) { - showGallery = true - galleryImages = loadGalleryImages(context) - } + LaunchedEffect(Unit) { + checkAndRequestPermission(context, permissionLauncher) } - LaunchedEffect(permissionsGranted) { - if (permissionsGranted) { - showGallery = true - galleryImages = loadGalleryImages(context) + Column(modifier = Modifier.fillMaxSize()) { + if (isLoading) { + CircularProgressIndicator(modifier = Modifier.align(Alignment.CenterHorizontally)) + } else if (galleryItems.isNotEmpty()) { + LazyVerticalGrid( + columns = GridCells.Fixed(3), + contentPadding = PaddingValues(4.dp), + ) { + items(galleryItems) { item -> + GalleryItemView( + item = item, + isSelected = selectedItems.contains(item), + selectedIndex = selectedItems.indexOf(item) + 1, + onClick = { + if (selectedItems.contains(item)) { + selectedItems.remove(item) + } else if (selectedItems.size < 3) { + selectedItems.add(item) + } + } + ) + } + } + } else { + Text("No images found", modifier = Modifier.align(Alignment.CenterHorizontally)) } } +} - Column { - Button(onClick = { - if (!permissionsGranted) { - launcher.launch(permissions.toTypedArray()) - } else { - showGallery = true - galleryImages = loadGalleryImages(context) +fun checkAndRequestPermission(context: Context, permissionLauncher: ManagedActivityResultLauncher) { + when { + Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> { + when (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_IMAGES)) { + PackageManager.PERMISSION_GRANTED -> loadImages(context) {} + else -> permissionLauncher.launch(Manifest.permission.READ_MEDIA_IMAGES) } - }) { - Text("Open Gallery") } - - if (permissionsGranted && showGallery) { - GalleryGrid( - images = galleryImages, - selectedImages = selectedImages, - onImageSelected = { image -> - selectedImages = when { - selectedImages.contains(image) -> selectedImages - image - selectedImages.size < 3 -> selectedImages + image - else -> selectedImages - } - } - ) - } else if (!permissionsGranted) { - // 권한 없음 + Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> { + loadImages(context) {} + } + else -> { + when (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) { + PackageManager.PERMISSION_GRANTED -> loadImages(context) {} + else -> permissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE) + } } } } -@Composable -fun GalleryGrid( - images: List, - selectedImages: List, - onImageSelected: (GalleryImage) -> Unit -) { - LazyVerticalGrid( - columns = GridCells.Fixed(3), - contentPadding = PaddingValues(4.dp) - ) { - items(images) { image -> - GalleryItem( - image = image, - isSelected = selectedImages.contains(image), - selectionOrder = selectedImages.indexOf(image) + 1, - onImageSelected = onImageSelected - ) +fun loadImages(context: Context, onComplete: (List) -> Unit) { + CoroutineScope(Dispatchers.IO).launch { + val contentResolver = context.contentResolver + val galleryItems = mutableListOf() + val projection = arrayOf( + MediaStore.Images.Media._ID, + MediaStore.Images.Media.DATE_ADDED + ) + val sortOrder = "${MediaStore.Images.Media.DATE_ADDED} DESC" + + contentResolver.query( + MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + projection, + null, + null, + sortOrder + )?.use { cursor -> + val idColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID) + var count = 0 + while (cursor.moveToNext() && count < 10) { + val id = cursor.getLong(idColumn) + val contentUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id) + galleryItems.add(GalleryItem(galleryItems.size, contentUri)) + count++ + } + } + withContext(Dispatchers.Main) { + onComplete(galleryItems) } } } @Composable -fun GalleryItem( - image: GalleryImage, +fun GalleryItemView( + item: GalleryItem, isSelected: Boolean, - selectionOrder: Int, - onImageSelected: (GalleryImage) -> Unit + selectedIndex: Int, + onClick: () -> Unit ) { Box( modifier = Modifier .padding(4.dp) .aspectRatio(1f) - .clickable { onImageSelected(image) } + .clickable { onClick() } ) { Image( - painter = rememberImagePainter(data = image.uri), + painter = rememberImagePainter(data = item.imageResource), contentDescription = null, modifier = Modifier.fillMaxSize(), contentScale = ContentScale.Crop ) - Surface( - color = if (isSelected) Color.Blue else Color.White, - shape = CircleShape, - modifier = Modifier - .size(24.dp) - .align(Alignment.TopEnd) - .padding(4.dp) - ) { - if (isSelected) { + if (isSelected) { + Box( + modifier = Modifier + .size(24.dp) + .align(Alignment.TopEnd) + .background(Color.Red, shape = CircleShape) + ) { Text( - text = selectionOrder.toString(), + text = selectedIndex.toString(), color = Color.White, - modifier = Modifier.wrapContentSize(Alignment.Center) + modifier = Modifier.align(Alignment.Center) ) } + } else { + Box( + modifier = Modifier + .size(24.dp) + .align(Alignment.TopEnd) + .border(2.dp, Color.Gray, CircleShape) + ) } } } -fun loadGalleryImages(context: Context): List { - val images = mutableListOf() - val projection = arrayOf( - MediaStore.Images.Media._ID, - MediaStore.Images.Media.BUCKET_DISPLAY_NAME, - MediaStore.Images.Media.DATE_TAKEN - ) - val sortOrder = "${MediaStore.Images.Media.DATE_TAKEN} 내림차순" - - context.contentResolver.query( - MediaStore.Images.Media.EXTERNAL_CONTENT_URI, - projection, - null, - null, - sortOrder - )?.use { cursor -> - val idColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID) - - while (cursor.moveToNext()) { - val id = cursor.getLong(idColumn) - val contentUri = ContentUris.withAppendedId( - MediaStore.Images.Media.EXTERNAL_CONTENT_URI, - id - ) - images.add(GalleryImage(id, contentUri)) - } - } - return images -} \ No newline at end of file +data class GalleryItem(val id: Int, val imageResource: Uri) From f259ca3ded9e70b1d52974b293f6ac1c7d5efdc6 Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Sat, 17 Aug 2024 23:38:56 +0900 Subject: [PATCH 03/12] =?UTF-8?q?[feat/#83]=20=EC=BB=A4=EC=8A=A4=ED=85=80?= =?UTF-8?q?=20=EA=B0=A4=EB=9F=AC=EB=A6=AC=20=EA=B5=AC=ED=98=84=20=EA=B1=B0?= =?UTF-8?q?=EC=9D=98=20=EB=81=9D...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 +- .../presentation/gallery/GalleryActivity.kt | 12 ++-- .../presentation/gallery/GalleryScreen.kt | 65 ++++++++++++++----- .../com/dpm/presentation/home/HomeActivity.kt | 18 ++--- .../seatreview/dialog/ImageUploadDialog.kt | 2 +- 5 files changed, 64 insertions(+), 35 deletions(-) rename presentation/src/main/java/com/{depromeet => dpm}/presentation/gallery/GalleryActivity.kt (63%) rename presentation/src/main/java/com/{depromeet => dpm}/presentation/gallery/GalleryScreen.kt (79%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a6f8f19d..5e866ba9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -126,7 +126,7 @@ android:exported="false" android:screenOrientation="portrait"/> - diff --git a/presentation/src/main/java/com/depromeet/presentation/gallery/GalleryActivity.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt similarity index 63% rename from presentation/src/main/java/com/depromeet/presentation/gallery/GalleryActivity.kt rename to presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt index 70de7333..a2622289 100644 --- a/presentation/src/main/java/com/depromeet/presentation/gallery/GalleryActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt @@ -1,11 +1,13 @@ -package com.depromeet.presentation.gallery +package com.dpm.presentation.gallery import android.os.Bundle import androidx.compose.material.MaterialTheme -import com.depromeet.core.base.BaseActivity import com.depromeet.presentation.databinding.ActivityGalleryBinding +import com.dpm.core.base.BaseActivity +import dagger.hilt.android.AndroidEntryPoint -class GalleryActivity: BaseActivity( +@AndroidEntryPoint +class GalleryActivity : BaseActivity( ActivityGalleryBinding::inflate ) { override fun onCreate(savedInstanceState: Bundle?) { @@ -17,7 +19,9 @@ class GalleryActivity: BaseActivity( private fun initView() { binding.cvGallery.setContent { MaterialTheme { - GalleryScreen() + GalleryScreen { + + } } } } diff --git a/presentation/src/main/java/com/depromeet/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt similarity index 79% rename from presentation/src/main/java/com/depromeet/presentation/gallery/GalleryScreen.kt rename to presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt index a75eefa0..69b1defd 100644 --- a/presentation/src/main/java/com/depromeet/presentation/gallery/GalleryScreen.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt @@ -1,4 +1,4 @@ -package com.depromeet.presentation.gallery +package com.dpm.presentation.gallery import android.Manifest import android.app.Activity @@ -55,9 +55,9 @@ import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import androidx.core.os.bundleOf import androidx.fragment.app.setFragmentResult +import coil.compose.AsyncImage import coil.compose.rememberImagePainter import com.depromeet.presentation.R -import com.depromeet.presentation.seatreview.dialog.ImageUploadDialog import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -65,17 +65,18 @@ import kotlinx.coroutines.withContext @Composable fun GalleryScreen( - + onImagesSelected: (List) -> Unit ) { - CustomGallery() + CustomGallery(onImagesSelected) } - @Composable -fun CustomGallery() { +fun CustomGallery( + onImagesSelected : (List) -> Unit +) { var galleryItems by remember { mutableStateOf>(emptyList()) } val selectedItems = remember { mutableStateListOf() } - var isLoading by remember { mutableStateOf(false) } + var isLoading by remember { mutableStateOf(true) } val context = LocalContext.current val permissionLauncher = rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted -> @@ -86,12 +87,18 @@ fun CustomGallery() { isLoading = false } } else { - Toast.makeText(context, "Permission denied", Toast.LENGTH_SHORT).show() + Toast.makeText(context, "권한이 거절되어있어용~", Toast.LENGTH_SHORT).show() + isLoading = false } } LaunchedEffect(Unit) { - checkAndRequestPermission(context, permissionLauncher) + checkAndRequestPermission(context, permissionLauncher) { + loadImages(context) { items -> + galleryItems = items + isLoading = false + } + } } Column(modifier = Modifier.fillMaxSize()) { @@ -102,6 +109,25 @@ fun CustomGallery() { columns = GridCells.Fixed(3), contentPadding = PaddingValues(4.dp), ) { + item( + key = "gallery_top_bar", + ) { + Spacer(modifier = Modifier.height(8.dp)) + Button( + onClick = { + onImagesSelected(selectedItems.map { it.imageResource }) + }, + modifier = Modifier.align(Alignment.CenterHorizontally) + ) { + Text("${selectedItems.size} 선택") + } + } + + item(key = "gallery_top_title") { + Text("갤러리 제목입니당~~", modifier = Modifier.align(Alignment.CenterHorizontally)) + Spacer(modifier = Modifier.height(30.dp)) + } + items(galleryItems) { item -> GalleryItemView( item = item, @@ -123,20 +149,24 @@ fun CustomGallery() { } } -fun checkAndRequestPermission(context: Context, permissionLauncher: ManagedActivityResultLauncher) { +private fun checkAndRequestPermission( + context: Context, + permissionLauncher: ManagedActivityResultLauncher, + onPermissionGranted: () -> Unit +) { when { Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> { when (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_IMAGES)) { - PackageManager.PERMISSION_GRANTED -> loadImages(context) {} + PackageManager.PERMISSION_GRANTED -> onPermissionGranted() else -> permissionLauncher.launch(Manifest.permission.READ_MEDIA_IMAGES) } } Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> { - loadImages(context) {} + onPermissionGranted() } else -> { when (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) { - PackageManager.PERMISSION_GRANTED -> loadImages(context) {} + PackageManager.PERMISSION_GRANTED -> onPermissionGranted() else -> permissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE) } } @@ -162,7 +192,7 @@ fun loadImages(context: Context, onComplete: (List) -> Unit) { )?.use { cursor -> val idColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID) var count = 0 - while (cursor.moveToNext() && count < 10) { + while (cursor.moveToNext()) { val id = cursor.getLong(idColumn) val contentUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id) galleryItems.add(GalleryItem(galleryItems.size, contentUri)) @@ -188,10 +218,9 @@ fun GalleryItemView( .aspectRatio(1f) .clickable { onClick() } ) { - Image( - painter = rememberImagePainter(data = item.imageResource), - contentDescription = null, - modifier = Modifier.fillMaxSize(), + AsyncImage( + model = item.imageResource, + contentDescription = "", contentScale = ContentScale.Crop ) diff --git a/presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt b/presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt index 01dfa955..617fca09 100644 --- a/presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt @@ -1,4 +1,4 @@ -package com.depromeet.presentation.home +package com.dpm.presentation.home import android.content.Intent import android.os.Bundle @@ -13,6 +13,7 @@ import com.dpm.designsystem.SpotImageSnackBar import com.dpm.domain.entity.response.home.ResponseHomeFeed import com.dpm.domain.entity.response.viewfinder.ResponseStadiums import com.dpm.presentation.extension.dpToPx +import com.dpm.presentation.gallery.GalleryActivity import com.dpm.presentation.home.adapter.StadiumAdapter import com.dpm.presentation.home.viewmodel.HomeGuiViewModel import com.dpm.presentation.seatrecord.SeatRecordActivity @@ -21,16 +22,6 @@ import com.dpm.presentation.seatreview.ReviewActivity import com.dpm.presentation.setting.SettingActivity import com.dpm.presentation.viewfinder.StadiumActivity import com.dpm.presentation.viewfinder.StadiumSelectionActivity -import com.depromeet.presentation.extension.dpToPx -import com.depromeet.presentation.gallery.GalleryActivity -import com.depromeet.presentation.home.adapter.StadiumAdapter -import com.depromeet.presentation.home.viewmodel.HomeGuiViewModel -import com.depromeet.presentation.seatreview.ReviewActivity -import com.depromeet.presentation.seatrecord.SeatRecordActivity -import com.depromeet.presentation.seatrecord.adapter.LinearSpacingItemDecoration -import com.depromeet.presentation.setting.SettingActivity -import com.depromeet.presentation.viewfinder.StadiumActivity -import com.depromeet.presentation.viewfinder.StadiumSelectionActivity import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint @@ -66,6 +57,11 @@ class HomeActivity : BaseActivity( } private fun initEvent() = with(binding) { + ivHomeAppBar.setOnClickListener { + Intent(this@HomeActivity, GalleryActivity::class.java).apply { + startActivity(this) + } + } clHomeArchiving.setOnClickListener { startSeatRecordActivity() } ivHomeInfo.setOnClickListener { showLevelDescriptionDialog() } clHomeScrap.setOnClickListener { diff --git a/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt b/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt index 9c679765..9b77b32b 100644 --- a/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt +++ b/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt @@ -34,7 +34,7 @@ class ImageUploadDialog : BindingBottomSheetDialog Date: Tue, 20 Aug 2024 23:59:20 +0900 Subject: [PATCH 04/12] =?UTF-8?q?[feat/#83]=20=EA=B0=A4=EB=9F=AC=EB=A6=AC?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=83=81=EB=8B=A8=EB=B7=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compileKotlin/cacheable/last-build.bin | Bin 18 -> 18 bytes .../local-state/build-history.bin | Bin 31 -> 65 bytes buildSrc/build/libs/buildSrc.jar | Bin 12626 -> 12626 bytes .../dpm/presentation/gallery/GalleryScreen.kt | 35 +++++++++++------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin b/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin index 30ae8eb2313cd246ea2e13dd4e477f085617ff96..2c4c3f06c20306b64dd7f502e0806d5ad62e6774 100644 GIT binary patch literal 18 YcmZ4UmVvdLhk=1{V(L4|xeP!605!w}y#N3J literal 18 YcmZ4UmVvdLhk=1{V%*I+8ySEA061?2H~;_u diff --git a/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin b/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin index 0b6c8d67d88f1c36ab6bb528ac37475de2a68857..586a0947a13df5c22c4abc966927dab7c2113db4 100644 GIT binary patch literal 65 ucmZ4UmVve0ngIfs85kHR#@(E=5y}Tqj1v diff --git a/buildSrc/build/libs/buildSrc.jar b/buildSrc/build/libs/buildSrc.jar index e34cd35c0b3d5a63d55c508550b3380f3279311b..08a6fa531a354064c39190bb47fd711f3c6139bd 100644 GIT binary patch delta 64 zcmcbVbSa59z?+#xgn@yBgW<;>p^3c3%s^^m^Ey!wz1c)eL>$DJ?5$e{7C53C#t3G} I>YFkF0Mu<3(EtDd delta 64 zcmcbVbSa59z?+#xgn@yBgMp<~a3XIpGmzTYyiOEEZ#EGV5eG3Qd+U~g1&-*3F;2dq L$Ff;Y--HPO2T~Am diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt index 69b1defd..56ea252f 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt @@ -19,22 +19,27 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.GridItemSpan import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Button import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable @@ -102,6 +107,21 @@ fun CustomGallery( } Column(modifier = Modifier.fillMaxSize()) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text("갤러리", style = MaterialTheme.typography.h6) + Button( + onClick = { + onImagesSelected(selectedItems.map { it.imageResource }) + } + ) { + Text("${selectedItems.size} 선택") + } + } if (isLoading) { CircularProgressIndicator(modifier = Modifier.align(Alignment.CenterHorizontally)) } else if (galleryItems.isNotEmpty()) { @@ -110,20 +130,9 @@ fun CustomGallery( contentPadding = PaddingValues(4.dp), ) { item( - key = "gallery_top_bar", + span = { GridItemSpan(3) }, + key = "gallery_top_title" ) { - Spacer(modifier = Modifier.height(8.dp)) - Button( - onClick = { - onImagesSelected(selectedItems.map { it.imageResource }) - }, - modifier = Modifier.align(Alignment.CenterHorizontally) - ) { - Text("${selectedItems.size} 선택") - } - } - - item(key = "gallery_top_title") { Text("갤러리 제목입니당~~", modifier = Modifier.align(Alignment.CenterHorizontally)) Spacer(modifier = Modifier.height(30.dp)) } From b8ad3916d406adb7b8dff293f05b4176c115d824 Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Sat, 24 Aug 2024 21:05:40 +0900 Subject: [PATCH 05/12] =?UTF-8?q?[feat/#83]=20=EA=B0=A4=EB=9F=AC=EB=A6=AC?= =?UTF-8?q?=20=EC=83=81=EB=8B=A8=EB=B0=94=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/build/kotlin/buildSrcjar-classes.txt | 2 +- .../compileKotlin/cacheable/last-build.bin | Bin 18 -> 18 bytes .../local-state/build-history.bin | Bin 31 -> 48 bytes buildSrc/build/libs/buildSrc.jar | Bin 12626 -> 12628 bytes .../presentation/gallery/GalleryActivity.kt | 7 +- .../dpm/presentation/gallery/GalleryScreen.kt | 143 ++++++++++++------ .../dpm/presentation/util/ComposableUtils.kt | 6 +- 7 files changed, 108 insertions(+), 50 deletions(-) diff --git a/buildSrc/build/kotlin/buildSrcjar-classes.txt b/buildSrc/build/kotlin/buildSrcjar-classes.txt index 3a74ac07..c98318a7 100644 --- a/buildSrc/build/kotlin/buildSrcjar-classes.txt +++ b/buildSrc/build/kotlin/buildSrcjar-classes.txt @@ -1 +1 @@ -C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\AndroidXDependencies.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\ClassPathPlugins.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\ComposeDependency.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\Constants.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\DependenciesKt.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\FirebaseDependencies.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\KaptDependencies.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\KotlinDependencies.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\MaterialDesignDependencies.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\TestDependencies.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\ThirdPartyDependencies.class;C:\Users\hojun\AndroidStudioProjects\depromeet\buildSrc\build\classes\kotlin\main\Versions.class \ No newline at end of file +/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/AndroidXDependencies.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/ClassPathPlugins.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/ComposeDependency.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/Constants.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/DependenciesKt.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/FirebaseDependencies.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/KaptDependencies.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/KotlinDependencies.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/MaterialDesignDependencies.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/TestDependencies.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/ThirdPartyDependencies.class:/Users/ssongsik/AndroidStudioProjects/SPOT-Android/buildSrc/build/classes/kotlin/main/Versions.class \ No newline at end of file diff --git a/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin b/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin index a86e531464242448d9ac96acf271466520598a8a..1486bb494f7565540056612ebf3f979574bc55be 100644 GIT binary patch literal 18 YcmZ4UmVvdLhk=1{V)IJDYz80z05hiqTmS$7 literal 18 YcmZ4UmVvdLhk=1{Vx^tVJq92E05eMjbpQYW diff --git a/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin b/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin index bc5ce9a7a160e39853f075092f66e857c589c167..313b59b0d7f456ccf3e932c3d148b1cf2dc8472b 100644 GIT binary patch literal 48 kcmZ4UmVvcgiva?d7#J8QHkWC?f$~8VP++BCHX}>~0MH!=9{>OV literal 31 ccmZ4UmVvcgk^ur385kHRR@&*@gYp>|09*(Jg8%>k diff --git a/buildSrc/build/libs/buildSrc.jar b/buildSrc/build/libs/buildSrc.jar index 40528c113364f311bcdd55e7d7d1557b77b3d245..e63c9a9fa147b34ce70373ba4b669818d8f56a05 100644 GIT binary patch delta 1613 zcmcbVbR~&5z?+#xgn@yBgJHo$iHW>w%ty9-o@nM(59CD#^Ev<8!OXyLhmC=OpMinF zIX|zsBr&g~ST8vzvA8%l#JBi%h={HKwp7`i<512HoxLeJle!M!BuibqS4Df`J-R#JT10e?!EWd;`yE5?{7l!cjBSn z@vYz2Uz?ctufE`RNqf@E$9Lm1Eau&n;j=0$sLv2`*IAK2Gw(K!%tLj@xyS0>lpp7I zX(~@Y-8(tB^y)Nw9-ZGSl~clm{eDL^-&pe1^YZG{jau6}^LF{q^Lfr|6~3`i)X7FI z`cU)C7}3g2k7IiO{A$_n`R`gtoalenl+};Y&4b<5T+}}Comk!3y2!Zrzvz_v%D=92 zM%Ww`{*_g4$WW}pE;6B8sVT`q)H0>fpSLFML2-?vnw-=Rq1)~WGS(F(EvkG| zlczgBTjAz5H(A+eo5eHBA{i<7#>FQJCv*QXIxcnG>i9irM9$ail88KU_DID}U_RFo zWMJT9VAx!uc8ZM~Rx|(=Yz~)BWnu;~xP)&&82c0!voZtAiOKtA6Tvc{*?&T0S|l!j z85^6guz+Qh31~4fFqi?0I|Yd8 zP%9j`C#Oj(O)}(B00q;XJ!xwf1J&IGnka>$ZUygTLwyafqA=eh-Z`uc4ADFc3^FK+ zngu4GRgeQ22J+X-0=jy3~xeN5AnK~sW z@6}fWTXo~l=8f}#Zb{`rcTbGWl6>-GXUbe*VFn6su2P%E1ZK<< z`^m%$l#0~-wP3vLY+q9-oP0?Pb1rKa;{R5r?(({?sYz;haQ}{S6rJB+FtpZ1~wVIUq z>%^G%zyEy;)puU`s8mtbe51~+=$RRL9r0TAvFcN1Yl%tZl^(wFo#}JR1>?O6Ws47d z^VJrRcxP$yINGJWFLwECv(I~FC#o?@zUw{Bw|xKKZBADA4*!2XbfYHwT3VF3X;O%kTQT9fz}D_}y5&#lKp#PU@JJUD5@O zqE|oj7T>Kud!cESDGPpx8ZOnJ1pi~q$! zPVK)>IM;iHRZo8S_2|uAYP#ODQex(0PSWBrwf$W3>ecJ%mp&c6IV~i$fAgx6pPQ8= zFLm#k7&&#-C;sXB{H`v$Ef!xm^L2vL!Z#@%bKTZTZO+v2UuaX`8kQPrT(mtk)cl#o zTz}VNmp->SzHAEI^T#z(ApB<1qo%CY?|;5^dvd|W-M-n&JT0R7B7f5Q=TQd_JdQhE z{(b$liHYy(3od{Ao%FPQwtf6(rtSCMZ@u&4f?8k1`3oEWE|aZ1oM&6vHhP{`zPvhhqf%LC-Y)-nPS1I*!Z$RgI@zd2 zA8KA1!&= z8!Ecgzg%r+I5SBmz(KE*qexZtbp3%JrCqCg3ZDvYZ%|su@?9}iW#R5JzT{mW>L=7B zb9kIQ6y=fkGvr2(%)%WVOG66R%)WYm8O!GUmuWQ`tZNcwXS$^K&sbEDxA@1o`8zfj z_FX;sZ%RnsjrhDP@qJN3m+REHHicBKi4-k&FJ7+}lkhR$!+zf(_U9TWO*$U^-6G|^ zs`I}>uSMl5jfa(&j)re|@kZcL@~ji;?k6HVeq1?}E@pRJJmt~CR{f2&EXOuBySqm` zxnNOdDbnYa6k=&6l-!-%r+j>2v4};NjQP$3`h{x>*A&0m%ZQTwHw$a(vT!4n2b;I@ z-e3Y31-F&wKp4{`FF+W++^OI)VX~Q6B3Oxo;tWV3F+pH4E4Z}CV7bM{%g7|c3@>0N z`|6s2N|?zly7uy*a^%LJ%^T;lFfgQYF)&CmAi$EwvdQH#vXce$c@%&pP~^Ym-+!bs zF)&O7mN{YwWeiIieOV_zF;D^7H#tXNn&}z)08op00RR91 diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt index a2622289..67a5aaae 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt @@ -19,9 +19,10 @@ class GalleryActivity : BaseActivity( private fun initView() { binding.cvGallery.setContent { MaterialTheme { - GalleryScreen { - - } + GalleryScreen( + onImagesSelected = { }, + onBackPressed = { finish() } + ) } } } diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt index 56ea252f..8e68d7aa 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt @@ -31,6 +31,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.GridItemSpan @@ -40,8 +41,11 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Button import androidx.compose.material.CircularProgressIndicator import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold import androidx.compose.material.Surface import androidx.compose.material.Text +import androidx.compose.material.TopAppBar +import androidx.compose.material.contentColorFor import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -52,9 +56,12 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.vectorResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat @@ -63,6 +70,8 @@ import androidx.fragment.app.setFragmentResult import coil.compose.AsyncImage import coil.compose.rememberImagePainter import com.depromeet.presentation.R +import com.dpm.designsystem.compose.ui.SpotTheme +import com.dpm.presentation.util.MultiStyleText import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -70,14 +79,18 @@ import kotlinx.coroutines.withContext @Composable fun GalleryScreen( - onImagesSelected: (List) -> Unit + onImagesSelected: (List) -> Unit, + onBackPressed: () -> Unit = { } ) { - CustomGallery(onImagesSelected) + CustomGallery(onImagesSelected) { + onBackPressed() + } } @Composable fun CustomGallery( - onImagesSelected : (List) -> Unit + onImagesSelected : (List) -> Unit, + onBackPressed: () -> Unit = { } ) { var galleryItems by remember { mutableStateOf>(emptyList()) } val selectedItems = remember { mutableStateListOf() } @@ -106,54 +119,96 @@ fun CustomGallery( } } - Column(modifier = Modifier.fillMaxSize()) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(16.dp), - horizontalArrangement = Arrangement.SpaceBetween - ) { - Text("갤러리", style = MaterialTheme.typography.h6) - Button( - onClick = { - onImagesSelected(selectedItems.map { it.imageResource }) + Scaffold( + topBar = { + TopAppBar( + title = { + Text( + modifier = Modifier.fillMaxWidth(), + text = "갤러리", + style = SpotTheme.typography.subtitle02, + textAlign = TextAlign.Center + ) + }, + navigationIcon = { + Image( + modifier = Modifier + .padding(start = 14.dp, top = 8.dp, bottom = 8.dp) + .clickable { onBackPressed() }, + imageVector = ImageVector.vectorResource(id = R.drawable.ic_chevron_left), + contentDescription = "back" + ) + }, + backgroundColor = Color.White, + actions = { + Box(modifier = Modifier.width(60.dp)) { + if (selectedItems.isEmpty()) { + Text( + modifier = Modifier.align(Alignment.CenterEnd).padding(end = 16.dp), + text = "선택", + style = SpotTheme.typography.body02, + ) + } else { + MultiStyleText( + modifier = Modifier.align(Alignment.CenterEnd).padding(end = 16.dp), + style = SpotTheme.typography.body02, + textWithColors = arrayOf( + Pair( + "${selectedItems.size} 선택".substring(0, 1), + SpotTheme.colors.actionEnabled + ), + Pair( + "${selectedItems.size} 선택".substring( + 1, + "${selectedItems.size} 선택".length + ), SpotTheme.colors.foregroundBodySebtext + ) + ) + ) + } + } } - ) { - Text("${selectedItems.size} 선택") - } + ) } - if (isLoading) { - CircularProgressIndicator(modifier = Modifier.align(Alignment.CenterHorizontally)) - } else if (galleryItems.isNotEmpty()) { - LazyVerticalGrid( - columns = GridCells.Fixed(3), - contentPadding = PaddingValues(4.dp), - ) { - item( - span = { GridItemSpan(3) }, - key = "gallery_top_title" + ) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(it) + ) { + if (isLoading) { + CircularProgressIndicator(modifier = Modifier.align(Alignment.CenterHorizontally)) + } else if (galleryItems.isNotEmpty()) { + LazyVerticalGrid( + columns = GridCells.Fixed(3), + contentPadding = PaddingValues(4.dp), ) { - Text("갤러리 제목입니당~~", modifier = Modifier.align(Alignment.CenterHorizontally)) - Spacer(modifier = Modifier.height(30.dp)) - } + item( + span = { GridItemSpan(3) }, + key = "gallery_top_title" + ) { + Text("갤러리 제목입니당~~", modifier = Modifier.align(Alignment.CenterHorizontally)) + Spacer(modifier = Modifier.height(30.dp)) + } - items(galleryItems) { item -> - GalleryItemView( - item = item, - isSelected = selectedItems.contains(item), - selectedIndex = selectedItems.indexOf(item) + 1, - onClick = { - if (selectedItems.contains(item)) { - selectedItems.remove(item) - } else if (selectedItems.size < 3) { - selectedItems.add(item) + items(galleryItems) { item -> + GalleryItemView( + item = item, + isSelected = selectedItems.contains(item), + selectedIndex = selectedItems.indexOf(item) + 1, + onClick = { + if (selectedItems.contains(item)) { + selectedItems.remove(item) + } else if (selectedItems.size < 3) { + selectedItems.add(item) + } } - } - ) + ) + } } + } else { + Text("No images found", modifier = Modifier.align(Alignment.CenterHorizontally)) } - } else { - Text("No images found", modifier = Modifier.align(Alignment.CenterHorizontally)) } } } diff --git a/presentation/src/main/java/com/dpm/presentation/util/ComposableUtils.kt b/presentation/src/main/java/com/dpm/presentation/util/ComposableUtils.kt index eefe26ef..fd92dbc0 100644 --- a/presentation/src/main/java/com/dpm/presentation/util/ComposableUtils.kt +++ b/presentation/src/main/java/com/dpm/presentation/util/ComposableUtils.kt @@ -2,6 +2,7 @@ package com.dpm.presentation.util import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.TextStyle @@ -9,9 +10,10 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.withStyle @Composable -fun MultiStyleText(style: TextStyle, vararg textWithColors: Pair) { +fun MultiStyleText(modifier: Modifier = Modifier, style: TextStyle, vararg textWithColors: Pair) { Text( - buildAnnotatedString { + modifier = modifier, + text = buildAnnotatedString { textWithColors.forEach { (text, color) -> withStyle(style = SpanStyle(color = color)) { append(text) From b5cdac51be6c2808ab4cd77a6bb0c063e2cd09d0 Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Sat, 24 Aug 2024 23:03:52 +0900 Subject: [PATCH 06/12] =?UTF-8?q?[feat/#83]=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8,=20=EA=B0=A4?= =?UTF-8?q?=EB=9F=AC=EB=A6=AC=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/gallery/GalleryActivity.kt | 18 +++++++++- .../dpm/presentation/gallery/GalleryScreen.kt | 15 +++++--- .../presentation/seatreview/ReviewActivity.kt | 2 +- .../seatreview/dialog/ImageUploadDialog.kt | 36 ++++++++++--------- .../com/dpm/presentation/util/ScreenType.kt | 6 ++++ 5 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 presentation/src/main/java/com/dpm/presentation/util/ScreenType.kt diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt index 67a5aaae..d60cc181 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt @@ -1,9 +1,14 @@ package com.dpm.presentation.gallery +import android.app.Activity +import android.content.Intent import android.os.Bundle import androidx.compose.material.MaterialTheme +import androidx.core.os.bundleOf import com.depromeet.presentation.databinding.ActivityGalleryBinding import com.dpm.core.base.BaseActivity +import com.dpm.presentation.seatreview.dialog.ImageUploadDialog +import com.dpm.presentation.seatreview.dialog.ImageUploadDialog.Companion.SELECTED_IMAGES import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint @@ -17,10 +22,21 @@ class GalleryActivity : BaseActivity( } private fun initView() { + val screenType = intent.getStringExtra("screenType") ?: "review" binding.cvGallery.setContent { MaterialTheme { GalleryScreen( - onImagesSelected = { }, + screenType = screenType, + onImagesSelected = { + if (screenType == "review") { + setResult(Activity.RESULT_OK, Intent().apply { + putStringArrayListExtra(SELECTED_IMAGES, ArrayList(it.map { uri -> uri.toString() })) + }) + finish() + } else { + + } + }, onBackPressed = { finish() } ) } diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt index 8e68d7aa..d7495378 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt @@ -79,12 +79,14 @@ import kotlinx.coroutines.withContext @Composable fun GalleryScreen( + screenType: String, onImagesSelected: (List) -> Unit, onBackPressed: () -> Unit = { } ) { - CustomGallery(onImagesSelected) { - onBackPressed() - } + CustomGallery( + onImagesSelected = onImagesSelected, + onBackPressed = onBackPressed + ) } @Composable @@ -150,7 +152,12 @@ fun CustomGallery( ) } else { MultiStyleText( - modifier = Modifier.align(Alignment.CenterEnd).padding(end = 16.dp), + modifier = Modifier + .align(Alignment.CenterEnd).padding(end = 16.dp) + .clickable { + onImagesSelected(selectedItems.map { it.imageResource }) + onBackPressed() + }, style = SpotTheme.typography.body02, textWithColors = arrayOf( Pair( diff --git a/presentation/src/main/java/com/dpm/presentation/seatreview/ReviewActivity.kt b/presentation/src/main/java/com/dpm/presentation/seatreview/ReviewActivity.kt index d7884bcf..36137eed 100644 --- a/presentation/src/main/java/com/dpm/presentation/seatreview/ReviewActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/seatreview/ReviewActivity.kt @@ -41,7 +41,7 @@ class ReviewActivity : BaseActivity({ companion object { private const val DATE_FORMAT = "yyyy.MM.dd" private const val ISO_DATE_FORMAT = "yyyy-MM-dd HH:mm" - private const val FRAGMENT_RESULT_KEY = "requestKey" + const val FRAGMENT_RESULT_KEY = "requestKey" private const val SELECTED_IMAGES = "selected_images" private const val MAX_SELECTED_IMAGES = 3 private const val REVIEW_MY_SEAT_DIALOG = "ReviewMySeatDialog" diff --git a/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt b/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt index eb8edace..bf98abad 100644 --- a/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt +++ b/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt @@ -2,6 +2,7 @@ package com.dpm.presentation.seatreview.dialog import android.Manifest import android.annotation.SuppressLint +import android.app.Activity import android.app.Activity.RESULT_OK import android.content.Context import android.content.Intent @@ -23,7 +24,10 @@ import com.depromeet.presentation.R import com.depromeet.presentation.databinding.FragmentUploadBottomSheetBinding import com.dpm.presentation.extension.setOnSingleClickListener import com.dpm.presentation.extension.toast +import com.dpm.presentation.gallery.GalleryActivity +import com.dpm.presentation.home.HomeActivity import com.dpm.presentation.home.dialog.UploadErrorDialog +import com.dpm.presentation.seatreview.ReviewActivity.Companion.FRAGMENT_RESULT_KEY import dagger.hilt.android.AndroidEntryPoint import java.io.File @@ -35,15 +39,24 @@ class ImageUploadDialog : BindingBottomSheetDialog private lateinit var takePhotoLauncher: ActivityResultLauncher private var imageUri: Uri? = null + private val galleryLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> + if (result.resultCode == RESULT_OK) { + val selectedImages = result.data?.getStringArrayListExtra(SELECTED_IMAGES) + selectedImages?.let { + setFragmentResult(FRAGMENT_RESULT_KEY, bundleOf(SELECTED_IMAGES to it)) + dismiss() + } + } + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setStyle(STYLE_NORMAL, R.style.TransparentBottomSheetDialogFragment) @@ -57,9 +70,10 @@ class ImageUploadDialog : BindingBottomSheetDialog - val validUris = uris.filter { uri -> - initCapacityLimitDialog(uri) - } - if (validUris.isNotEmpty()) { - val uriList = validUris.map { it.toString() } - setFragmentResult(REQUEST_KEY, bundleOf(SELECTED_IMAGES to uriList)) - } - dismiss() - } - takePhotoLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> if (result.resultCode == RESULT_OK) { diff --git a/presentation/src/main/java/com/dpm/presentation/util/ScreenType.kt b/presentation/src/main/java/com/dpm/presentation/util/ScreenType.kt new file mode 100644 index 00000000..2842d9f4 --- /dev/null +++ b/presentation/src/main/java/com/dpm/presentation/util/ScreenType.kt @@ -0,0 +1,6 @@ +package com.dpm.presentation.util + +enum class ScreenType { + REVIEW, + PROFILE +} \ No newline at end of file From 1095ed7d840e0af957e2db3b7abd7db1217603ec Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Sat, 24 Aug 2024 23:40:02 +0900 Subject: [PATCH 07/12] =?UTF-8?q?[feat/#83]=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dpm/presentation/gallery/GalleryActivity.kt | 5 +++-- .../main/java/com/dpm/presentation/gallery/GalleryScreen.kt | 1 + .../src/main/java/com/dpm/presentation/home/HomeActivity.kt | 6 ------ .../dpm/presentation/seatreview/dialog/ImageUploadDialog.kt | 3 ++- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt index d60cc181..610e6b6f 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt @@ -9,6 +9,7 @@ import com.depromeet.presentation.databinding.ActivityGalleryBinding import com.dpm.core.base.BaseActivity import com.dpm.presentation.seatreview.dialog.ImageUploadDialog import com.dpm.presentation.seatreview.dialog.ImageUploadDialog.Companion.SELECTED_IMAGES +import com.dpm.presentation.util.ScreenType import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint @@ -22,13 +23,13 @@ class GalleryActivity : BaseActivity( } private fun initView() { - val screenType = intent.getStringExtra("screenType") ?: "review" + val screenType = intent.getStringExtra("screenType") ?: ScreenType.REVIEW.name binding.cvGallery.setContent { MaterialTheme { GalleryScreen( screenType = screenType, onImagesSelected = { - if (screenType == "review") { + if (screenType == ScreenType.REVIEW.name) { setResult(Activity.RESULT_OK, Intent().apply { putStringArrayListExtra(SELECTED_IMAGES, ArrayList(it.map { uri -> uri.toString() })) }) diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt index d7495378..cc15d2a2 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt @@ -72,6 +72,7 @@ import coil.compose.rememberImagePainter import com.depromeet.presentation.R import com.dpm.designsystem.compose.ui.SpotTheme import com.dpm.presentation.util.MultiStyleText +import com.dpm.presentation.util.ScreenType import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt b/presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt index 73830048..06748e1a 100644 --- a/presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/home/HomeActivity.kt @@ -13,7 +13,6 @@ import com.dpm.designsystem.SpotImageSnackBar import com.dpm.domain.entity.response.home.ResponseHomeFeed import com.dpm.domain.entity.response.viewfinder.ResponseStadiums import com.dpm.presentation.extension.dpToPx -import com.dpm.presentation.gallery.GalleryActivity import com.dpm.presentation.home.adapter.StadiumAdapter import com.dpm.presentation.home.dialog.LevelDescriptionDialog import com.dpm.presentation.home.dialog.LevelupDialog @@ -61,11 +60,6 @@ class HomeActivity : BaseActivity( } private fun initEvent() = with(binding) { - ivHomeAppBar.setOnClickListener { - Intent(this@HomeActivity, GalleryActivity::class.java).apply { - startActivity(this) - } - } clHomeArchiving.setOnClickListener { startSeatRecordActivity() } ivHomeInfo.setOnClickListener { showLevelDescriptionDialog() } clHomeScrap.setOnClickListener { diff --git a/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt b/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt index bf98abad..7c87ee9a 100644 --- a/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt +++ b/presentation/src/main/java/com/dpm/presentation/seatreview/dialog/ImageUploadDialog.kt @@ -28,6 +28,7 @@ import com.dpm.presentation.gallery.GalleryActivity import com.dpm.presentation.home.HomeActivity import com.dpm.presentation.home.dialog.UploadErrorDialog import com.dpm.presentation.seatreview.ReviewActivity.Companion.FRAGMENT_RESULT_KEY +import com.dpm.presentation.util.ScreenType import dagger.hilt.android.AndroidEntryPoint import java.io.File @@ -71,7 +72,7 @@ class ImageUploadDialog : BindingBottomSheetDialog Date: Sun, 25 Aug 2024 00:22:16 +0900 Subject: [PATCH 08/12] =?UTF-8?q?[feat/#83]=20=EA=B0=A4=EB=9F=AC=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compileKotlin/cacheable/last-build.bin | Bin 18 -> 18 bytes .../local-state/build-history.bin | Bin 31 -> 31 bytes buildSrc/build/libs/buildSrc.jar | Bin 12628 -> 12628 bytes .../presentation/gallery/GalleryActivity.kt | 4 +- .../dpm/presentation/gallery/GalleryScreen.kt | 37 ++++++++++++++---- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin b/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin index d9fa56953bffd44e3d984c36363094a39b62c43b..ffcc628c253c75afa8aacd86b2c3e95f7caaf790 100644 GIT binary patch literal 18 YcmZ4UmVvdLhk=1{V#_1%XAD390675#O8@`> literal 18 YcmZ4UmVvdLhk=1{V(DIgK?WcI05f$2MgRZ+ diff --git a/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin b/buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin index 14cd9f30912201bed97fa6aa777dff3911f79043..873f309523a16df02136f9567b2fe168c36343a5 100644 GIT binary patch literal 31 dcmZ4UmVvcgk^ur385kHRwmkBF2IVs_003p|1z7+9 literal 31 ccmZ4UmVvcgk^ur385kHRmhSZzgz^~}09!`{Q~&?~ diff --git a/buildSrc/build/libs/buildSrc.jar b/buildSrc/build/libs/buildSrc.jar index daec2f307ebbb22416ddeeb2a4adc3533f2d8c17..f13397b9e2a356a03cf446426c9378fe6fb4b44b 100644 GIT binary patch delta 265 zcmcbTbR~&5z?+#xgn@yBgW>5uiHW>wEJwC{j+kif$qeLfY<|QHqBm!-JYoYge7RGZ zz>KZDHz14&0*hHeB9qO;62UUF#C}3#rb%9aFfwJXuz;l;6lXw0ZY$4$Fsjt1K^VfC z=3q6GeRWO1PMF-PYX>&>n64F=X4bO=)AoAaV7gb&6--~%a|hG%`d(lg)|1!Te?@eH==28+rl&ynv zn6Z`j281y|U@ @@ -286,7 +304,7 @@ fun GalleryItemView( ) { Box( modifier = Modifier - .padding(4.dp) + .padding(0.5.dp) .aspectRatio(1f) .clickable { onClick() } ) { @@ -299,9 +317,10 @@ fun GalleryItemView( if (isSelected) { Box( modifier = Modifier + .padding(8.dp) .size(24.dp) .align(Alignment.TopEnd) - .background(Color.Red, shape = CircleShape) + .background(SpotTheme.colors.strokePositivePrimary, shape = CircleShape) ) { Text( text = selectedIndex.toString(), @@ -312,9 +331,11 @@ fun GalleryItemView( } else { Box( modifier = Modifier + .padding(8.dp) .size(24.dp) .align(Alignment.TopEnd) - .border(2.dp, Color.Gray, CircleShape) + .border(2.dp, Color.White, CircleShape) + .background(SpotTheme.colors.transferBlack01, shape = CircleShape) ) } } From aa49a1e74b6441ccba15c8ee97031dd2b03c632e Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Sun, 25 Aug 2024 16:30:02 +0900 Subject: [PATCH 09/12] =?UTF-8?q?[feat/#83]=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=20=EC=9D=B8=ED=85=90=ED=8A=B8=20=ED=83=80=EC=9E=85=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/gallery/GalleryActivity.kt | 6 ++++- .../home/dialog/ProfileImageUploadDialog.kt | 23 ++++++++++++++++++- .../dialog/main/ImageUploadDialog.kt | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt index d5f66ad3..ddf296ae 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryActivity.kt @@ -6,6 +6,7 @@ import android.os.Bundle import androidx.compose.material.MaterialTheme import com.depromeet.presentation.databinding.ActivityGalleryBinding import com.dpm.core.base.BaseActivity +import com.dpm.presentation.home.dialog.ProfileImageUploadDialog.Companion.SELECTED_IMAGE import com.dpm.presentation.seatreview.dialog.main.ImageUploadDialog.Companion.SELECTED_IMAGES import com.dpm.presentation.util.ScreenType import dagger.hilt.android.AndroidEntryPoint @@ -33,7 +34,10 @@ class GalleryActivity : BaseActivity( }) finish() } else { - + setResult(Activity.RESULT_OK, Intent().apply { + putExtra(SELECTED_IMAGE, it[0].toString()) + }) + finish() } }, onBackPressed = { finish() } diff --git a/presentation/src/main/java/com/dpm/presentation/home/dialog/ProfileImageUploadDialog.kt b/presentation/src/main/java/com/dpm/presentation/home/dialog/ProfileImageUploadDialog.kt index f8de679b..cc86b7d4 100644 --- a/presentation/src/main/java/com/dpm/presentation/home/dialog/ProfileImageUploadDialog.kt +++ b/presentation/src/main/java/com/dpm/presentation/home/dialog/ProfileImageUploadDialog.kt @@ -16,12 +16,18 @@ import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.core.content.ContextCompat import androidx.core.content.FileProvider +import androidx.core.os.bundleOf import androidx.fragment.app.activityViewModels +import androidx.fragment.app.setFragmentResult import com.depromeet.presentation.R import com.depromeet.presentation.databinding.FragmentProfileEditBottomSheetBinding import com.dpm.core.base.BindingBottomSheetDialog import com.dpm.presentation.extension.toast +import com.dpm.presentation.gallery.GalleryActivity import com.dpm.presentation.home.viewmodel.ProfileEditViewModel +import com.dpm.presentation.seatreview.ReviewActivity +import com.dpm.presentation.seatreview.dialog.main.ImageUploadDialog +import com.dpm.presentation.util.ScreenType import dagger.hilt.android.AndroidEntryPoint import java.io.File @@ -30,6 +36,9 @@ class ProfileImageUploadDialog() : BindingBottomSheetDialog private var imageUri: Uri? = null + private val galleryLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> + if (result.resultCode == RESULT_OK) { + val selectedImages = result.data?.getStringExtra(SELECTED_IMAGE) + selectedImages?.let { + handleSelectedImage(Uri.parse(it)) + } + } + } + private val activityResultLauncher = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { permissions -> var permissionGranted = true @@ -75,7 +93,10 @@ class ProfileImageUploadDialog() : BindingBottomSheetDialog Date: Sun, 25 Aug 2024 16:33:37 +0900 Subject: [PATCH 10/12] =?UTF-8?q?[feat/#83]=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20UI=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dpm/presentation/gallery/GalleryScreen.kt | 60 ++++++++++++------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt index df605258..b3f498d8 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt @@ -85,6 +85,7 @@ fun GalleryScreen( onBackPressed: () -> Unit = { } ) { CustomGallery( + screenType = screenType, onImagesSelected = onImagesSelected, onBackPressed = onBackPressed ) @@ -92,6 +93,7 @@ fun GalleryScreen( @Composable fun CustomGallery( + screenType: String, onImagesSelected : (List) -> Unit, onBackPressed: () -> Unit = { } ) { @@ -108,7 +110,7 @@ fun CustomGallery( isLoading = false } } else { - Toast.makeText(context, "권한이 거절되어있어용~", Toast.LENGTH_SHORT).show() + Toast.makeText(context, "권한이 거절되어 있습니다.", Toast.LENGTH_SHORT).show() isLoading = false } } @@ -154,28 +156,39 @@ fun CustomGallery( style = SpotTheme.typography.body02, ) } else { - MultiStyleText( - modifier = Modifier - .align(Alignment.CenterEnd) - .padding(end = 16.dp) - .clickable { - onImagesSelected(selectedItems.map { it.imageResource }) - onBackPressed() - }, - style = SpotTheme.typography.body02, - textWithColors = arrayOf( - Pair( - "${selectedItems.size} 선택".substring(0, 1), - SpotTheme.colors.actionEnabled - ), - Pair( - "${selectedItems.size} 선택".substring( - 1, - "${selectedItems.size} 선택".length - ), SpotTheme.colors.foregroundBodySebtext + if (screenType == ScreenType.REVIEW.name) { + MultiStyleText( + modifier = Modifier + .align(Alignment.CenterEnd) + .padding(end = 16.dp) + .clickable { + onImagesSelected(selectedItems.map { it.imageResource }) + onBackPressed() + }, + style = SpotTheme.typography.body02, + textWithColors = arrayOf( + Pair( + "${selectedItems.size} 선택".substring(0, 1), + SpotTheme.colors.actionEnabled + ), + Pair( + "${selectedItems.size} 선택".substring( + 1, + "${selectedItems.size} 선택".length + ), SpotTheme.colors.foregroundBodySebtext + ) ) ) - ) + } else { + Text( + modifier = Modifier + .align(Alignment.CenterEnd) + .padding(end = 16.dp), + text = "선택", + style = SpotTheme.typography.body02, + color = SpotTheme.colors.actionEnabled + ) + } } } } @@ -188,7 +201,10 @@ fun CustomGallery( .padding(it) ) { if (isLoading) { - CircularProgressIndicator(modifier = Modifier.align(Alignment.CenterHorizontally)) + CircularProgressIndicator( + modifier = Modifier.align(Alignment.CenterHorizontally), + color = SpotTheme.colors.actionEnabled + ) } else if (galleryItems.isNotEmpty()) { LazyVerticalGrid( columns = GridCells.Fixed(3), From 7f2aea6b036a9dff994f543aaaa20ac7118c8148 Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Sun, 25 Aug 2024 16:42:58 +0900 Subject: [PATCH 11/12] =?UTF-8?q?[feat/#83]=20=ED=99=94=EB=A9=B4=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=ED=83=80=EC=9D=B4=ED=8B=80=ED=85=8D=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=B6=84=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dpm/presentation/gallery/GalleryScreen.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt index b3f498d8..489beab3 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt @@ -183,7 +183,11 @@ fun CustomGallery( Text( modifier = Modifier .align(Alignment.CenterEnd) - .padding(end = 16.dp), + .padding(end = 16.dp) + .clickable { + onImagesSelected(selectedItems.map { it.imageResource }) + onBackPressed() + }, text = "선택", style = SpotTheme.typography.body02, color = SpotTheme.colors.actionEnabled @@ -216,14 +220,22 @@ fun CustomGallery( Column { Spacer(modifier = Modifier.height(30.dp)) Text( - text = "\uD83D\uDC40 잊지 못할 직관 후기 사진을 남겨보세요 ⚾️", + text = if (screenType == ScreenType.REVIEW.name) { + "\uD83D\uDC40 잊지 못할 직관 후기 사진을 남겨보세요 ⚾️" + } else { + "프로필 사진을 선택해 주세요" + }, modifier = Modifier.fillMaxWidth(), style = SpotTheme.typography.subtitle02, textAlign = TextAlign.Center, color = SpotTheme.colors.foregroundBodySubtitle ) Text( - text = "사진, 영상 포함 최대 3장, 15mb까지 올릴 수 있어요", + text = if (screenType == ScreenType.REVIEW.name) { + "사진, 영상 포함 최대 3장, 15mb까지 올릴 수 있어요" + } else { + "최대 5MB까지 올릴 수 있어요" + }, modifier = Modifier.fillMaxWidth(), style = SpotTheme.typography.body03, textAlign = TextAlign.Center, From 7e3ffdba9578f021c4fbdc99715d80571cd80617 Mon Sep 17 00:00:00 2001 From: sgsk88 Date: Sun, 25 Aug 2024 16:52:26 +0900 Subject: [PATCH 12/12] =?UTF-8?q?[feat/#83]=20=EC=84=A0=ED=83=9D=EB=90=9C?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=8A=A4=ED=81=AC=EB=A6=B0?= =?UTF-8?q?=ED=83=80=EC=9E=85=20UI=20=EB=B6=84=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/drawable/ic_image_selected.xml | 25 +++++++++ .../dpm/presentation/gallery/GalleryScreen.kt | 54 +++++++++++++------ 2 files changed, 64 insertions(+), 15 deletions(-) create mode 100644 core/designsystem/src/main/res/drawable/ic_image_selected.xml diff --git a/core/designsystem/src/main/res/drawable/ic_image_selected.xml b/core/designsystem/src/main/res/drawable/ic_image_selected.xml new file mode 100644 index 00000000..e62090c7 --- /dev/null +++ b/core/designsystem/src/main/res/drawable/ic_image_selected.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + diff --git a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt index 489beab3..78549fa3 100644 --- a/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt +++ b/presentation/src/main/java/com/dpm/presentation/gallery/GalleryScreen.kt @@ -247,14 +247,26 @@ fun CustomGallery( items(galleryItems) { item -> GalleryItemView( + screenType = screenType, item = item, isSelected = selectedItems.contains(item), selectedIndex = selectedItems.indexOf(item) + 1, onClick = { - if (selectedItems.contains(item)) { - selectedItems.remove(item) - } else if (selectedItems.size < 3) { - selectedItems.add(item) + if (screenType == ScreenType.REVIEW.name) { + if (selectedItems.contains(item)) { + selectedItems.remove(item) + } else if (selectedItems.size < 3) { + selectedItems.add(item) + } + } else { + if (selectedItems.contains(item)) { + selectedItems.remove(item) + } else if (selectedItems.size < 1) { + selectedItems.add(item) + } else { + selectedItems.remove(selectedItems[0]) + selectedItems.add(item) + } } } ) @@ -325,6 +337,7 @@ fun loadImages(context: Context, onComplete: (List) -> Unit) { @Composable fun GalleryItemView( + screenType: String, item: GalleryItem, isSelected: Boolean, selectedIndex: Int, @@ -343,17 +356,28 @@ fun GalleryItemView( ) if (isSelected) { - Box( - modifier = Modifier - .padding(8.dp) - .size(24.dp) - .align(Alignment.TopEnd) - .background(SpotTheme.colors.strokePositivePrimary, shape = CircleShape) - ) { - Text( - text = selectedIndex.toString(), - color = Color.White, - modifier = Modifier.align(Alignment.Center) + if (screenType == ScreenType.REVIEW.name) { + Box( + modifier = Modifier + .padding(8.dp) + .size(24.dp) + .align(Alignment.TopEnd) + .background(SpotTheme.colors.strokePositivePrimary, shape = CircleShape) + ) { + Text( + text = selectedIndex.toString(), + color = Color.White, + modifier = Modifier.align(Alignment.Center) + ) + } + } else { + Image( + imageVector = ImageVector.vectorResource(id = com.depromeet.designsystem.R.drawable.ic_image_selected), + contentDescription = "selected", + modifier = Modifier + .padding(8.dp) + .size(24.dp) + .align(Alignment.TopEnd) ) } } else {