Merge branch 'recloudstream:master' into master
This commit is contained in:
commit
569efdabb8
|
@ -1203,9 +1203,12 @@ data class AnimeLoadResponse(
|
|||
override var backgroundPosterUrl: String? = null,
|
||||
) : LoadResponse, EpisodeResponse
|
||||
|
||||
/**
|
||||
* If episodes already exist appends the list.
|
||||
* */
|
||||
fun AnimeLoadResponse.addEpisodes(status: DubStatus, episodes: List<Episode>?) {
|
||||
if (episodes.isNullOrEmpty()) return
|
||||
this.episodes[status] = episodes
|
||||
this.episodes[status] = (this.episodes[status] ?: emptyList()) + episodes
|
||||
}
|
||||
|
||||
suspend fun MainAPI.newAnimeLoadResponse(
|
||||
|
|
|
@ -1592,8 +1592,8 @@ class ResultViewModel2 : ViewModel() {
|
|||
val idIndex = ep.key.id
|
||||
for ((index, i) in ep.value.withIndex()) {
|
||||
val episode = i.episode ?: (index + 1)
|
||||
val id = mainId + episode + idIndex * 1000000
|
||||
if (!existingEpisodes.contains(episode)) {
|
||||
val id = mainId + episode + idIndex * 1_000_000 + (i.season?.times(10_000) ?: 0)
|
||||
if (!existingEpisodes.contains(id)) {
|
||||
existingEpisodes.add(id)
|
||||
val seasonData = loadResponse.seasonNames.getSeason(i.season)
|
||||
val eps =
|
||||
|
@ -1602,7 +1602,7 @@ class ResultViewModel2 : ViewModel() {
|
|||
filterName(i.name),
|
||||
i.posterUrl,
|
||||
episode,
|
||||
null,
|
||||
seasonData?.season ?: i.season,
|
||||
if (seasonData != null) seasonData.displaySeason else i.season,
|
||||
i.data,
|
||||
loadResponse.apiName,
|
||||
|
@ -1615,7 +1615,7 @@ class ResultViewModel2 : ViewModel() {
|
|||
mainId
|
||||
)
|
||||
|
||||
val season = eps.season ?: 0
|
||||
val season = eps.seasonIndex ?: 0
|
||||
val indexer = EpisodeIndexer(ep.key, season)
|
||||
episodes[indexer]?.add(eps) ?: run {
|
||||
episodes[indexer] = mutableListOf(eps)
|
||||
|
@ -1630,14 +1630,13 @@ class ResultViewModel2 : ViewModel() {
|
|||
mutableMapOf()
|
||||
val existingEpisodes = HashSet<Int>()
|
||||
for ((index, episode) in loadResponse.episodes.sortedBy {
|
||||
(it.season?.times(10000) ?: 0) + (it.episode ?: 0)
|
||||
(it.season?.times(10_000) ?: 0) + (it.episode ?: 0)
|
||||
}.withIndex()) {
|
||||
val episodeIndex = episode.episode ?: (index + 1)
|
||||
val id =
|
||||
mainId + (episode.season?.times(100000) ?: 0) + episodeIndex + 1
|
||||
mainId + (episode.season?.times(100_000) ?: 0) + episodeIndex + 1
|
||||
if (!existingEpisodes.contains(id)) {
|
||||
existingEpisodes.add(id)
|
||||
val seasonIndex = episode.season?.minus(1)
|
||||
val seasonData =
|
||||
loadResponse.seasonNames.getSeason(episode.season)
|
||||
|
||||
|
@ -1647,7 +1646,7 @@ class ResultViewModel2 : ViewModel() {
|
|||
filterName(episode.name),
|
||||
episode.posterUrl,
|
||||
episodeIndex,
|
||||
seasonIndex,
|
||||
seasonData?.season ?: episode.season,
|
||||
if (seasonData != null) seasonData.displaySeason else episode.season,
|
||||
episode.data,
|
||||
loadResponse.apiName,
|
||||
|
@ -1660,7 +1659,7 @@ class ResultViewModel2 : ViewModel() {
|
|||
mainId
|
||||
)
|
||||
|
||||
val season = episode.season ?: 0
|
||||
val season = ep.seasonIndex ?: 0
|
||||
val indexer = EpisodeIndexer(DubStatus.None, season)
|
||||
|
||||
episodes[indexer]?.add(ep) ?: kotlin.run {
|
||||
|
|
|
@ -200,16 +200,23 @@ class InAppUpdater {
|
|||
private suspend fun Activity.downloadUpdate(url: String): Boolean {
|
||||
try {
|
||||
Log.d(LOG_TAG, "Downloading update: $url")
|
||||
val appUpdateName = "CloudStream"
|
||||
val appUpdateSuffix = "apk"
|
||||
|
||||
val localContext = this
|
||||
// Delete all old updates
|
||||
this.cacheDir.listFiles()?.filter {
|
||||
it.name.startsWith(appUpdateName) && it.extension == appUpdateSuffix
|
||||
}?.forEach {
|
||||
it.deleteOnExit()
|
||||
}
|
||||
|
||||
val downloadedFile = File.createTempFile("CloudStream", ".apk")
|
||||
val downloadedFile = File.createTempFile(appUpdateName, ".$appUpdateSuffix")
|
||||
val sink: BufferedSink = downloadedFile.sink().buffer()
|
||||
|
||||
updateLock.withLock {
|
||||
sink.writeAll(app.get(url).body.source())
|
||||
sink.close()
|
||||
openApk(localContext, Uri.fromFile(downloadedFile))
|
||||
openApk(this, Uri.fromFile(downloadedFile))
|
||||
}
|
||||
return true
|
||||
} catch (e: Exception) {
|
||||
|
|
|
@ -1,131 +1,134 @@
|
|||
<?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"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_rowWeight="1"
|
||||
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:textColor="?attr/textColor"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="Test" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/WhiteButton"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
app:icon="@drawable/ic_baseline_add_24"
|
||||
android:text="@string/create_account"
|
||||
android:id="@+id/create_account"
|
||||
android:layout_width="wrap_content" />
|
||||
</FrameLayout>
|
||||
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_marginBottom="60dp"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:textColorHint="?attr/grayTextColor"
|
||||
android:hint="@string/example_username"
|
||||
android:autofillHints="username"
|
||||
android:id="@+id/login_username_input"
|
||||
android:nextFocusRight="@id/cancel_btt"
|
||||
android:nextFocusLeft="@id/apply_btt"
|
||||
android:nextFocusDown="@id/login_email_input"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"
|
||||
tools:ignore="LabelFor" />
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
<EditText
|
||||
android:textColorHint="?attr/grayTextColor"
|
||||
android:autofillHints="emailAddress"
|
||||
android:hint="@string/example_email"
|
||||
android:id="@+id/login_email_input"
|
||||
android:nextFocusRight="@id/cancel_btt"
|
||||
android:nextFocusLeft="@id/apply_btt"
|
||||
android:nextFocusUp="@id/login_username_input"
|
||||
android:nextFocusDown="@id/login_server_input"
|
||||
android:layout_rowWeight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textEmailAddress"
|
||||
tools:ignore="LabelFor" />
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:textColor="?attr/textColor"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="Test" />
|
||||
|
||||
<EditText
|
||||
android:textColorHint="?attr/grayTextColor"
|
||||
android:hint="@string/example_ip"
|
||||
android:id="@+id/login_server_input"
|
||||
android:nextFocusRight="@id/cancel_btt"
|
||||
android:nextFocusLeft="@id/apply_btt"
|
||||
android:nextFocusUp="@id/login_email_input"
|
||||
android:nextFocusDown="@id/login_password_input"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textUri"
|
||||
tools:ignore="LabelFor" />
|
||||
|
||||
<EditText
|
||||
android:textColorHint="?attr/grayTextColor"
|
||||
android:hint="@string/example_password"
|
||||
android:id="@+id/login_password_input"
|
||||
android:nextFocusRight="@id/cancel_btt"
|
||||
android:nextFocusLeft="@id/apply_btt"
|
||||
android:nextFocusUp="@id/login_server_input"
|
||||
android:nextFocusDown="@id/apply_btt"
|
||||
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textVisiblePassword"
|
||||
tools:ignore="LabelFor"
|
||||
android:autofillHints="password" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/create_account"
|
||||
style="@style/WhiteButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:text="@string/create_account"
|
||||
app:icon="@drawable/ic_baseline_add_24" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/apply_btt_holder"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="bottom|end"
|
||||
android:layout_marginTop="-60dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginBottom="60dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/login_username_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp">
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="username"
|
||||
android:hint="@string/example_username"
|
||||
android:inputType="text"
|
||||
android:nextFocusLeft="@id/apply_btt"
|
||||
android:nextFocusRight="@id/cancel_btt"
|
||||
android:nextFocusDown="@id/login_email_input"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:textColorHint="?attr/grayTextColor"
|
||||
tools:ignore="LabelFor" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/login_email_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="emailAddress"
|
||||
android:hint="@string/example_email"
|
||||
android:inputType="textEmailAddress"
|
||||
android:nextFocusLeft="@id/apply_btt"
|
||||
android:nextFocusRight="@id/cancel_btt"
|
||||
|
||||
android:nextFocusUp="@id/login_username_input"
|
||||
android:nextFocusDown="@id/login_server_input"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:textColorHint="?attr/grayTextColor"
|
||||
tools:ignore="LabelFor" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/login_server_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/example_ip"
|
||||
android:inputType="textUri"
|
||||
android:nextFocusLeft="@id/apply_btt"
|
||||
android:nextFocusRight="@id/cancel_btt"
|
||||
android:nextFocusUp="@id/login_email_input"
|
||||
android:nextFocusDown="@id/login_password_input"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:textColorHint="?attr/grayTextColor"
|
||||
tools:ignore="LabelFor" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/login_password_input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="password"
|
||||
android:hint="@string/example_password"
|
||||
android:inputType="textVisiblePassword"
|
||||
android:nextFocusLeft="@id/apply_btt"
|
||||
|
||||
android:nextFocusRight="@id/cancel_btt"
|
||||
android:nextFocusUp="@id/login_server_input"
|
||||
android:nextFocusDown="@id/apply_btt"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:textColorHint="?attr/grayTextColor"
|
||||
tools:ignore="LabelFor" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/apply_btt_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginTop="-60dp"
|
||||
android:gravity="bottom|end"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/WhiteButton"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:text="@string/login"
|
||||
android:id="@+id/apply_btt"
|
||||
android:layout_width="wrap_content" />
|
||||
android:id="@+id/apply_btt"
|
||||
style="@style/WhiteButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:text="@string/login" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/BlackButton"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:text="@string/sort_cancel"
|
||||
android:id="@+id/cancel_btt"
|
||||
android:layout_width="wrap_content" />
|
||||
android:id="@+id/cancel_btt"
|
||||
style="@style/BlackButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:text="@string/sort_cancel" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue