Default Seerr login to Jellyfin and prefill Wolfskin Seerr URL
All checks were successful
review/firstmate Exact-diff check: JELLYFIN first, API key last; URL prefill from one constant; unit test; apk-debug+test green
All checks were successful
review/firstmate Exact-diff check: JELLYFIN first, API key last; URL prefill from one constant; unit test; apk-debug+test green
This commit is contained in:
parent
7d6f041b55
commit
af885eae58
4 changed files with 33 additions and 6 deletions
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.github.damontecres.wholphin
|
||||||
|
|
||||||
|
/** Wolfskin-specific defaults kept in one place to keep upstream diffs small. */
|
||||||
|
object WolfskinDefaults {
|
||||||
|
const val SEERR_URL = "https://seerr.justinvisser.org"
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns [url] when it has content, otherwise the Wolfskin Seerr URL so the user can still edit it. */
|
||||||
|
fun seerrUrlPrefill(url: String = ""): String = if (url.isBlank()) WolfskinDefaults.SEERR_URL else url
|
||||||
|
|
@ -30,6 +30,7 @@ import androidx.compose.ui.unit.dp
|
||||||
import androidx.tv.material3.MaterialTheme
|
import androidx.tv.material3.MaterialTheme
|
||||||
import androidx.tv.material3.Text
|
import androidx.tv.material3.Text
|
||||||
import com.github.damontecres.wholphin.R
|
import com.github.damontecres.wholphin.R
|
||||||
|
import com.github.damontecres.wholphin.seerrUrlPrefill
|
||||||
import com.github.damontecres.wholphin.ui.PreviewTvSpec
|
import com.github.damontecres.wholphin.ui.PreviewTvSpec
|
||||||
import com.github.damontecres.wholphin.ui.components.Button
|
import com.github.damontecres.wholphin.ui.components.Button
|
||||||
import com.github.damontecres.wholphin.ui.components.EditTextBox
|
import com.github.damontecres.wholphin.ui.components.EditTextBox
|
||||||
|
|
@ -54,7 +55,7 @@ fun AddSeerrServerApiKey(
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
.wrapContentSize(),
|
.wrapContentSize(),
|
||||||
) {
|
) {
|
||||||
var url by remember { mutableStateOf("") }
|
var url by remember { mutableStateOf(seerrUrlPrefill()) }
|
||||||
var apiKey by remember { mutableStateOf("") }
|
var apiKey by remember { mutableStateOf("") }
|
||||||
|
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
|
|
@ -166,7 +167,7 @@ fun AddSeerrServerUsername(
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
.wrapContentSize(),
|
.wrapContentSize(),
|
||||||
) {
|
) {
|
||||||
var url by remember { mutableStateOf("") }
|
var url by remember { mutableStateOf(seerrUrlPrefill()) }
|
||||||
var username by remember { mutableStateOf(username) }
|
var username by remember { mutableStateOf(username) }
|
||||||
var password by remember { mutableStateOf("") }
|
var password by remember { mutableStateOf("") }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,10 +89,6 @@ fun ChooseSeerrLoginType(
|
||||||
title = stringResource(R.string.seerr_login),
|
title = stringResource(R.string.seerr_login),
|
||||||
items =
|
items =
|
||||||
listOf(
|
listOf(
|
||||||
DialogItem(
|
|
||||||
text = stringResource(R.string.api_key),
|
|
||||||
onClick = { onChoose.invoke(SeerrAuthMethod.API_KEY) },
|
|
||||||
),
|
|
||||||
DialogItem(
|
DialogItem(
|
||||||
text = stringResource(R.string.seerr_jellyfin_user),
|
text = stringResource(R.string.seerr_jellyfin_user),
|
||||||
onClick = { onChoose.invoke(SeerrAuthMethod.JELLYFIN) },
|
onClick = { onChoose.invoke(SeerrAuthMethod.JELLYFIN) },
|
||||||
|
|
@ -101,6 +97,10 @@ fun ChooseSeerrLoginType(
|
||||||
text = stringResource(R.string.seerr_local_user),
|
text = stringResource(R.string.seerr_local_user),
|
||||||
onClick = { onChoose.invoke(SeerrAuthMethod.LOCAL) },
|
onClick = { onChoose.invoke(SeerrAuthMethod.LOCAL) },
|
||||||
),
|
),
|
||||||
|
DialogItem(
|
||||||
|
text = stringResource(R.string.api_key),
|
||||||
|
onClick = { onChoose.invoke(SeerrAuthMethod.API_KEY) },
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.github.damontecres.wholphin
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class WolfskinDefaultsTest {
|
||||||
|
@Test
|
||||||
|
fun emptyUrlIsPrefilledWithWolfskinSeerrUrl() {
|
||||||
|
assertEquals(WolfskinDefaults.SEERR_URL, seerrUrlPrefill())
|
||||||
|
assertEquals(WolfskinDefaults.SEERR_URL, seerrUrlPrefill(" "))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun enteredUrlIsKept() {
|
||||||
|
assertEquals("https://seerr.example.org", seerrUrlPrefill("https://seerr.example.org"))
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue