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

음원 파일 업로드 (유저 입력) #103

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 2 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand All @@ -12,7 +11,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.CatchyTape">
<activity
android:name=".feature.login.LoginActivity"
android:name=".MainActivity"
android:exported="true">
<intent-filter>
HamBP marked this conversation as resolved.
Show resolved Hide resolved
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nav_graph"
app:startDestination="@id/login_nav_graph">
app:startDestination="@id/home_nav_graph">

<include app:graph="@navigation/home_navigation" />
<include app:graph="@navigation/login_navigation" />
<include app:graph="@navigation/upload_navigation" />

</navigation>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class AndroidLibraryPlugin : Plugin<Project> {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
apply("kotlin-kapt")
}

extensions.configure<LibraryExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.google.android.material.appbar.MaterialToolbar


abstract class BaseFragment<VB : ViewDataBinding>(
Expand All @@ -31,4 +33,10 @@ abstract class BaseFragment<VB : ViewDataBinding>(
super.onDestroyView()
_binding = null
}

protected fun setupBackStack(toolbar: MaterialToolbar){
toolbar.setNavigationOnClickListener {
findNavController().popBackStack()
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

업로드화면에서 사용할 거라면 업로드 모듈에서 해도 되지 않을까?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

다른 화면에서도 사용가능성 고려 및
애써서, core-ui 로 모듈을 나누어 놨으니, ui 관련은 모아두는 게 적합하다고 생각했어요~

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.ohdodok.catchytape.core.ui.bindingadapter

import android.widget.AutoCompleteTextView
import androidx.databinding.BindingAdapter


@BindingAdapter("changeSelectedPosition")
fun AutoCompleteTextView.bindPosition(onChange: (Int) -> Unit) {
setOnItemClickListener { _, _, position, _ -> onChange(position) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/on_surface" android:state_enabled="true" />
<item android:color="@color/on_surface_variant" />
</selector>
5 changes: 5 additions & 0 deletions android/core/ui/src/main/res/drawable/ic_cancel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM15.59,7L12,10.59 8.41,7 7,8.41 10.59,12 7,15.59 8.41,17 12,13.41 15.59,17 17,15.59 13.41,12 17,8.41z"/>
</vector>
1 change: 1 addition & 0 deletions android/core/ui/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="genre_items">
<item>장르를 선택해 주세요.</item>
<item>genre1</item>
<item>genre2</item>
<item>genre3</item>
Comment on lines 2 to 7
Copy link
Member

Choose a reason for hiding this comment

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

장르는 서버에서 내려주기로해서 이 배열은 없어도 될 거 같아

Copy link
Collaborator Author

@2taezeat 2taezeat Nov 16, 2023

Choose a reason for hiding this comment

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

서버 api 가 아직 없는 상황에서, 아무것도 선택안한 경우, 버튼 비활성화를 고려해서 넣었습니다~

Copy link
Member

Choose a reason for hiding this comment

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

서버 api가 없는 경우면 viewModel 에서 임시로 dummy 리스트를 들고있게 구현하면 나중에 더 수정하기 쉬워져

Expand Down
15 changes: 14 additions & 1 deletion android/core/ui/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>

<style name="Base.Theme.CatchyTape" parent="Theme.Material3.DayNight.NoActionBar">
<item name="colorPrimary">@color/primary</item>
Expand Down Expand Up @@ -58,4 +58,17 @@
<item name="android:textCursorDrawable">@color/black</item>
<item name="android:textColorHighlight">@color/key_variant</item>
</style>


<style name="CompleteButton" parent="Widget.AppCompat.Button">
<item name="android:textSize">22sp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:minWidth">0dp</item>
<item name="android:minHeight">0dp</item>
<item name="android:paddingHorizontal">0dp</item>
<item name="android:textColor">@drawable/btn_complete_selector</item>
</style>


</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package com.ohdodok.catchytape.feature.home

import android.os.Bundle
import android.view.View
import androidx.core.net.toUri
import androidx.fragment.app.viewModels
import androidx.navigation.NavDeepLinkRequest
import androidx.navigation.fragment.findNavController
import com.ohdodok.catchytape.core.ui.BaseFragment
import com.ohdodok.catchytape.feature.home.databinding.FragmentHomeBinding
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
private val viewModel: HomeViewModel by viewModels()
Expand All @@ -15,5 +19,14 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
super.onViewCreated(view, savedInstanceState)
binding.viewModel = viewModel
binding.rvRecentlyAddedSong.adapter = MusicHorizontalAdapter()



binding.ibUpload.setOnClickListener {
val request = NavDeepLinkRequest.Builder
.fromUri("android-app://com.ohdodok.catchytape/upload_fragment".toUri())
.build()
findNavController().navigate(request)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
app:title="@string/home" />

<ImageButton
android:id="@+id/ib_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_horizontal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class UploadFragment : BaseFragment<FragmentUploadBinding>(R.layout.fragment_upl
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.viewModel = viewModel
setupBackStack(binding.tbUploadAppbar)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package com.ohdodok.catchytape.feature.upload

import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow

class UploadViewModel : ViewModel() {

val uploadMusicTitle = MutableStateFlow<String>("")
HamBP marked this conversation as resolved.
Show resolved Hide resolved

private val _uploadMusicGenrePosition = MutableStateFlow(0)
val uploadMusicGenrePosition = _uploadMusicGenrePosition.asStateFlow()


val onChangePosition: (Int) -> Unit = { position: Int -> _uploadMusicGenrePosition.value = position }
}
39 changes: 16 additions & 23 deletions android/feature/upload/src/main/res/layout/fragment_upload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/tb_upload_appbar"
style="@style/ToolBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navigationIcon="@drawable/ic_arrow_back"
app:pop_back_stack="@{null}"
app:title="@string/upload">

<Button
style="@style/BodyMedium"
<TextView
HamBP marked this conversation as resolved.
Show resolved Hide resolved
android:id="@+id/tv_complete"
style="@style/TitleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:background="@android:color/transparent"
android:minWidth="0dp"
android:minHeight="0dp"
android:paddingEnd="@dimen/margin_horizontal"
android:text="@string/complete"
android:textColor="@color/on_surface" />
android:textColor="@color/on_surface"
app:genre_position="@{viewModel.uploadMusicGenrePosition}"
app:music_title="@{viewModel.uploadMusicTitle}" />

HamBP marked this conversation as resolved.
Show resolved Hide resolved

</com.google.android.material.appbar.MaterialToolbar>

Expand Down Expand Up @@ -65,13 +69,17 @@
android:layout_marginHorizontal="@dimen/margin_horizontal"
android:layout_marginTop="@dimen/extra_large"
android:hint="@string/title"
app:endIconDrawable="@drawable/ic_cancel"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cv_upload_thumbnail">

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:maxLength="10"
android:text="@={viewModel.uploadMusicTitle}" />

</com.google.android.material.textfield.TextInputLayout>

Expand All @@ -91,26 +99,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
app:change_selected_position="@{viewModel.onChangePosition}"
app:simpleItems="@array/genre_items" />

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_horizontal"
android:layout_marginTop="@dimen/medium"
android:hint="@string/description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_genre">

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</com.google.android.material.textfield.TextInputLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/upload_navigation"
app:startDestination="@id/upload_navigation">
app:startDestination="@id/upload_fragment">

<fragment
android:id="@+id/upload_navigation"
android:id="@+id/upload_fragment"
android:name="com.ohdodok.catchytape.feature.upload.UploadFragment"
android:label="upload"
tools:layout="@layout/fragment_upload"/>
tools:layout="@layout/fragment_upload">

<deepLink app:uri="android-app://com.ohdodok.catchytape/upload_fragment" />

</fragment>

</navigation>