forked from recloudstream/cloudstream
		
	fixed lang bug
This commit is contained in:
		
							parent
							
								
									672dc995a5
								
							
						
					
					
						commit
						960a71a2d7
					
				
					 12 changed files with 16 additions and 45 deletions
				
			
		|  | @ -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?) { | ||||
|  |  | |||
|  | @ -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) | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -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) | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) | ||||
|     } | ||||
| } | ||||
|  | @ -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) | ||||
|  |  | |||
|  | @ -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( | ||||
|  |  | |||
|  | @ -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<Preference>(getString(R.string.manual_check_update_key))!! | ||||
|  |  | |||
|  | @ -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) | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -28,7 +28,7 @@ class HttpSession { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public val sessionCookies = CookieJar() | ||||
|     val sessionCookies = CookieJar() | ||||
| 
 | ||||
|     fun get( | ||||
|         url: String, headers: Map<String, String?> = mapOf(), | ||||
|  |  | |||
|  | @ -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<String, String> = mapOf() | ||||
|  | @ -79,7 +77,7 @@ class M3u8Helper { | |||
|         return url.contains("https://") && url.contains("http://") | ||||
|     } | ||||
| 
 | ||||
|     public fun m3u8Generation(m3u8: M3u8Stream): List<M3u8Stream> { | ||||
|     fun m3u8Generation(m3u8: M3u8Stream): List<M3u8Stream> { | ||||
|         val generate = sequence { | ||||
|             val m3u8Parent = getParentLink(m3u8.streamUrl) | ||||
|             val response = khttp.get(m3u8.streamUrl, headers = m3u8.headers) | ||||
|  |  | |||
|  | @ -24,8 +24,6 @@ object SingleSelectionHelper { | |||
|         callback: (List<Int>) -> Unit, | ||||
|         dismissCallback: () -> Unit | ||||
|     ) { | ||||
|         this.updateLocale() | ||||
| 
 | ||||
|         val realShowApply = showApply || isMultiSelect | ||||
|         val listView = dialog.findViewById<ListView>(R.id.listview1)!! | ||||
|         val textView = dialog.findViewById<TextView>(R.id.text1)!! | ||||
|  | @ -100,8 +98,6 @@ object SingleSelectionHelper { | |||
|         dismissCallback: () -> Unit, | ||||
|         callback: (List<Int>) -> 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) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue