Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<!-- To use IP camera for external camera type-->
<!-- TODO: need to check to move this permission to presenter module -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />

<application
android:name=".MainApplication"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class AppPreferencesRepository @Inject constructor(
it.internalCameraCaptureMode
}

override suspend fun setInterenalCameraCaptureMode(
override suspend fun setInternalCameraCaptureMode(
@IntRange(from = 0, to = 2) captureMode: Int
) {
appPreferences.updateData {
Expand All @@ -98,20 +98,6 @@ class AppPreferencesRepository @Inject constructor(
}
}

override fun getInternalCameraAspectRatio(): Flow<Int> =
appPreferencesFlow.map {
it.internalCameraAspectRatio
}

override suspend fun setInterenalCameraAspectRatio(
@IntRange(from = -1, to = 1) aspectRatio: Int
) {
appPreferences.updateData {
it.toBuilder()
.setInternalCameraAspectRatio(aspectRatio)
.build()
}
}

override suspend fun clearAll() {
appPreferences.updateData {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.foke.together.domain.interactor
import android.content.Context
import android.graphics.Bitmap
import android.net.Uri
import com.foke.together.domain.interactor.entity.CameraSourceType
import com.foke.together.domain.output.ImageRepositoryInterface
import com.foke.together.util.AppPolicy
import dagger.hilt.android.qualifiers.ApplicationContext
Expand All @@ -16,7 +17,7 @@ class GeneratePhotoFrameUseCaseV1 @Inject constructor(
// 촬영한 이미지 리스트 관리
// TODO: 추후 세션 관리와 엮어서 처리하기
@Deprecated("Not in use")
fun getCapturedImageListUri(): List<Uri> = imageRepositoryInterface.getCachedImageUriList()
fun getCapturedImageListUri(sourceType: CameraSourceType): List<Uri> = imageRepositoryInterface.getCachedImageUriList(sourceType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GeneratePhotoFrameUseCaseV1 을 deprecated한 이유가 Session으로 전환 작업을 위한 내용이었는데
아래 커밋 참고해보면 좋을 것 같습니다~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 내용은 InternalCamera로 기존 기초적인 실행을 위해 인자를 추가했습니다.
Deprecated 된 함수인건 확인하고있습니다.

@Deprecated("Not in use")
suspend fun clearCapturedImageList() = imageRepositoryInterface.clearCacheDir()

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,35 @@ import androidx.lifecycle.LifecycleOwner
import com.foke.together.domain.output.InternalCameraRepositoryInterface
import javax.inject.Inject

class GetInternalCameraPreviewUseCase @Inject constructor(
class InternalCameraUseCase @Inject constructor(
private val internalCameraRepository: InternalCameraRepositoryInterface,
) {
suspend operator fun invoke(
suspend fun initial(
context: Context,
previewView: PreviewView,
lifecycleOwner: LifecycleOwner,
previewView : PreviewView,
cameraSelector: CameraSelector,
imageAnalysis: ImageAnalysis?,
imageAnalyzer: ImageAnalysis.Analyzer?,
@IntRange(from = 0, to = 2) captureMode: Int,
@IntRange(from = 0, to = 3) flashMode: Int,
@IntRange(from = -1, to = 1) aspectRatio: Int
) = internalCameraRepository.showCameraPreview(
) = internalCameraRepository.initial(
context = context,
lifecycleOwner = lifecycleOwner,
previewView = previewView,
selector = cameraSelector,
imageAnalysis = imageAnalysis,
captureMode = captureMode,
flashMode = flashMode,
aspectRatio = aspectRatio
selector = cameraSelector,
imageAnalyzer = imageAnalyzer,
previewView = previewView,
)

suspend fun capture(
context: Context,
fileName : String,
) = internalCameraRepository.capture(
context = context,
fileName = fileName
)
suspend fun release(
context: Context
) = internalCameraRepository.release(context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ interface AppPreferenceInterface {
)

fun getInternalCameraCaptureMode(): Flow<Int>
suspend fun setInterenalCameraCaptureMode(
suspend fun setInternalCameraCaptureMode(
@IntRange(from = 0, to = 2) captureMode: Int
)

fun getInternalCameraAspectRatio(): Flow<Int>
suspend fun setInterenalCameraAspectRatio(
@IntRange(from = -1, to = 1) aspectRatio: Int
)

suspend fun clearAll()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package com.foke.together.domain.output

import android.graphics.Bitmap
import android.net.Uri
import com.foke.together.domain.interactor.entity.CameraSourceType
import com.foke.together.domain.interactor.entity.CutFrameTypeV1

interface ImageRepositoryInterface {
fun getCutFrameType(): CutFrameTypeV1
suspend fun setCutFrameType(type: Int)
// 촬영한 사진들 모음
suspend fun cachingImage(image: Bitmap, fileName: String) : Uri
fun getCachedImageUriList() : List<Uri>

fun getCachedImageUriList(sourceType: CameraSourceType) : List<Uri>
suspend fun clearCacheDir()

// 완성된 프레임 모음
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ import android.graphics.Bitmap
import androidx.annotation.IntRange
import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageCapture
import androidx.camera.view.PreviewView
import androidx.lifecycle.LifecycleOwner

interface InternalCameraRepositoryInterface {
suspend fun capture(context: Context): Result<Bitmap>
suspend fun showCameraPreview(
suspend fun capture(
context: Context,
fileName : String,
)
suspend fun initial(
context: Context,
lifecycleOwner: LifecycleOwner,
previewView: PreviewView,
previewView : PreviewView,
selector : CameraSelector,
imageAnalysis: ImageAnalysis?,
@IntRange(from = 0, to = 2) captureMode: Int,
@IntRange(from = 0, to = 3) flashMode: Int,
@IntRange(from = -1, to = 1) aspectRatio: Int
imageAnalyzer: ImageAnalysis.Analyzer?,
)
suspend fun release(context: Context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import android.content.Context
import android.graphics.Bitmap
import android.graphics.ImageDecoder
import android.net.Uri
import android.provider.MediaStore
import com.foke.together.domain.interactor.GetCameraSourceTypeUseCase
import com.foke.together.domain.interactor.entity.CameraSourceType
import com.foke.together.domain.interactor.entity.CutFrameTypeV1
import com.foke.together.domain.output.ImageRepositoryInterface
import com.foke.together.util.AppPolicy
import com.foke.together.util.ImageFileUtil
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.map
import javax.inject.Inject

class ImageRepository @Inject constructor(
Expand All @@ -25,12 +29,53 @@ class ImageRepository @Inject constructor(
return ImageFileUtil.cacheBitmap(context, image, fileName)
}

override fun getCachedImageUriList(): List<Uri> {
override fun getCachedImageUriList(sourceType: CameraSourceType): List<Uri> {
var uriList = mutableListOf<Uri>()
context.cacheDir.listFiles().forEach {
if(it.name.contains(AppPolicy.CAPTURED_FOUR_CUT_IMAGE_NAME)){
// capture로 시작하는 파일만 반환
uriList.add(Uri.fromFile(it))
when(sourceType){
CameraSourceType.EXTERNAL -> {
context.cacheDir.listFiles().forEach {
if(it.name.contains(AppPolicy.CAPTURED_FOUR_CUT_IMAGE_NAME)){
// capture로 시작하는 파일만 반환
uriList.add(Uri.fromFile(it))
}
}
}
CameraSourceType.INTERNAL -> {
val projection = arrayOf(
MediaStore.Images.Media._ID,
MediaStore.Images.Media.DISPLAY_NAME,
MediaStore.Images.Media.DATE_ADDED
)
val selection = "${MediaStore.Images.Media.RELATIVE_PATH} LIKE ?"
val selectionArgs = arrayOf("%Pictures/4cuts/backup%")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: 4cuts 를 4cut 단수형으로 바꿀 필요가 있을까 궁금합니다!

val sortOrder = "${MediaStore.Images.Media.DATE_ADDED} DESC"

val cursor = context.contentResolver.query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection,
selection,
selectionArgs,
sortOrder
)

cursor?.use {
val idColumn = it.getColumnIndexOrThrow(MediaStore.Images.Media._ID)
val latestUris = mutableListOf<Uri>()

var count = 0
while (it.moveToNext() && count < AppPolicy.CAPTURE_COUNT) {
val id = it.getLong(idColumn)
val contentUri = Uri.withAppendedPath(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
id.toString()
)
latestUris.add(contentUri)
count++
}

latestUris.reverse()
uriList.addAll(latestUris)
}
}
}
return uriList
Expand Down
Loading