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

Migrate spotless to 6.21.0 #79

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MainActivity : ComponentActivity() {
WebRtcSessionManagerImpl(
context = this,
signalingClient = SignalingClient(),
peerConnectionFactory = StreamPeerConnectionFactory(this)
peerConnectionFactory = StreamPeerConnectionFactory(this),
)
}

Expand All @@ -60,7 +60,7 @@ class MainActivity : ComponentActivity() {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
color = MaterialTheme.colors.background,
) {
var onCallScreen by remember { mutableStateOf(BuildConfig.BUILD_TYPE == "benchmark") }
val state by sessionManager.signalingClient.sessionStateFlow.collectAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import org.webrtc.VideoTrack
@Composable
fun VideoRendererasd(
videoTrack: VideoTrack,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) {
val trackState: MutableState<VideoTrack?> = remember { mutableStateOf(null) }
var view: VideoTextureViewRenderer? by remember { mutableStateOf(null) }
Expand All @@ -60,20 +60,20 @@ fun VideoRendererasd(
override fun onFirstFrameRendered() = Unit

override fun onFrameResolutionChanged(p0: Int, p1: Int, p2: Int) = Unit
}
},
)
setupVideo(trackState, videoTrack, this)
view = this
}
},
update = { v -> setupVideo(trackState, videoTrack, v) },
modifier = modifier
modifier = modifier,
)
}

