This commit is contained in:
2024-08-27 17:30:04 -04:00
parent 30de189e27
commit 2def4bebce
4 changed files with 6 additions and 61 deletions

View File

@@ -31,7 +31,6 @@ import com.google.android.horologist.annotations.ExperimentalHorologistApi
fun ControlDashboard( fun ControlDashboard(
controlDashboardUiState: ControlDashboardUiState, controlDashboardUiState: ControlDashboardUiState,
onMicClicked: () -> Unit, onMicClicked: () -> Unit,
onPlayClicked: () -> Unit,
recordingProgress: Float, recordingProgress: Float,
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
@@ -39,13 +38,7 @@ fun ControlDashboard(
contentAlignment = Alignment.Center, contentAlignment = Alignment.Center,
modifier = modifier.fillMaxSize() modifier = modifier.fillMaxSize()
) { ) {
// Show the progress indicator only when recording
if (controlDashboardUiState.micState.expanded) {
CircularProgressIndicator(
progress = recordingProgress,
modifier = modifier.fillMaxSize()
)
}
Row( Row(
horizontalArrangement = Arrangement.spacedBy(8.dp) 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)
)
} }
} }
} }

View File

@@ -128,9 +128,6 @@ fun WearApp(greetingName: String) {
scope.launch { scope.launch {
mainState.onMicClicked() 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)
}
}
} }
} }

View File

@@ -154,34 +154,6 @@ sealed class PlaybackState {
object Recording : 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. * A helper function to record, updating the progress state while recording.
* *

View File

@@ -18,8 +18,7 @@ fun SpeakerRecordingScreen(
playbackState: PlaybackState, playbackState: PlaybackState,
isPermissionDenied: Boolean, isPermissionDenied: Boolean,
recordingProgress: Float, recordingProgress: Float,
onMicClicked: () -> Unit, onMicClicked: () -> Unit
onPlayClicked: () -> Unit
) { ) {
ScreenScaffold { ScreenScaffold {
// Determine the control dashboard state. // Determine the control dashboard state.
@@ -31,7 +30,6 @@ fun SpeakerRecordingScreen(
ControlDashboard( ControlDashboard(
controlDashboardUiState = controlDashboardUiState, controlDashboardUiState = controlDashboardUiState,
onMicClicked = onMicClicked, onMicClicked = onMicClicked,
onPlayClicked = onPlayClicked,
recordingProgress = recordingProgress recordingProgress = recordingProgress
) )
} }
@@ -98,7 +96,6 @@ fun SpeakerScreenPreview(
playbackState = playbackState, playbackState = playbackState,
isPermissionDenied = true, isPermissionDenied = true,
recordingProgress = 0.25f, recordingProgress = 0.25f,
onMicClicked = {}, onMicClicked = {}
onPlayClicked = {}
) )
} }