diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index 5a2d004c..3e02827d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -7,6 +7,7 @@ import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.content.res.ColorStateList +import android.content.res.Configuration import android.content.res.Resources import android.os.Build import android.os.Bundle @@ -23,7 +24,6 @@ import com.google.android.gms.cast.framework.CastButtonFactory import com.jaredrummler.android.colorpicker.ColorPickerDialogListener import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.APIHolder.restrictedApis -import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO import com.lagradost.cloudstream3.ui.download.DownloadChildFragment @@ -70,6 +70,11 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { onDialogDismissedEvent.invoke(dialogId) } + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + updateLocale() // android fucks me by chaining lang when rotating the phone + } + companion object { var canEnterPipMode: Boolean = false var canShowPipMode: Boolean = false @@ -186,20 +191,18 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { .remove(currentFragment) .commitAllowingStateLoss() backEvent.invoke(true) - this.updateLocale() return true } backEvent.invoke(false) - this.updateLocale() return false } override fun onBackPressed() { this.updateLocale() - if (backPressed()) return super.onBackPressed() + this.updateLocale() } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildFragment.kt index d830966c..fbb5d05a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadChildFragment.kt @@ -7,13 +7,12 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale import com.lagradost.cloudstream3.R -import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.DataStore.getKey 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.VideoDownloadManager 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? { - context?.updateLocale() - return inflater.inflate(R.layout.fragment_child_downloads, container, false) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt index 98962e31..3cd7e04d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt @@ -10,7 +10,6 @@ import androidx.lifecycle.ViewModelProvider import androidx.navigation.findNavController import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.isMovieType import com.lagradost.cloudstream3.mvvm.observe @@ -61,8 +60,6 @@ class DownloadFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - context?.updateLocale() - downloadsViewModel = ViewModelProvider(this).get(DownloadViewModel::class.java) observe(downloadsViewModel.noDownloadsText) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index 79907c5c..c0430f38 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -19,7 +19,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.APIHolder.apis 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.observe import com.lagradost.cloudstream3.ui.AutofitRecyclerView @@ -96,8 +95,6 @@ class HomeFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - context?.updateLocale() - homeViewModel = ViewModelProvider(this).get(HomeViewModel::class.java) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt index 481638a1..7591efe5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt @@ -68,7 +68,6 @@ import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.MainActivity.Companion.canEnterPipMode import com.lagradost.cloudstream3.MainActivity.Companion.isInPIPMode import com.lagradost.cloudstream3.MainActivity.Companion.showToast -import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.normalSafeApiCall @@ -949,8 +948,6 @@ class PlayerFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) context?.let { ctx -> - ctx.updateLocale() - setPreferredSubLanguage(ctx.getAutoSelectLanguageISO639_1()) } @@ -2048,8 +2045,6 @@ class PlayerFragment : Fragment() { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - context?.updateLocale() - return inflater.inflate(R.layout.fragment_player, container, false) } } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index 631dbcfe..b52c6630 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -1,8 +1,11 @@ package com.lagradost.cloudstream3.ui.result 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.Intent import android.content.Intent.* import android.net.Uri import android.os.Bundle @@ -32,7 +35,6 @@ import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.APIHolder.getApiFromName import com.lagradost.cloudstream3.APIHolder.getId 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.observe import com.lagradost.cloudstream3.ui.WatchType @@ -169,8 +171,6 @@ class ResultFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle?, ): View? { - context?.updateLocale() - viewModel = ViewModelProvider(activity ?: this).get(ResultViewModel::class.java) return inflater.inflate(R.layout.fragment_result, container, false) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt index 1744e891..9949627b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt @@ -21,7 +21,6 @@ import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.APIHolder.getApiSettings import com.lagradost.cloudstream3.APIHolder.getApiTypeSettings import com.lagradost.cloudstream3.HomePageList -import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.TvType 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.hideKeyboard import kotlinx.android.synthetic.main.fragment_search.* -import java.util.HashSet class SearchFragment : Fragment() { private lateinit var searchViewModel: SearchViewModel @@ -48,8 +46,6 @@ class SearchFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle?, ): View? { - context?.updateLocale() - searchViewModel = ViewModelProvider(this).get(SearchViewModel::class.java) activity?.window?.setSoftInputMode( diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt index 50478783..5363c413 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt @@ -7,7 +7,6 @@ import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceManager import com.lagradost.cloudstream3.MainActivity.Companion.setLocale import com.lagradost.cloudstream3.MainActivity.Companion.showToast -import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment @@ -21,7 +20,6 @@ class SettingsFragment : PreferenceFragmentCompat() { var count = 0 override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - context?.updateLocale() hideKeyboard() setPreferencesFromResource(R.xml.settings, rootKey) val updatePreference = findPreference(getString(R.string.manual_check_update_key))!! diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt index 068775f2..4a2d4b32 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt @@ -22,7 +22,6 @@ import com.google.android.exoplayer2.ui.CaptionStyleCompat import com.jaredrummler.android.colorpicker.ColorPickerDialog import com.lagradost.cloudstream3.MainActivity import com.lagradost.cloudstream3.MainActivity.Companion.showToast -import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.setKey @@ -175,7 +174,6 @@ class SubtitlesFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle?, ): View? { - context?.updateLocale() return inflater.inflate(R.layout.subtitle_settings, container, false) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/HttpSession.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/HttpSession.kt index 9c5c0079..bb19a070 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/HttpSession.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/HttpSession.kt @@ -28,7 +28,7 @@ class HttpSession { } } - public val sessionCookies = CookieJar() + val sessionCookies = CookieJar() fun get( url: String, headers: Map = mapOf(), diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt index 0f1980d0..cc97fa07 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt @@ -1,12 +1,10 @@ package com.lagradost.cloudstream3.utils -import java.lang.Exception -import java.util.* +import com.lagradost.cloudstream3.mvvm.logError import javax.crypto.Cipher import javax.crypto.spec.IvParameterSpec import javax.crypto.spec.SecretKeySpec import kotlin.math.pow -import com.lagradost.cloudstream3.mvvm.logError class M3u8Helper { @@ -53,7 +51,7 @@ class M3u8Helper { return st != null && (st.value.isNotEmpty() || st.destructured.component1() != "NONE") } - public data class M3u8Stream( + data class M3u8Stream( val streamUrl: String, val quality: Int? = null, val headers: Map = mapOf() @@ -79,7 +77,7 @@ class M3u8Helper { return url.contains("https://") && url.contains("http://") } - public fun m3u8Generation(m3u8: M3u8Stream): List { + fun m3u8Generation(m3u8: M3u8Stream): List { val generate = sequence { val m3u8Parent = getParentLink(m3u8.streamUrl) val response = khttp.get(m3u8.streamUrl, headers = m3u8.headers) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt index 6378c2bf..439ee7db 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt @@ -24,8 +24,6 @@ object SingleSelectionHelper { callback: (List) -> Unit, dismissCallback: () -> Unit ) { - this.updateLocale() - val realShowApply = showApply || isMultiSelect val listView = dialog.findViewById(R.id.listview1)!! val textView = dialog.findViewById(R.id.text1)!! @@ -100,8 +98,6 @@ object SingleSelectionHelper { dismissCallback: () -> Unit, callback: (List) -> Unit, ) { - this.updateLocale() - val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom).setView(R.layout.bottom_selection_dialog) @@ -118,8 +114,6 @@ object SingleSelectionHelper { dismissCallback: () -> Unit, callback: (Int) -> Unit, ) { - this.updateLocale() - val builder = AlertDialog.Builder(this, R.style.AlertDialogCustom).setView(R.layout.bottom_selection_dialog) @@ -145,8 +139,6 @@ object SingleSelectionHelper { dismissCallback: () -> Unit, callback: (Int) -> Unit, ) { - this.updateLocale() - val builder = BottomSheetDialog(this) builder.setContentView(R.layout.bottom_selection_dialog)