Skip to content

Commit c0568c5

Browse files
committed
통화화면 controller 추가
1 parent d223ab8 commit c0568c5

File tree

15 files changed

+142
-334
lines changed

15 files changed

+142
-334
lines changed

app/src/main/java/com/example/webrtc/ComposeActivity.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/src/main/java/com/example/webrtc/WebRTCApp.kt

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/src/main/java/com/example/webrtc/WebRTCConnectActivity.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.lifecycle.lifecycleScope
77
import com.example.domain.event.PeerConnectionEvent
88
import com.example.domain.event.WebRTCEvent
99
import com.example.domain.state.UiState
10+
import com.example.presentaion.ui_component.WebRTCController
1011
import com.example.presentaion.viewmodel.ConnectionViewModel
1112
import com.example.webrtc.databinding.ActivityWebRtcconnectBinding
1213
import dagger.hilt.android.AndroidEntryPoint
@@ -24,15 +25,24 @@ class WebRTCConnectActivity : AppCompatActivity() {
2425
super.onCreate(savedInstanceState)
2526
binding = ActivityWebRtcconnectBinding.inflate(layoutInflater)
2627
setContentView(binding.root)
28+
setCompose()
2729
collectConnectionEvent()
2830
collectRTCEvent()
2931
collectState()
3032
}
3133

34+
private fun setCompose() {
35+
binding.composeView.apply {
36+
setContent {
37+
WebRTCController(viewModel = viewModel)
38+
}
39+
}
40+
}
41+
3242
private fun collectState() {
3343
lifecycleScope.launch {
34-
viewModel.uiState.collect{
35-
when(it){
44+
viewModel.uiState.collect {
45+
when (it) {
3646
is UiState.UnInitialized -> viewModel.initRTC()
3747
}
3848
}

app/src/main/res/layout/activity_web_rtcconnect.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
tools:context="com.example.presentaion.view.WebRTCConnectActivity">
7+
tools:context=".WebRTCConnectActivity">
88

99
<org.webrtc.SurfaceViewRenderer
1010
android:id="@+id/remoteView"
@@ -13,9 +13,17 @@
1313

1414
<org.webrtc.SurfaceViewRenderer
1515
android:id="@+id/localView"
16-
android:layout_width="200dp"
17-
android:layout_height="300dp"
16+
android:layout_width="150dp"
17+
android:layout_height="200dp"
1818
android:layout_margin="25dp"
19+
app:layout_constraintBottom_toTopOf="@+id/compose_view"
20+
app:layout_constraintStart_toStartOf="parent" />
21+
22+
<androidx.compose.ui.platform.ComposeView
23+
android:id="@+id/compose_view"
24+
android:layout_width="match_parent"
25+
android:layout_height="100dp"
1926
app:layout_constraintBottom_toBottomOf="parent"
27+
app:layout_constraintEnd_toEndOf="parent"
2028
app:layout_constraintStart_toStartOf="parent" />
2129
</androidx.constraintlayout.widget.ConstraintLayout>

presentaion/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ dependencies {
5151
implementation 'androidx.core:core-ktx:1.8.0'
5252
implementation 'androidx.appcompat:appcompat:1.6.1'
5353
implementation 'com.google.android.material:material:1.9.0'
54+
implementation 'androidx.compose.ui:ui-tooling-preview:1.4.3'
5455
testImplementation 'junit:junit:4.13.2'
5556
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
5657
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
5758

5859
implementation 'com.google.dagger:hilt-android:2.45'
60+
debugImplementation 'androidx.compose.ui:ui-tooling:1.4.3'
5961
kapt 'com.google.dagger:hilt-android-compiler:2.45'
6062

6163
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.example.presentaion.ui_component
2+
3+
import androidx.compose.material.FloatingActionButton
4+
import androidx.compose.material.Icon
5+
import androidx.compose.material.icons.Icons
6+
import androidx.compose.material.icons.filled.Face
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.runtime.State
9+
import androidx.compose.runtime.mutableStateOf
10+
import androidx.compose.runtime.saveable.rememberSaveable
11+
import androidx.compose.ui.graphics.Color
12+
import androidx.compose.ui.graphics.vector.ImageVector
13+
import androidx.compose.ui.tooling.preview.Preview
14+
15+
@Composable
16+
fun MenuButton(
17+
imageVector: ImageVector,
18+
description: String,
19+
defaultBackgroundColor: Color,
20+
state: State<Boolean> = mutableStateOf(true),
21+
onClick: () -> Unit
22+
) {
23+
FloatingActionButton(
24+
onClick = onClick,
25+
backgroundColor = if (state.value) defaultBackgroundColor else Color.Gray
26+
) {
27+
Icon(imageVector = imageVector, contentDescription = description)
28+
}
29+
}
30+
31+
@Composable
32+
@Preview
33+
fun MenuPreview() {
34+
val isClicked = rememberSaveable { mutableStateOf(false) }
35+
MenuButton(
36+
imageVector = Icons.Default.Face,
37+
description = "Face",
38+
defaultBackgroundColor = Color.Green,
39+
state = isClicked
40+
) {
41+
42+
}
43+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.example.presentaion.ui_component
2+
3+
import androidx.compose.foundation.layout.Arrangement
4+
import androidx.compose.foundation.layout.Row
5+
import androidx.compose.foundation.layout.fillMaxSize
6+
import androidx.compose.material.icons.Icons
7+
import androidx.compose.material.icons.filled.Call
8+
import androidx.compose.material.icons.filled.Close
9+
import androidx.compose.material.icons.filled.Face
10+
import androidx.compose.runtime.Composable
11+
import androidx.compose.runtime.mutableStateOf
12+
import androidx.compose.runtime.saveable.rememberSaveable
13+
import androidx.compose.ui.Alignment
14+
import androidx.compose.ui.Modifier
15+
import androidx.compose.ui.graphics.Color
16+
import androidx.compose.ui.tooling.preview.Preview
17+
import com.example.presentaion.viewmodel.ConnectionViewModel
18+
19+
@Composable
20+
fun WebRTCController(viewModel: ConnectionViewModel) {
21+
val isCallClicked = rememberSaveable { mutableStateOf(false) }
22+
val isVideoClicked = rememberSaveable { mutableStateOf(false) }
23+
Row(
24+
Modifier.fillMaxSize(),
25+
verticalAlignment = Alignment.CenterVertically,
26+
horizontalArrangement = Arrangement.SpaceEvenly
27+
) {
28+
MenuButton(
29+
imageVector = Icons.Default.Call,
30+
description = "Call",
31+
defaultBackgroundColor = Color.Green,
32+
state = isCallClicked
33+
) {
34+
isCallClicked.value = !isCallClicked.value
35+
viewModel.toggleVoice()
36+
}
37+
MenuButton(
38+
imageVector = Icons.Default.Face,
39+
description = "Face",
40+
defaultBackgroundColor = Color.Green,
41+
state = isVideoClicked
42+
) {
43+
isVideoClicked.value = !isVideoClicked.value
44+
viewModel.toggleVideo()
45+
}
46+
MenuButton(
47+
imageVector = Icons.Default.Close,
48+
description = "Close",
49+
defaultBackgroundColor = Color.Red
50+
) {
51+
viewModel.closeSession()
52+
}
53+
}
54+
}
55+
56+
@Composable
57+
@Preview
58+
fun ControllerPreview() {
59+
60+
}

presentaion/src/main/java/com/example/presentaion/view/ConnectScreen.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.

presentaion/src/main/java/com/example/presentaion/view/ConnectionFragment.kt

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)