-
Notifications
You must be signed in to change notification settings - Fork 0
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
Upload UI 상태 #147
Merged
Merged
Upload UI 상태 #147
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fda6172
feat : upload api 정의
youlalala 2436eb8
feat : 파일 업로드 버튼 UI
youlalala 85d82e1
refactor : 장르 선택 로직 정리
youlalala e1b51f3
feat : 파일명 가져오기
youlalala c600fe4
chore : glide library 추가
youlalala 48abf43
feat : progress indicator 추가
youlalala 616f5a2
feat : 완료 버튼 활성화 유무 조건 변경
youlalala 634e41e
feat : progress bar visibility 설정
youlalala 3b23d72
feat : upload ui state 정리
youlalala 0e74aed
Merge branch 'develop' into android/feature/60
youlalala 39a4240
feat : camera icon visible 정의
youlalala 399ba9d
chore : 필요 없는 import 문 삭제
youlalala 4dfc6e2
feat : empty 상태 제거
youlalala 3af0340
feat : file 상태 관리
youlalala d577bd8
feat : flow 처리 순서 변경
youlalala 1dfbf3b
refactor : file 변환 위치 변경
youlalala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
android/core/data/src/main/java/com/ohdodok/catchytape/core/data/api/MusicApi.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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
package com.ohdodok.catchytape.core.data.api | ||
|
||
import com.ohdodok.catchytape.core.data.model.MusicGenresResponse | ||
import com.ohdodok.catchytape.core.data.model.MusicRequest | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
|
||
interface MusicApi { | ||
|
||
@GET("musics/genres") | ||
suspend fun getGenres(): Response<MusicGenresResponse> | ||
|
||
@POST("musics") | ||
suspend fun postMusic( | ||
@Body music: MusicRequest | ||
): Response<Unit> | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
android/core/data/src/main/java/com/ohdodok/catchytape/core/data/api/UploadApi.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.ohdodok.catchytape.core.data.api | ||
|
||
import com.ohdodok.catchytape.core.data.model.UrlResponse | ||
import retrofit2.Response | ||
import retrofit2.http.Headers | ||
import retrofit2.http.POST | ||
|
||
interface UploadApi { | ||
|
||
@POST("upload/music") | ||
@Headers("Content-Type: audio/mpeg") | ||
suspend fun uploadMusic( | ||
): Response<UrlResponse> | ||
|
||
@POST("upload/image") | ||
@Headers("Content-Type: image/png") | ||
suspend fun uploadImage( | ||
): Response<UrlResponse> | ||
|
||
} |
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
7 changes: 7 additions & 0 deletions
7
android/core/data/src/main/java/com/ohdodok/catchytape/core/data/model/MusicRequest.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,7 @@ | ||
package com.ohdodok.catchytape.core.data.model | ||
|
||
data class MusicRequest ( | ||
val title: String, | ||
val cover: String, | ||
val file: String | ||
) |
5 changes: 5 additions & 0 deletions
5
android/core/data/src/main/java/com/ohdodok/catchytape/core/data/model/UrlResponse.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,5 @@ | ||
package com.ohdodok.catchytape.core.data.model | ||
|
||
data class UrlResponse( | ||
val url: String | ||
) |
24 changes: 24 additions & 0 deletions
24
...core/domain/src/main/java/com/ohdodok/catchytape/core/domain/usecase/UploadFileUseCase.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,24 @@ | ||
package com.ohdodok.catchytape.core.domain.usecase | ||
|
||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
class UploadFileUseCase @Inject constructor( | ||
|
||
) { | ||
|
||
fun getImgUrl(file: File): Flow<String> = flow { | ||
// todo : 서버 기다리는 중.. | ||
delay(1000) | ||
emit("https://kr.object.ncloudstorage.com/catchy-tape-bucket2/image/%EC%8A%A4%ED%81%AC%EB%A6%B0%EC%83%B7%202023-11-21%20180100.png") | ||
} | ||
|
||
fun getAudioUrl(file: File): Flow<String> = flow { | ||
// todo : 서버 기다리는 중.. | ||
delay(1000) | ||
emit("https://kr.object.ncloudstorage.com/catchy-tape-bucket2/music/2/%EC%9D%B4%EB%85%B8%EB%9E%98.mp3") | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
android/core/ui/src/main/java/com/ohdodok/catchytape/core/ui/BindingAdapters.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,12 @@ | ||
package com.ohdodok.catchytape.core.ui | ||
|
||
import android.widget.ImageView | ||
import androidx.databinding.BindingAdapter | ||
import com.bumptech.glide.Glide | ||
|
||
@BindingAdapter("imageUrl") | ||
fun ImageView.bindImg(url: String) { | ||
Glide.with(this.context) | ||
.load(url) | ||
.into(this) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package com.ohdodok.catchytape.feature.upload | ||
|
||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.provider.OpenableColumns | ||
import android.view.View | ||
import androidx.activity.result.PickVisualMediaRequest | ||
import androidx.activity.result.contract.ActivityResultContracts | ||
import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia | ||
import androidx.core.net.toFile | ||
import androidx.fragment.app.viewModels | ||
import com.ohdodok.catchytape.catchytape.upload.R | ||
import com.ohdodok.catchytape.catchytape.upload.databinding.FragmentUploadBinding | ||
|
@@ -18,28 +19,43 @@ class UploadFragment : BaseFragment<FragmentUploadBinding>(R.layout.fragment_upl | |
|
||
private val imagePickerLauncher = registerForActivityResult(PickVisualMedia()) { uri -> | ||
if (uri == null) return@registerForActivityResult | ||
|
||
viewModel.uploadImage(uri.toFile()) | ||
viewModel.uploadImage(uri) | ||
} | ||
|
||
private val filePickerLauncher = | ||
registerForActivityResult(ActivityResultContracts.GetContent()) { uri -> | ||
if (uri == null) return@registerForActivityResult | ||
|
||
viewModel.uploadAudio(uri.toFile()) | ||
binding.btnFile.text = getFileName(uri) | ||
viewModel.uploadAudio(uri) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.viewModel = viewModel | ||
|
||
setUpFileBtn() | ||
setupBackStack(binding.tbUpload) | ||
setupSelectThumbnailImage() | ||
} | ||
|
||
private fun setUpFileBtn() { | ||
binding.btnFile.setOnClickListener { | ||
filePickerLauncher.launch("audio/*") | ||
} | ||
} | ||
|
||
private fun setupSelectThumbnailImage() { | ||
binding.cvUploadThumbnail.setOnClickListener { | ||
imagePickerLauncher.launch(PickVisualMediaRequest(PickVisualMedia.ImageOnly)) | ||
} | ||
} | ||
|
||
private fun getFileName(uri: Uri): String? { | ||
val contentResolver = requireContext().contentResolver | ||
contentResolver.query(uri, null, null, null, null)?.use { cursor -> | ||
val nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME) | ||
cursor.moveToFirst() | ||
return cursor.getString(nameIndex) | ||
} | ||
return null | ||
} | ||
Comment on lines
+53
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 함수 하는 일이 무엇인가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 파일이름을 가져오는 함수입니당 공식문서 참고했어용 |
||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position 이 필요한 것 같지 않아서 선택한 텍스트로 판단하도록 바꼈습니당