David Liu

minor sample app improvements

  1 +<vector xmlns:android="http://schemas.android.com/apk/res/android"
  2 + android:width="24dp"
  3 + android:height="24dp"
  4 + android:viewportWidth="24"
  5 + android:viewportHeight="24"
  6 + android:tint="?attr/colorControlNormal">
  7 + <path
  8 + android:fillColor="@android:color/white"
  9 + android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM17,15.59L15.59,17 12,13.41 8.41,17 7,15.59 10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59z"/>
  10 +</vector>
@@ -12,6 +12,7 @@ import androidx.compose.foundation.background @@ -12,6 +12,7 @@ import androidx.compose.foundation.background
12 import androidx.compose.foundation.layout.* 12 import androidx.compose.foundation.layout.*
13 import androidx.compose.foundation.lazy.LazyRow 13 import androidx.compose.foundation.lazy.LazyRow
14 import androidx.compose.material.* 14 import androidx.compose.material.*
  15 +import androidx.compose.material.ripple.rememberRipple
15 import androidx.compose.runtime.* 16 import androidx.compose.runtime.*
16 import androidx.compose.runtime.livedata.observeAsState 17 import androidx.compose.runtime.livedata.observeAsState
17 import androidx.compose.ui.Alignment 18 import androidx.compose.ui.Alignment
@@ -98,6 +99,7 @@ class CallActivity : AppCompatActivity() { @@ -98,6 +99,7 @@ class CallActivity : AppCompatActivity() {
98 videoEnabled, 99 videoEnabled,
99 flipButtonEnabled, 100 flipButtonEnabled,
100 screencastEnabled, 101 screencastEnabled,
  102 + onExitClick = { finish() }
101 ) 103 )
102 } 104 }
103 } 105 }
@@ -122,6 +124,7 @@ class CallActivity : AppCompatActivity() { @@ -122,6 +124,7 @@ class CallActivity : AppCompatActivity() {
122 videoEnabled: Boolean = true, 124 videoEnabled: Boolean = true,
123 flipButtonEnabled: Boolean = true, 125 flipButtonEnabled: Boolean = true,
124 screencastEnabled: Boolean = false, 126 screencastEnabled: Boolean = false,
  127 + onExitClick: () -> Unit = {},
125 ) { 128 ) {
126 AppTheme(darkTheme = true) { 129 AppTheme(darkTheme = true) {
127 ConstraintLayout( 130 ConstraintLayout(
@@ -187,8 +190,13 @@ class CallActivity : AppCompatActivity() { @@ -187,8 +190,13 @@ class CallActivity : AppCompatActivity() {
187 horizontalArrangement = Arrangement.SpaceEvenly, 190 horizontalArrangement = Arrangement.SpaceEvenly,
188 verticalAlignment = Alignment.Bottom, 191 verticalAlignment = Alignment.Bottom,
189 ) { 192 ) {
  193 + val controlSize = 40.dp
  194 + val controlPadding = 4.dp
190 Surface( 195 Surface(
191 onClick = { viewModel.setMicEnabled(!micEnabled) }, 196 onClick = { viewModel.setMicEnabled(!micEnabled) },
  197 + indication = rememberRipple(false),
  198 + modifier = Modifier.size(controlSize)
  199 + .padding(controlPadding)
192 ) { 200 ) {
193 val resource = 201 val resource =
194 if (micEnabled) R.drawable.outline_mic_24 else R.drawable.outline_mic_off_24 202 if (micEnabled) R.drawable.outline_mic_24 else R.drawable.outline_mic_off_24
@@ -200,6 +208,9 @@ class CallActivity : AppCompatActivity() { @@ -200,6 +208,9 @@ class CallActivity : AppCompatActivity() {
200 } 208 }
201 Surface( 209 Surface(
202 onClick = { viewModel.setCameraEnabled(!videoEnabled) }, 210 onClick = { viewModel.setCameraEnabled(!videoEnabled) },
  211 + indication = rememberRipple(false),
  212 + modifier = Modifier.size(controlSize)
  213 + .padding(controlPadding)
203 ) { 214 ) {
204 val resource = 215 val resource =
205 if (videoEnabled) R.drawable.outline_videocam_24 else R.drawable.outline_videocam_off_24 216 if (videoEnabled) R.drawable.outline_videocam_24 else R.drawable.outline_videocam_off_24
@@ -211,6 +222,9 @@ class CallActivity : AppCompatActivity() { @@ -211,6 +222,9 @@ class CallActivity : AppCompatActivity() {
211 } 222 }
212 Surface( 223 Surface(
213 onClick = { viewModel.flipCamera() }, 224 onClick = { viewModel.flipCamera() },
  225 + indication = rememberRipple(false),
  226 + modifier = Modifier.size(controlSize)
  227 + .padding(controlPadding)
214 ) { 228 ) {
215 Icon( 229 Icon(
216 painterResource(id = R.drawable.outline_flip_camera_android_24), 230 painterResource(id = R.drawable.outline_flip_camera_android_24),
@@ -226,6 +240,9 @@ class CallActivity : AppCompatActivity() { @@ -226,6 +240,9 @@ class CallActivity : AppCompatActivity() {
226 viewModel.stopScreenCapture() 240 viewModel.stopScreenCapture()
227 } 241 }
228 }, 242 },
  243 + indication = rememberRipple(false),
  244 + modifier = Modifier.size(controlSize)
  245 + .padding(controlPadding)
229 ) { 246 ) {
230 val resource = 247 val resource =
231 if (screencastEnabled) R.drawable.baseline_cast_connected_24 else R.drawable.baseline_cast_24 248 if (screencastEnabled) R.drawable.baseline_cast_connected_24 else R.drawable.baseline_cast_24
@@ -235,6 +252,18 @@ class CallActivity : AppCompatActivity() { @@ -235,6 +252,18 @@ class CallActivity : AppCompatActivity() {
235 tint = Color.White, 252 tint = Color.White,
236 ) 253 )
237 } 254 }
  255 + Surface(
  256 + onClick = { onExitClick() },
  257 + indication = rememberRipple(false),
  258 + modifier = Modifier.size(controlSize)
  259 + .padding(controlPadding)
  260 + ) {
  261 + Icon(
  262 + painterResource(id = R.drawable.ic_baseline_cancel_24),
  263 + contentDescription = "Flip Camera",
  264 + tint = Color.White,
  265 + )
  266 + }
238 } 267 }
239 } 268 }
240 } 269 }
@@ -151,6 +151,8 @@ class CallActivity : AppCompatActivity() { @@ -151,6 +151,8 @@ class CallActivity : AppCompatActivity() {
151 ) 151 )
152 } 152 }
153 153
  154 + binding.exit.setOnClickListener { finish() }
  155 +
154 // Grab audio focus for video call 156 // Grab audio focus for video call
155 val audioManager = getSystemService(AUDIO_SERVICE) as AudioManager 157 val audioManager = getSystemService(AUDIO_SERVICE) as AudioManager
156 with(audioManager) { 158 with(audioManager) {
@@ -103,5 +103,13 @@ @@ -103,5 +103,13 @@
103 android:background="?android:attr/selectableItemBackground" 103 android:background="?android:attr/selectableItemBackground"
104 android:padding="@dimen/control_padding" 104 android:padding="@dimen/control_padding"
105 android:src="@drawable/baseline_cast_24" /> 105 android:src="@drawable/baseline_cast_24" />
  106 +
  107 + <ImageView
  108 + android:id="@+id/exit"
  109 + android:layout_width="@dimen/control_size"
  110 + android:layout_height="@dimen/control_size"
  111 + android:background="?android:attr/selectableItemBackground"
  112 + android:padding="@dimen/control_padding"
  113 + android:src="@drawable/ic_baseline_cancel_24" />
106 </LinearLayout> 114 </LinearLayout>
107 </androidx.constraintlayout.widget.ConstraintLayout> 115 </androidx.constraintlayout.widget.ConstraintLayout>