From 258c50a95eebb3381b265d6c1bc13d75dd970b5e Mon Sep 17 00:00:00 2001 From: damontecres <154766448+damontecres@users.noreply.github.com> Date: Sun, 30 Nov 2025 20:26:42 -0500 Subject: [PATCH] Add support for Android TV 6 & 7.0 (#350) Adds support for Android TV 6.0 & 7.0 by reduce the min SDK to 23. Going below 23 isn't practical since new releases of Jetpack libs require 23+. Also includes some clean up for better gradle syncs & actually use the datetime APIs available from desugaring on older versions. Needs more testing before merge Closes #341 --- README.md | 2 +- app/build.gradle.kts | 49 +++++++------------ .../damontecres/wholphin/ui/Formatting.kt | 29 +++-------- 3 files changed, 26 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index e333c763..8fd53cfa 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ The first time you attempt an update, the OS should guide you through enabling t ## Compatibility -Requires Android 7.1+ (or Fire TV OS 6+) and Jellyfin server `10.10.x` (tested on primarily `10.10.7`). +Requires Android 6+ (or Fire TV OS 6+) and Jellyfin server `10.10.x` or `10.11.x` (tested on primarily `10.11.3`). The app is tested on a variety of Android TV/Fire TV OS devices, but if you encounter issues, please file an issue! diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c92407dd..5f59fc6f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,7 +1,7 @@ import com.google.protobuf.gradle.id import com.mikepenz.aboutlibraries.plugin.DuplicateMode import com.mikepenz.aboutlibraries.plugin.DuplicateRule -import java.io.ByteArrayOutputStream +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import java.util.Base64 import java.util.Properties @@ -21,31 +21,17 @@ val isCI = if (System.getenv("CI") != null) System.getenv("CI").toBoolean() else val shouldSign = isCI && System.getenv("KEY_ALIAS") != null val ffmpegModuleExists = project.file("libs/lib-decoder-ffmpeg-release.aar").exists() -fun getVersionCode(): Int { - val stdout = ByteArrayOutputStream() - exec { - commandLine = listOf("git", "tag", "--list", "v*", "p*") - standardOutput = stdout - } - return stdout - .toString() - .trim() - .lines() - .size -} +val gitTags = + providers + .exec { commandLine("git", "tag", "--list", "v*", "p*") } + .standardOutput.asText + .get() -fun getAppVersion(): String { - val stdout = ByteArrayOutputStream() - exec { - commandLine = listOf("git", "describe", "--tags", "--long", "--match=v*") - standardOutput = stdout - } - return stdout - .toString() - .trim() - .removePrefix("v") - .ifBlank { "0.0.0" } -} +val gitDescribe = + providers + .exec { commandLine("git", "describe", "--tags", "--long", "--match=v*") } + .standardOutput.asText + .getOrElse("v0.0.0") android { namespace = "com.github.damontecres.wholphin" @@ -53,10 +39,10 @@ android { defaultConfig { applicationId = "com.github.damontecres.wholphin" - minSdk = 25 + minSdk = 23 targetSdk = 36 - versionCode = getVersionCode() - versionName = getAppVersion() + versionCode = gitTags.trim().lines().size + versionName = gitDescribe.trim() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -79,8 +65,11 @@ android { targetCompatibility = JavaVersion.VERSION_11 isCoreLibraryDesugaringEnabled = true } - kotlinOptions { - jvmTarget = "11" + kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_11 + javaParameters = true + } } buildFeatures { buildConfig = true diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/Formatting.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/Formatting.kt index f6404e87..7641d399 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/Formatting.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/Formatting.kt @@ -1,6 +1,5 @@ package com.github.damontecres.wholphin.ui -import android.os.Build import androidx.annotation.StringRes import com.github.damontecres.wholphin.R import org.jellyfin.sdk.model.api.BaseItemDto @@ -12,33 +11,17 @@ import java.time.format.FormatStyle import java.util.Locale val TimeFormatter: DateTimeFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT) +val DateFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("MMM d, yyyy") + +// TODO server returns in UTC, but sdk converts to local time +// eg 2020-02-14T00:00:00.0000000Z => 2020-02-13T17:00:00 PT => Feb 13, 2020 /** * Format a [LocalDateTime] as `Aug 24, 2000` */ -fun formatDateTime(dateTime: LocalDateTime): String = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - // TODO server returns in UTC, but sdk converts to local time - // eg 2020-02-14T00:00:00.0000000Z => 2020-02-13T17:00:00 PT => Feb 13, 2020 - val formatter = DateTimeFormatter.ofPattern("MMM d, yyyy") - formatter.format(dateTime) - } else if (dateTime.toString().length >= 10) { - dateTime.toString().substring(0, 10) - } else { - dateTime.toString() - } +fun formatDateTime(dateTime: LocalDateTime): String = DateFormatter.format(dateTime) -fun formatDate(dateTime: LocalDate): String = - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - // TODO server returns in UTC, but sdk converts to local time - // eg 2020-02-14T00:00:00.0000000Z => 2020-02-13T17:00:00 PT => Feb 13, 2020 - val formatter = DateTimeFormatter.ofPattern("MMM d, yyyy") - formatter.format(dateTime) - } else if (dateTime.toString().length >= 10) { - dateTime.toString().substring(0, 10) - } else { - dateTime.toString() - } +fun formatDate(dateTime: LocalDate): String = DateFormatter.format(dateTime) /** * If the item has season & episode info, format as `S# E#`