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

Rewrite DeviceUtils and Utils in Kotlin #2056

Merged
merged 3 commits into from
Sep 15, 2022
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 @@ -114,7 +114,7 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
/**
* Enable AC3
*/
var ac3Enabled = booleanPreference("pref_bitstream_ac3", !DeviceUtils.isFireTvStickGen1())
var ac3Enabled = booleanPreference("pref_bitstream_ac3", !DeviceUtils.isFireTvStickGen1)

/**
* Default audio delay in milliseconds for libVLC
Expand Down Expand Up @@ -218,7 +218,7 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
putInt("libvlc_audio_delay", it.getLong("libvlc_audio_delay", 0).toInt())

// Disable AC3 (Dolby Digital) on Fire Stick Gen 1 devices
if (DeviceUtils.isFireTvStickGen1()) putBoolean("pref_bitstream_ac3", false)
if (DeviceUtils.isFireTvStickGen1) putBoolean("pref_bitstream_ac3", false)
}

// v0.13.3 to v0.13.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ enum class AudioBehavior {
DOWNMIX_TO_STEREO
}

val defaultAudioBehavior = if (DeviceUtils.isChromecastWithGoogleTV()) AudioBehavior.DOWNMIX_TO_STEREO
val defaultAudioBehavior = if (DeviceUtils.isChromecastWithGoogleTV) AudioBehavior.DOWNMIX_TO_STEREO
else AudioBehavior.DIRECT_STREAM
77 changes: 0 additions & 77 deletions app/src/main/java/org/jellyfin/androidtv/util/DeviceUtils.java

This file was deleted.

53 changes: 53 additions & 0 deletions app/src/main/java/org/jellyfin/androidtv/util/DeviceUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.jellyfin.androidtv.util

import android.os.Build

object DeviceUtils {
// Chromecast with Google TV
private const val CHROMECAST_GOOGLE_TV = "Chromecast"
private const val FIRE_TV_PREFIX = "AFT"

// Fire TV Stick Models
private const val FIRE_STICK_MODEL_GEN_1 = "AFTM"
private const val FIRE_STICK_MODEL_GEN_2 = "AFTT"
private const val FIRE_STICK_MODEL_GEN_3 = "AFTSSS"
private const val FIRE_STICK_LITE_MODEL = "AFTSS"
private const val FIRE_STICK_4K_MODEL = "AFTMM"
private const val FIRE_STICK_4K_MAX_MODEL = "AFTKA"

// Fire TV Cube Models
private const val FIRE_CUBE_MODEL_GEN_1 = "AFTA"

Check warning

Code scanning / detekt

Private member is unused and should be removed.

Private property `FIRE_CUBE_MODEL_GEN_1` is unused.
private const val FIRE_CUBE_MODEL_GEN_2 = "AFTR"

Check warning

Code scanning / detekt

Private member is unused and should be removed.

Private property `FIRE_CUBE_MODEL_GEN_2` is unused.

// Fire TV (Box) Models
private const val FIRE_TV_MODEL_GEN_1 = "AFTB"
private const val FIRE_TV_MODEL_GEN_2 = "AFTS"
private const val FIRE_TV_MODEL_GEN_3 = "AFTN"

Check warning

Code scanning / detekt

Private member is unused and should be removed.

Private property `FIRE_TV_MODEL_GEN_3` is unused.

// Nvidia Shield TV Model
private const val SHIELD_TV_MODEL = "SHIELD Android TV"
private const val UNKNOWN = "Unknown"

// Stub to allow for mock injection
fun getBuildModel(): String = Build.MODEL ?: UNKNOWN

@JvmStatic val isChromecastWithGoogleTV: Boolean get() = getBuildModel() == CHROMECAST_GOOGLE_TV
@JvmStatic val isFireTv: Boolean get() = getBuildModel().startsWith(FIRE_TV_PREFIX)
@JvmStatic val isFireTvStickGen1: Boolean get() = getBuildModel() == FIRE_STICK_MODEL_GEN_1
@JvmStatic val isFireTvStick4k: Boolean get() = getBuildModel() in listOf(FIRE_STICK_4K_MODEL, FIRE_STICK_4K_MAX_MODEL)
@JvmStatic val isShieldTv: Boolean get() = getBuildModel() == SHIELD_TV_MODEL

@JvmStatic
fun has4kVideoSupport(): Boolean = getBuildModel() != UNKNOWN && getBuildModel() !in listOf(
// These devices only support a max video resolution of 1080p
FIRE_STICK_MODEL_GEN_1,
FIRE_STICK_MODEL_GEN_2,
FIRE_STICK_MODEL_GEN_3,
FIRE_STICK_LITE_MODEL,
FIRE_TV_MODEL_GEN_1,
FIRE_TV_MODEL_GEN_2
)

@JvmStatic
fun is60(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
}
142 changes: 0 additions & 142 deletions app/src/main/java/org/jellyfin/androidtv/util/Utils.java

This file was deleted.

Loading