small UI fix and download fix

This commit is contained in:
LagradOst 2021-10-31 19:28:35 +01:00
parent bd8350f255
commit 3cf79fa5b2
8 changed files with 68 additions and 36 deletions

View file

@ -36,11 +36,13 @@ object DownloadButtonSetup {
builder.setTitle(R.string.delete_file)
.setMessage(
ctx.getString(R.string.delete_message).format(ctx.getNameFull(
ctx.getString(R.string.delete_message).format(
ctx.getNameFull(
click.data.name,
click.data.episode,
click.data.season
))
)
)
)
.setPositiveButton(R.string.delete, dialogClickListener)
.setNegativeButton(R.string.cancel, dialogClickListener)
@ -54,6 +56,11 @@ object DownloadButtonSetup {
}
DOWNLOAD_ACTION_RESUME_DOWNLOAD -> {
activity?.let { ctx ->
if (VideoDownloadManager.downloadStatus.containsKey(id) && VideoDownloadManager.downloadStatus[id] == VideoDownloadManager.DownloadType.IsPaused) {
VideoDownloadManager.downloadEvent.invoke(
Pair(click.data.id, VideoDownloadManager.DownloadActionType.Resume)
)
} else {
val pkg = VideoDownloadManager.getDownloadResumePackage(ctx, id)
if (pkg != null) {
VideoDownloadManager.downloadFromResumeUsingWorker(ctx, pkg)
@ -64,6 +71,7 @@ object DownloadButtonSetup {
}
}
}
}
DOWNLOAD_ACTION_LONG_CLICK -> {
activity?.let { act ->
val length =
@ -86,7 +94,8 @@ object DownloadButtonSetup {
click.data.id.toString()
) ?: return
act.navigate(R.id.global_to_navigation_player, PlayerFragment.newInstance(
act.navigate(
R.id.global_to_navigation_player, PlayerFragment.newInstance(
UriData(
info.path.toString(),
keyInfo.relativePath,
@ -98,7 +107,8 @@ object DownloadButtonSetup {
click.data.season
),
act.getViewPos(click.data.id)?.position ?: 0
))
)
)
}
}
}

View file

@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
@ -15,8 +16,9 @@ import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.isMovieType
import com.lagradost.cloudstream3.mvvm.observe
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
import com.lagradost.cloudstream3.utils.AppUtils.loadResult
import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE
import com.lagradost.cloudstream3.utils.DataStore.getFolderName
import com.lagradost.cloudstream3.utils.DataStore
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
import com.lagradost.cloudstream3.utils.VideoDownloadHelper
@ -99,13 +101,24 @@ class DownloadFragment : Fragment() {
DownloadHeaderAdapter(
ArrayList(),
{ click ->
when (click.action) {
0 -> {
if (click.data.type.isMovieType()) {
//wont be called
} else {
val folder = getFolderName(DOWNLOAD_EPISODE_CACHE, click.data.id.toString())
val folder = DataStore.getFolderName(DOWNLOAD_EPISODE_CACHE, click.data.id.toString())
val navController = activity?.findNavController(R.id.nav_host_fragment)
navController?.navigate(R.id.navigation_download_child, DownloadChildFragment.newInstance(click.data.name,folder))
navController?.navigate(
R.id.navigation_download_child,
DownloadChildFragment.newInstance(click.data.name, folder)
)
}
}
1 -> {
(activity as AppCompatActivity?)?.loadResult(click.data.url, click.data.apiName)
}
}
},
{ downloadClickEvent ->
if (downloadClickEvent.data !is VideoDownloadHelper.DownloadEpisodeCached) return@DownloadHeaderAdapter

View file

@ -105,6 +105,9 @@ class DownloadHeaderAdapter(
val d = card.data
poster?.setImage(d.poster)
poster?.setOnClickListener {
clickCallback.invoke(DownloadHeaderClickEvent(1, d))
}
title.text = d.name
val mbString = "%.1f".format(card.totalBytes / 1000000f)

View file

@ -85,6 +85,8 @@
android:visibility="visible"
/>
<ImageView
android:tint="?attr/white"
android:visibility="visible"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"

View file

@ -40,7 +40,7 @@
<View
android:layout_weight="0.5"
android:id="@+id/download_used"
android:background="@color/usedStorageColor"
android:background="?attr/white"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<View
@ -52,7 +52,7 @@
<View
android:id="@+id/download_free"
android:layout_weight="0.10"
android:background="@color/freeStorageColor"
android:background="?attr/grayTextColor"
android:layout_width="0dp"
android:layout_height="match_parent"/>
</LinearLayout>
@ -65,7 +65,7 @@
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_gravity="center_vertical"
android:background="@color/usedStorageColor"
android:background="?attr/white"
android:layout_width="10dp"
android:layout_height="10dp"/>
<TextView
@ -94,7 +94,7 @@
<View
android:layout_margin="5dp"
android:layout_gravity="center_vertical"
android:background="@color/freeStorageColor"
android:background="?attr/grayTextColor"
android:layout_width="10dp"
android:layout_height="10dp"/>
<TextView

View file

@ -109,6 +109,8 @@
android:nextFocusLeft="@id/episode_holder"
android:nextFocusRight="@id/episode_holder"
android:tint="?attr/white"
android:id="@+id/result_episode_download"
android:visibility="visible"
android:layout_marginEnd="10dp"

View file

@ -113,6 +113,8 @@
android:nextFocusRight="@id/episode_holder"
android:id="@+id/result_episode_download"
android:tint="?attr/white"
android:visibility="visible"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"

View file

@ -37,8 +37,8 @@
<color name="iconColor">#9ba0a6</color>
<color name="usedStorageColor">#FFF</color>
<color name="freeStorageColor">#676767</color>
<!-- <color name="usedStorageColor">?attr/white</color>#fff-->
<!-- <color name="freeStorageColor">?attr/grayTextColor</color> #676767-->
<!--Light Mode -->
<color name="lightPrimaryGrayBackground">#f1f1f1</color>