fixed lang bug

This commit is contained in:
LagradOst 2021-09-03 11:13:34 +02:00
parent 672dc995a5
commit 960a71a2d7
12 changed files with 16 additions and 45 deletions

View file

@ -7,6 +7,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.content.res.Configuration
import android.content.res.Resources import android.content.res.Resources
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@ -23,7 +24,6 @@ import com.google.android.gms.cast.framework.CastButtonFactory
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.APIHolder.restrictedApis import com.lagradost.cloudstream3.APIHolder.restrictedApis
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
import com.lagradost.cloudstream3.ui.download.DownloadChildFragment import com.lagradost.cloudstream3.ui.download.DownloadChildFragment
@ -70,6 +70,11 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
onDialogDismissedEvent.invoke(dialogId) onDialogDismissedEvent.invoke(dialogId)
} }
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
updateLocale() // android fucks me by chaining lang when rotating the phone
}
companion object { companion object {
var canEnterPipMode: Boolean = false var canEnterPipMode: Boolean = false
var canShowPipMode: Boolean = false var canShowPipMode: Boolean = false
@ -186,20 +191,18 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
.remove(currentFragment) .remove(currentFragment)
.commitAllowingStateLoss() .commitAllowingStateLoss()
backEvent.invoke(true) backEvent.invoke(true)
this.updateLocale()
return true return true
} }
backEvent.invoke(false) backEvent.invoke(false)
this.updateLocale()
return false return false
} }
override fun onBackPressed() { override fun onBackPressed() {
this.updateLocale() this.updateLocale()
if (backPressed()) return if (backPressed()) return
super.onBackPressed() super.onBackPressed()
this.updateLocale()
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

View file

@ -7,13 +7,12 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.Coroutines.main
import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.getKeys import com.lagradost.cloudstream3.utils.DataStore.getKeys
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.utils.VideoDownloadHelper import com.lagradost.cloudstream3.utils.VideoDownloadHelper
import com.lagradost.cloudstream3.utils.VideoDownloadManager import com.lagradost.cloudstream3.utils.VideoDownloadManager
import kotlinx.android.synthetic.main.fragment_child_downloads.* import kotlinx.android.synthetic.main.fragment_child_downloads.*
@ -42,8 +41,6 @@ class DownloadChildFragment : Fragment() {
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
context?.updateLocale()
return inflater.inflate(R.layout.fragment_child_downloads, container, false) return inflater.inflate(R.layout.fragment_child_downloads, container, false)
} }

View file

@ -10,7 +10,6 @@ import androidx.lifecycle.ViewModelProvider
import androidx.navigation.findNavController import androidx.navigation.findNavController
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.isMovieType import com.lagradost.cloudstream3.isMovieType
import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.mvvm.observe
@ -61,8 +60,6 @@ class DownloadFragment : Fragment() {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
context?.updateLocale()
downloadsViewModel = downloadsViewModel =
ViewModelProvider(this).get(DownloadViewModel::class.java) ViewModelProvider(this).get(DownloadViewModel::class.java)
observe(downloadsViewModel.noDownloadsText) { observe(downloadsViewModel.noDownloadsText) {

View file

@ -19,7 +19,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.MainActivity.Companion.backEvent import com.lagradost.cloudstream3.MainActivity.Companion.backEvent
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.mvvm.observe
import com.lagradost.cloudstream3.ui.AutofitRecyclerView import com.lagradost.cloudstream3.ui.AutofitRecyclerView
@ -96,8 +95,6 @@ class HomeFragment : Fragment() {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
context?.updateLocale()
homeViewModel = homeViewModel =
ViewModelProvider(this).get(HomeViewModel::class.java) ViewModelProvider(this).get(HomeViewModel::class.java)

View file

@ -68,7 +68,6 @@ import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.MainActivity.Companion.canEnterPipMode import com.lagradost.cloudstream3.MainActivity.Companion.canEnterPipMode
import com.lagradost.cloudstream3.MainActivity.Companion.isInPIPMode import com.lagradost.cloudstream3.MainActivity.Companion.isInPIPMode
import com.lagradost.cloudstream3.MainActivity.Companion.showToast import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
@ -949,8 +948,6 @@ class PlayerFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
context?.let { ctx -> context?.let { ctx ->
ctx.updateLocale()
setPreferredSubLanguage(ctx.getAutoSelectLanguageISO639_1()) setPreferredSubLanguage(ctx.getAutoSelectLanguageISO639_1())
} }
@ -2048,8 +2045,6 @@ class PlayerFragment : Fragment() {
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
context?.updateLocale()
return inflater.inflate(R.layout.fragment_player, container, false) return inflater.inflate(R.layout.fragment_player, container, false)
} }
} }

View file

@ -1,8 +1,11 @@
package com.lagradost.cloudstream3.ui.result package com.lagradost.cloudstream3.ui.result
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.* import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Context.CLIPBOARD_SERVICE import android.content.Context.CLIPBOARD_SERVICE
import android.content.Intent
import android.content.Intent.* import android.content.Intent.*
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
@ -32,7 +35,6 @@ import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.getApiFromName import com.lagradost.cloudstream3.APIHolder.getApiFromName
import com.lagradost.cloudstream3.APIHolder.getId import com.lagradost.cloudstream3.APIHolder.getId
import com.lagradost.cloudstream3.MainActivity.Companion.showToast import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.mvvm.observe
import com.lagradost.cloudstream3.ui.WatchType import com.lagradost.cloudstream3.ui.WatchType
@ -169,8 +171,6 @@ class ResultFragment : Fragment() {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle?, savedInstanceState: Bundle?,
): View? { ): View? {
context?.updateLocale()
viewModel = viewModel =
ViewModelProvider(activity ?: this).get(ResultViewModel::class.java) ViewModelProvider(activity ?: this).get(ResultViewModel::class.java)
return inflater.inflate(R.layout.fragment_result, container, false) return inflater.inflate(R.layout.fragment_result, container, false)

View file

@ -21,7 +21,6 @@ import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.APIHolder.getApiSettings import com.lagradost.cloudstream3.APIHolder.getApiSettings
import com.lagradost.cloudstream3.APIHolder.getApiTypeSettings import com.lagradost.cloudstream3.APIHolder.getApiTypeSettings
import com.lagradost.cloudstream3.HomePageList import com.lagradost.cloudstream3.HomePageList
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.TvType import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.Resource
@ -38,7 +37,6 @@ import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
import kotlinx.android.synthetic.main.fragment_search.* import kotlinx.android.synthetic.main.fragment_search.*
import java.util.HashSet
class SearchFragment : Fragment() { class SearchFragment : Fragment() {
private lateinit var searchViewModel: SearchViewModel private lateinit var searchViewModel: SearchViewModel
@ -48,8 +46,6 @@ class SearchFragment : Fragment() {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle?, savedInstanceState: Bundle?,
): View? { ): View? {
context?.updateLocale()
searchViewModel = searchViewModel =
ViewModelProvider(this).get(SearchViewModel::class.java) ViewModelProvider(this).get(SearchViewModel::class.java)
activity?.window?.setSoftInputMode( activity?.window?.setSoftInputMode(

View file

@ -7,7 +7,6 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.MainActivity.Companion.setLocale import com.lagradost.cloudstream3.MainActivity.Companion.setLocale
import com.lagradost.cloudstream3.MainActivity.Companion.showToast import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
@ -21,7 +20,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
var count = 0 var count = 0
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
context?.updateLocale()
hideKeyboard() hideKeyboard()
setPreferencesFromResource(R.xml.settings, rootKey) setPreferencesFromResource(R.xml.settings, rootKey)
val updatePreference = findPreference<Preference>(getString(R.string.manual_check_update_key))!! val updatePreference = findPreference<Preference>(getString(R.string.manual_check_update_key))!!

View file

@ -22,7 +22,6 @@ import com.google.android.exoplayer2.ui.CaptionStyleCompat
import com.jaredrummler.android.colorpicker.ColorPickerDialog import com.jaredrummler.android.colorpicker.ColorPickerDialog
import com.lagradost.cloudstream3.MainActivity import com.lagradost.cloudstream3.MainActivity
import com.lagradost.cloudstream3.MainActivity.Companion.showToast import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.setKey import com.lagradost.cloudstream3.utils.DataStore.setKey
@ -175,7 +174,6 @@ class SubtitlesFragment : Fragment() {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle?, savedInstanceState: Bundle?,
): View? { ): View? {
context?.updateLocale()
return inflater.inflate(R.layout.subtitle_settings, container, false) return inflater.inflate(R.layout.subtitle_settings, container, false)
} }

View file

@ -28,7 +28,7 @@ class HttpSession {
} }
} }
public val sessionCookies = CookieJar() val sessionCookies = CookieJar()
fun get( fun get(
url: String, headers: Map<String, String?> = mapOf(), url: String, headers: Map<String, String?> = mapOf(),

View file

@ -1,12 +1,10 @@
package com.lagradost.cloudstream3.utils package com.lagradost.cloudstream3.utils
import java.lang.Exception import com.lagradost.cloudstream3.mvvm.logError
import java.util.*
import javax.crypto.Cipher import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec import javax.crypto.spec.SecretKeySpec
import kotlin.math.pow import kotlin.math.pow
import com.lagradost.cloudstream3.mvvm.logError
class M3u8Helper { class M3u8Helper {
@ -53,7 +51,7 @@ class M3u8Helper {
return st != null && (st.value.isNotEmpty() || st.destructured.component1() != "NONE") return st != null && (st.value.isNotEmpty() || st.destructured.component1() != "NONE")
} }
public data class M3u8Stream( data class M3u8Stream(
val streamUrl: String, val streamUrl: String,
val quality: Int? = null, val quality: Int? = null,
val headers: Map<String, String> = mapOf() val headers: Map<String, String> = mapOf()
@ -79,7 +77,7 @@ class M3u8Helper {
return url.contains("https://") && url.contains("http://") return url.contains("https://") && url.contains("http://")
} }
public fun m3u8Generation(m3u8: M3u8Stream): List<M3u8Stream> { fun m3u8Generation(m3u8: M3u8Stream): List<M3u8Stream> {
val generate = sequence { val generate = sequence {
val m3u8Parent = getParentLink(m3u8.streamUrl) val m3u8Parent = getParentLink(m3u8.streamUrl)
val response = khttp.get(m3u8.streamUrl, headers = m3u8.headers) val response = khttp.get(m3u8.streamUrl, headers = m3u8.headers)

View file

@ -24,8 +24,6 @@ object SingleSelectionHelper {
callback: (List<Int>) -> Unit, callback: (List<Int>) -> Unit,
dismissCallback: () -> Unit dismissCallback: () -> Unit
) { ) {
this.updateLocale()
val realShowApply = showApply || isMultiSelect val realShowApply = showApply || isMultiSelect
val listView = dialog.findViewById<ListView>(R.id.listview1)!! val listView = dialog.findViewById<ListView>(R.id.listview1)!!
val textView = dialog.findViewById<TextView>(R.id.text1)!! val textView = dialog.findViewById<TextView>(R.id.text1)!!
@ -100,8 +98,6 @@ object SingleSelectionHelper {
dismissCallback: () -> Unit, dismissCallback: () -> Unit,
callback: (List<Int>) -> Unit, callback: (List<Int>) -> Unit,
) { ) {
this.updateLocale()
val builder = val builder =
AlertDialog.Builder(this, R.style.AlertDialogCustom).setView(R.layout.bottom_selection_dialog) AlertDialog.Builder(this, R.style.AlertDialogCustom).setView(R.layout.bottom_selection_dialog)
@ -118,8 +114,6 @@ object SingleSelectionHelper {
dismissCallback: () -> Unit, dismissCallback: () -> Unit,
callback: (Int) -> Unit, callback: (Int) -> Unit,
) { ) {
this.updateLocale()
val builder = val builder =
AlertDialog.Builder(this, R.style.AlertDialogCustom).setView(R.layout.bottom_selection_dialog) AlertDialog.Builder(this, R.style.AlertDialogCustom).setView(R.layout.bottom_selection_dialog)
@ -145,8 +139,6 @@ object SingleSelectionHelper {
dismissCallback: () -> Unit, dismissCallback: () -> Unit,
callback: (Int) -> Unit, callback: (Int) -> Unit,
) { ) {
this.updateLocale()
val builder = val builder =
BottomSheetDialog(this) BottomSheetDialog(this)
builder.setContentView(R.layout.bottom_selection_dialog) builder.setContentView(R.layout.bottom_selection_dialog)