-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
696 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
domain/src/main/java/com/foke/together/domain/interactor/GeneratePhotoFrameUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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.CutFrameType | ||
import com.foke.together.domain.output.ImageRepositoryInterface | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GeneratePhotoFrameUseCase @Inject constructor( | ||
@ApplicationContext private val context: Context, | ||
private val imageRepositoryInterface: ImageRepositoryInterface | ||
){ | ||
fun getCutFrameType(): CutFrameType = imageRepositoryInterface.getCutFrameType() | ||
suspend fun setCutFrameType(type: Int) = imageRepositoryInterface.setCutFrameType(type) | ||
|
||
fun getCapturedImageListUri(): List<Uri> = imageRepositoryInterface.getCachedImageUriList() | ||
suspend fun clearCapturedImageList() = imageRepositoryInterface.clearCacheDir() | ||
suspend fun saveGraphicsLayerImage(image: Bitmap, fileName: String) = imageRepositoryInterface.cachingImage(image, fileName) | ||
suspend fun saveFinalImage(image: Bitmap, fileName: String) = imageRepositoryInterface.saveToStorage(image, fileName) | ||
} |
26 changes: 26 additions & 0 deletions
26
domain/src/main/java/com/foke/together/domain/interactor/entity/CutFrameType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.foke.together.domain.interactor.entity | ||
|
||
enum class CutFrameType { | ||
MAKER_FAIRE, | ||
FOURCUT_LIGHT, | ||
FOURCUT_DARK; | ||
|
||
companion object { | ||
fun findBy(name: String): CutFrameType { | ||
return when (name) { | ||
MAKER_FAIRE.name -> MAKER_FAIRE | ||
FOURCUT_LIGHT.name -> FOURCUT_LIGHT | ||
FOURCUT_DARK.name -> FOURCUT_DARK | ||
else -> throw IllegalArgumentException("Unknown value: $name") | ||
} | ||
} | ||
fun findBy(ordinal: Int): CutFrameType { | ||
return when (ordinal) { | ||
MAKER_FAIRE.ordinal -> MAKER_FAIRE | ||
FOURCUT_LIGHT.ordinal -> FOURCUT_LIGHT | ||
FOURCUT_DARK.ordinal -> FOURCUT_DARK | ||
else -> throw IllegalArgumentException("Unknown value: $ordinal") | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
domain/src/main/java/com/foke/together/domain/output/ImageRepositoryInterface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.foke.together.domain.output | ||
|
||
import android.graphics.Bitmap | ||
import android.net.Uri | ||
import android.os.Environment | ||
import com.foke.together.domain.interactor.entity.CutFrameType | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface ImageRepositoryInterface { | ||
fun getCutFrameType(): CutFrameType | ||
suspend fun setCutFrameType(type: Int) | ||
// 촬영한 사진들 모음 | ||
suspend fun cachingImage(image: Bitmap, fileName: String) : Uri | ||
fun getCachedImageUriList() : List<Uri> | ||
suspend fun clearCacheDir() | ||
|
||
// 완성된 프레임 모음 | ||
suspend fun saveToStorage(image: Bitmap, fileName :String) : Uri | ||
fun getUriToBitmap(imageUri: Uri): Bitmap | ||
} |
60 changes: 60 additions & 0 deletions
60
external/src/main/java/com/foke/together/external/repository/ImageRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.foke.together.external.repository | ||
|
||
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.entity.CutFrameType | ||
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.Flow | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class ImageRepository @Inject constructor( | ||
@ApplicationContext private val context: Context | ||
): ImageRepositoryInterface{ | ||
private var cutFrameType: CutFrameType = CutFrameType.MAKER_FAIRE | ||
|
||
override fun getCutFrameType(): CutFrameType = cutFrameType | ||
override suspend fun setCutFrameType(type: Int) { | ||
cutFrameType = CutFrameType.findBy(type) | ||
} | ||
|
||
override suspend fun cachingImage(image: Bitmap, fileName: String): Uri { | ||
return ImageFileUtil.cacheBitmap(context, image, fileName) | ||
} | ||
|
||
override fun getCachedImageUriList(): 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)) | ||
} | ||
} | ||
return uriList | ||
} | ||
|
||
override suspend fun clearCacheDir() { | ||
context.cacheDir.listFiles().forEach { | ||
if(it.name.contains(".jpg")){ | ||
it.delete() | ||
} | ||
} | ||
} | ||
|
||
override suspend fun saveToStorage(image: Bitmap, fileName: String): Uri { | ||
return ImageFileUtil.saveBitmapToStorage(context, image, fileName) | ||
} | ||
|
||
override fun getUriToBitmap(imageUri: Uri): Bitmap { | ||
return ImageDecoder.decodeBitmap(ImageDecoder.createSource(context.contentResolver, imageUri)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 58 additions & 33 deletions
91
presenter/src/main/java/com/foke/together/presenter/frame/FourCutFrame.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.