mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	code cleanup
This commit is contained in:
		
							parent
							
								
									7b62788f0b
								
							
						
					
					
						commit
						96dd822fa1
					
				
					 35 changed files with 72 additions and 110 deletions
				
			
		|  | @ -8,7 +8,6 @@ import com.lagradost.cloudstream3.mvvm.normalSafeApiCall | |||
| import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread | ||||
| import org.acra.ReportField | ||||
| import org.acra.config.CoreConfiguration | ||||
| import org.acra.config.toast | ||||
| import org.acra.data.CrashReportData | ||||
| import org.acra.data.StringFormat | ||||
| import org.acra.ktx.initAcra | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ package com.lagradost.cloudstream3 | |||
| import android.app.Activity | ||||
| import android.app.PictureInPictureParams | ||||
| import android.content.ComponentName | ||||
| import android.content.Context | ||||
| import android.content.Intent | ||||
| import android.content.pm.PackageManager | ||||
| import android.content.res.ColorStateList | ||||
|  | @ -76,6 +75,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { | |||
|         lateinit var navOptions: NavOptions | ||||
| 
 | ||||
|         var currentToast: Toast? = null | ||||
| 
 | ||||
|         fun showToast(act: Activity?, @StringRes message: Int, duration: Int) { | ||||
|             if (act == null) return | ||||
|             showToast(act, act.getString(message), duration) | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ class GogoanimeProvider : MainAPI() { | |||
|             TvType.ONA | ||||
|         ) | ||||
| 
 | ||||
|     override fun getMainPage(): HomePageResponse? { | ||||
|     override fun getMainPage(): HomePageResponse { | ||||
|         val headers = mapOf( | ||||
|             "authority" to "ajax.gogo-load.com", | ||||
|             "sec-ch-ua" to "\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\"", | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ class WcoStream : ExtractorApi() { | |||
| 
 | ||||
|         val html = khttp.get(url, headers = mapOf("Referer" to "https://wcostream.cc/")).text | ||||
|         val (Id) = "/e/(.*?)?domain".toRegex().find(url)!!.destructured | ||||
|         val (skey) = """skey\s=\s['\"](.*?)['\"];""".toRegex().find(html)!!.destructured | ||||
|         val (skey) = """skey\s=\s['"](.*?)['"];""".toRegex().find(html)!!.destructured | ||||
| 
 | ||||
|         val apiLink = "$baseUrl/info/$Id?domain=wcostream.cc&skey=$skey" | ||||
|         val referrer = "$baseUrl/e/$Id?domain=wcostream.cc" | ||||
|  |  | |||
|  | @ -37,7 +37,7 @@ class XStreamCdn : ExtractorApi() { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     override fun getUrl(url: String, referer: String?): List<ExtractorLink>? { | ||||
|     override fun getUrl(url: String, referer: String?): List<ExtractorLink> { | ||||
|         val headers = mapOf( | ||||
|             "Referer" to url, | ||||
|             "User-Agent" to "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0", | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ package com.lagradost.cloudstream3.mvvm | |||
| import android.util.Log | ||||
| import androidx.lifecycle.LifecycleOwner | ||||
| import androidx.lifecycle.LiveData | ||||
| import androidx.lifecycle.Observer | ||||
| import com.bumptech.glide.load.HttpException | ||||
| import com.lagradost.cloudstream3.ErrorLoadingException | ||||
| import kotlinx.coroutines.Dispatchers | ||||
|  | @ -12,11 +11,11 @@ import java.net.SocketTimeoutException | |||
| import java.net.UnknownHostException | ||||
| 
 | ||||
| fun <T> LifecycleOwner.observe(liveData: LiveData<T>, action: (t: T) -> Unit) { | ||||
|     liveData.observe(this, Observer { it?.let { t -> action(t) } }) | ||||
|     liveData.observe(this) { it?.let { t -> action(t) } } | ||||
| } | ||||
| 
 | ||||
| fun <T> LifecycleOwner.observeDirectly(liveData: LiveData<T>, action: (t: T) -> Unit) { | ||||
|     liveData.observe(this, Observer { it?.let { t -> action(t) } }) | ||||
|     liveData.observe(this) { it?.let { t -> action(t) } } | ||||
|     val currentValue = liveData.value | ||||
|     if (currentValue != null) | ||||
|         action(currentValue) | ||||
|  | @ -64,7 +63,7 @@ suspend fun <T> safeApiCall( | |||
|                     Resource.Failure(true, null, null, "Please try again later.") | ||||
|                 } | ||||
|                 is HttpException -> { | ||||
|                     Resource.Failure(false, throwable.statusCode, null, throwable.localizedMessage) | ||||
|                     Resource.Failure(false, throwable.statusCode, null, throwable.localizedMessage ?: "") | ||||
|                 } | ||||
|                 is UnknownHostException -> { | ||||
|                     Resource.Failure(true, null, null, "Cannot connect to server, try again later.") | ||||
|  | @ -76,7 +75,7 @@ suspend fun <T> safeApiCall( | |||
|                     Resource.Failure(false, null, null, "This operation is not implemented.") | ||||
|                 } | ||||
|                 else -> { | ||||
|                     val stackTraceMsg = throwable.localizedMessage + "\n\n" + throwable.stackTrace.joinToString( | ||||
|                     val stackTraceMsg = (throwable.localizedMessage ?: "") + "\n\n" + throwable.stackTrace.joinToString( | ||||
|                         separator = "\n" | ||||
|                     ) { | ||||
|                         "${it.fileName} ${it.lineNumber}" | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ package com.lagradost.cloudstream3.receivers | |||
| import android.content.BroadcastReceiver | ||||
| import android.content.Context | ||||
| import android.content.Intent | ||||
| import android.os.Build | ||||
| import android.util.Log | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ class MyMiniControllerFragment : MiniControllerFragment() { | |||
|         if (obtainStyledAttributes.hasValue(R.styleable.CustomCast_customCastBackgroundColor)) { | ||||
|             currentColor = obtainStyledAttributes.getColor(R.styleable.CustomCast_customCastBackgroundColor, 0) | ||||
|         } | ||||
| 
 | ||||
|         obtainStyledAttributes.recycle() | ||||
|         super.onInflate(context, attributeSet, bundle) | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -7,7 +7,6 @@ import androidx.lifecycle.LiveData | |||
| import androidx.lifecycle.MutableLiveData | ||||
| import androidx.lifecycle.ViewModel | ||||
| import androidx.lifecycle.viewModelScope | ||||
| import com.lagradost.cloudstream3.TvType | ||||
| import com.lagradost.cloudstream3.isMovieType | ||||
| import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE | ||||
| import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE | ||||
|  |  | |||
|  | @ -9,10 +9,9 @@ import android.widget.TextView | |||
| import androidx.core.widget.ContentLoadingProgressBar | ||||
| import com.google.android.material.button.MaterialButton | ||||
| import com.lagradost.cloudstream3.R | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons | ||||
| import com.lagradost.cloudstream3.utils.Coroutines | ||||
| import com.lagradost.cloudstream3.utils.IDisposable | ||||
| import com.lagradost.cloudstream3.utils.VideoDownloadHelper | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons | ||||
| import com.lagradost.cloudstream3.utils.VideoDownloadManager | ||||
| 
 | ||||
| class EasyDownloadButton : IDisposable { | ||||
|  |  | |||
|  | @ -3,19 +3,11 @@ package com.lagradost.cloudstream3.ui.home | |||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import android.widget.ImageView | ||||
| import android.widget.TextView | ||||
| import androidx.cardview.widget.CardView | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import com.bumptech.glide.Glide | ||||
| import com.bumptech.glide.load.model.GlideUrl | ||||
| import com.lagradost.cloudstream3.* | ||||
| import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_LOAD | ||||
| import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_SHOW_METADATA | ||||
| import com.lagradost.cloudstream3.R | ||||
| import com.lagradost.cloudstream3.SearchResponse | ||||
| import com.lagradost.cloudstream3.ui.search.SearchClickCallback | ||||
| import com.lagradost.cloudstream3.ui.search.SearchResultBuilder | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.setImage | ||||
| import kotlinx.android.synthetic.main.home_result_grid.view.* | ||||
| 
 | ||||
| class HomeChildItemAdapter( | ||||
|     var cardList: List<SearchResponse>, | ||||
|  |  | |||
|  | @ -8,7 +8,6 @@ import android.widget.TextView | |||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import com.lagradost.cloudstream3.HomePageList | ||||
| import com.lagradost.cloudstream3.R | ||||
| import com.lagradost.cloudstream3.SearchResponse | ||||
| import com.lagradost.cloudstream3.ui.search.SearchClickCallback | ||||
| import kotlinx.android.synthetic.main.homepage_parent.view.* | ||||
| 
 | ||||
|  |  | |||
|  | @ -853,7 +853,7 @@ class PlayerFragment : Fragment() { | |||
|             if (realLang.length == 2) SubtitleHelper.fromTwoLettersToLanguage(realLang) ?: realLang else realLang | ||||
| 
 | ||||
|         if (!this::exoPlayer.isInitialized) return | ||||
|         (exoPlayer?.trackSelector as DefaultTrackSelector?)?.let { trackSelector -> | ||||
|         (exoPlayer.trackSelector as DefaultTrackSelector?)?.let { trackSelector -> | ||||
|             if (lang.isNullOrBlank()) { | ||||
|                 trackSelector.setParameters( | ||||
|                     trackSelector.buildUponParameters() | ||||
|  | @ -1028,11 +1028,11 @@ class PlayerFragment : Fragment() { | |||
|             observeDirectly(viewModel.episodes) { _episodes -> | ||||
|                 episodes = _episodes | ||||
|                 if (isLoading) { | ||||
|                     if (playerData.episodeIndex > 0 && playerData.episodeIndex < episodes.size) { | ||||
|                     /*if (playerData.episodeIndex > 0 && playerData.episodeIndex < episodes.size) { | ||||
| 
 | ||||
|                     } else { | ||||
|                         // WHAT THE FUCK DID YOU DO | ||||
|                     } | ||||
|                     }*/ | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|  | @ -1304,11 +1304,11 @@ class PlayerFragment : Fragment() { | |||
|                     playbackPosition = if (this::exoPlayer.isInitialized) exoPlayer.currentPosition else 0 | ||||
|                     setMirrorId(sources[sourceIndex].getId()) | ||||
|                     initPlayer(getCurrentUrl()) | ||||
|                 } else { | ||||
|                 } /*else { | ||||
|                     if (isPlaying) { | ||||
|                         // exoPlayer.play() | ||||
|                     } | ||||
|                 } | ||||
|                 }*/ | ||||
| 
 | ||||
|                 if (subtitleIndex != startIndexFromMap) { | ||||
|                     setPreferredSubLanguage(if (subtitleIndex <= 0) null else currentSubtitles[subtitleIndex - 1]) | ||||
|  |  | |||
|  | @ -6,7 +6,6 @@ import android.view.View | |||
| import android.view.ViewGroup | ||||
| import android.widget.ImageView | ||||
| import android.widget.TextView | ||||
| import android.widget.Toast | ||||
| import androidx.annotation.LayoutRes | ||||
| import androidx.core.widget.ContentLoadingProgressBar | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
|  |  | |||
|  | @ -1,29 +1,17 @@ | |||
| package com.lagradost.cloudstream3.ui.search | ||||
| 
 | ||||
| import android.app.Activity | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import android.widget.FrameLayout | ||||
| import android.widget.ImageView | ||||
| import android.widget.TextView | ||||
| import androidx.cardview.widget.CardView | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import com.bumptech.glide.Glide | ||||
| import com.bumptech.glide.load.model.GlideUrl | ||||
| import com.lagradost.cloudstream3.AnimeSearchResponse | ||||
| import com.lagradost.cloudstream3.DubStatus | ||||
| import com.lagradost.cloudstream3.SearchResponse | ||||
| import com.lagradost.cloudstream3.TvType | ||||
| import com.lagradost.cloudstream3.ui.AutofitRecyclerView | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.getGridFormatId | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.toPx | ||||
| import com.lagradost.cloudstream3.ui.AutofitRecyclerView | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.setImage | ||||
| import kotlinx.android.synthetic.main.search_result_compact.view.backgroundCard | ||||
| import kotlinx.android.synthetic.main.search_result_compact.view.imageText | ||||
| import kotlinx.android.synthetic.main.search_result_compact.view.imageView | ||||
| import kotlinx.android.synthetic.main.search_result_grid.view.* | ||||
| import kotlinx.android.synthetic.main.search_result_compact.view.* | ||||
| import kotlin.math.roundToInt | ||||
| 
 | ||||
| const val SEARCH_ACTION_LOAD = 0 | ||||
|  |  | |||
|  | @ -7,7 +7,6 @@ import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_PLAY_FILE | |||
| import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick | ||||
| import com.lagradost.cloudstream3.ui.download.DownloadClickEvent | ||||
| import com.lagradost.cloudstream3.ui.result.START_ACTION_LOAD_EP | ||||
| import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST | ||||
| import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult | ||||
| import com.lagradost.cloudstream3.utils.DataStoreHelper | ||||
| import com.lagradost.cloudstream3.utils.VideoDownloadHelper | ||||
|  |  | |||
|  | @ -12,9 +12,7 @@ import android.net.NetworkCapabilities | |||
| import android.net.Uri | ||||
| import android.os.Build | ||||
| import android.provider.MediaStore | ||||
| import android.view.View | ||||
| import androidx.appcompat.app.AppCompatActivity | ||||
| import androidx.preference.PreferenceManager | ||||
| import com.google.android.gms.cast.framework.CastContext | ||||
| import com.google.android.gms.cast.framework.CastState | ||||
| import com.google.android.gms.common.ConnectionResult | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ package com.lagradost.cloudstream3.utils | |||
| 
 | ||||
| import android.content.Context | ||||
| import com.google.android.gms.cast.CastMediaControlIntent | ||||
| import com.google.android.gms.cast.LaunchOptions | ||||
| import com.google.android.gms.cast.framework.CastOptions | ||||
| import com.google.android.gms.cast.framework.OptionsProvider | ||||
| import com.google.android.gms.cast.framework.SessionProvider | ||||
|  |  | |||
|  | @ -1,6 +1,5 @@ | |||
| package com.lagradost.cloudstream3.utils | ||||
| 
 | ||||
| import com.lagradost.cloudstream3.SubtitleFile | ||||
| import com.lagradost.cloudstream3.extractors.* | ||||
| import com.lagradost.cloudstream3.mvvm.normalSafeApiCall | ||||
| 
 | ||||
|  |  | |||
|  | @ -44,13 +44,13 @@ class InAppUpdater { | |||
| 
 | ||||
|         data class GithubObject( | ||||
|             @JsonProperty("sha") val sha: String, // sha 256 hash | ||||
| 			@JsonProperty("type") val type: String, // object type | ||||
| 			@JsonProperty("url") val url: String, | ||||
|             @JsonProperty("type") val type: String, // object type | ||||
|             @JsonProperty("url") val url: String, | ||||
|         ) | ||||
| 
 | ||||
|         data class GithubTag( | ||||
|             @JsonProperty("object") val github_object: GithubObject, | ||||
|         ) | ||||
| 		 | ||||
| 		data class GithubTag( | ||||
| 			@JsonProperty("object") val github_object: GithubObject, | ||||
| 		) | ||||
| 
 | ||||
|         data class Update( | ||||
|             @JsonProperty("shouldUpdate") val shouldUpdate: Boolean, | ||||
|  | @ -80,7 +80,7 @@ class InAppUpdater { | |||
|             val url = "https://api.github.com/repos/LagradOst/CloudStream-3/releases" | ||||
|             val headers = mapOf("Accept" to "application/vnd.github.v3+json") | ||||
|             val response = | ||||
|                     mapper.readValue<List<GithubRelease>>(khttp.get(url, headers = headers).text) | ||||
|                 mapper.readValue<List<GithubRelease>>(khttp.get(url, headers = headers).text) | ||||
| 
 | ||||
|             val versionRegex = Regex("""(.*?((\d)\.(\d)\.(\d)).*\.apk)""") | ||||
| 
 | ||||
|  | @ -92,26 +92,29 @@ class InAppUpdater { | |||
|                     versionRegex.find(it.name)?.groupValues?.get(2) | ||||
|                 }).toList().lastOrNull()*/ | ||||
|             val found = | ||||
|                     response.filter { rel -> | ||||
|                         !rel.prerelease | ||||
|                     }.sortedWith(compareBy { release -> | ||||
|                         release.assets.filter { it.content_type == "application/vnd.android.package-archive" } | ||||
|                                 .getOrNull(0)?.name?.let { it1 -> | ||||
|                                     versionRegex.find( | ||||
|                                             it1 | ||||
|                                     )?.groupValues?.get(2) | ||||
|                                 } | ||||
|                     }).toList().lastOrNull() | ||||
|                 response.filter { rel -> | ||||
|                     !rel.prerelease | ||||
|                 }.sortedWith(compareBy { release -> | ||||
|                     release.assets.filter { it.content_type == "application/vnd.android.package-archive" } | ||||
|                         .getOrNull(0)?.name?.let { it1 -> | ||||
|                             versionRegex.find( | ||||
|                                 it1 | ||||
|                             )?.groupValues?.get(2) | ||||
|                         } | ||||
|                 }).toList().lastOrNull() | ||||
|             val foundAsset = found?.assets?.getOrNull(0) | ||||
|             val currentVersion = packageName?.let { | ||||
|                 packageManager.getPackageInfo(it, | ||||
|                         0) | ||||
|                 packageManager.getPackageInfo( | ||||
|                     it, | ||||
|                     0 | ||||
|                 ) | ||||
|             } | ||||
| 
 | ||||
|             val foundVersion = foundAsset?.name?.let { versionRegex.find(it) } | ||||
|             val shouldUpdate = if (found != null && foundAsset?.browser_download_url != "" && foundVersion != null) currentVersion?.versionName?.compareTo( | ||||
|             val shouldUpdate = | ||||
|                 if (found != null && foundAsset?.browser_download_url != "" && foundVersion != null) currentVersion?.versionName?.compareTo( | ||||
|                     foundVersion.groupValues[2] | ||||
|             )!! < 0 else false | ||||
|                 )!! < 0 else false | ||||
|             return if (foundVersion != null) { | ||||
|                 Update(shouldUpdate, foundAsset.browser_download_url, foundVersion.groupValues[2], found.body) | ||||
|             } else { | ||||
|  | @ -161,6 +164,7 @@ class InAppUpdater { | |||
|             val localContext = this | ||||
| 
 | ||||
|             val id = downloadManager.enqueue(request) | ||||
| 
 | ||||
|             registerReceiver( | ||||
|                 object : BroadcastReceiver() { | ||||
|                     override fun onReceive(context: Context?, intent: Intent?) { | ||||
|  | @ -173,8 +177,7 @@ class InAppUpdater { | |||
|                         val c = downloadManager.query(query) | ||||
| 
 | ||||
|                         if (c.moveToFirst()) { | ||||
|                             val columnIndex = c | ||||
|                                 .getColumnIndex(DownloadManager.COLUMN_STATUS) | ||||
|                             val columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS) | ||||
|                             if (DownloadManager.STATUS_SUCCESSFUL == c | ||||
|                                     .getInt(columnIndex) | ||||
|                             ) { | ||||
|  | @ -217,8 +220,10 @@ class InAppUpdater { | |||
|                 if (update.shouldUpdate && update.updateURL != null) { | ||||
|                     runOnUiThread { | ||||
|                         val currentVersion = packageName?.let { | ||||
|                             packageManager.getPackageInfo(it, | ||||
|                                 0) | ||||
|                             packageManager.getPackageInfo( | ||||
|                                 it, | ||||
|                                 0 | ||||
|                             ) | ||||
|                         } | ||||
| 
 | ||||
|                         val builder: AlertDialog.Builder = AlertDialog.Builder(this) | ||||
|  | @ -233,23 +238,19 @@ class InAppUpdater { | |||
|                                     val downloadStatus = context.downloadUpdate(update.updateURL) | ||||
|                                     if (!downloadStatus) { | ||||
|                                         runOnUiThread { | ||||
|                                             showToast(context, | ||||
|                                             showToast( | ||||
|                                                 context, | ||||
|                                                 "Download Failed", | ||||
|                                                 Toast.LENGTH_LONG) | ||||
|                                                 Toast.LENGTH_LONG | ||||
|                                             ) | ||||
|                                         } | ||||
|                                     } /*else { | ||||
|                                         activity.runOnUiThread { | ||||
|                                             Toast.makeText(localContext, | ||||
|                                                 "Downloaded APK", | ||||
|                                                 Toast.LENGTH_LONG).show() | ||||
|                                         } | ||||
|                                     }*/ | ||||
|                                     } | ||||
|                                 } | ||||
|                             } | ||||
| 
 | ||||
|                             setNegativeButton("Cancel") { _, _ -> } | ||||
| 
 | ||||
|                             if(checkAutoUpdate) { | ||||
|                             if (checkAutoUpdate) { | ||||
|                                 setNeutralButton("Don't show again") { _, _ -> | ||||
|                                     settingsManager.edit().putBoolean("auto_update", false).apply() | ||||
|                                 } | ||||
|  |  | |||
|  | @ -31,7 +31,7 @@ class JsUnpacker(packedJS: String?) { | |||
|         val js = packedJS | ||||
|         try { | ||||
|             var p = | ||||
|                 Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL) | ||||
|                 Pattern.compile("""}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL) | ||||
|             var m = p.matcher(js) | ||||
|             if (m.find() && m.groupCount() == 4) { | ||||
|                 val payload = m.group(1).replace("\\'", "'") | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ import android.content.Context | |||
| import android.view.View | ||||
| import android.widget.* | ||||
| import androidx.appcompat.app.AlertDialog | ||||
| import androidx.core.util.forEach | ||||
| import androidx.core.view.marginLeft | ||||
| import androidx.core.view.marginRight | ||||
| import androidx.core.view.marginTop | ||||
|  |  | |||
|  | @ -1,6 +1,5 @@ | |||
| package com.lagradost.cloudstream3.utils | ||||
| 
 | ||||
| import com.lagradost.cloudstream3.SearchResponse | ||||
| import com.lagradost.cloudstream3.TvType | ||||
| import com.lagradost.cloudstream3.ui.download.EasyDownloadButton | ||||
| 
 | ||||
|  |  | |||
|  | @ -7,7 +7,6 @@ import android.net.Uri | |||
| import android.os.Build | ||||
| import android.os.Environment | ||||
| import android.provider.MediaStore | ||||
| import android.webkit.MimeTypeMap | ||||
| import android.widget.Toast | ||||
| import androidx.annotation.DrawableRes | ||||
| import androidx.annotation.RequiresApi | ||||
|  | @ -26,7 +25,6 @@ import com.lagradost.cloudstream3.utils.DataStore.getKey | |||
| import com.lagradost.cloudstream3.utils.DataStore.removeKey | ||||
| import com.lagradost.cloudstream3.utils.DataStore.setKey | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute | ||||
| import com.lagradost.cloudstream3.utils.VideoDownloadManager.getExistingDownloadUriOrNullQ | ||||
| import kotlinx.coroutines.Dispatchers | ||||
| import kotlinx.coroutines.delay | ||||
| import kotlinx.coroutines.withContext | ||||
|  | @ -35,7 +33,6 @@ import java.lang.Thread.sleep | |||
| import java.net.URL | ||||
| import java.net.URLConnection | ||||
| import java.util.* | ||||
| import kotlin.collections.ArrayList | ||||
| 
 | ||||
| const val DOWNLOAD_CHANNEL_ID = "cloudstream3.general" | ||||
| const val DOWNLOAD_CHANNEL_NAME = "Downloads" | ||||
|  | @ -91,7 +88,7 @@ object VideoDownloadManager { | |||
|         val referer: String | ||||
|     } | ||||
| 
 | ||||
|     fun VideoDownloadManager.IDownloadableMinimum.getId(): Int { | ||||
|     fun IDownloadableMinimum.getId(): Int { | ||||
|         return url.hashCode() | ||||
|     } | ||||
| 
 | ||||
|  | @ -146,9 +143,9 @@ object VideoDownloadManager { | |||
|     private const val ERROR_CONTENT_RESOLVER_CANT_OPEN_STREAM = -8 | ||||
|     private const val ERROR_CONTENT_RESOLVER_NOT_FOUND = -9 | ||||
| 
 | ||||
|     const val KEY_RESUME_PACKAGES = "download_resume" | ||||
|     private const val KEY_RESUME_PACKAGES = "download_resume" | ||||
|     const val KEY_DOWNLOAD_INFO = "download_info" | ||||
|     const val KEY_RESUME_QUEUE_PACKAGES = "download_q_resume" | ||||
|     private const val KEY_RESUME_QUEUE_PACKAGES = "download_q_resume" | ||||
| 
 | ||||
|     val downloadStatus = HashMap<Int, DownloadType>() | ||||
|     val downloadStatusEvent = Event<Pair<Int, DownloadType>>() | ||||
|  | @ -428,7 +425,7 @@ object VideoDownloadManager { | |||
|                 ) | ||||
|             val folder = File(normalPath) | ||||
|             if (folder.isDirectory) { | ||||
|                 return folder.listFiles().map { Pair(it.name, it.toUri()) } | ||||
|                 return folder.listFiles()?.map { Pair(it.name, it.toUri()) } | ||||
|             } | ||||
|             return null | ||||
|         } | ||||
|  | @ -934,7 +931,7 @@ object VideoDownloadManager { | |||
|         context.setKey(KEY_RESUME_QUEUE_PACKAGES, dQueue) | ||||
|     } | ||||
| 
 | ||||
|     fun isMyServiceRunning(context: Context, serviceClass: Class<*>): Boolean { | ||||
|     /*fun isMyServiceRunning(context: Context, serviceClass: Class<*>): Boolean { | ||||
|         val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager? | ||||
|         for (service in manager!!.getRunningServices(Int.MAX_VALUE)) { | ||||
|             if (serviceClass.name == service.service.className) { | ||||
|  | @ -942,7 +939,7 @@ object VideoDownloadManager { | |||
|             } | ||||
|         } | ||||
|         return false | ||||
|     } | ||||
|     }*/ | ||||
| 
 | ||||
|     fun downloadEpisode( | ||||
|         context: Activity?, | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <font-family xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|              xmlns:app="http://schemas.android.com/apk/res-auto"> | ||||
| <font-family | ||||
|         xmlns:app="http://schemas.android.com/apk/res-auto"> | ||||
|     <font | ||||
|             app:fontStyle="normal" | ||||
|             app:fontWeight="100" | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         xmlns:tools="http://schemas.android.com/tools" | ||||
|         android:orientation="vertical" | ||||
|         android:layout_width="match_parent" | ||||
|         android:background="?attr/bitDarkerGrayBackground" | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" | ||||
|         android:layout_height="match_parent" | ||||
|         android:orientation="horizontal" | ||||
|         android:keepScreenOn="true" | ||||
|         app:backgroundTint="@android:color/black" | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         xmlns:tools="http://schemas.android.com/tools" | ||||
|         android:orientation="vertical" | ||||
|         android:layout_width="match_parent" | ||||
|         android:background="?attr/darkBackground" | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         xmlns:tools="http://schemas.android.com/tools" | ||||
|         android:orientation="vertical" | ||||
|         android:layout_width="match_parent" | ||||
|         android:background="@null" | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         xmlns:tools="http://schemas.android.com/tools" | ||||
|         android:orientation="vertical" | ||||
|         android:layout_width="match_parent" | ||||
|         android:background="@null" | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         xmlns:tools="http://schemas.android.com/tools" | ||||
|         android:orientation="vertical" | ||||
|         android:layout_width="match_parent" | ||||
|         android:background="?attr/bitDarkerGrayBackground" | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
|         xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" | ||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|         android:orientation="vertical" | ||||
| 
 | ||||
|         android:focusable="true" | ||||
|  |  | |||
|  | @ -9,7 +9,6 @@ | |||
| > | ||||
|     <androidx.cardview.widget.CardView | ||||
|             android:foreground="?android:attr/selectableItemBackgroundBorderless" | ||||
|             xmlns:card_view="http://schemas.android.com/apk/res-auto" | ||||
|             android:id="@+id/backgroundCard" | ||||
|             android:layout_margin="2dp" | ||||
|             android:layout_width="match_parent" | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
|         android:layout_height="match_parent" | ||||
|         android:id="@+id/subs_root" | ||||
|         android:background="?attr/bitDarkerGrayBackground" | ||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
| > | ||||
|     <LinearLayout | ||||
|             android:orientation="vertical" | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <paths xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
| <paths> | ||||
|     <external-path | ||||
|             name="external" | ||||
|             path="." /> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue