Skip to content

Commit c0fe830

Browse files
committed
modify base url [#162]
1 parent 173255d commit c0fe830

File tree

4 files changed

+43
-47
lines changed

4 files changed

+43
-47
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.foke.together.domain.interactor.web
2+
3+
import com.foke.together.domain.interactor.entity.AccountData
4+
import com.foke.together.domain.output.RemoteRepositoryInterface
5+
import com.foke.together.util.AppLog
6+
import javax.inject.Inject
7+
8+
class RegisterUseCase @Inject constructor(
9+
private val remoteRepository: RemoteRepositoryInterface,
10+
) {
11+
suspend operator fun invoke(id: String, password: String, name: String): Result<Unit> {
12+
return remoteRepository.registerAccount(AccountData(id, password, name))
13+
.onSuccess {
14+
AppLog.i("RegisterUseCase", "init", "register success: ${it}")
15+
}.onFailure { ee ->
16+
AppLog.e("RegisterUseCase", "init", "error: ${ee}")
17+
}
18+
}
19+
}

presenter/src/main/java/com/foke/together/presenter/viewmodel/HomeViewModel.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope
55
import com.foke.together.domain.interactor.AppInitUseCase
66
import com.foke.together.domain.interactor.session.CreateNewSessionUseCase
77
import com.foke.together.domain.interactor.web.GetCurrentUserInformationUseCase
8+
import com.foke.together.domain.interactor.web.RegisterUseCase
89
import com.foke.together.domain.interactor.web.SignInUseCase
910
import com.foke.together.util.AppLog
1011
import com.foke.together.util.di.IODispatcher
@@ -17,6 +18,7 @@ import javax.inject.Inject
1718
class HomeViewModel @Inject constructor(
1819
@IODispatcher private val ioDispatcher: CoroutineDispatcher,
1920
private val signInUseCase: SignInUseCase,
21+
private val registerUseCase: RegisterUseCase,
2022
private val getCurrentUserInformationUseCase: GetCurrentUserInformationUseCase,
2123
private val appInitUseCase: AppInitUseCase,
2224
private val createNewSessionUseCase: CreateNewSessionUseCase
@@ -25,11 +27,18 @@ class HomeViewModel @Inject constructor(
2527
viewModelScope.launch(ioDispatcher) {
2628
// init external camera ip address
2729
appInitUseCase()
28-
2930
// TODO: this is test code. remove later
31+
32+
// TODO: add register function in Settings
33+
// registerUseCase(
34+
35+
// "1234",
36+
// "maker-faire-2025"
37+
// )
38+
3039
signInUseCase(
31-
"test@test.com",
32-
"1234"
40+
"maker-faire-2025@test.com",
41+
"1234",
3342
)
3443
// TODO: this is test code. remove later
3544
getCurrentUserInformationUseCase()

presenter/src/main/java/com/foke/together/presenter/viewmodel/ShareViewModel.kt

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,34 @@
11
package com.foke.together.presenter.viewmodel
22

33
import android.content.Context
4-
import android.graphics.Bitmap
54
import android.net.Uri
6-
import androidx.compose.runtime.getValue
7-
import androidx.compose.runtime.mutableStateOf
8-
import androidx.compose.runtime.setValue
95
import androidx.core.content.FileProvider
106
import androidx.core.net.toFile
117
import androidx.lifecycle.ViewModel
128
import androidx.lifecycle.viewModelScope
139
import com.foke.together.domain.interactor.GeneratePhotoFrameUseCaseV1
14-
import com.foke.together.domain.interactor.GetQRCodeUseCase
1510
import com.foke.together.domain.interactor.entity.Status
1611
import com.foke.together.domain.interactor.session.ClearSessionUseCase
1712
import com.foke.together.domain.interactor.session.GetCurrentSessionUseCase
1813
import com.foke.together.domain.interactor.session.UpdateSessionStatusUseCase
19-
import com.foke.together.domain.interactor.web.GetDownloadUrlUseCase
20-
import com.foke.together.domain.interactor.web.UploadFileUseCase
21-
import com.foke.together.util.AppLog
22-
import com.foke.together.util.AppPolicy
2314
import com.foke.together.util.ImageFileUtil
2415
import dagger.hilt.android.lifecycle.HiltViewModel
2516
import dagger.hilt.android.qualifiers.ApplicationContext
26-
import kotlinx.coroutines.flow.MutableStateFlow
2717
import kotlinx.coroutines.launch
2818
import javax.inject.Inject
2919

3020
@HiltViewModel
3121
class ShareViewModel @Inject constructor(
3222
@ApplicationContext private val context: Context,
33-
private val getQRCodeUseCase: GetQRCodeUseCase,
34-
private val getDownloadUrlUseCase: GetDownloadUrlUseCase,
35-
private val uploadFileUseCase: UploadFileUseCase,
36-
private val generatePhotoFrameUseCaseV1: GeneratePhotoFrameUseCaseV1,
3723
private val getCurrentSessionUseCase: GetCurrentSessionUseCase,
3824
private val updateSessionStatusUseCase: UpdateSessionStatusUseCase,
39-
private val clearSessionUseCase: ClearSessionUseCase
25+
private val clearSessionUseCase: ClearSessionUseCase,
26+
generatePhotoFrameUseCaseV1: GeneratePhotoFrameUseCaseV1
4027
): ViewModel() {
41-
val qrCodeBitmap = MutableStateFlow<Bitmap?>(null)
28+
val qrCodeBitmap = getCurrentSessionUseCase()?.qrCodeBitmap
4229
val singleImageUri: Uri = generatePhotoFrameUseCaseV1.getFinalSingleImageUri()
4330
val twoImageUri: Uri = generatePhotoFrameUseCaseV1.getFinalTwoImageUri()
4431

45-
init {
46-
viewModelScope.launch {
47-
generateQRcode()
48-
}
49-
}
50-
5132
fun downloadImage(): Result<Unit> {
5233
return getCurrentSessionUseCase()?.let { session ->
5334
val imageBitmap = ImageFileUtil.getBitmapFromUri(context, singleImageUri)
@@ -64,23 +45,7 @@ class ShareViewModel @Inject constructor(
6445
}
6546
}
6647

67-
private suspend fun generateQRcode() {
68-
getCurrentSessionUseCase()?.let { session ->
69-
val sessionKey = session.sessionId.toString()
70-
71-
val result = uploadFileUseCase(sessionKey, singleImageUri.toFile())
72-
AppLog.d(TAG, "generateQRcode" ,"result: $result")
73-
74-
val downloadUrl: String = getDownloadUrlUseCase(sessionKey).getOrElse { "https://foke.clon.dev" }
75-
if (AppPolicy.isDebugMode) {
76-
AppLog.e(TAG, "generateQRcode", "sessionKey: $sessionKey")
77-
AppLog.e(TAG, "generateQRcode", "downloadUrl: $downloadUrl")
78-
}
79-
qrCodeBitmap.value = getQRCodeUseCase(sessionKey, downloadUrl).getOrNull()
80-
}
81-
}
82-
83-
fun shareImage() {
48+
fun shareImage(context: Context) {
8449
val contentUri = FileProvider.getUriForFile(
8550
context,
8651
"com.foke.together.fileprovider",

util/src/main/java/com/foke/together/util/AppPolicy.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package com.foke.together.util
22

3+
import androidx.compose.ui.unit.dp
34
import kotlin.time.Duration.Companion.seconds
45

56
object AppPolicy {
67
const val isDebugMode = true // TODO: change to false
78
const val isNoCameraDebugMode = false // TODO: change to false
89

910
// network
10-
const val WEB_SERVER_URL = "https://4cuts.store/"
11-
const val WEB_CONNECT_TIMEOUT = 10L
12-
const val WEB_READ_TIMEOUT = 10L
13-
const val WEB_WRITE_TIMEOUT = 10L
11+
const val WEB_SERVER_URL = "https://4cut.us/"
12+
const val WEB_CONNECT_TIMEOUT = 20L
13+
const val WEB_READ_TIMEOUT = 20L
14+
const val WEB_WRITE_TIMEOUT = 20L
1415
const val WEB_FILE_MAX_CONTENT_LENGTH = 20971520
1516

1617
const val EXTERNAL_CAMERA_DEFAULT_SERVER_URL = "http://0.0.0.0"
@@ -19,9 +20,11 @@ object AppPolicy {
1920
const val EXTERNAL_CAMERA_WRITE_TIMEOUT = 10L
2021

2122
// capture settings
22-
val CAPTURE_INTERVAL = 10.seconds
23+
val CAPTURE_INTERVAL = 7.seconds
2324
const val CAPTURE_COUNT = 4
2425
const val COUNTDOWN_INTERVAL = 10L
26+
const val PREVIEW_INTERVAL = 5L
27+
val PRINT_IMAGE_MARGIN = 15.dp
2528

2629
// file settings
2730
const val CAPTURED_FOUR_CUT_IMAGE_NAME = "capture"

0 commit comments

Comments
 (0)