Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import java.util.Properties
import org.gradle.api.provider.Property
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

val appVersionCode = 140
val appVersionName = "3.4.4"
val appVersionCode = 141
val appVersionName = "3.4.5"

plugins {
alias(libs.plugins.android.application)
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/java/com/example/xtreamplayer/MainActivityUi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2041,11 +2041,8 @@ fun RootScreen(
onSave = { apiKey, userAgent ->
settingsViewModel.setOpenSubtitlesApiKey(apiKey)
settingsViewModel.setOpenSubtitlesUserAgent(userAgent)
Toast.makeText(
context,
"OpenSubtitles settings saved",
Toast.LENGTH_SHORT
).show()
val message = if (apiKey.isBlank()) "API key cleared" else "OpenSubtitles settings saved"
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
showApiKeyDialog = false
},
onDismiss = { showApiKeyDialog = false }
Expand Down
47 changes: 44 additions & 3 deletions app/src/main/java/com/example/xtreamplayer/ui/SubtitleDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ fun ApiKeyInputDialog(
val context = LocalContext.current
val inputFocusRequester = remember { FocusRequester() }
val userAgentFocusRequester = remember { FocusRequester() }
val clearFocusRequester = remember { FocusRequester() }
val saveFocusRequester = remember { FocusRequester() }

LaunchedEffect(Unit) {
Expand Down Expand Up @@ -728,13 +729,22 @@ fun ApiKeyInputDialog(
fontFamily = AppTheme.fontFamily
)

Spacer(modifier = Modifier.height(6.dp))
Spacer(modifier = Modifier.height(4.dp))

val interactionSource = remember { MutableInteractionSource() }
val isFocused by interactionSource.collectIsFocusedAsState()
val shape = RoundedCornerShape(8.dp)
val borderColor = if (isFocused) FocusBorderColor else SecondaryBorderColor

Text(
text = "32-character token from opensubtitles.com",
color = MutedTextColor,
fontSize = 11.sp,
fontFamily = AppTheme.fontFamily
)

Spacer(modifier = Modifier.height(6.dp))

BasicTextField(
value = apiKey,
onValueChange = { apiKey = it },
Expand Down Expand Up @@ -788,6 +798,15 @@ fun ApiKeyInputDialog(
fontFamily = AppTheme.fontFamily
)

Spacer(modifier = Modifier.height(4.dp))

Text(
text = "Any name identifying your app, e.g. XtreamPlayer",
color = MutedTextColor,
fontSize = 11.sp,
fontFamily = AppTheme.fontFamily
)

Spacer(modifier = Modifier.height(6.dp))

val userAgentInteractionSource = remember { MutableInteractionSource() }
Expand Down Expand Up @@ -867,10 +886,32 @@ fun ApiKeyInputDialog(

FocusableButton(
onClick = {
if (apiKey.isBlank() || userAgent.isBlank()) {
apiKey = ""
userAgent = ""
},
colors = ButtonDefaults.buttonColors(
containerColor = SecondaryBorderColor,
contentColor = AppTheme.colors.textPrimary
),
modifier = Modifier.focusRequester(clearFocusRequester)
) {
Text(
text = "Clear",
fontFamily = AppTheme.fontFamily,
fontWeight = FontWeight.SemiBold
)
}

Spacer(modifier = Modifier.width(12.dp))

FocusableButton(
onClick = {
val keyBlank = apiKey.isBlank()
val agentBlank = userAgent.isBlank()
if (keyBlank != agentBlank) {
Toast.makeText(
context,
"Enter API key and user agent",
"Enter both API key and user agent",
Toast.LENGTH_SHORT
).show()
return@FocusableButton
Expand Down
Loading