private fun cleanTrack(
view: VideoTextureViewRenderer?,
trackState: MutableState<VideoTrack?>
trackState: MutableState<VideoTrack?>,
) {
view?.let { trackState.value?.removeSink(it) }
trackState.value = null
Expand All @@ -82,7 +82,7 @@ private fun cleanTrack(
private fun setupVideo(
trackState: MutableState<VideoTrack?>,
track: VideoTrack,
renderer: VideoTextureViewRenderer
renderer: VideoTextureViewRenderer,
) {
if (trackState.value == track) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import io.getstream.webrtc.sample.compose.webrtc.WebRTCSessionState
@Composable
fun StageScreen(
state: WebRTCSessionState,
onJoinCall: () -> Unit
onJoinCall: () -> Unit,
) {
Box(modifier = Modifier.fillMaxSize()) {
var enabledCall by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -67,12 +67,12 @@ fun StageScreen(
Button(
modifier = Modifier.align(Alignment.Center),
enabled = enabledCall,
onClick = { onJoinCall.invoke() }
onClick = { onJoinCall.invoke() },
) {
Text(
text = text,
fontSize = 26.sp,
fontWeight = FontWeight.Bold
fontWeight = FontWeight.Bold,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ package io.getstream.webrtc.sample.compose.ui.screens.video

data class CallMediaState(
val isMicrophoneEnabled: Boolean = true,
val isCameraEnabled: Boolean = true
val isCameraEnabled: Boolean = true,
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import io.getstream.webrtc.sample.compose.ui.theme.Primary

sealed class CallAction {
data class ToggleMicroPhone(
val isEnabled: Boolean
val isEnabled: Boolean,
) : CallAction()

data class ToggleCamera(
val isEnabled: Boolean
val isEnabled: Boolean,
) : CallAction()

object FlipCamera : CallAction()
Expand All @@ -42,54 +42,54 @@ data class VideoCallControlAction(
val icon: Painter,
val iconTint: Color,
val background: Color,
val callAction: CallAction
val callAction: CallAction,
)

@Composable
fun buildDefaultCallControlActions(
callMediaState: CallMediaState
callMediaState: CallMediaState,
): List<VideoCallControlAction> {
val microphoneIcon =
painterResource(
id = if (callMediaState.isMicrophoneEnabled) {
R.drawable.ic_mic_on
} else {
R.drawable.ic_mic_off
}
},
)

val cameraIcon = painterResource(
id = if (callMediaState.isCameraEnabled) {
R.drawable.ic_videocam_on
} else {
R.drawable.ic_videocam_off
}
},
)

return listOf(
VideoCallControlAction(
icon = microphoneIcon,
iconTint = Color.White,
background = Primary,
callAction = CallAction.ToggleMicroPhone(callMediaState.isMicrophoneEnabled)
callAction = CallAction.ToggleMicroPhone(callMediaState.isMicrophoneEnabled),
),
VideoCallControlAction(
icon = cameraIcon,
iconTint = Color.White,
background = Primary,
callAction = CallAction.ToggleCamera(callMediaState.isCameraEnabled)
callAction = CallAction.ToggleCamera(callMediaState.isCameraEnabled),
),
VideoCallControlAction(
icon = painterResource(id = R.drawable.ic_camera_flip),
iconTint = Color.White,
background = Primary,
callAction = CallAction.FlipCamera
callAction = CallAction.FlipCamera,
),
VideoCallControlAction(
icon = painterResource(id = R.drawable.ic_call_end),
iconTint = Color.White,
background = Disabled,
callAction = CallAction.LeaveCall
)
callAction = CallAction.LeaveCall,
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ import androidx.compose.ui.unit.dp
fun VideoCallControls(
modifier: Modifier,
callMediaState: CallMediaState,
actions: List<VideoCallControlAction> = buildDefaultCallControlActions(callMediaState = callMediaState),
onCallAction: (CallAction) -> Unit
actions: List<VideoCallControlAction> =
buildDefaultCallControlActions(callMediaState = callMediaState),
onCallAction: (CallAction) -> Unit,
) {
LazyRow(
modifier = modifier.padding(bottom = 12.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceEvenly
horizontalArrangement = Arrangement.SpaceEvenly,
) {
items(actions) { action ->
Box(
modifier = Modifier
.size(56.dp)
.clip(CircleShape)
.background(action.background)
.background(action.background),
) {
Icon(
modifier = Modifier
Expand All @@ -58,7 +59,7 @@ fun VideoCallControls(
.clickable { onCallAction(action.callAction) },
tint = action.iconTint,
painter = action.icon,
contentDescription = null
contentDescription = null,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun VideoCallScreen() {
}

Box(
modifier = Modifier.fillMaxSize()
modifier = Modifier.fillMaxSize(),
) {
var parentSize: IntSize by remember { mutableStateOf(IntSize(0, 0)) }

Expand All @@ -74,7 +74,7 @@ fun VideoCallScreen() {
.fillMaxSize()
.onSizeChanged { parentSize = it },
eglBaseContext = sessionManager.peerConnectionFactory.eglBaseContext,
rendererEvents = rendererEvents
rendererEvents = rendererEvents,
)
}

Expand All @@ -88,7 +88,7 @@ fun VideoCallScreen() {
parentBounds = parentSize,
paddingValues = PaddingValues(0.dp),
eglBaseContext = sessionManager.peerConnectionFactory.eglBaseContext,
rendererEvents = rendererEvents
rendererEvents = rendererEvents,
)
}

Expand Down Expand Up @@ -117,7 +117,7 @@ fun VideoCallScreen() {
activity?.finish()
}
}
}
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import androidx.compose.ui.unit.dp
val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
large = RoundedCornerShape(0.dp),
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import androidx.compose.runtime.Composable
private val DarkColorPalette = darkColors(
primary = Purple200,
primaryVariant = Purple700,
secondary = Teal200
secondary = Teal200,
)

private val LightColorPalette = lightColors(
primary = Purple500,
primaryVariant = Purple700,
secondary = Teal200
secondary = Teal200,

/* Other default colors to override
background = Color.White,
Expand All @@ -46,7 +46,7 @@ private val LightColorPalette = lightColors(
@Composable
fun WebrtcSampleComposeTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
val colors = if (darkTheme) {
DarkColorPalette
Expand All @@ -58,6 +58,6 @@ fun WebrtcSampleComposeTheme(
colors = colors,
typography = Typography,
shapes = Shapes,
content = content
content = content,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ val Typography = Typography(
body1 = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
)
fontSize = 16.sp,
),
/* Other default text styles to override
button = TextStyle(
fontFamily = FontFamily.Default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ enum class WebRTCSessionState {
Creating, // Creating session, offer has been sent
Ready, // Both clients available and ready to initiate session
Impossible, // We have less than two clients connected to the server
Offline // unable to connect signaling server
Offline, // unable to connect signaling server
}

enum class SignalingCommand {
STATE, // Command for WebRTCSessionState
OFFER, // to send or receive offer
ANSWER, // to send or receive answer
ICE // to send and receive ice candidates
ICE, // to send and receive ice candidates
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ package io.getstream.webrtc.sample.compose.webrtc.audio

typealias AudioDeviceChangeListener = (
audioDevices: List<AudioDevice>,
selectedAudioDevice: AudioDevice?
selectedAudioDevice: AudioDevice?,
) -> Unit
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import android.media.AudioManager
internal class AudioFocusRequestWrapper {

@SuppressLint("NewApi")
fun buildRequest(audioFocusChangeListener: AudioManager.OnAudioFocusChangeListener): AudioFocusRequest {
fun buildRequest(
audioFocusChangeListener: AudioManager.OnAudioFocusChangeListener,
): AudioFocusRequest {
val playbackAttributes = AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AudioSwitchHandler constructor(private val context: Context) : AudioHandle
context = context,
audioFocusChangeListener = onAudioFocusChangeListener
?: defaultOnAudioFocusChangeListener,
preferredDeviceList = preferredDeviceList ?: defaultPreferredDeviceList
preferredDeviceList = preferredDeviceList ?: defaultPreferredDeviceList,
)
audioSwitch = switch
switch.start(audioDeviceChangeListener ?: defaultAudioDeviceChangeListener)
Expand All @@ -84,7 +84,7 @@ class AudioSwitchHandler constructor(private val context: Context) : AudioHandle
object : AudioDeviceChangeListener {
override fun invoke(
audioDevices: List<AudioDevice>,
selectedAudioDevice: AudioDevice?
selectedAudioDevice: AudioDevice?,
) {
StreamLog.i(TAG) { "[onAudioDeviceChange] selectedAudioDevice: $selectedAudioDevice" }
}
Expand All @@ -95,7 +95,7 @@ class AudioSwitchHandler constructor(private val context: Context) : AudioHandle
AudioDevice.BluetoothHeadset::class.java,
AudioDevice.WiredHeadset::class.java,
AudioDevice.Earpiece::class.java,
AudioDevice.Speakerphone::class.java
AudioDevice.Speakerphone::class.java,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class AudioManagerAdapterImpl(
private val context: Context,
private val audioManager: AudioManager,
private val audioFocusRequest: AudioFocusRequestWrapper = AudioFocusRequestWrapper(),
private val audioFocusChangeListener: AudioManager.OnAudioFocusChangeListener
private val audioFocusChangeListener: AudioManager.OnAudioFocusChangeListener,
) : AudioManagerAdapter {

private val logger by taggedLogger("Call:AudioManager")
Expand Down Expand Up @@ -69,15 +69,21 @@ internal class AudioManagerAdapterImpl(
audioRequest = audioFocusRequest.buildRequest(audioFocusChangeListener)
audioRequest?.let {
val result = audioManager.requestAudioFocus(it)
logger.i { "[setAudioFocus] #new; completed: ${result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED}" }
logger.i {
"[setAudioFocus] #new; completed: " +
"${result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED}"
}
}
} else {
val result = audioManager.requestAudioFocus(
audioFocusChangeListener,
AudioManager.STREAM_VOICE_CALL,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT,
)
logger.i { "[setAudioFocus] #old; completed: ${result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED}" }
logger.i {
"[setAudioFocus] #old; completed: " +
"${result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED}"
}
}
/*
* Start by setting MODE_IN_COMMUNICATION as default audio mode. It is
Expand Down
Loading
Loading