This commit is contained in:
parent
3d4f5aaf4a
commit
9fa326c571
6 changed files with 149 additions and 4 deletions
|
@ -154,6 +154,7 @@ import java.io.FileOutputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
import java.util.Timer
|
import java.util.Timer
|
||||||
import java.util.TimerTask
|
import java.util.TimerTask
|
||||||
|
@ -1539,3 +1540,26 @@ fun getYoutubeId(url: String): String {
|
||||||
val matchResult = regex.find(url)
|
val matchResult = regex.find(url)
|
||||||
return matchResult?.groupValues?.getOrNull(1) ?: ""
|
return matchResult?.groupValues?.getOrNull(1) ?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLanguageCode(language: String): CharSequence {
|
||||||
|
val locales = Locale.getAvailableLocales()
|
||||||
|
for (locale in locales) {
|
||||||
|
if (locale.displayLanguage.equals(language, ignoreCase = true)) {
|
||||||
|
val lang: CharSequence = locale.language
|
||||||
|
return lang
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val out: CharSequence = "null"
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLanguageName(language: String): String? {
|
||||||
|
val locales = Locale.getAvailableLocales()
|
||||||
|
for (locale in locales) {
|
||||||
|
if (locale.language.equals(language, ignoreCase = true)) {
|
||||||
|
return locale.displayLanguage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ import ani.dantotsu.download.DownloadsManager.Companion.getSubDirectory
|
||||||
import ani.dantotsu.download.video.Helper
|
import ani.dantotsu.download.video.Helper
|
||||||
import ani.dantotsu.dp
|
import ani.dantotsu.dp
|
||||||
import ani.dantotsu.getCurrentBrightnessValue
|
import ani.dantotsu.getCurrentBrightnessValue
|
||||||
|
import ani.dantotsu.getLanguageCode
|
||||||
import ani.dantotsu.hideSystemBars
|
import ani.dantotsu.hideSystemBars
|
||||||
import ani.dantotsu.hideSystemBarsExtendView
|
import ani.dantotsu.hideSystemBarsExtendView
|
||||||
import ani.dantotsu.isOnline
|
import ani.dantotsu.isOnline
|
||||||
|
@ -1396,13 +1397,57 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
||||||
val ext = episode.extractors?.find { it.server.name == episode.selectedExtractor } ?: return
|
val ext = episode.extractors?.find { it.server.name == episode.selectedExtractor } ?: return
|
||||||
extractor = ext
|
extractor = ext
|
||||||
video = ext.videos.getOrNull(episode.selectedVideo) ?: return
|
video = ext.videos.getOrNull(episode.selectedVideo) ?: return
|
||||||
|
val subLanguages = arrayOf(
|
||||||
|
"Albanian",
|
||||||
|
"Arabic",
|
||||||
|
"Bosnian",
|
||||||
|
"Bulgarian",
|
||||||
|
"Chinese",
|
||||||
|
"Croatian",
|
||||||
|
"Czech",
|
||||||
|
"Danish",
|
||||||
|
"Dutch",
|
||||||
|
"English",
|
||||||
|
"Estonian",
|
||||||
|
"Finnish",
|
||||||
|
"French",
|
||||||
|
"Georgian",
|
||||||
|
"German",
|
||||||
|
"Greek",
|
||||||
|
"Hebrew",
|
||||||
|
"Hindi",
|
||||||
|
"Indonesian",
|
||||||
|
"Irish",
|
||||||
|
"Italian",
|
||||||
|
"Japanese",
|
||||||
|
"Korean",
|
||||||
|
"Lithuanian",
|
||||||
|
"Luxembourgish",
|
||||||
|
"Macedonian",
|
||||||
|
"Mongolian",
|
||||||
|
"Norwegian",
|
||||||
|
"Polish",
|
||||||
|
"Portuguese",
|
||||||
|
"Punjabi",
|
||||||
|
"Romanian",
|
||||||
|
"Russian",
|
||||||
|
"Serbian",
|
||||||
|
"Slovak",
|
||||||
|
"Slovenian",
|
||||||
|
"Spanish",
|
||||||
|
"Turkish",
|
||||||
|
"Ukrainian",
|
||||||
|
"Urdu",
|
||||||
|
"Vietnamese",
|
||||||
|
)
|
||||||
|
val lang = subLanguages[PrefManager.getVal(PrefName.SubLanguage)]
|
||||||
subtitle = intent.getSerialized("subtitle")
|
subtitle = intent.getSerialized("subtitle")
|
||||||
?: when (val subLang: String? =
|
?: when (val subLang: String? =
|
||||||
PrefManager.getNullableCustomVal("subLang_${media.id}", null, String::class.java)) {
|
PrefManager.getNullableCustomVal("subLang_${media.id}", null, String::class.java)) {
|
||||||
null -> {
|
null -> {
|
||||||
when (episode.selectedSubtitle) {
|
when (episode.selectedSubtitle) {
|
||||||
null -> null
|
null -> null
|
||||||
-1 -> ext.subtitles.find { it.language.trim() == "English" || it.language == "en-US" }
|
-1 -> ext.subtitles.find { it.language.contains( lang, ignoreCase = true ) || it.language.contains( getLanguageCode(lang), ignoreCase = true ) }
|
||||||
else -> ext.subtitles.getOrNull(episode.selectedSubtitle!!)
|
else -> ext.subtitles.getOrNull(episode.selectedSubtitle!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ani.dantotsu.settings
|
package ani.dantotsu.settings
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.app.Dialog
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
@ -32,7 +33,6 @@ import ani.dantotsu.util.customAlertDialog
|
||||||
import com.google.android.material.slider.Slider.OnChangeListener
|
import com.google.android.material.slider.Slider.OnChangeListener
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
|
||||||
class PlayerSettingsActivity : AppCompatActivity() {
|
class PlayerSettingsActivity : AppCompatActivity() {
|
||||||
lateinit var binding: ActivityPlayerSettingsBinding
|
lateinit var binding: ActivityPlayerSettingsBinding
|
||||||
private val player = "player_settings"
|
private val player = "player_settings"
|
||||||
|
@ -318,6 +318,61 @@ class PlayerSettingsActivity : AppCompatActivity() {
|
||||||
toggleSubOptions(isChecked)
|
toggleSubOptions(isChecked)
|
||||||
}
|
}
|
||||||
toggleSubOptions(binding.subSwitch.isChecked)
|
toggleSubOptions(binding.subSwitch.isChecked)
|
||||||
|
val subLanguages = arrayOf(
|
||||||
|
"Albanian",
|
||||||
|
"Arabic",
|
||||||
|
"Bosnian",
|
||||||
|
"Bulgarian",
|
||||||
|
"Chinese",
|
||||||
|
"Croatian",
|
||||||
|
"Czech",
|
||||||
|
"Danish",
|
||||||
|
"Dutch",
|
||||||
|
"English",
|
||||||
|
"Estonian",
|
||||||
|
"Finnish",
|
||||||
|
"French",
|
||||||
|
"Georgian",
|
||||||
|
"German",
|
||||||
|
"Greek",
|
||||||
|
"Hebrew",
|
||||||
|
"Hindi",
|
||||||
|
"Indonesian",
|
||||||
|
"Irish",
|
||||||
|
"Italian",
|
||||||
|
"Japanese",
|
||||||
|
"Korean",
|
||||||
|
"Lithuanian",
|
||||||
|
"Luxembourgish",
|
||||||
|
"Macedonian",
|
||||||
|
"Mongolian",
|
||||||
|
"Norwegian",
|
||||||
|
"Polish",
|
||||||
|
"Portuguese",
|
||||||
|
"Punjabi",
|
||||||
|
"Romanian",
|
||||||
|
"Russian",
|
||||||
|
"Serbian",
|
||||||
|
"Slovak",
|
||||||
|
"Slovenian",
|
||||||
|
"Spanish",
|
||||||
|
"Turkish",
|
||||||
|
"Ukrainian",
|
||||||
|
"Urdu",
|
||||||
|
"Vietnamese",
|
||||||
|
)
|
||||||
|
val subLanguageDialog = AlertDialog.Builder(this, R.style.MyPopup)
|
||||||
|
.setTitle(getString(R.string.subtitle_langauge))
|
||||||
|
binding.videoSubLanguage.setOnClickListener {
|
||||||
|
val dialog = subLanguageDialog.setSingleChoiceItems(
|
||||||
|
subLanguages,
|
||||||
|
PrefManager.getVal(PrefName.SubLanguage)
|
||||||
|
) { dialog, count ->
|
||||||
|
PrefManager.setVal(PrefName.SubLanguage, count)
|
||||||
|
dialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
dialog.window?.setDimAmount(0.8f)
|
||||||
|
}
|
||||||
val colorsPrimary =
|
val colorsPrimary =
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"Black",
|
"Black",
|
||||||
|
|
|
@ -92,6 +92,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
||||||
CursedSpeeds(Pref(Location.Player, Boolean::class, false)),
|
CursedSpeeds(Pref(Location.Player, Boolean::class, false)),
|
||||||
Resize(Pref(Location.Player, Int::class, 0)),
|
Resize(Pref(Location.Player, Int::class, 0)),
|
||||||
Subtitles(Pref(Location.Player, Boolean::class, true)),
|
Subtitles(Pref(Location.Player, Boolean::class, true)),
|
||||||
|
SubLanguage(Pref(Location.Player, Int::class, 9)),
|
||||||
PrimaryColor(Pref(Location.Player, Int::class, 4)),
|
PrimaryColor(Pref(Location.Player, Int::class, 4)),
|
||||||
SecondaryColor(Pref(Location.Player, Int::class, 0)),
|
SecondaryColor(Pref(Location.Player, Int::class, 0)),
|
||||||
Outline(Pref(Location.Player, Int::class, 0)),
|
Outline(Pref(Location.Player, Int::class, 0)),
|
||||||
|
|
|
@ -225,6 +225,25 @@
|
||||||
app:showText="false"
|
app:showText="false"
|
||||||
app:thumbTint="@color/button_switch_track" />
|
app:thumbTint="@color/button_switch_track" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/videoSubLanguage"
|
||||||
|
style="@style/Widget.Material3.Button.TextButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:paddingHorizontal="32dp"
|
||||||
|
android:text="@string/subtitle_langauge"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textColor="@color/bg_opp"
|
||||||
|
app:cornerRadius="0dp"
|
||||||
|
app:icon="@drawable/ic_round_subtitles_24"
|
||||||
|
app:iconPadding="16dp"
|
||||||
|
app:iconSize="24dp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/videoSubColorPrimary"
|
android:id="@+id/videoSubColorPrimary"
|
||||||
style="@style/Widget.Material3.Button.TextButton"
|
style="@style/Widget.Material3.Button.TextButton"
|
||||||
|
|
|
@ -1073,5 +1073,6 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||||
<string name="private_mode">Private</string>
|
<string name="private_mode">Private</string>
|
||||||
<string name="omega_cursed">you have been Ǫ̴̺̙͎̤̫͓̮̰̿͝M̴͇̤͗́̾̈́̑̍̿̈͌͝Ȅ̴̡̨̛͉̣̙̩̲̣̤̟̪̣̎͗̎̆̒̉͆̆̕ͅͅǴ̸̯̬̗̠̙͛͐̀̈͋̀̈̽́̎̿͘͘͝ͅĀ̶̧̲̀ͅ ̴̢̟͕̜̓̾̓C̶̬̜̰̘̝̱̫͓͙̭̈́͐͋̓̏̈̍̓̀̌̾̚Ư̸̛̤̱̈́͆̽͊͛̐̓́̑͘̕̕͝R̸̨̨͈̬̱̺͕̪̪̘͕͎̂͛́̅̆̓̀͝ͅS̴̨̨̛̩̭̗̹̰̭̥͉̮̝̠̓̔͆̂͊͆̀̈́̅̕͘̚͝È̴̢̛̝͈̳͉͈͒͒̒̄̏̈̈́D̸̢̡̨̜̞̩̼̫̹̗̮͛̀̈̋̾̇̕̕͜ͅ</string>
|
<string name="omega_cursed">you have been Ǫ̴̺̙͎̤̫͓̮̰̿͝M̴͇̤͗́̾̈́̑̍̿̈͌͝Ȅ̴̡̨̛͉̣̙̩̲̣̤̟̪̣̎͗̎̆̒̉͆̆̕ͅͅǴ̸̯̬̗̠̙͛͐̀̈͋̀̈̽́̎̿͘͘͝ͅĀ̶̧̲̀ͅ ̴̢̟͕̜̓̾̓C̶̬̜̰̘̝̱̫͓͙̭̈́͐͋̓̏̈̍̓̀̌̾̚Ư̸̛̤̱̈́͆̽͊͛̐̓́̑͘̕̕͝R̸̨̨͈̬̱̺͕̪̪̘͕͎̂͛́̅̆̓̀͝ͅS̴̨̨̛̩̭̗̹̰̭̥͉̮̝̠̓̔͆̂͊͆̀̈́̅̕͘̚͝È̴̢̛̝͈̳͉͈͒͒̒̄̏̈̈́D̸̢̡̨̜̞̩̼̫̹̗̮͛̀̈̋̾̇̕̕͜ͅ</string>
|
||||||
<string name="omega_freed">you have been freed</string>
|
<string name="omega_freed">you have been freed</string>
|
||||||
|
<string name="subtitle_langauge">Subtitle Langauge</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue