Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

프레임 및 UI Dimension 작업 #84

Merged
merged 2 commits into from
Oct 11, 2024
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
15 changes: 14 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:usesCleartextTraffic="true" />
android:usesCleartextTraffic="true" >

<!-- To use Sharing feature -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.foke.together.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_files" />
</provider>

</application>
<!-- TODO: temporary add usesCleartextTraffic. remove later -->

<!-- TODO: support back-up-->
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/xml/provider_files.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path
name="cache"
path="." /> <!--Context.getCacheDir() 내부 저장소-->
<files-path
name="files"
path="." /> <!--Context.getFilesDir() 내부 저장소-->
<external-path
name="external"
path="."/> <!-- Environment.getExternalStorageDirectory() 외부 저장소-->
<external-cache-path
name="external-cache"
path="."/> <!-- Context.getExternalCacheDir() 외부 저장소-->
<external-files-path
name="external-files"
path="."/> <!-- Context.getExternalFilesDir() 외부 저장소-->
</paths>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.graphics.Bitmap
import android.net.Uri
import com.foke.together.domain.interactor.entity.CutFrameType
import com.foke.together.domain.output.ImageRepositoryInterface
import com.foke.together.util.AppPolicy
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
Expand All @@ -20,4 +21,20 @@ class GeneratePhotoFrameUseCase @Inject constructor(
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)

fun getFinalSingleImageUri(): Uri {
var finalSingleImageUri: Uri = Uri.EMPTY
context.cacheDir.listFiles().forEach {
file -> if (file.name.contains("${AppPolicy.SINGLE_ROW_FINAL_IMAGE_NAME}")) { finalSingleImageUri = Uri.fromFile(file) }
}
return finalSingleImageUri
}

fun getFinalTwoImageUri(): Uri {
var finalTwoImageUri: Uri = Uri.EMPTY
context.cacheDir.listFiles().forEach {
file -> if (file.name.contains("${AppPolicy.TWO_ROW_FINAL_IMAGE_NAME}")) { finalTwoImageUri = Uri.fromFile(file) }
}
return finalTwoImageUri
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.foke.together.domain.interactor.entity

enum class FramePosition {
LEFT,
RIGHT;
fun findBy(ordinal: Int): FramePosition {
return when (ordinal) {
LEFT.ordinal -> LEFT
RIGHT.ordinal -> RIGHT
else -> throw IllegalArgumentException("Unknown value: $ordinal")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.foke.together.domain.interactor.web

import com.foke.together.util.AppPolicy
import javax.inject.Inject

// Download url
// https://4cuts.store/download/{user_name}/{key}
class GetDownloadUrlUseCase @Inject constructor(
private val getCurrentUserInformationUseCase: GetCurrentUserInformationUseCase
) {
suspend operator fun invoke(key: String): Result<String> {
getCurrentUserInformationUseCase()
.onSuccess {
"${AppPolicy.WEB_SERVER_URL}download/${it.name}/$key"
}
return Result.failure(Exception("Unknown error"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.foke.together.domain.interactor.web

import com.foke.together.domain.output.SessionRepositoryInterface
import javax.inject.Inject

class SessionKeyUseCase @Inject constructor(
private val sessionRepository: SessionRepositoryInterface
) {
suspend fun setSessionKey() {
sessionRepository.setSessionKey()
}

fun getSessionKey(): String {
return sessionRepository.getSessionKey()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.foke.together.domain.output

interface SessionRepositoryInterface {
suspend fun setSessionKey()
fun getSessionKey(): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ImageRepository @Inject constructor(
return uriList
}

//TODO: file작업코드는 repository에서 하지말고 Util로 옮겨놓기
override suspend fun clearCacheDir() {
context.cacheDir.listFiles().forEach {
if(it.name.contains(".jpg")){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.foke.together.external.repository

import com.foke.together.domain.output.SessionRepositoryInterface
import com.foke.together.util.TimeUtil
import javax.inject.Inject

class SessionRepository @Inject constructor(): SessionRepositoryInterface {
private var sessionKey: String = ""
override suspend fun setSessionKey() {
sessionKey = TimeUtil.getCurrentTimeSec()
}

override fun getSessionKey(): String {
return sessionKey
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package com.foke.together.external.repository.di
import com.foke.together.domain.output.ExternalCameraRepositoryInterface
import com.foke.together.domain.output.ImageRepositoryInterface
import com.foke.together.domain.output.QRCodeRepositoryInterface
import com.foke.together.domain.output.SessionRepositoryInterface
import com.foke.together.external.repository.ExternalCameraRepository
import com.foke.together.external.repository.ImageRepository
import com.foke.together.external.repository.QRCodeRepository
import com.foke.together.external.repository.SessionRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -32,4 +34,10 @@ abstract class RepositoryModule {
abstract fun bindQRCodeRepository(
qrCodeRepository: QRCodeRepository
): QRCodeRepositoryInterface

@Singleton
@Binds
abstract fun bindSessionRepository(
sessionRepository: SessionRepository
): SessionRepositoryInterface
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
Expand All @@ -26,6 +27,8 @@ import androidx.compose.ui.graphics.rememberGraphicsLayer
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand All @@ -35,6 +38,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.foke.together.domain.interactor.entity.FramePosition
import com.foke.together.presenter.R
import com.foke.together.presenter.theme.FourCutTogetherTheme
import com.foke.together.presenter.theme.highContrastDarkColorScheme
Expand All @@ -48,13 +52,31 @@ import kotlinx.coroutines.launch
fun FourCutFrame(
// TODO: Need to refactoring. separate frame design with application theme
designColorScheme: ColorScheme = mediumContrastLightColorScheme,
cameraImageUrlList : List<Uri>? = null
cameraImageUrlList : List<Uri>? = null,
position: FramePosition? = null
) {
ConstraintLayout(
modifier = Modifier
.aspectRatio(ratio = 0.3333f)
.background(color = designColorScheme.surface)
.border(1.dp, designColorScheme.inverseSurface)
.padding(
start = position.let {
when(it){
FramePosition.LEFT -> 20.dp
FramePosition.RIGHT -> 0.dp
null -> 10.dp
}
},
end = position.let {
when(it){
FramePosition.LEFT -> 0.dp
FramePosition.RIGHT -> 20.dp
null -> 10.dp
}
},
top = 40.dp
)
) {
val (cameraColumn, decorateRow) = createRefs()
LazyColumn(
Expand All @@ -67,9 +89,8 @@ fun FourCutFrame(
bottom.linkTo(decorateRow.top)
start.linkTo(parent.start)
end.linkTo(parent.end)
width = Dimension.fillToConstraints
height = Dimension.wrapContent
}
.wrapContentSize()
) {
items(AppPolicy.CAPTURE_COUNT){
//TODO: add camera image
Expand Down Expand Up @@ -114,7 +135,9 @@ fun FourCutFrame(
text = TimeUtil.getCurrentDisplayTime(),
modifier = Modifier.weight(1f),
color = designColorScheme.inverseSurface,
fontSize = 12.sp
fontSize = 15.sp,
textAlign = TextAlign.Center,
fontWeight = FontWeight.Bold
)
}
}
Expand Down
Loading