Skip to content

Commit 3fb808b

Browse files
committed
fix codacy
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent eb33ffb commit 3fb808b

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

app/src/main/java/com/nextcloud/client/player/ui/PlayerActivity.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import android.content.Intent
1313
import android.content.res.Configuration
1414
import android.graphics.Rect
1515
import android.media.AudioManager
16+
import android.os.Build
1617
import android.os.Bundle
1718
import android.util.Rational
1819
import android.view.View
@@ -119,10 +120,9 @@ class PlayerActivity :
119120
playerView.onStart()
120121
}
121122

122-
private fun Intent.getPlaybackFileType(): PlaybackFileType {
123-
return getSerializableArgument(PLAYBACK_FILE_TYPE, PlaybackFileType::class.java)
123+
private fun Intent.getPlaybackFileType(): PlaybackFileType =
124+
getSerializableArgument(PLAYBACK_FILE_TYPE, PlaybackFileType::class.java)
124125
?: throw IllegalStateException("Playback file type was not defined")
125-
}
126126

127127
override fun onStart() {
128128
super.onStart()
@@ -175,11 +175,14 @@ class PlayerActivity :
175175

176176
private fun createPictureInPictureParams(): PictureInPictureParams = PictureInPictureParams.Builder().let {
177177
it.setAspectRatio(pipAspectRatio)
178+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
179+
it.setAutoEnterEnabled(true)
180+
}
178181
getSourceRectHint().let(it::setSourceRectHint)
179182
it.build()
180183
}
181184

182-
private fun getSourceRectHint(): Rect? {
185+
private fun getSourceRectHint(): Rect {
183186
val containerRect = Rect()
184187
playerView.getGlobalVisibleRect(containerRect)
185188
val sourceHeightHint = (containerRect.width() / pipAspectRatio.toFloat()).toInt()

app/src/main/java/com/nextcloud/client/player/ui/control/PlayerControlView.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,26 +190,35 @@ class PlayerControlView @JvmOverloads constructor(
190190
private fun renderRepeatButton(repeatSingle: Boolean) {
191191
binding.ivRepeat.iconTint = ContextCompat.getColorStateList(
192192
binding.root.context,
193-
if (repeatSingle) R.color.player_accent_color
194-
else R.color.player_default_icon_color
193+
if (repeatSingle) {
194+
R.color.player_accent_color
195+
} else {
196+
R.color.player_default_icon_color
197+
}
195198
)
196199
binding.ivRepeat.tag = if (repeatSingle) TAG_CLICK_COMMAND_DO_NOT_REPEAT else TAG_CLICK_COMMAND_REPEAT
197200
}
198201

199202
private fun renderShuffleButton(shuffle: Boolean) {
200203
binding.ivRandom.iconTint = ContextCompat.getColorStateList(
201204
binding.root.context,
202-
if (shuffle) R.color.player_accent_color
203-
else R.color.player_default_icon_color
205+
if (shuffle) {
206+
R.color.player_accent_color
207+
} else {
208+
R.color.player_default_icon_color
209+
}
204210
)
205211
binding.ivRandom.tag = if (shuffle) TAG_CLICK_COMMAND_DO_NOT_SHUFFLE else TAG_CLICK_COMMAND_SHUFFLE
206212
}
207213

208214
private fun renderPlayPauseButton(isPlaying: Boolean) {
209215
binding.ivPlayPause.icon = AppCompatResources.getDrawable(
210216
binding.root.context,
211-
if (isPlaying) R.drawable.player_ic_pause
212-
else R.drawable.player_ic_play
217+
if (isPlaying) {
218+
R.drawable.player_ic_pause
219+
} else {
220+
R.drawable.player_ic_play
221+
}
213222
)
214223
binding.ivPlayPause.tag = if (isPlaying) TAG_CLICK_COMMAND_PAUSE else TAG_CLICK_COMMAND_PLAY
215224
}

0 commit comments

Comments
 (0)