-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: preferred subtitles and audio tracks languages
- Loading branch information
1 parent
10ecf37
commit f1ed68c
Showing
8 changed files
with
206 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/main/java/live/mehiz/mpvkt/preferences/AudioPreferences.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package live.mehiz.mpvkt.preferences | ||
|
||
import live.mehiz.mpvkt.preferences.preference.PreferenceStore | ||
|
||
class AudioPreferences(preferenceStore: PreferenceStore) { | ||
val preferredLanguages = preferenceStore.getString("audio_preferred_languages") | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/live/mehiz/mpvkt/preferences/SubtitlesPreferences.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package live.mehiz.mpvkt.preferences | ||
|
||
import live.mehiz.mpvkt.preferences.preference.PreferenceStore | ||
|
||
class SubtitlesPreferences(preferenceStore: PreferenceStore) { | ||
val preferredLanguages = preferenceStore.getString("sub_preferred_languages") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
app/src/main/java/live/mehiz/mpvkt/ui/preferences/AudioPreferencesScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package live.mehiz.mpvkt.ui.preferences | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextField | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import cafe.adriel.voyager.core.screen.Screen | ||
import cafe.adriel.voyager.navigator.LocalNavigator | ||
import cafe.adriel.voyager.navigator.currentOrThrow | ||
import live.mehiz.mpvkt.R | ||
import live.mehiz.mpvkt.preferences.AudioPreferences | ||
import me.zhanghai.compose.preference.ProvidePreferenceLocals | ||
import me.zhanghai.compose.preference.textFieldPreference | ||
import org.koin.compose.koinInject | ||
|
||
object AudioPreferencesScreen : Screen { | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
override fun Content() { | ||
val navigator = LocalNavigator.currentOrThrow | ||
val preferences = koinInject<AudioPreferences>() | ||
Scaffold( | ||
topBar = { | ||
TopAppBar( | ||
title = { | ||
Text(stringResource(R.string.pref_audio)) | ||
}, | ||
navigationIcon = { | ||
IconButton(onClick = { navigator.pop() }) { | ||
Icon(Icons.AutoMirrored.Default.ArrowBack, null) | ||
} | ||
} | ||
) | ||
}, | ||
) { padding -> | ||
ProvidePreferenceLocals { | ||
LazyColumn( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(padding) | ||
) { | ||
textFieldPreference( | ||
preferences.preferredLanguages.key(), | ||
defaultValue = preferences.preferredLanguages.defaultValue(), | ||
textToValue = { it }, | ||
title = { Text(stringResource(R.string.pref_preferred_languages)) }, | ||
summary = { if(it.isNotBlank()) Text(it) }, | ||
textField = { value, onValueChange, _ -> | ||
Column { | ||
Text(stringResource(`is`.xyz.mpv.R.string.pref_default_audio_language_message)) | ||
TextField( | ||
value, | ||
onValueChange, | ||
modifier = Modifier.fillMaxWidth() | ||
) | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
app/src/main/java/live/mehiz/mpvkt/ui/preferences/SubtitlesPreferencesScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package live.mehiz.mpvkt.ui.preferences | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.outlined.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextField | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import cafe.adriel.voyager.core.screen.Screen | ||
import cafe.adriel.voyager.navigator.LocalNavigator | ||
import cafe.adriel.voyager.navigator.currentOrThrow | ||
import live.mehiz.mpvkt.R | ||
import live.mehiz.mpvkt.preferences.SubtitlesPreferences | ||
import me.zhanghai.compose.preference.ProvidePreferenceLocals | ||
import me.zhanghai.compose.preference.textFieldPreference | ||
import org.koin.compose.koinInject | ||
|
||
object SubtitlesPreferencesScreen : Screen { | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
override fun Content() { | ||
val navigator = LocalNavigator.currentOrThrow | ||
val preferences = koinInject<SubtitlesPreferences>() | ||
|
||
Scaffold( | ||
topBar = { | ||
TopAppBar( | ||
title = { | ||
Text(stringResource(R.string.pref_preferred_languages)) | ||
}, | ||
navigationIcon = { | ||
IconButton(onClick = { navigator.pop() }) { | ||
Icon(Icons.AutoMirrored.Outlined.ArrowBack, null) | ||
} | ||
}, | ||
) | ||
}, | ||
) { padding -> | ||
ProvidePreferenceLocals { | ||
LazyColumn( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(padding), | ||
) { | ||
textFieldPreference( | ||
preferences.preferredLanguages.key(), | ||
defaultValue = preferences.preferredLanguages.defaultValue(), | ||
textToValue = { it }, | ||
title = { Text(stringResource(R.string.pref_preferred_languages)) }, | ||
summary = { if(it.isNotBlank()) Text(it) }, | ||
textField = { value, onValueChange, _ -> | ||
Column { | ||
Text(stringResource(`is`.xyz.mpv.R.string.pref_default_subtitle_language_message)) | ||
TextField( | ||
value, | ||
onValueChange, | ||
modifier = Modifier.fillMaxWidth() | ||
) | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters