From d57ff3897e65f6b9095874c2e851a266e2ea4265 Mon Sep 17 00:00:00 2001 From: Damontecres Date: Thu, 11 Dec 2025 16:08:13 -0500 Subject: [PATCH 1/4] Update dependencies --- app/build.gradle.kts | 39 ++++++++++++--------------------------- gradle/libs.versions.toml | 33 ++++++++++++++++----------------- 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f91be2ec1..99f12b184 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,7 +1,6 @@ import com.android.build.gradle.internal.cxx.io.writeTextIfDifferent import com.android.build.gradle.internal.tasks.factory.dependsOn import com.google.protobuf.gradle.id -import java.io.ByteArrayOutputStream import java.util.Base64 import java.util.Properties @@ -20,31 +19,17 @@ plugins { alias(libs.plugins.protobuf) } -fun getVersionCode(): Int { - val stdout = ByteArrayOutputStream() - exec { - commandLine = listOf("git", "tag", "--list", "v*") - standardOutput = stdout - } - return stdout - .toString() - .trim() - .lines() - .size -} +val gitTags = + providers + .exec { commandLine("git", "tag", "--list", "v*") } + .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.stashapp" @@ -68,8 +53,8 @@ android { minSdk = 23 targetSdk = 36 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - versionCode = getVersionCode() - versionName = getAppVersion() + versionCode = gitTags.trim().lines().size + versionName = gitDescribe.trim().removePrefix("v").ifBlank { "0.0.0" } vectorDrawables.useSupportLibrary = true } signingConfigs { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 46c3380db..4535c51c2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,8 @@ [versions] acra = "5.13.1" -activity-compose = "1.11.0" +activity-compose = "1.12.1" androidsvg-aar = "1.4" -android-application = "8.13.0" +android-application = "8.13.2" apollo = "4.3.3" androidx-media3 = "1.8.0" androidx-test = "1.7.0" @@ -11,11 +11,10 @@ androidx-test-ext-junit = "1.3.0" androidx-test-ext-truth = "1.7.0" auto-service = "1.1.1" coil-compose = "3.3.0" -compose-bom = "2025.11.00" -compose-runtime = "1.9.4" +compose-bom = "2025.12.00" compose-wheel-picker = "1.0.0-rc02" constraintlayout = "2.2.1" -datastore = "1.1.7" +datastore = "1.2.0" desugar_jdk_libs = "2.1.5" markwon-core = "4.6.2" core-ktx = "1.17.0" @@ -29,12 +28,12 @@ leanback = "1.2.0" leanback-preference = "1.2.0" leanback-tab = "1.1.0" leanback-grid = "1.0.0" -lifecycle-process = "2.9.4" -lifecycle-viewmodel-compose = "2.9.4" +lifecycle-process = "2.10.0" +lifecycle-viewmodel-compose = "2.10.0" material = "1.13.0" material3-adaptive = "1.0.0-alpha06" material3-android = "1.4.0" -mockito-core = "5.20.0" +mockito-core = "5.21.0" mockito-kotlin = "6.1.0" navigation-reimagined = "1.5.0" parcelable-core = "0.9.0" @@ -42,11 +41,11 @@ preference-ktx-version = "1.2.1" previewseekbar = "3.1.1" previewseekbar-media3 = "1.1.1.0" protobuf = "0.9.5" -protobuf-javalite = "4.33.0" +protobuf-javalite = "4.33.2" restring = "6.0.0" reword = "4.0.4" -room = "2.8.3" -swiperefreshlayout = "1.1.0" +room = "2.8.4" +swiperefreshlayout = "1.2.0" tv-foundation = "1.0.0-alpha12" tv-material = "1.0.1" viewpump = "4.0.14" @@ -124,17 +123,17 @@ zoomlayout = { module = "com.otaliastudios:zoomlayout", version.ref = "zoomlayou androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" } androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" } -androidx-compose-runtime = { module = "androidx.compose.runtime:runtime-android", version.ref = "compose-runtime" } -androidx-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose-runtime" } +androidx-compose-runtime = { module = "androidx.compose.runtime:runtime-android" } +androidx-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" } androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycle-viewmodel-compose" } androidx-material3-android = { module = "androidx.compose.material3:material3-android", version.ref = "material3-android" } -androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose-runtime" } -androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose-runtime" } -androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose-runtime" } +androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling-preview" } androidx-tv-foundation = { module = "androidx.tv:tv-foundation", version.ref = "tv-foundation" } androidx-tv-material = { module = "androidx.tv:tv-material", version.ref = "tv-material" } androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } -androidx-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose-runtime" } +androidx-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" } [plugins] android-application = { id = "com.android.application", version.ref = "android-application" } From e98cc64d04ca6a8ad8721af6e6d9756921216b4d Mon Sep 17 00:00:00 2001 From: Damontecres Date: Thu, 11 Dec 2025 16:37:28 -0500 Subject: [PATCH 2/4] More version bumps --- .github/workflows/main.yml | 6 +++--- .github/workflows/pr.yml | 2 +- .github/workflows/release.yml | 10 +++++----- .pre-commit-config.yaml | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c515fed3e..c3b53b906 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ env: APK_SHORT_NAME: StashAppAndroidTV-release.apk APK_DEBUG_SHORT_NAME: StashAppAndroidTV-debug.apk BRANCH_NAME: ${{ github.ref_name }} - BUILD_TOOLS_VERSION: 35.0.0 + BUILD_TOOLS_VERSION: 36.0.0 jobs: build: @@ -28,13 +28,13 @@ jobs: contents: write steps: - name: Checkout the code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 # Need the tags to build submodules: true # Need the submodules to build # Setup the SDKs - name: Setup JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: zulu java-version: '21' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1c61c4b6a..807a0dd2c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,7 +8,7 @@ defaults: shell: bash env: - BUILD_TOOLS_VERSION: 35.0.0 + BUILD_TOOLS_VERSION: 36.0.0 BUILD_DIRS_ARTIFACT: build-dirs jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ebf4f7f2..75e1904c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ defaults: env: APK_SHORT_NAME: StashAppAndroidTV.apk - BUILD_TOOLS_VERSION: 35.0.0 + BUILD_TOOLS_VERSION: 36.0.0 jobs: publish: @@ -20,16 +20,16 @@ jobs: contents: write steps: - name: Checkout the code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 # Need the tags to build submodules: true # Need the submodules to build - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: '3.10' + python-version: '3.12' - name: Setup JDK - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: zulu java-version: '21' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a8788fdb9..f8ec6d53e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,16 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-xml - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.12.0 + rev: v2.15.0 hooks: - id: pretty-format-kotlin - args: [ --autofix, --ktlint-version=1.4.1 ] + args: [ --autofix, --ktlint-version=1.8.0 ] - repo: local hooks: - id: check-debug-enabled From de4677be9237d35d419714c32329493a9660dbf8 Mon Sep 17 00:00:00 2001 From: Damontecres Date: Thu, 11 Dec 2025 16:47:49 -0500 Subject: [PATCH 3/4] Update style for ktlint 1.8.0 --- .../compiler/StashApolloCompilerPlugin.kt | 13 +- .../damontecres/stashapp/DebugFragment.kt | 3 +- .../stashapp/FilterDebugFragment.kt | 1 + .../damontecres/stashapp/FilterFragment.kt | 17 ++- .../stashapp/MarkerDetailsFragment.kt | 4 +- .../damontecres/stashapp/RootActivity.kt | 1 + .../stashapp/SceneDetailsFragment.kt | 5 +- .../damontecres/stashapp/SearchForFragment.kt | 62 ++++++-- .../damontecres/stashapp/StashExoPlayer.kt | 20 ++- .../stashapp/filter/CreateObjectFilterStep.kt | 7 +- .../stashapp/filter/DescriptionExtractors.kt | 135 ++++++++++++++---- .../stashapp/filter/output/FilterWriter.kt | 71 ++++++--- .../filter/picker/SearchPickerFragment.kt | 14 +- .../stashapp/filter/picker/TwoValuePicker.kt | 2 +- .../stashapp/image/ImageDetailsFragment.kt | 5 +- .../stashapp/image/ImageFragment.kt | 44 +++--- .../stashapp/image/ImageViewFragment.kt | 7 +- .../stashapp/navigation/Destination.kt | 4 +- .../stashapp/navigation/NavigationManager.kt | 88 +++++++++--- .../navigation/NavigationManagerCompose.kt | 31 ++-- .../NavigationOnItemViewClickedListener.kt | 15 +- .../stashapp/playback/PlaybackFragment.kt | 12 +- .../playback/PlaybackSceneFragment.kt | 7 +- .../stashapp/playback/StashPlayerView.kt | 7 +- .../stashapp/playback/StreamUtils.kt | 50 +++++-- .../presenters/FilterArgsPresenter.kt | 12 +- .../stashapp/presenters/StashImageCardView.kt | 6 +- .../stashapp/setup/SetupStep1ServerUrl.kt | 12 +- .../stashapp/setup/SetupStep2Ssl.kt | 12 +- .../stashapp/setup/SetupStep3ApiKey.kt | 3 +- .../stashapp/suppliers/DataSupplierFactory.kt | 52 +++++-- .../GroupRelationshipDataSupplier.kt | 13 +- .../github/damontecres/stashapp/ui/Themes.kt | 20 ++- .../damontecres/stashapp/ui/cards/Cards.kt | 32 +++-- .../stashapp/ui/components/Dialogs.kt | 7 +- .../stashapp/ui/components/Rating.kt | 3 +- .../stashapp/ui/components/TimestampPicker.kt | 2 +- .../components/filter/BasicFilterSettings.kt | 2 + .../components/playback/PlaybackDebugInfo.kt | 15 +- .../playback/PlaybackPageContent.kt | 44 ++++-- .../components/playback/PlaylistListDialog.kt | 10 +- .../components/prefs/ComposablePreference.kt | 31 ++-- .../components/prefs/PreferencesViewModel.kt | 4 +- .../ui/components/prefs/StashPreference.kt | 27 +++- .../ui/components/server/ConfigurePin.kt | 2 +- .../stashapp/ui/nav/ApplicationContent.kt | 41 ++++-- .../stashapp/ui/nav/DestinationContent.kt | 54 ++++--- .../stashapp/ui/pages/FilterPage.kt | 6 +- .../stashapp/ui/pages/ImagePage.kt | 20 ++- .../stashapp/ui/pages/PerformerPage.kt | 9 +- .../stashapp/ui/pages/SceneDetailsPage.kt | 9 +- .../stashapp/ui/pages/SearchForPage.kt | 48 +++++-- .../stashapp/ui/util/ModifierUtils.kt | 10 +- .../stashapp/util/AlphabetSearchUtils.kt | 6 +- .../stashapp/util/AndroidExtensions.kt | 10 +- .../damontecres/stashapp/util/Constants.kt | 8 +- .../stashapp/util/FrontPageParser.kt | 23 ++- .../stashapp/util/OptionalSerializer.kt | 20 ++- .../stashapp/util/ServerPreferences.kt | 14 +- .../stashapp/views/PlayAllOnClickListener.kt | 4 +- .../stashapp/views/SkipIndicator.kt | 2 +- .../stashapp/ObjectFilterParsingTests.kt | 4 +- 62 files changed, 905 insertions(+), 317 deletions(-) diff --git a/apollo-compiler/src/main/java/com/github/damontecres/apollo/compiler/StashApolloCompilerPlugin.kt b/apollo-compiler/src/main/java/com/github/damontecres/apollo/compiler/StashApolloCompilerPlugin.kt index 9380cb21e..36ce58647 100644 --- a/apollo-compiler/src/main/java/com/github/damontecres/apollo/compiler/StashApolloCompilerPlugin.kt +++ b/apollo-compiler/src/main/java/com/github/damontecres/apollo/compiler/StashApolloCompilerPlugin.kt @@ -46,11 +46,14 @@ class StashApolloCompilerPlugin : ApolloCompilerPlugin { val newFileSpecs = input.fileSpecs.map { file -> - if (file.name.endsWith("FilterType") && - file.name !in - setOf( - "FindFilterType", - "SavedFindFilterType", + if ( + ( + file.name.endsWith("FilterType") && + file.name !in + setOf( + "FindFilterType", + "SavedFindFilterType", + ) ) || file.name.endsWith("CriterionInput") ) { diff --git a/app/src/main/java/com/github/damontecres/stashapp/DebugFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/DebugFragment.kt index dc90d6d54..068ba0631 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/DebugFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/DebugFragment.kt @@ -279,8 +279,7 @@ class DebugFragment : Fragment(R.layout.debug) { values.forEach { value -> val valueView = TextView(requireContext()) valueView.text = - if (isApiKey && value != null - ) { + if (isApiKey && value != null) { value.take(4) + "..." + value.takeLast(8) } else { value diff --git a/app/src/main/java/com/github/damontecres/stashapp/FilterDebugFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/FilterDebugFragment.kt index 0da0c3752..8097192f3 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/FilterDebugFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/FilterDebugFragment.kt @@ -74,6 +74,7 @@ class FilterDebugFragment : Fragment(R.layout.filter_debug) { // table.isStretchAllColumns = true } } + else -> { val titleView = TextView(requireContext()) titleView.text = "No items" diff --git a/app/src/main/java/com/github/damontecres/stashapp/FilterFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/FilterFragment.kt index f79f11447..ee0e70022 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/FilterFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/FilterFragment.kt @@ -301,16 +301,25 @@ class FilterFragment : override fun getItem(position: Int): Any { if (createEnabled) { return when (position) { - 0 -> "Create filter" - 1 -> "Create filter from current" - 2 -> + 0 -> { + "Create filter" + } + + 1 -> { + "Create filter from current" + } + + 2 -> { if (filters.isEmpty()) { "No saved filters" } else { "Saved filters" } + } - else -> filters[position - 3] + else -> { + filters[position - 3] + } } } return filters[position] diff --git a/app/src/main/java/com/github/damontecres/stashapp/MarkerDetailsFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/MarkerDetailsFragment.kt index b462b76d3..2c8609da9 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/MarkerDetailsFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/MarkerDetailsFragment.kt @@ -215,7 +215,9 @@ class MarkerDetailsFragment : DetailsSupportFragment() { } } - else -> throw IllegalArgumentException("Unknown action id $sourceId") + else -> { + throw IllegalArgumentException("Unknown action id $sourceId") + } } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/RootActivity.kt b/app/src/main/java/com/github/damontecres/stashapp/RootActivity.kt index 4fbe47fb2..71b6dcedf 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/RootActivity.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/RootActivity.kt @@ -122,6 +122,7 @@ class RootActivity : } ServerViewModel.ServerConnection.Pending -> {} + ServerViewModel.ServerConnection.Success -> {} } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/SceneDetailsFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/SceneDetailsFragment.kt index cc0007d96..615dfda94 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/SceneDetailsFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/SceneDetailsFragment.kt @@ -313,7 +313,9 @@ class SceneDetailsFragment : DetailsSupportFragment() { } } - DataType.SCENE, DataType.MARKER, DataType.IMAGE, DataType.GALLERY -> throw IllegalArgumentException() + DataType.SCENE, DataType.MARKER, DataType.IMAGE, DataType.GALLERY -> { + throw IllegalArgumentException() + } } } } @@ -641,7 +643,6 @@ class SceneDetailsFragment : DetailsSupportFragment() { StashAction.ADD_GROUP -> DataType.GROUP StashAction.SET_STUDIO -> DataType.STUDIO StashAction.CREATE_MARKER -> DataType.TAG - else -> throw RuntimeException("Unsupported search for type $action") } val title = diff --git a/app/src/main/java/com/github/damontecres/stashapp/SearchForFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/SearchForFragment.kt index 91fb711d1..61bfff1d3 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/SearchForFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/SearchForFragment.kt @@ -151,7 +151,9 @@ class SearchForFragment : mutationEngine.createStudio(name = name) } - else -> throw IllegalArgumentException("Unsupported datatype $dataType") + else -> { + throw IllegalArgumentException("Unsupported datatype $dataType") + } } if (item != null) { Toast @@ -215,7 +217,7 @@ class SearchForFragment : ) val results = when (dataType) { - DataType.GALLERY -> + DataType.GALLERY -> { // Cannot add an image to a zip/folder gallery, so exclude them queryEngine.findGalleries( filter, @@ -229,8 +231,11 @@ class SearchForFragment : ), ), ) + } - else -> queryEngine.find(dataType, filter) + else -> { + queryEngine.find(dataType, filter) + } } resultsAdapter.addAll(0, results) adapter.set( @@ -282,11 +287,26 @@ class SearchForFragment : if (mostRecentIds.isNotEmpty()) { val items = when (dataType) { - DataType.PERFORMER -> queryEngine.findPerformers(performerIds = mostRecentIds) - DataType.TAG -> queryEngine.getTags(mostRecentIds) - DataType.STUDIO -> queryEngine.findStudios(studioIds = mostRecentIds) - DataType.GALLERY -> queryEngine.findGalleries(galleryIds = mostRecentIds) - DataType.GROUP -> queryEngine.findGroups(groupIds = mostRecentIds) + DataType.PERFORMER -> { + queryEngine.findPerformers(performerIds = mostRecentIds) + } + + DataType.TAG -> { + queryEngine.getTags(mostRecentIds) + } + + DataType.STUDIO -> { + queryEngine.findStudios(studioIds = mostRecentIds) + } + + DataType.GALLERY -> { + queryEngine.findGalleries(galleryIds = mostRecentIds) + } + + DataType.GROUP -> { + queryEngine.findGroups(groupIds = mostRecentIds) + } + else -> { listOf() } @@ -358,7 +378,7 @@ class SearchForFragment : viewLifecycleOwner.lifecycleScope.launch(exceptionHandler) { val results = when (dataType) { - DataType.GALLERY -> + DataType.GALLERY -> { // Cannot add an image to a zip gallery, so exclude them queryEngine.findGalleries( filter, @@ -372,8 +392,11 @@ class SearchForFragment : ), ), ) + } - else -> queryEngine.find(dataType, filter) + else -> { + queryEngine.find(dataType, filter) + } } val createAllowed = allowCreate(dataType, query, results) if (createAllowed && readOnlyModeDisabled()) { @@ -476,10 +499,21 @@ class SearchForFragment : items.none { it.name.lowercase() == q || it.aliases.any { it.lowercase() == q } } } - DataType.SCENE -> false - DataType.MARKER -> false - DataType.IMAGE -> false - DataType.GALLERY -> false + DataType.SCENE -> { + false + } + + DataType.MARKER -> { + false + } + + DataType.IMAGE -> { + false + } + + DataType.GALLERY -> { + false + } } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/StashExoPlayer.kt b/app/src/main/java/com/github/damontecres/stashapp/StashExoPlayer.kt index 8479441b2..ffdf69546 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/StashExoPlayer.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/StashExoPlayer.kt @@ -116,27 +116,37 @@ class StashExoPlayer private constructor() { } } - else -> throw IllegalArgumentException("Unknown HTTP client: $httpClientChoice") + else -> { + throw IllegalArgumentException("Unknown HTTP client: $httpClientChoice") + } } Log.d(TAG, "createInstance") val preferences = PreferenceManager.getDefaultSharedPreferences(context) val skipForward = when (skipParams) { - is SkipParams.Default -> + is SkipParams.Default -> { preferences.getInt( context.getString(R.string.pref_key_skip_forward_time), 30, ) * 1000L - is SkipParams.Values -> skipParams.skipForward + } + + is SkipParams.Values -> { + skipParams.skipForward + } } val skipBack = when (skipParams) { - is SkipParams.Default -> + is SkipParams.Default -> { preferences.getInt( context.getString(R.string.pref_key_skip_back_time), 10, ) * 1000L - is SkipParams.Values -> skipParams.skipBack + } + + is SkipParams.Values -> { + skipParams.skipBack + } } val trackSelector = DefaultTrackSelector(context) trackSelector.parameters = diff --git a/app/src/main/java/com/github/damontecres/stashapp/filter/CreateObjectFilterStep.kt b/app/src/main/java/com/github/damontecres/stashapp/filter/CreateObjectFilterStep.kt index b3275f7a1..2d55ade08 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/filter/CreateObjectFilterStep.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/filter/CreateObjectFilterStep.kt @@ -143,7 +143,7 @@ class CreateObjectFilterStep : CreateFilterGuidedStepFragment() { nextStep(DurationPickerFragment(filterOption)) } - else -> + else -> { // Get the picker for the sub-filter type when (filterOption.type) { IntCriterionInput::class -> { @@ -211,8 +211,11 @@ class CreateObjectFilterStep : CreateFilterGuidedStepFragment() { nextStep(CircumcisionPickerFragment(filterOption)) } - else -> throw UnsupportedOperationException("$filterOption") + else -> { + throw UnsupportedOperationException("$filterOption") + } } + } } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/filter/DescriptionExtractors.kt b/app/src/main/java/com/github/damontecres/stashapp/filter/DescriptionExtractors.kt index b79db9165..b80d91395 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/filter/DescriptionExtractors.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/filter/DescriptionExtractors.kt @@ -58,19 +58,47 @@ import kotlin.time.toDuration */ fun extractTitle(item: StashData): String? = when (item) { - is TagData -> item.name - is PerformerData -> item.name - is StudioData -> item.name - is GalleryData -> item.name - is ImageData -> item.titleOrFilename - is MarkerData -> + is TagData -> { + item.name + } + + is PerformerData -> { + item.name + } + + is StudioData -> { + item.name + } + + is GalleryData -> { + item.name + } + + is ImageData -> { + item.titleOrFilename + } + + is MarkerData -> { item.title.ifBlank { item.primary_tag.slimTagData.name } - is GroupData -> item.name - is SlimSceneData -> item.titleOrFilename - is FullSceneData -> item.titleOrFilename - else -> throw IllegalArgumentException("${item::class.qualifiedName} not supported") + } + + is GroupData -> { + item.name + } + + is SlimSceneData -> { + item.titleOrFilename + } + + is FullSceneData -> { + item.titleOrFilename + } + + else -> { + throw IllegalArgumentException("${item::class.qualifiedName} not supported") + } } /** @@ -135,11 +163,14 @@ fun filterSummary( val toStr = when (f.modifier) { CriterionModifier.EQUALS -> resolvedTitles.firstOrNull() ?: "" + CriterionModifier.INCLUDES_ALL -> resolvedTitles.toString() + CriterionModifier.INCLUDES -> resolvedTitles.toString() // Short circuit and return CriterionModifier.IS_NULL, CriterionModifier.NOT_NULL -> return modStr + else -> throw IllegalArgumentException("${f.modifier}") }.ifBlank { null } @@ -173,11 +204,14 @@ fun filterSummary( val toStr = when (f.modifier) { CriterionModifier.EQUALS -> resolvedTitles.firstOrNull() ?: "" + CriterionModifier.INCLUDES_ALL -> resolvedTitles.toString() + CriterionModifier.INCLUDES -> resolvedTitles.toString() // Short circuit and return CriterionModifier.IS_NULL, CriterionModifier.NOT_NULL -> return modStr + else -> throw IllegalArgumentException("${f.modifier}") }.ifBlank { null } @@ -233,9 +267,13 @@ fun filterSummaryRating(f: IntCriterionInput): String { CriterionModifier.NOT_EQUALS, CriterionModifier.GREATER_THAN, CriterionModifier.LESS_THAN, - -> getRatingString(value, ratingsAsStars) + -> { + getRatingString(value, ratingsAsStars) + } - CriterionModifier.IS_NULL, CriterionModifier.NOT_NULL -> null + CriterionModifier.IS_NULL, CriterionModifier.NOT_NULL -> { + null + } CriterionModifier.BETWEEN, CriterionModifier.NOT_BETWEEN -> { val valueStr = getRatingAsDecimalString(value, ratingsAsStars) @@ -251,7 +289,9 @@ fun filterSummaryRating(f: IntCriterionInput): String { } } - else -> throw IllegalArgumentException("${f.modifier}") + else -> { + throw IllegalArgumentException("${f.modifier}") + } } return if (toStr != null) { @@ -497,20 +537,57 @@ fun filterSummary( filterSummaryDuration(value as IntCriterionInput) } else { when (value) { - is IntCriterionInput -> filterSummary(value) - is FloatCriterionInput -> filterSummary(value) - is StringCriterionInput -> filterSummary(value) - is PhashDistanceCriterionInput -> filterSummary(value) - is PHashDuplicationCriterionInput -> filterSummary(value) - is ResolutionCriterionInput -> filterSummary(value) - is OrientationCriterionInput -> filterSummary(value) - is StashIDCriterionInput -> filterSummary(value) - is TimestampCriterionInput -> filterSummary(value) - is DateCriterionInput -> filterSummary(value) - is GenderCriterionInput -> filterSummary(value) - is CircumcisionCriterionInput -> filterSummary(value) - - is Boolean, String -> value.toString() + is IntCriterionInput -> { + filterSummary(value) + } + + is FloatCriterionInput -> { + filterSummary(value) + } + + is StringCriterionInput -> { + filterSummary(value) + } + + is PhashDistanceCriterionInput -> { + filterSummary(value) + } + + is PHashDuplicationCriterionInput -> { + filterSummary(value) + } + + is ResolutionCriterionInput -> { + filterSummary(value) + } + + is OrientationCriterionInput -> { + filterSummary(value) + } + + is StashIDCriterionInput -> { + filterSummary(value) + } + + is TimestampCriterionInput -> { + filterSummary(value) + } + + is DateCriterionInput -> { + filterSummary(value) + } + + is GenderCriterionInput -> { + filterSummary(value) + } + + is CircumcisionCriterionInput -> { + filterSummary(value) + } + + is Boolean, String -> { + value.toString() + } is MultiCriterionInput -> { val dataType = FilterWriter.getType(filterDataType, name)!! @@ -522,7 +599,9 @@ fun filterSummary( filterSummary(value, idLookup(dataType, value.getAllIds())) } - else -> value.toString() + else -> { + value.toString() + } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/filter/output/FilterWriter.kt b/app/src/main/java/com/github/damontecres/stashapp/filter/output/FilterWriter.kt index faf6c71a8..176e7318f 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/filter/output/FilterWriter.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/filter/output/FilterWriter.kt @@ -44,18 +44,53 @@ class FilterWriter( } else { val value = when (o) { - is IntCriterionInput -> o.toMap() - is FloatCriterionInput -> o.toMap() - is StringCriterionInput -> o.toMap() - is PhashDistanceCriterionInput -> o.toMap() - is PHashDuplicationCriterionInput -> o.toMap() - is ResolutionCriterionInput -> o.toMap() - is OrientationCriterionInput -> o.toMap() - is StashIDCriterionInput -> o.toMap() - is TimestampCriterionInput -> o.toMap() - is DateCriterionInput -> o.toMap() - is GenderCriterionInput -> o.toMap() - is CircumcisionCriterionInput -> o.toMap() + is IntCriterionInput -> { + o.toMap() + } + + is FloatCriterionInput -> { + o.toMap() + } + + is StringCriterionInput -> { + o.toMap() + } + + is PhashDistanceCriterionInput -> { + o.toMap() + } + + is PHashDuplicationCriterionInput -> { + o.toMap() + } + + is ResolutionCriterionInput -> { + o.toMap() + } + + is OrientationCriterionInput -> { + o.toMap() + } + + is StashIDCriterionInput -> { + o.toMap() + } + + is TimestampCriterionInput -> { + o.toMap() + } + + is DateCriterionInput -> { + o.toMap() + } + + is GenderCriterionInput -> { + o.toMap() + } + + is CircumcisionCriterionInput -> { + o.toMap() + } is Boolean, is String -> { mapOf( @@ -78,11 +113,15 @@ class FilterWriter( o.toMap(items) } - is StashDataFilter -> convertFilter(o) + is StashDataFilter -> { + convertFilter(o) + } - else -> throw UnsupportedOperationException( - "Unable to convert ${filter::class.simpleName}.${param.name} (${o::class.qualifiedName})", - ) + else -> { + throw UnsupportedOperationException( + "Unable to convert ${filter::class.simpleName}.${param.name} (${o::class.qualifiedName})", + ) + } } put(param.name, value) } diff --git a/app/src/main/java/com/github/damontecres/stashapp/filter/picker/SearchPickerFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/filter/picker/SearchPickerFragment.kt index bd5d42902..6255ff8d0 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/filter/picker/SearchPickerFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/filter/picker/SearchPickerFragment.kt @@ -137,7 +137,7 @@ class SearchPickerFragment( ) val results = when (dataType) { - DataType.GALLERY -> + DataType.GALLERY -> { // Cannot add an image to a zip/folder gallery, so exclude them queryEngine.findGalleries( filter, @@ -151,8 +151,11 @@ class SearchPickerFragment( ), ), ) + } - else -> queryEngine.find(dataType, filter) + else -> { + queryEngine.find(dataType, filter) + } } resultsAdapter.addAll(0, results) adapter.set( @@ -236,7 +239,7 @@ class SearchPickerFragment( viewLifecycleOwner.lifecycleScope.launch(exceptionHandler) { val results = when (dataType) { - DataType.GALLERY -> + DataType.GALLERY -> { // Cannot add an image to a zip gallery, so exclude them queryEngine.findGalleries( filter, @@ -250,8 +253,11 @@ class SearchPickerFragment( ), ), ) + } - else -> queryEngine.find(dataType, filter) + else -> { + queryEngine.find(dataType, filter) + } } if (results.isNotEmpty()) { searchResultsAdapter.addAll(0, results) diff --git a/app/src/main/java/com/github/damontecres/stashapp/filter/picker/TwoValuePicker.kt b/app/src/main/java/com/github/damontecres/stashapp/filter/picker/TwoValuePicker.kt index 209e0bb30..146cb8bbb 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/filter/picker/TwoValuePicker.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/filter/picker/TwoValuePicker.kt @@ -137,7 +137,7 @@ abstract class TwoValuePicker( collapseSubActions() setActionsDiffCallback(null) this.actions = createActionList() - if (value1 == null || modifier.hasTwoValues() && value2 == null) { + if (value1 == null || (modifier.hasTwoValues() && value2 == null)) { enableFinish(false) } else { enableFinish(true) diff --git a/app/src/main/java/com/github/damontecres/stashapp/image/ImageDetailsFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/image/ImageDetailsFragment.kt index 5c4cd3ec3..38d8cb7fb 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/image/ImageDetailsFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/image/ImageDetailsFragment.kt @@ -231,7 +231,9 @@ class ImageDetailsFragment : DetailsSupportFragment() { } } - DataType.GROUP, DataType.SCENE, DataType.MARKER, DataType.IMAGE -> throw IllegalArgumentException() + DataType.GROUP, DataType.SCENE, DataType.MARKER, DataType.IMAGE -> { + throw IllegalArgumentException() + } } } } @@ -605,7 +607,6 @@ class ImageDetailsFragment : DetailsSupportFragment() { StashAction.ADD_PERFORMER -> DataType.PERFORMER StashAction.SET_STUDIO -> DataType.STUDIO StashAction.ADD_GALLERY -> DataType.GALLERY - else -> throw RuntimeException("Unsupported search for type $action") } serverViewModel.navigationManager.navigate( diff --git a/app/src/main/java/com/github/damontecres/stashapp/image/ImageFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/image/ImageFragment.kt index aeec9d3e9..6315357b1 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/image/ImageFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/image/ImageFragment.kt @@ -213,44 +213,54 @@ class ImageFragment : keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && ( - keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT || - keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT || - keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT || - keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT + Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && + ( + keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT || + keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT || + keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT || + keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT + ) ) fun isLeft(keyCode: Int): Boolean = keyCode == KeyEvent.KEYCODE_DPAD_LEFT || - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && ( - keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT || - keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT + Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && + ( + keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT || + keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT + ) ) fun isRight(keyCode: Int): Boolean = keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && ( - keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT || - keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT + Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && + ( + keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT || + keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT + ) ) fun isUp(keyCode: Int): Boolean = keyCode == KeyEvent.KEYCODE_DPAD_UP || - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && ( - keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT || - keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT + Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && + ( + keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT || + keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT + ) ) fun isDown(keyCode: Int): Boolean = keyCode == KeyEvent.KEYCODE_DPAD_DOWN || - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && ( - keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT || - keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT + Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && + ( + keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT || + keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT + ) ) } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/image/ImageViewFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/image/ImageViewFragment.kt index 334147d31..72ac47ba5 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/image/ImageViewFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/image/ImageViewFragment.kt @@ -194,22 +194,25 @@ class ImageViewFragment : } when (rotation) { 0 -> {} - 90 -> + + 90 -> { (panX to panY).apply { panX = second panY = -first } + } 180 -> { panX = -panX panY = -panY } - 270 -> + 270 -> { (panX to panY).apply { panX = -second panY = first } + } } panX *= mainImage.scaleX mainImage.panBy(panX, panY, true) diff --git a/app/src/main/java/com/github/damontecres/stashapp/navigation/Destination.kt b/app/src/main/java/com/github/damontecres/stashapp/navigation/Destination.kt index 3fecbc405..1863a5103 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/navigation/Destination.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/navigation/Destination.kt @@ -216,7 +216,9 @@ sealed class Destination( throw IllegalArgumentException("Image not supported") } - else -> Item(dataType, item.id) + else -> { + Item(dataType, item.id) + } } fun getDataType(item: StashData): DataType = diff --git a/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationManager.kt b/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationManager.kt index 02ca2275d..294deade0 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationManager.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationManager.kt @@ -141,17 +141,45 @@ class NavigationManagerLeanback( } val fragment = when (destination) { - Destination.Main -> MainFragment() - Destination.Search -> StashSearchFragment() - is Destination.Settings -> SettingsFragment() - Destination.Pin -> PinFragment() - Destination.SettingsPin -> SettingsPinEntryFragment() - Destination.Setup -> SetupFragment() - - is Destination.UpdateApp -> UpdateAppFragment() - is Destination.ReleaseChangelog -> UpdateChangelogFragment() - is Destination.ManageServers -> ManageServersFragment() - is Destination.CreateFilter -> CreateFilterFragment() + Destination.Main -> { + MainFragment() + } + + Destination.Search -> { + StashSearchFragment() + } + + is Destination.Settings -> { + SettingsFragment() + } + + Destination.Pin -> { + PinFragment() + } + + Destination.SettingsPin -> { + SettingsPinEntryFragment() + } + + Destination.Setup -> { + SetupFragment() + } + + is Destination.UpdateApp -> { + UpdateAppFragment() + } + + is Destination.ReleaseChangelog -> { + UpdateChangelogFragment() + } + + is Destination.ManageServers -> { + ManageServersFragment() + } + + is Destination.CreateFilter -> { + CreateFilterFragment() + } is Destination.Item -> { when (destination.dataType) { @@ -166,16 +194,30 @@ class NavigationManagerLeanback( } } - is Destination.MarkerDetails -> MarkerDetailsFragment() + is Destination.MarkerDetails -> { + MarkerDetailsFragment() + } - is Destination.Slideshow -> ImageFragment() + is Destination.Slideshow -> { + ImageFragment() + } - is Destination.Filter -> FilterFragment() + is Destination.Filter -> { + FilterFragment() + } - is Destination.SearchFor -> SearchForFragment() - is Destination.UpdateMarker -> MarkerPickerFragment() + is Destination.SearchFor -> { + SearchForFragment() + } + + is Destination.UpdateMarker -> { + MarkerPickerFragment() + } + + is Destination.Playback -> { + PlaybackSceneFragment() + } - is Destination.Playback -> PlaybackSceneFragment() is Destination.Playlist -> { when (destination.filterArgs.dataType) { DataType.SCENE -> PlaylistScenesFragment() @@ -184,11 +226,17 @@ class NavigationManagerLeanback( } } - is Destination.Debug -> DebugFragment() + is Destination.Debug -> { + DebugFragment() + } - is Destination.LicenseInfo -> LicenseFragment() + is Destination.LicenseInfo -> { + LicenseFragment() + } - Destination.ChooseTheme -> throw IllegalArgumentException("ChooseTheme not supported unless using Compose") + Destination.ChooseTheme -> { + throw IllegalArgumentException("ChooseTheme not supported unless using Compose") + } } fragment.arguments = Bundle().putDestination(destination) diff --git a/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationManagerCompose.kt b/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationManagerCompose.kt index f55d49677..f11d481ef 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationManagerCompose.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationManagerCompose.kt @@ -71,16 +71,30 @@ class NavigationManagerCompose( val fragment = when (destination) { // is Destination.Settings -> SettingsFragment() - Destination.Pin -> PinFragment() - Destination.SettingsPin -> SettingsPinEntryFragment() -// Destination.Setup -> SetupFragment() + Destination.Pin -> { + PinFragment() + } + + Destination.SettingsPin -> { + SettingsPinEntryFragment() + } + + // Destination.Setup -> SetupFragment() + + is Destination.UpdateApp -> { + UpdateAppFragment() + } + + is Destination.ReleaseChangelog -> { + UpdateChangelogFragment() + } - is Destination.UpdateApp -> UpdateAppFragment() - is Destination.ReleaseChangelog -> UpdateChangelogFragment() -// is Destination.ManageServers -> ManageServersFragment() + // is Destination.ManageServers -> ManageServersFragment() // is Destination.CreateFilter -> CreateFilterFragment() // is Destination.UpdateMarker -> MarkerPickerFragment() - is Destination.LicenseInfo -> LicenseFragment() + is Destination.LicenseInfo -> { + LicenseFragment() + } else -> { if (getCurrentFragment() != navDrawerFragment) { @@ -89,7 +103,8 @@ class NavigationManagerCompose( } when (destination) { Destination.Main -> navigate(Destination.Main, true) -// is Destination.Filter -> controller.navigate(destination) + + // is Destination.Filter -> controller.navigate(destination) else -> navigate(destination, false) } return diff --git a/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationOnItemViewClickedListener.kt b/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationOnItemViewClickedListener.kt index b1287c99b..4dcd95d29 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationOnItemViewClickedListener.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/navigation/NavigationOnItemViewClickedListener.kt @@ -31,12 +31,13 @@ class NavigationOnItemViewClickedListener( ) { val destination = when (item) { - is MarkerData -> + is MarkerData -> { Destination.Playback( item.scene.minimalSceneData.id, (item.seconds * 1000L).toLong(), PlaybackMode.Choose, ) + } is ImageData -> { val filterAndPosition = imageFilterLookup!!.invoke(item) @@ -51,11 +52,17 @@ class NavigationOnItemViewClickedListener( } } - is StashData -> Destination.fromStashData(item) + is StashData -> { + Destination.fromStashData(item) + } - is FilterArgs -> Destination.Filter(item, true) + is FilterArgs -> { + Destination.Filter(item, true) + } - else -> null + else -> { + null + } } if (destination != null) { navigationManager.navigate(destination) diff --git a/app/src/main/java/com/github/damontecres/stashapp/playback/PlaybackFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/playback/PlaybackFragment.kt index 338354abf..8ad27e879 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/playback/PlaybackFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/playback/PlaybackFragment.kt @@ -226,20 +226,24 @@ abstract class PlaybackFragment( ) { debugSceneId.text = scene.id when (streamDecision.transcodeDecision) { - TranscodeDecision.Transcode -> + TranscodeDecision.Transcode -> { debugPlaybackTextView.text = getString(R.string.transcode) + } - is TranscodeDecision.ForcedTranscode -> + is TranscodeDecision.ForcedTranscode -> { debugPlaybackTextView.text = getString(R.string.force_transcode) + " " + streamDecision.transcodeDecision.streamLabel + } - TranscodeDecision.DirectPlay -> + TranscodeDecision.DirectPlay -> { debugPlaybackTextView.text = getString(R.string.direct) + } - TranscodeDecision.ForcedDirectPlay -> + TranscodeDecision.ForcedDirectPlay -> { debugPlaybackTextView.text = getString(R.string.force_direct) + } } debugVideoTextView.text = if (streamDecision.videoSupported) scene.videoCodec else "${scene.videoCodec} (unsupported)" diff --git a/app/src/main/java/com/github/damontecres/stashapp/playback/PlaybackSceneFragment.kt b/app/src/main/java/com/github/damontecres/stashapp/playback/PlaybackSceneFragment.kt index 5bdcb8c60..f4c1a5a7f 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/playback/PlaybackSceneFragment.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/playback/PlaybackSceneFragment.kt @@ -47,7 +47,7 @@ class PlaybackSceneFragment : PlaybackFragment() { repeatMode = Player.REPEAT_MODE_ONE } - getString(R.string.playback_finished_return) -> + getString(R.string.playback_finished_return) -> { StashExoPlayer.addListener( object : Player.Listener { @@ -62,6 +62,7 @@ class PlaybackSceneFragment : PlaybackFragment() { } }, ) + } getString(R.string.playback_finished_do_nothing) -> { StashExoPlayer.addListener( @@ -76,7 +77,9 @@ class PlaybackSceneFragment : PlaybackFragment() { ) } - else -> Log.w(TAG, "Unknown playbackFinishedBehavior: $finishedBehavior") + else -> { + Log.w(TAG, "Unknown playbackFinishedBehavior: $finishedBehavior") + } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/playback/StashPlayerView.kt b/app/src/main/java/com/github/damontecres/stashapp/playback/StashPlayerView.kt index b9018282a..20db29b0f 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/playback/StashPlayerView.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/playback/StashPlayerView.kt @@ -40,13 +40,16 @@ class StashPlayerView( val isPaused = !player!!.isPlaying if (isPaused) { when (keyCode) { - KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> + KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> { Util.handlePlayPauseButtonAction( player, true, ) + } - KeyEvent.KEYCODE_MEDIA_PLAY -> Util.handlePlayButtonAction(player) + KeyEvent.KEYCODE_MEDIA_PLAY -> { + Util.handlePlayButtonAction(player) + } } return true } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { diff --git a/app/src/main/java/com/github/damontecres/stashapp/playback/StreamUtils.kt b/app/src/main/java/com/github/damontecres/stashapp/playback/StreamUtils.kt index 31da103d0..98112d64f 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/playback/StreamUtils.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/playback/StreamUtils.kt @@ -112,8 +112,11 @@ fun buildMediaItem( // As recommended by https://developer.android.com/media/media3/exoplayer/hls#using-mediaitem // Specify the mimetype for HLS & DASH streams "hls" -> MimeTypes.APPLICATION_M3U8 + "dash" -> MimeTypes.APPLICATION_MPD + "mp4" -> MimeTypes.APPLICATION_MP4 + else -> null } val builder = @@ -340,15 +343,42 @@ data class TrackSupport( } else { val type = when (codecs) { - MimeTypes.TEXT_VTT -> "vtt" - MimeTypes.APPLICATION_VOBSUB -> "vobsub" - MimeTypes.APPLICATION_SUBRIP -> "srt" - MimeTypes.TEXT_SSA -> "ssa" - MimeTypes.APPLICATION_PGS -> "pgs" - MimeTypes.APPLICATION_DVBSUBS -> "dvd" - MimeTypes.APPLICATION_TTML -> "ttml" - MimeTypes.TEXT_UNKNOWN -> "unknown" - null -> "unknown" + MimeTypes.TEXT_VTT -> { + "vtt" + } + + MimeTypes.APPLICATION_VOBSUB -> { + "vobsub" + } + + MimeTypes.APPLICATION_SUBRIP -> { + "srt" + } + + MimeTypes.TEXT_SSA -> { + "ssa" + } + + MimeTypes.APPLICATION_PGS -> { + "pgs" + } + + MimeTypes.APPLICATION_DVBSUBS -> { + "dvd" + } + + MimeTypes.APPLICATION_TTML -> { + "ttml" + } + + MimeTypes.TEXT_UNKNOWN -> { + "unknown" + } + + null -> { + "unknown" + } + else -> { val split = codecs.split("/") if (split.size > 1) split[1] else codecs @@ -433,7 +463,7 @@ fun maybeMuteAudio( TAG, "maybeMuteAudio: playAudioPreview=$playAudioPreview, startMuted=$startMuted, checkPreviewAudioPref=$checkPreviewAudioPref", ) - if (!playAudioPreview && checkPreviewAudioPref || startMuted) { + if ((!playAudioPreview && checkPreviewAudioPref) || startMuted) { if (C.TRACK_TYPE_AUDIO !in it.trackSelectionParameters.disabledTrackTypes) { Log.v(TAG, "Disabling audio") it.trackSelectionParameters = diff --git a/app/src/main/java/com/github/damontecres/stashapp/presenters/FilterArgsPresenter.kt b/app/src/main/java/com/github/damontecres/stashapp/presenters/FilterArgsPresenter.kt index 41b79657b..901ab6bdb 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/presenters/FilterArgsPresenter.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/presenters/FilterArgsPresenter.kt @@ -15,29 +15,33 @@ class FilterArgsPresenter( cardView.titleText = cardView.context.getString(R.string.stashapp_view_all) when (item.dataType) { - DataType.SCENE -> + DataType.SCENE -> { cardView.setMainImageDimensions( ScenePresenter.CARD_WIDTH, ScenePresenter.CARD_HEIGHT, ) + } - DataType.STUDIO -> + DataType.STUDIO -> { cardView.setMainImageDimensions( StudioPresenter.CARD_WIDTH, StudioPresenter.CARD_HEIGHT, ) + } - DataType.PERFORMER -> + DataType.PERFORMER -> { cardView.setMainImageDimensions( PerformerPresenter.CARD_WIDTH, PerformerPresenter.CARD_HEIGHT, ) + } - DataType.TAG -> + DataType.TAG -> { cardView.setMainImageDimensions( TagPresenter.CARD_WIDTH, TagPresenter.CARD_HEIGHT, ) + } DataType.GROUP -> { cardView.setMainImageDimensions( diff --git a/app/src/main/java/com/github/damontecres/stashapp/presenters/StashImageCardView.kt b/app/src/main/java/com/github/damontecres/stashapp/presenters/StashImageCardView.kt index 71bb73d04..eddb18fda 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/presenters/StashImageCardView.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/presenters/StashImageCardView.kt @@ -435,10 +435,8 @@ class StashImageCardView( fun updateImageLayoutParams(imageMatchParent: Boolean) { val current = imageView.layoutParams.height - if (imageMatchParent && - current != ViewGroup.LayoutParams.MATCH_PARENT || - !imageMatchParent && - current != ViewGroup.LayoutParams.WRAP_CONTENT + if ((imageMatchParent && current != ViewGroup.LayoutParams.MATCH_PARENT) || + (!imageMatchParent && current != ViewGroup.LayoutParams.WRAP_CONTENT) ) { imageView.setImageDrawable(null) imageView.updateLayoutParams { diff --git a/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep1ServerUrl.kt b/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep1ServerUrl.kt index 57f71e5db..14b6b4b0f 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep1ServerUrl.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep1ServerUrl.kt @@ -84,13 +84,19 @@ class SetupStep1ServerUrl : SetupGuidedStepSupportFragment() { viewLifecycleOwner.lifecycleScope.launch(StashCoroutineExceptionHandler()) { val result = testConnection(serverUrl.toString(), null, false) when (result) { - TestResult.SelfSignedCertRequired -> nextStep(SetupStep2Ssl(state)) + TestResult.SelfSignedCertRequired -> { + nextStep(SetupStep2Ssl(state)) + } - TestResult.AuthRequired -> nextStep(SetupStep3ApiKey(state)) + TestResult.AuthRequired -> { + nextStep(SetupStep3ApiKey(state)) + } is TestResult.Success, is TestResult.UnsupportedVersion, - -> nextStep(SetupStep4Pin(state)) + -> { + nextStep(SetupStep4Pin(state)) + } is TestResult.Error, TestResult.SslRequired, diff --git a/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep2Ssl.kt b/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep2Ssl.kt index b11225e38..58905f8b9 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep2Ssl.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep2Ssl.kt @@ -50,11 +50,15 @@ class SetupStep2Ssl( viewLifecycleOwner.lifecycleScope.launch(StashCoroutineExceptionHandler()) { val result = testConnection(newState.serverUrl, null, true) when (result) { - TestResult.AuthRequired -> nextStep(SetupStep3ApiKey(newState)) + TestResult.AuthRequired -> { + nextStep(SetupStep3ApiKey(newState)) + } is TestResult.Error, TestResult.SslRequired, - -> requireActivity().supportFragmentManager.popBackStack() + -> { + requireActivity().supportFragmentManager.popBackStack() + } TestResult.SelfSignedCertRequired -> { Log.w(TAG, "Trusting certs, but still error") @@ -62,7 +66,9 @@ class SetupStep2Ssl( is TestResult.Success, is TestResult.UnsupportedVersion, - -> nextStep(SetupStep4Pin(newState)) + -> { + nextStep(SetupStep4Pin(newState)) + } } } } else { diff --git a/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep3ApiKey.kt b/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep3ApiKey.kt index cd6235ead..ff2cf2337 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep3ApiKey.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/setup/SetupStep3ApiKey.kt @@ -136,8 +136,9 @@ class SetupStep3ApiKey( is TestResult.Success, is TestResult.UnsupportedVersion, - -> + -> { nextStep(SetupStep4Pin(setupState.copy(apiKey = apiKey.toString()))) + } } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/suppliers/DataSupplierFactory.kt b/app/src/main/java/com/github/damontecres/stashapp/suppliers/DataSupplierFactory.kt index 82974c316..8561eb912 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/suppliers/DataSupplierFactory.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/suppliers/DataSupplierFactory.kt @@ -35,16 +35,32 @@ class DataSupplierFactory( } if (args.override != null) { return when (args.override) { - is DataSupplierOverride.PerformerTags -> PerformerTagDataSupplier(args.override.performerId) - is DataSupplierOverride.GalleryPerformer -> GalleryPerformerDataSupplier(args.override.galleryId) - is DataSupplierOverride.GalleryTag -> GalleryTagDataSupplier(args.override.galleryId) - is DataSupplierOverride.GroupTags -> GroupTagDataSupplier(args.override.groupId) - is DataSupplierOverride.StudioTags -> StudioTagDataSupplier(args.override.studioId) - is DataSupplierOverride.GroupRelationship -> + is DataSupplierOverride.PerformerTags -> { + PerformerTagDataSupplier(args.override.performerId) + } + + is DataSupplierOverride.GalleryPerformer -> { + GalleryPerformerDataSupplier(args.override.galleryId) + } + + is DataSupplierOverride.GalleryTag -> { + GalleryTagDataSupplier(args.override.galleryId) + } + + is DataSupplierOverride.GroupTags -> { + GroupTagDataSupplier(args.override.groupId) + } + + is DataSupplierOverride.StudioTags -> { + StudioTagDataSupplier(args.override.studioId) + } + + is DataSupplierOverride.GroupRelationship -> { GroupRelationshipDataSupplier( args.override.groupId, args.override.type, ) + } DataSupplierOverride.Playlist -> { if (args.dataType == DataType.SCENE) { @@ -62,53 +78,61 @@ class DataSupplierFactory( } as StashPagingSource.DataSupplier } else { return when (args.dataType) { - DataType.SCENE -> + DataType.SCENE -> { SceneDataSupplier( args.findFilter?.toFindFilterType(), filterParser.convertSceneFilterType(args.objectFilter), ) + } - DataType.TAG -> + DataType.TAG -> { TagDataSupplier( args.findFilter?.toFindFilterType(), filterParser.convertTagFilterType(args.objectFilter), ) + } - DataType.STUDIO -> + DataType.STUDIO -> { StudioDataSupplier( args.findFilter?.toFindFilterType(), filterParser.convertStudioFilterType(args.objectFilter), ) + } - DataType.MARKER -> + DataType.MARKER -> { MarkerDataSupplier( args.findFilter?.toFindFilterType(), filterParser.convertSceneMarkerFilterType(args.objectFilter), ) + } - DataType.IMAGE -> + DataType.IMAGE -> { ImageDataSupplier( args.findFilter?.toFindFilterType(), filterParser.convertImageFilterType(args.objectFilter), ) + } - DataType.GALLERY -> + DataType.GALLERY -> { GalleryDataSupplier( args.findFilter?.toFindFilterType(), filterParser.convertGalleryFilterType(args.objectFilter), ) + } - DataType.PERFORMER -> + DataType.PERFORMER -> { PerformerDataSupplier( args.findFilter?.toFindFilterType(), filterParser.convertPerformerFilterType(args.objectFilter), ) + } - DataType.GROUP -> + DataType.GROUP -> { GroupDataSupplier( args.findFilter?.toFindFilterType(), filterParser.convertGroupFilterType(args.objectFilter), ) + } } as StashPagingSource.DataSupplier } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/suppliers/GroupRelationshipDataSupplier.kt b/app/src/main/java/com/github/damontecres/stashapp/suppliers/GroupRelationshipDataSupplier.kt index e5dddf058..441cdf5c9 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/suppliers/GroupRelationshipDataSupplier.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/suppliers/GroupRelationshipDataSupplier.kt @@ -29,34 +29,39 @@ class GroupRelationshipDataSupplier( override fun parseCountQuery(data: CountGroupRelationshipsQuery.Data): Int = when (type) { - GroupRelationshipType.SUB -> + GroupRelationshipType.SUB -> { data.findGroups.groups .firstOrNull() ?.sub_group_count - GroupRelationshipType.CONTAINING -> + } + + GroupRelationshipType.CONTAINING -> { data.findGroups.groups .firstOrNull() ?.containing_groups ?.size + } } ?: 0 override fun parseQuery(data: FindGroupRelationshipsQuery.Data): List = data.findGroups.groups .map { when (type) { - GroupRelationshipType.SUB -> + GroupRelationshipType.SUB -> { it.sub_groups.map { subGroup -> subGroup.groupDescriptionData.toRelationship( type, ) } + } - GroupRelationshipType.CONTAINING -> + GroupRelationshipType.CONTAINING -> { it.containing_groups.map { containingGroup -> containingGroup.groupDescriptionData.toRelationship( type, ) } + } } }.flatten() } diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/Themes.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/Themes.kt index 98e2767e0..32fb7ce34 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/Themes.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/Themes.kt @@ -54,8 +54,14 @@ fun chooseColorScheme( colorSchemeSet: ColorSchemeSet, ): AppColorScheme = when (themeStyle) { - ThemeStyle.LIGHT -> colorSchemeSet.light - ThemeStyle.DARK -> colorSchemeSet.dark + ThemeStyle.LIGHT -> { + colorSchemeSet.light + } + + ThemeStyle.DARK -> { + colorSchemeSet.dark + } + else -> { if (isSystemInDark) { colorSchemeSet.dark @@ -145,8 +151,14 @@ fun Material3AppTheme( val colorSchemeSet = currentColorSchemeSet ?: defaultColorSchemeSet val colorScheme = when (themeStyle) { - ThemeStyle.LIGHT -> colorSchemeSet.light - ThemeStyle.DARK -> colorSchemeSet.dark + ThemeStyle.LIGHT -> { + colorSchemeSet.light + } + + ThemeStyle.DARK -> { + colorSchemeSet.dark + } + else -> { if (isSystemInDarkTheme()) { colorSchemeSet.dark diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/cards/Cards.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/cards/Cards.kt index 12d92b83a..4fa5ba71e 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/cards/Cards.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/cards/Cards.kt @@ -498,7 +498,7 @@ fun StashCard( cardContext: CardContext = CardContext.None, ) { when (item) { - is SlimSceneData? -> + is SlimSceneData? -> { SceneCard( uiConfig, item, @@ -508,8 +508,9 @@ fun StashCard( modifier, cardContext = cardContext as? CardContext.SceneCardContext, ) + } - is FullSceneData? -> + is FullSceneData? -> { SceneCard( uiConfig, item?.asSlimeSceneData, @@ -519,8 +520,9 @@ fun StashCard( modifier, cardContext = cardContext as? CardContext.SceneCardContext, ) + } - is PerformerData? -> + is PerformerData? -> { PerformerCard( uiConfig, item, @@ -529,8 +531,9 @@ fun StashCard( getFilterAndPosition, modifier, ) + } - is ImageData? -> + is ImageData? -> { ImageCard( uiConfig, item, @@ -539,8 +542,9 @@ fun StashCard( getFilterAndPosition, modifier, ) + } - is GalleryData? -> + is GalleryData? -> { GalleryCard( uiConfig, item, @@ -549,8 +553,9 @@ fun StashCard( getFilterAndPosition, modifier, ) + } - is MarkerData? -> + is MarkerData? -> { MarkerCard( uiConfig, item, @@ -559,8 +564,9 @@ fun StashCard( getFilterAndPosition, modifier, ) + } - is GroupData? -> + is GroupData? -> { GroupCard( uiConfig, item, @@ -570,6 +576,7 @@ fun StashCard( modifier, cardContext = cardContext as? CardContext.GroupCardContext, ) + } is GroupRelationshipData? -> { GroupCard( @@ -583,7 +590,7 @@ fun StashCard( ) } - is StudioData? -> + is StudioData? -> { StudioCard( uiConfig, item, @@ -592,8 +599,9 @@ fun StashCard( getFilterAndPosition, modifier, ) + } - is TagData? -> + is TagData? -> { TagCard( uiConfig, item, @@ -602,6 +610,8 @@ fun StashCard( getFilterAndPosition, modifier, ) + } + is FilterArgs -> { ViewAllCard( filter = item, @@ -636,7 +646,9 @@ fun StashCard( ) } - else -> throw UnsupportedOperationException("Item with class ${item?.javaClass} not supported.") + else -> { + throw UnsupportedOperationException("Item with class ${item?.javaClass} not supported.") + } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/Dialogs.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/Dialogs.kt index 57364c23d..54b966b57 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/Dialogs.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/Dialogs.kt @@ -190,9 +190,11 @@ fun DialogPopup( } items(dialogItems) { when (it) { - is DialogItemDivider -> HorizontalDivider(Modifier.height(16.dp)) + is DialogItemDivider -> { + HorizontalDivider(Modifier.height(16.dp)) + } - is DialogItem -> + is DialogItem -> { ListItem( selected = false, enabled = !waiting && it.enabled, @@ -209,6 +211,7 @@ fun DialogPopup( trailingContent = it.trailingContent, modifier = Modifier, ) + } } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/Rating.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/Rating.kt index aa840255e..9419fdf9c 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/Rating.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/Rating.kt @@ -248,8 +248,9 @@ fun StarRating( if (playSoundOnFocus) playOnClickSound(context) val newRating100 = when (precision) { - StarRatingPrecision.FULL -> + StarRatingPrecision.FULL -> { if (i == 1 && rating100 > 0 && rating100 <= 20) 0 else i * 20 + } StarRatingPrecision.HALF -> { if (rating100 > i * 20) { diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/TimestampPicker.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/TimestampPicker.kt index 5ccc02bb0..8667618a5 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/TimestampPicker.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/TimestampPicker.kt @@ -202,7 +202,7 @@ fun WheelPicker( result }, ), - unfocusedCount = if (isNotTvDevice || activated && focused) 1 else 0, + unfocusedCount = if ((isNotTvDevice || activated) && focused) 1 else 0, count = count, state = state, ) { index -> diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/filter/BasicFilterSettings.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/filter/BasicFilterSettings.kt index 3f9240872..3715cfa2a 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/filter/BasicFilterSettings.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/filter/BasicFilterSettings.kt @@ -70,7 +70,9 @@ fun BasicFilterSettings( when (objectFilterCount) { // TODO i18n for plurals 1 -> "1 " + stringResource(R.string.stashapp_filter) + in 2..Int.MAX_VALUE -> objectFilterCount.toString() + " " + stringResource(R.string.stashapp_filters) + else -> null }, showArrow = true, diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaybackDebugInfo.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaybackDebugInfo.kt index ee1821367..00e0f3909 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaybackDebugInfo.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaybackDebugInfo.kt @@ -34,16 +34,23 @@ fun PlaybackDebugInfo( ) { val transcodeText = when (streamDecision.transcodeDecision) { - TranscodeDecision.Transcode -> stringResource(R.string.transcode) + TranscodeDecision.Transcode -> { + stringResource(R.string.transcode) + } - is TranscodeDecision.ForcedTranscode -> + is TranscodeDecision.ForcedTranscode -> { stringResource( R.string.force_transcode, ) + " " + streamDecision.transcodeDecision.streamLabel + } - TranscodeDecision.DirectPlay -> stringResource(R.string.direct) + TranscodeDecision.DirectPlay -> { + stringResource(R.string.direct) + } - TranscodeDecision.ForcedDirectPlay -> stringResource(R.string.force_direct) + TranscodeDecision.ForcedDirectPlay -> { + stringResource(R.string.force_direct) + } } val videoText = if (streamDecision.videoSupported) scene.videoCodec else "${scene.videoCodec} (unsupported)" val audioText = if (streamDecision.audioSupported) scene.audioCodec else "${scene.audioCodec} (unsupported)" diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaybackPageContent.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaybackPageContent.kt index 20eb9a03e..e9c307d19 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaybackPageContent.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaybackPageContent.kt @@ -616,7 +616,9 @@ fun PlaybackPageContent( } } - else -> true + else -> { + true + } } if (showError) { Toast @@ -663,7 +665,7 @@ fun PlaybackPageContent( } var skipPosition by remember { mutableLongStateOf(0L) } val updateSkipIndicator = { delta: Long -> - if (skipIndicatorDuration > 0 && delta < 0 || skipIndicatorDuration < 0 && delta > 0) { + if ((skipIndicatorDuration > 0 && delta < 0) || (skipIndicatorDuration < 0 && delta > 0)) { skipIndicatorDuration = 0 } skipIndicatorDuration += delta @@ -810,7 +812,9 @@ fun PlaybackPageContent( showDebugInfo = !showDebugInfo } - PlaybackAction.ShowVideoFilterDialog -> showFilterDialog = true + PlaybackAction.ShowVideoFilterDialog -> { + showFilterDialog = true + } PlaybackAction.ShowPlaylist -> { if (playlistPager != null && playlistPager.size > 1) { @@ -829,8 +833,14 @@ fun PlaybackPageContent( controllerViewState.hideControls() } - is PlaybackAction.PlaybackSpeed -> playbackSpeed = it.value - is PlaybackAction.Scale -> contentScale = it.scale + is PlaybackAction.PlaybackSpeed -> { + playbackSpeed = it.value + } + + is PlaybackAction.Scale -> { + contentScale = it.scale + } + is PlaybackAction.ToggleAudio -> { if (toggleAudio(player, audioIndex, it.index)) { audioIndex = it.index @@ -979,7 +989,7 @@ fun Player.setupFinishedBehavior( repeatMode = Player.REPEAT_MODE_ONE } - PlaybackFinishBehavior.GO_BACK -> + PlaybackFinishBehavior.GO_BACK -> { StashExoPlayer.addListener( object : Player.Listener { @@ -990,6 +1000,7 @@ fun Player.setupFinishedBehavior( } }, ) + } PlaybackFinishBehavior.DO_NOTHING -> { StashExoPlayer.addListener( @@ -1004,11 +1015,12 @@ fun Player.setupFinishedBehavior( ) } - else -> + else -> { Log.w( PlaybackSceneFragment.TAG, "Unknown playbackFinishedBehavior: $finishedBehavior", ) + } } } @@ -1073,9 +1085,17 @@ class PlaybackKeyHandler( updateSkipIndicator(-player.seekBackIncrement) } - Key.MediaNext -> if (player.isCommandAvailable(Player.COMMAND_SEEK_TO_NEXT)) player.seekToNext() - Key.MediaPrevious -> if (player.isCommandAvailable(Player.COMMAND_SEEK_TO_PREVIOUS)) player.seekToPrevious() - else -> result = false + Key.MediaNext -> { + if (player.isCommandAvailable(Player.COMMAND_SEEK_TO_NEXT)) player.seekToNext() + } + + Key.MediaPrevious -> { + if (player.isCommandAvailable(Player.COMMAND_SEEK_TO_PREVIOUS)) player.seekToPrevious() + } + + else -> { + result = false + } } } else if (it.key == Key.Enter && !controllerViewState.controlsVisible) { controllerViewState.showControls() @@ -1102,7 +1122,7 @@ fun toggleSubtitles( ): Boolean { val subtitleTracks = player.currentTracks.groups.filter { it.type == C.TRACK_TYPE_TEXT && it.isSupported } - if (index !in subtitleTracks.indices || currentActiveSubtitleIndex != null && currentActiveSubtitleIndex == index) { + if (index !in subtitleTracks.indices || (currentActiveSubtitleIndex != null && currentActiveSubtitleIndex == index)) { Log.v( TAG, "Deactivating subtitles", @@ -1140,7 +1160,7 @@ fun toggleAudio( ): Boolean { val audioTracks = player.currentTracks.groups.filter { it.type == C.TRACK_TYPE_AUDIO && it.isSupported } - if (index !in audioTracks.indices || audioIndex != null && audioIndex == index) { + if (index !in audioTracks.indices || (audioIndex != null && audioIndex == index)) { Log.v( TAG, "Deactivating audio", diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaylistListDialog.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaylistListDialog.kt index b18309663..666ff4f87 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaylistListDialog.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/playback/PlaylistListDialog.kt @@ -46,8 +46,14 @@ fun PlaylistListDialog( items = MappedList(pager) { index, item -> when (item) { - is MarkerData -> item.toPlayListItem(index) - is SlimSceneData -> item.toPlayListItem(index) + is MarkerData -> { + item.toPlayListItem(index) + } + + is SlimSceneData -> { + item.toPlayListItem(index) + } + else -> { PlaylistItem( index, diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/ComposablePreference.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/ComposablePreference.kt index 303590cf8..e050d5f0d 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/ComposablePreference.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/ComposablePreference.kt @@ -98,9 +98,13 @@ fun ComposablePreference( onCacheClear.invoke() } - StashPreference.TriggerScan -> MutationEngine(server).triggerScan() + StashPreference.TriggerScan -> { + MutationEngine(server).triggerScan() + } - StashPreference.TriggerGenerate -> MutationEngine(server).triggerGenerate() + StashPreference.TriggerGenerate -> { + MutationEngine(server).triggerGenerate() + } StashPreference.MigratePreferences -> { scope.launch(StashCoroutineExceptionHandler(autoToast = true)) { @@ -121,13 +125,15 @@ fun ComposablePreference( CompanionPlugin.sendLogCat(context, server, true) } - else -> null + else -> { + null + } } } } when (preference) { - StashPreference.CurrentServer -> + StashPreference.CurrentServer -> { ClickPreference( title = title, onClick = onClick, @@ -135,8 +141,9 @@ fun ComposablePreference( interactionSource = interactionSource, modifier = modifier, ) + } - StashPreference.UseNewUI -> + StashPreference.UseNewUI -> { SwitchPreference( title = title, value = value as Boolean, @@ -145,6 +152,7 @@ fun ComposablePreference( interactionSource = interactionSource, modifier = modifier, ) + } StashPreference.NetworkCache -> { preference as StashSliderPreference @@ -204,7 +212,7 @@ fun ComposablePreference( } } - is StashDestinationPreference -> + is StashDestinationPreference -> { ClickPreference( title = title, onClick = { @@ -214,8 +222,9 @@ fun ComposablePreference( interactionSource = interactionSource, modifier = modifier, ) + } - is StashClickablePreference -> + is StashClickablePreference -> { ClickPreference( title = title, onClick = onClick, @@ -224,8 +233,9 @@ fun ComposablePreference( interactionSource = interactionSource, modifier = modifier, ) + } - is StashSwitchPreference -> + is StashSwitchPreference -> { SwitchPreference( title = title, value = value as Boolean, @@ -234,6 +244,7 @@ fun ComposablePreference( interactionSource = interactionSource, modifier = modifier, ) + } is StashPinPreference -> { val enabled = (value as String).isNotNullOrBlank() @@ -258,7 +269,8 @@ fun ComposablePreference( modifier = Modifier, ) } - is StashStringPreference -> + + is StashStringPreference -> { ClickPreference( title = title, onClick = { @@ -289,6 +301,7 @@ fun ComposablePreference( interactionSource = interactionSource, modifier = modifier, ) + } is StashChoicePreference -> { val values = stringArrayResource(preference.displayValues).toList() diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/PreferencesViewModel.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/PreferencesViewModel.kt index 3d212c3e7..584259a1c 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/PreferencesViewModel.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/PreferencesViewModel.kt @@ -69,7 +69,9 @@ class PreferencesViewModel : ViewModel() { val index = mutable.indexOfFirstOrNull { it.id == jobData.id } // Timer for removing? when (type) { - JobStatusUpdateType.ADD -> mutable.add(jobData) + JobStatusUpdateType.ADD -> { + mutable.add(jobData) + } JobStatusUpdateType.REMOVE -> { if (index != null && index >= 0) { diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/StashPreference.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/StashPreference.kt index 9e7904591..0dca5d24a 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/StashPreference.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/prefs/StashPreference.kt @@ -242,16 +242,21 @@ sealed interface StashPreference { ) value?.let { when (it) { - context.getString(R.string.playback_finished_repeat) -> + context.getString(R.string.playback_finished_repeat) -> { PlaybackFinishBehavior.REPEAT + } - context.getString(R.string.playback_finished_return) -> + context.getString(R.string.playback_finished_return) -> { PlaybackFinishBehavior.GO_BACK + } - context.getString(R.string.playback_finished_do_nothing) -> + context.getString(R.string.playback_finished_do_nothing) -> { PlaybackFinishBehavior.DO_NOTHING + } - else -> PlaybackFinishBehavior.DO_NOTHING + else -> { + PlaybackFinishBehavior.DO_NOTHING + } } } ?: PlaybackFinishBehavior.DO_NOTHING }, @@ -1024,8 +1029,11 @@ sealed interface StashPreference { null, ) when (value) { - "Disabled", "", null -> Resolution.UNSPECIFIED - else -> + "Disabled", "", null -> { + Resolution.UNSPECIFIED + } + + else -> { value.let { try { Resolution.valueOf("RES_" + it.uppercase()) @@ -1034,6 +1042,7 @@ sealed interface StashPreference { Resolution.UNSPECIFIED } } + } } }, prefSetter = { context: Context, editor: SharedPreferences.Editor, value: Resolution -> @@ -1305,7 +1314,10 @@ sealed interface StashPreference { null, ) when (value?.lowercase()) { - "default", "builtin", "", null -> PlaybackHttpClient.OKHTTP + "default", "builtin", "", null -> { + PlaybackHttpClient.OKHTTP + } + else -> { try { PlaybackHttpClient.valueOf(value.uppercase()) @@ -1320,6 +1332,7 @@ sealed interface StashPreference { val string = when (value) { PlaybackHttpClient.BUILTIN -> "default" + PlaybackHttpClient.OKHTTP, PlaybackHttpClient.UNRECOGNIZED, -> "okhttp" diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/components/server/ConfigurePin.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/components/server/ConfigurePin.kt index e7b56a374..c83e85764 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/components/server/ConfigurePin.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/components/server/ConfigurePin.kt @@ -43,7 +43,7 @@ fun ConfigurePin( var pin1 by remember { mutableStateOf("") } var pin2 by remember { mutableStateOf("") } - val valid = pin1.isBlank() || pin1.toIntOrNull() != null && pin1 == pin2 + val valid = pin1.isBlank() || (pin1.toIntOrNull() != null && pin1 == pin2) LazyColumn( verticalArrangement = Arrangement.spacedBy(8.dp), diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/nav/ApplicationContent.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/nav/ApplicationContent.kt index 843045811..4a6f50b98 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/nav/ApplicationContent.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/nav/ApplicationContent.kt @@ -165,30 +165,41 @@ fun ApplicationContent( // Highlight on the nav drawer as user navigates around the app selectedScreen = when (destination) { - Destination.Main -> DrawerPage.HomePage + Destination.Main -> { + DrawerPage.HomePage + } - Destination.Search -> DrawerPage.SearchPage + Destination.Search -> { + DrawerPage.SearchPage + } Destination.SettingsPin, is Destination.Settings, - -> DrawerPage.SettingPage + -> { + DrawerPage.SettingPage + } - is Destination.Item -> + is Destination.Item -> { pages.firstOrNull { it is DrawerPage.DataTypePage && it.dataType == destination.dataType } + } - is Destination.MarkerDetails -> + is Destination.MarkerDetails -> { pages.firstOrNull { it is DrawerPage.DataTypePage && it.dataType == DataType.MARKER } + } - is Destination.Filter -> + is Destination.Filter -> { pages.firstOrNull { it is DrawerPage.DataTypePage && it.dataType == destination.filterArgs.dataType } + } - else -> null + else -> { + null + } } val onSelectScreen = { page: DrawerPage -> @@ -204,9 +215,15 @@ fun ApplicationContent( } else { val pageDest = when (page) { - DrawerPage.HomePage -> Destination.Main - DrawerPage.SearchPage -> Destination.Search - DrawerPage.SettingPage -> + DrawerPage.HomePage -> { + Destination.Main + } + + DrawerPage.SearchPage -> { + Destination.Search + } + + DrawerPage.SettingPage -> { if (composeUiConfig.readOnlyModeDisabled) { Destination.Settings( PreferenceScreenOption.BASIC, @@ -214,13 +231,15 @@ fun ApplicationContent( } else { Destination.SettingsPin } + } - is DrawerPage.DataTypePage -> + is DrawerPage.DataTypePage -> { Destination.Filter( server.serverPreferences.getDefaultFilter( page.dataType, ), ) + } } navigationManager.navigateFromNavDrawer(pageDest) } diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/nav/DestinationContent.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/nav/DestinationContent.kt index aab0014ce..f79795d1a 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/nav/DestinationContent.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/nav/DestinationContent.kt @@ -50,8 +50,11 @@ fun DestinationContent( onUpdateTitle: ((AnnotatedString) -> Unit)? = null, ) { when (destination) { - is Destination.Pin -> throw UnsupportedOperationException("Destination.Pin") -// PinEntryPage( + is Destination.Pin -> { + throw UnsupportedOperationException("Destination.Pin") + } + + // PinEntryPage( // pinPreference = R.string.pref_key_pin_code, // title = stringResource(R.string.enter_pin), // onCorrectPin = { @@ -65,8 +68,11 @@ fun DestinationContent( // modifier = Modifier.fillMaxSize(), // ) - is Destination.SettingsPin -> throw UnsupportedOperationException("Destination.SettingsPin") -// PinEntryPage( + is Destination.SettingsPin -> { + throw UnsupportedOperationException("Destination.SettingsPin") + } + + // PinEntryPage( // pinPreference = R.string.pref_key_read_only_mode_pin, // title = stringResource(R.string.enter_settings_pin), // onCorrectPin = { @@ -137,7 +143,7 @@ fun DestinationContent( ) } - Destination.ChooseTheme -> + Destination.ChooseTheme -> { ChooseThemePage( server = server, navigationManager = navManager, @@ -145,8 +151,9 @@ fun DestinationContent( onChooseTheme = onChangeTheme, modifier = modifier, ) + } - is Destination.CreateFilter -> + is Destination.CreateFilter -> { CreateFilterScreen( uiConfig = composeUiConfig, dataType = destination.dataType, @@ -155,8 +162,9 @@ fun DestinationContent( onUpdateTitle = onUpdateTitle, modifier = modifier, ) + } - is Destination.UpdateMarker -> + is Destination.UpdateMarker -> { MarkerTimestampPage( server = server, navigationManager = navManager, @@ -164,13 +172,15 @@ fun DestinationContent( markerId = destination.markerId, modifier = Modifier.fillMaxSize(), ) + } - is Destination.Debug -> + is Destination.Debug -> { DebugPage( server = server, uiConfig = composeUiConfig, modifier = Modifier.fillMaxSize(), ) + } Destination.Main -> { MainPage( @@ -207,7 +217,7 @@ fun DestinationContent( ) } - is Destination.MarkerDetails -> + is Destination.MarkerDetails -> { MarkerPage( server = server, uiConfig = composeUiConfig, @@ -215,10 +225,11 @@ fun DestinationContent( itemOnClick = itemOnClick, onUpdateTitle = onUpdateTitle, ) + } is Destination.Item -> { when (destination.dataType) { - DataType.SCENE -> + DataType.SCENE -> { SceneDetailsPage( modifier = modifier, server = server, @@ -237,8 +248,9 @@ fun DestinationContent( }, onUpdateTitle = onUpdateTitle, ) + } - DataType.PERFORMER -> + DataType.PERFORMER -> { PerformerPage( modifier = modifier, server = server, @@ -248,8 +260,9 @@ fun DestinationContent( uiConfig = composeUiConfig, onUpdateTitle = onUpdateTitle, ) + } - DataType.TAG -> + DataType.TAG -> { TagPage( modifier = modifier, server = server, @@ -260,8 +273,9 @@ fun DestinationContent( uiConfig = composeUiConfig, onUpdateTitle = onUpdateTitle, ) + } - DataType.STUDIO -> + DataType.STUDIO -> { StudioPage( modifier = modifier, server = server, @@ -272,8 +286,9 @@ fun DestinationContent( uiConfig = composeUiConfig, onUpdateTitle = onUpdateTitle, ) + } - DataType.GALLERY -> + DataType.GALLERY -> { GalleryPage( modifier = modifier, server = server, @@ -283,8 +298,9 @@ fun DestinationContent( uiConfig = composeUiConfig, onUpdateTitle = onUpdateTitle, ) + } - DataType.GROUP -> + DataType.GROUP -> { GroupPage( modifier = modifier, server = server, @@ -295,8 +311,9 @@ fun DestinationContent( uiConfig = composeUiConfig, onUpdateTitle = onUpdateTitle, ) + } - DataType.MARKER -> + DataType.MARKER -> { MarkerPage( server = server, uiConfig = composeUiConfig, @@ -304,8 +321,11 @@ fun DestinationContent( itemOnClick = itemOnClick, onUpdateTitle = onUpdateTitle, ) + } - DataType.IMAGE -> throw IllegalArgumentException("Image not supported in Destination.Item") + DataType.IMAGE -> { + throw IllegalArgumentException("Image not supported in Destination.Item") + } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/FilterPage.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/FilterPage.kt index 86313cc70..0ea820499 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/FilterPage.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/FilterPage.kt @@ -81,21 +81,23 @@ fun FilterPage( val dataType = initialFilter.dataType val currentFilter = viewModel.currentFilter when (it) { - CreateFilter.FROM_CURRENT -> + CreateFilter.FROM_CURRENT -> { navigationManager.navigate( Destination.CreateFilter( dataType, currentFilter, ), ) + } - CreateFilter.NEW_FILTER -> + CreateFilter.NEW_FILTER -> { navigationManager.navigate( Destination.CreateFilter( dataType, null, ), ) + } } }, itemOnClick = itemOnClick, diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/ImagePage.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/ImagePage.kt index 27a90303c..90fa10e29 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/ImagePage.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/ImagePage.kt @@ -600,16 +600,28 @@ fun ImagePage( onRatingChange = { viewModel.updateRating(image.id, it) }, addItem = { item -> when (item) { - is TagData -> viewModel.addTag(image.id, item.id) - is PerformerData -> viewModel.addPerformer(image.id, item.id) + is TagData -> { + viewModel.addTag(image.id, item.id) + } + + is PerformerData -> { + viewModel.addPerformer(image.id, item.id) + } + else -> {} } }, removeItem = { item -> focusManager.moveFocus(FocusDirection.Previous) when (item) { - is TagData -> viewModel.removeTag(image.id, item.id) - is PerformerData -> viewModel.removePerformer(image.id, item.id) + is TagData -> { + viewModel.removeTag(image.id, item.id) + } + + is PerformerData -> { + viewModel.removePerformer(image.id, item.id) + } + else -> {} } }, diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/PerformerPage.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/PerformerPage.kt index 51cc4184c..f3cd03eb0 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/PerformerPage.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/PerformerPage.kt @@ -257,21 +257,23 @@ fun PerformerPage( val rating100 by viewModel.rating100.observeAsState(0) when (val state = loadingState) { - PerformerLoadingState.Error -> + PerformerLoadingState.Error -> { Text( "Error", style = MaterialTheme.typography.displayLarge, color = MaterialTheme.colorScheme.onBackground, ) + } - PerformerLoadingState.Loading -> + PerformerLoadingState.Loading -> { Text( "Loading...", style = MaterialTheme.typography.displayLarge, color = MaterialTheme.colorScheme.onBackground, ) + } - is PerformerLoadingState.Success -> + is PerformerLoadingState.Success -> { PerformerDetailsPage( server = server, perf = state.performer, @@ -296,6 +298,7 @@ fun PerformerPage( }, modifier = modifier.fillMaxSize(), ) + } null -> {} } diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/SceneDetailsPage.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/SceneDetailsPage.kt index 51e548c8e..68ac5c0d0 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/SceneDetailsPage.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/SceneDetailsPage.kt @@ -143,14 +143,17 @@ fun SceneDetailsPage( } when (val state = loadingState) { - SceneLoadingState.Error -> + SceneLoadingState.Error -> { Text( "Error", style = MaterialTheme.typography.displayLarge, color = MaterialTheme.colorScheme.onBackground, ) + } - SceneLoadingState.Loading -> CircularProgress() + SceneLoadingState.Loading -> { + CircularProgress() + } is SceneLoadingState.Success -> { LaunchedEffect(Unit) { @@ -181,7 +184,6 @@ fun SceneDetailsPage( is GalleryData -> viewModel.addGallery(item.id) is StudioData -> viewModel.setStudio(item.id) is MarkerData -> viewModel.addMarker(item) - is FullMarkerData -> throw UnsupportedOperationException() is ImageData, is ExtraImageData, is SlimImageData -> throw UnsupportedOperationException() is SlimSceneData, is FullSceneData, is VideoSceneData, is MinimalSceneData -> throw UnsupportedOperationException() @@ -195,7 +197,6 @@ fun SceneDetailsPage( is GalleryData -> viewModel.removeGallery(item.id) is StudioData -> viewModel.removeStudio() is MarkerData, is FullMarkerData -> viewModel.removeMarker(item.id) - is ImageData, is ExtraImageData, is SlimImageData -> throw UnsupportedOperationException() is SlimSceneData, is FullSceneData, is VideoSceneData, is MinimalSceneData -> throw UnsupportedOperationException() } diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/SearchForPage.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/SearchForPage.kt index 11d4f1aef..e7bc2b230 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/pages/SearchForPage.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/pages/SearchForPage.kt @@ -257,11 +257,26 @@ fun SearchForPage( if (mostRecentIds.isNotEmpty()) { recent = when (dataType) { - DataType.PERFORMER -> queryEngine.findPerformers(performerIds = mostRecentIds) - DataType.TAG -> queryEngine.getTags(mostRecentIds) - DataType.STUDIO -> queryEngine.findStudios(studioIds = mostRecentIds) - DataType.GALLERY -> queryEngine.findGalleries(galleryIds = mostRecentIds) - DataType.GROUP -> queryEngine.findGroups(groupIds = mostRecentIds) + DataType.PERFORMER -> { + queryEngine.findPerformers(performerIds = mostRecentIds) + } + + DataType.TAG -> { + queryEngine.getTags(mostRecentIds) + } + + DataType.STUDIO -> { + queryEngine.findStudios(studioIds = mostRecentIds) + } + + DataType.GALLERY -> { + queryEngine.findGalleries(galleryIds = mostRecentIds) + } + + DataType.GROUP -> { + queryEngine.findGroups(groupIds = mostRecentIds) + } + else -> { listOf() } @@ -287,7 +302,7 @@ fun SearchForPage( scope.launch(StashCoroutineExceptionHandler() + Dispatchers.IO) { suggestions = when (dataType) { - DataType.GALLERY -> + DataType.GALLERY -> { // Cannot add an image to a zip/folder gallery, so exclude them queryEngine.findGalleries( filter, @@ -301,8 +316,11 @@ fun SearchForPage( ), ), ) + } - else -> queryEngine.find(dataType, filter) + else -> { + queryEngine.find(dataType, filter) + } } } } @@ -341,21 +359,23 @@ fun SearchForPage( item { when (val result = results) { - is SearchState.NoQuery -> + is SearchState.NoQuery -> { Text( text = stringResource(R.string.waiting_for_query), style = MaterialTheme.typography.titleLarge, color = MaterialTheme.colorScheme.onSurface, ) + } - SearchState.Pending -> + SearchState.Pending -> { Text( text = stringResource(R.string.searching), style = MaterialTheme.typography.titleLarge, color = MaterialTheme.colorScheme.onSurface, ) + } - SearchState.NoResults -> + SearchState.NoResults -> { Column(verticalArrangement = Arrangement.spacedBy(16.dp)) { Text( text = stringResource(R.string.stashapp_studio_tagger_no_results_found), @@ -379,8 +399,9 @@ fun SearchForPage( ) } } + } - is SearchState.Success -> + is SearchState.Success -> { SearchItemsRow( title = stringResource(R.string.results), items = result.items, @@ -398,6 +419,7 @@ fun SearchForPage( ), modifier = Modifier.padding(start = startPadding, bottom = bottomPadding), ) + } } } if (suggestions.isNotEmpty()) { @@ -456,7 +478,9 @@ suspend fun handleCreate( mutationEngine.createStudio(name = name) } - else -> throw IllegalArgumentException("Unsupported datatype $dataType") + else -> { + throw IllegalArgumentException("Unsupported datatype $dataType") + } } if (item != null) { Toast diff --git a/app/src/main/java/com/github/damontecres/stashapp/ui/util/ModifierUtils.kt b/app/src/main/java/com/github/damontecres/stashapp/ui/util/ModifierUtils.kt index 8a2d88832..12525f34e 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/ui/util/ModifierUtils.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/ui/util/ModifierUtils.kt @@ -234,7 +234,7 @@ fun getPlayDestinationForItem( ): Destination? { val destination = when (item) { - is SlimSceneData -> + is SlimSceneData -> { Destination.Playback( item.id, if (server.serverPreferences.alwaysStartFromBeginning) { @@ -244,13 +244,15 @@ fun getPlayDestinationForItem( }, PlaybackMode.Choose, ) + } - is MarkerData -> + is MarkerData -> { Destination.Playback( item.scene.minimalSceneData.id, item.seconds.toLongMilliseconds, PlaybackMode.Choose, ) + } is ImageData -> { filterAndPosition?.let { @@ -262,7 +264,9 @@ fun getPlayDestinationForItem( } } - else -> null + else -> { + null + } } if (destination != null) { return destination diff --git a/app/src/main/java/com/github/damontecres/stashapp/util/AlphabetSearchUtils.kt b/app/src/main/java/com/github/damontecres/stashapp/util/AlphabetSearchUtils.kt index 0a45a4d4d..93b930c1e 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/util/AlphabetSearchUtils.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/util/AlphabetSearchUtils.kt @@ -42,7 +42,6 @@ class AlphabetSearchUtils { is StudioFilterType -> filter.AND is TagFilterType -> filter.AND is SceneMarkerFilterType -> throw IllegalArgumentException() - else -> throw IllegalArgumentException() }.getOrNull() return if (andFilter != null) { @@ -107,13 +106,18 @@ class AlphabetSearchUtils { val transformed = when (filterArgs.dataType) { DataType.GROUP -> (andObjectFilter as GroupFilterType).copy(name = stringCriterion) + DataType.PERFORMER -> (andObjectFilter as PerformerFilterType).copy(name = stringCriterion) + DataType.STUDIO -> (andObjectFilter as StudioFilterType).copy(name = stringCriterion) + DataType.TAG -> (andObjectFilter as TagFilterType).copy(name = stringCriterion) // TODO use filename DataType.SCENE -> (andObjectFilter as SceneFilterType).copy(title = stringCriterion) + DataType.IMAGE -> (andObjectFilter as ImageFilterType).copy(title = stringCriterion) + DataType.GALLERY -> (andObjectFilter as GalleryFilterType).copy(title = stringCriterion) DataType.MARKER -> TODO() diff --git a/app/src/main/java/com/github/damontecres/stashapp/util/AndroidExtensions.kt b/app/src/main/java/com/github/damontecres/stashapp/util/AndroidExtensions.kt index d96467f91..3736d3840 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/util/AndroidExtensions.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/util/AndroidExtensions.kt @@ -14,12 +14,20 @@ val DataType.defaultCardWidth get() = when (this) { SCENE -> 345 + GROUP -> 250 + MARKER -> 345 - PERFORMER -> 254 // 2/3 of height + + PERFORMER -> 254 + + // 2/3 of height STUDIO -> 327 + TAG -> 250 + IMAGE -> 345 + GALLERY -> 345 } diff --git a/app/src/main/java/com/github/damontecres/stashapp/util/Constants.kt b/app/src/main/java/com/github/damontecres/stashapp/util/Constants.kt index f5d068ef1..a1e19e0f5 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/util/Constants.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/util/Constants.kt @@ -294,10 +294,13 @@ suspend fun testStashConnection( val message = when (val cause = ex.cause) { is UnknownHostException, is ConnectException -> cause.localizedMessage + is SSLHandshakeException -> "server may be using a self-signed certificate" + // TODO handle case where cert is for a different host // is SSLPeerUnverifiedException-> is IOException -> cause.localizedMessage + else -> ex.localizedMessage } if (showToast) { @@ -963,6 +966,7 @@ fun getUiTabs( prefKey = R.string.pref_key_ui_performer_tabs defaultArrayKey = R.array.performer_tabs } + DataType.GALLERY -> { prefKey = R.string.pref_key_ui_gallery_tabs defaultArrayKey = R.array.gallery_tabs @@ -983,7 +987,9 @@ fun getUiTabs( defaultArrayKey = R.array.tag_tabs } - else -> throw UnsupportedOperationException("$dataType not supported") + else -> { + throw UnsupportedOperationException("$dataType not supported") + } } val defaultValues = context.resources.getStringArray(defaultArrayKey).toSet() return PreferenceManager diff --git a/app/src/main/java/com/github/damontecres/stashapp/util/FrontPageParser.kt b/app/src/main/java/com/github/damontecres/stashapp/util/FrontPageParser.kt index 10bb0b82c..485dae433 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/util/FrontPageParser.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/util/FrontPageParser.kt @@ -49,8 +49,14 @@ class FrontPageParser( val filterType = frontPageFilter["__typename"]?.toString()?.lowercase() ) { - "customfilter" -> addCustomFilterRow(frontPageFilter) - "savedfilter" -> addSavedFilterRow(frontPageFilter) + "customfilter" -> { + addCustomFilterRow(frontPageFilter) + } + + "savedfilter" -> { + addSavedFilterRow(frontPageFilter) + } + else -> { Log.w( TAG, @@ -69,18 +75,23 @@ class FrontPageParser( (msg["values"] as Map)["objects"] as String val description = when (msg["id"].toString()) { - "recently_added_objects" -> + "recently_added_objects" -> { context.getString( R.string.stashapp_recently_added_objects, objType, ) + } - "recently_released_objects" -> + "recently_released_objects" -> { context.getString( R.string.stashapp_recently_released_objects, objType, ) - else -> objType + } + + else -> { + objType + } } val sortBy = @@ -88,7 +99,9 @@ class FrontPageParser( ?: when (msg["id"].toString()) { // Just in case, fall back to a reasonable default "recently_added_objects" -> "created_at" + "recently_released_objects" -> "date" + else -> null } val mode = FilterMode.safeValueOf(frontPageFilter["mode"] as String) diff --git a/app/src/main/java/com/github/damontecres/stashapp/util/OptionalSerializer.kt b/app/src/main/java/com/github/damontecres/stashapp/util/OptionalSerializer.kt index ae070937f..579c9bda1 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/util/OptionalSerializer.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/util/OptionalSerializer.kt @@ -83,10 +83,22 @@ class CustomFieldCriterionInputSerializer : KSerializer decoder.decodeString() - INT_TYPE -> decoder.decodeInt() - DOUBLE_TYPE -> decoder.decodeDouble() - FLOAT_TYPE -> decoder.decodeFloat() + STRING_TYPE -> { + decoder.decodeString() + } + + INT_TYPE -> { + decoder.decodeInt() + } + + DOUBLE_TYPE -> { + decoder.decodeDouble() + } + + FLOAT_TYPE -> { + decoder.decodeFloat() + } + else -> { val msg = "Unknown decoding type: $type" Log.e(TAG, msg) diff --git a/app/src/main/java/com/github/damontecres/stashapp/util/ServerPreferences.kt b/app/src/main/java/com/github/damontecres/stashapp/util/ServerPreferences.kt index 09814fdcc..dadfaa1f5 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/util/ServerPreferences.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/util/ServerPreferences.kt @@ -454,9 +454,17 @@ class ServerPreferences( JSONObject(map).toMap().values.toList() } - is JSONObject -> value.toMap() - JSONObject.NULL -> null - else -> value + is JSONObject -> { + value.toMap() + } + + JSONObject.NULL -> { + null + } + + else -> { + value + } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/views/PlayAllOnClickListener.kt b/app/src/main/java/com/github/damontecres/stashapp/views/PlayAllOnClickListener.kt index 3452b1e8b..1ebd43617 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/views/PlayAllOnClickListener.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/views/PlayAllOnClickListener.kt @@ -75,7 +75,9 @@ class PlayAllOnClickListener( ) } - else -> throw UnsupportedOperationException("DataType $dataType") + else -> { + throw UnsupportedOperationException("DataType $dataType") + } } } } diff --git a/app/src/main/java/com/github/damontecres/stashapp/views/SkipIndicator.kt b/app/src/main/java/com/github/damontecres/stashapp/views/SkipIndicator.kt index 774b3e0d4..1e7ae1338 100644 --- a/app/src/main/java/com/github/damontecres/stashapp/views/SkipIndicator.kt +++ b/app/src/main/java/com/github/damontecres/stashapp/views/SkipIndicator.kt @@ -42,7 +42,7 @@ class SkipIndicator( @SuppressLint("SetTextI18n") fun update(delta: Long) { // If switching from fast forward to back (or vice versa), reset the value - if (currentSkip > 0 && delta < 0 || currentSkip < 0 && delta > 0) { + if ((currentSkip > 0 && delta < 0) || (currentSkip < 0 && delta > 0)) { currentSkip = 0 } currentSkip += (delta / 1000) diff --git a/app/src/test/java/com/github/damontecres/stashapp/ObjectFilterParsingTests.kt b/app/src/test/java/com/github/damontecres/stashapp/ObjectFilterParsingTests.kt index eda40949d..2003f7383 100644 --- a/app/src/test/java/com/github/damontecres/stashapp/ObjectFilterParsingTests.kt +++ b/app/src/test/java/com/github/damontecres/stashapp/ObjectFilterParsingTests.kt @@ -380,7 +380,9 @@ class ObjectFilterParsingTests { Assert.assertEquals(prop.name, expected.depth, actual.depth) } - else -> Assert.assertEquals(prop.name, expected, actual) + else -> { + Assert.assertEquals(prop.name, expected, actual) + } } } } From a4ccd6712ec951d963a8ed6cd200f9480e5e8cc2 Mon Sep 17 00:00:00 2001 From: Damontecres Date: Fri, 12 Dec 2025 15:31:33 -0500 Subject: [PATCH 4/4] Suppress lint issue for now --- app/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 99f12b184..9bb2fb263 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -123,6 +123,7 @@ android { } lint { disable.add("MissingTranslation") + disable.add("LocalContextGetResourceValueCall") // TODO } room { schemaDirectory("$projectDir/schemas")