yacwc
This commit is contained in:
@@ -31,7 +31,6 @@ import com.google.android.horologist.annotations.ExperimentalHorologistApi
|
||||
fun ControlDashboard(
|
||||
controlDashboardUiState: ControlDashboardUiState,
|
||||
onMicClicked: () -> Unit,
|
||||
onPlayClicked: () -> Unit,
|
||||
recordingProgress: Float,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -39,13 +38,7 @@ fun ControlDashboard(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier.fillMaxSize()
|
||||
) {
|
||||
// Show the progress indicator only when recording
|
||||
if (controlDashboardUiState.micState.expanded) {
|
||||
CircularProgressIndicator(
|
||||
progress = recordingProgress,
|
||||
modifier = modifier.fillMaxSize()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
@@ -61,12 +54,7 @@ fun ControlDashboard(
|
||||
}
|
||||
)
|
||||
|
||||
ControlDashboardButton(
|
||||
buttonState = controlDashboardUiState.playState,
|
||||
onClick = onPlayClicked,
|
||||
imageVector = Icons.Filled.PlayArrow,
|
||||
contentDescription = stringResource(id = R.string.play_recording)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +128,6 @@ fun WearApp(greetingName: String) {
|
||||
scope.launch {
|
||||
mainState.onMicClicked()
|
||||
}
|
||||
},
|
||||
onPlayClicked = {
|
||||
navController.navigate("player")
|
||||
}
|
||||
)
|
||||
|
||||
@@ -157,17 +154,8 @@ fun WearApp(greetingName: String) {
|
||||
}
|
||||
}
|
||||
}
|
||||
composable("player") {
|
||||
SpeakerPlayerScreen(
|
||||
volumeViewModel = volumeViewModel,
|
||||
onVolumeClick = { navController.navigate("volume") }
|
||||
)
|
||||
}
|
||||
composable("volume") {
|
||||
ScreenScaffold(timeText = {}) {
|
||||
VolumeScreen(volumeViewModel = volumeViewModel)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,34 +154,6 @@ sealed class PlaybackState {
|
||||
object Recording : PlaybackState()
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the device has a way to output audio and if it is supported.
|
||||
*
|
||||
* This could be an on-device speaker, or a connected bluetooth device.
|
||||
*/
|
||||
private fun speakerIsSupported(activity: Activity): Boolean {
|
||||
val hasAudioOutputFeature =
|
||||
activity.packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)
|
||||
val devices = activity.getSystemService<AudioManager>()!!
|
||||
.getDevices(AudioManager.GET_DEVICES_OUTPUTS)
|
||||
|
||||
// We can only trust AudioDeviceInfo.TYPE_BUILTIN_SPEAKER if the device advertises
|
||||
// FEATURE_AUDIO_OUTPUT
|
||||
val hasBuiltInSpeaker = devices.any { it.type == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER } &&
|
||||
hasAudioOutputFeature
|
||||
|
||||
// Check all the Wear supported BT devices
|
||||
// https://developer.android.com/training/wearables/apps/audio
|
||||
val hasBluetoothSpeaker = devices.any {
|
||||
it.type == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP ||
|
||||
it.type == AudioDeviceInfo.TYPE_BLE_BROADCAST ||
|
||||
it.type == AudioDeviceInfo.TYPE_BLE_SPEAKER ||
|
||||
it.type == AudioDeviceInfo.TYPE_BLE_HEADSET
|
||||
}
|
||||
|
||||
return hasBuiltInSpeaker || hasBluetoothSpeaker
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function to record, updating the progress state while recording.
|
||||
*
|
||||
|
||||
@@ -18,8 +18,7 @@ fun SpeakerRecordingScreen(
|
||||
playbackState: PlaybackState,
|
||||
isPermissionDenied: Boolean,
|
||||
recordingProgress: Float,
|
||||
onMicClicked: () -> Unit,
|
||||
onPlayClicked: () -> Unit
|
||||
onMicClicked: () -> Unit
|
||||
) {
|
||||
ScreenScaffold {
|
||||
// Determine the control dashboard state.
|
||||
@@ -31,7 +30,6 @@ fun SpeakerRecordingScreen(
|
||||
ControlDashboard(
|
||||
controlDashboardUiState = controlDashboardUiState,
|
||||
onMicClicked = onMicClicked,
|
||||
onPlayClicked = onPlayClicked,
|
||||
recordingProgress = recordingProgress
|
||||
)
|
||||
}
|
||||
@@ -98,7 +96,6 @@ fun SpeakerScreenPreview(
|
||||
playbackState = playbackState,
|
||||
isPermissionDenied = true,
|
||||
recordingProgress = 0.25f,
|
||||
onMicClicked = {},
|
||||
onPlayClicked = {}
|
||||
onMicClicked = {}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user