diff --git a/app/build.gradle b/app/build.gradle index b80c820f..8ece81c4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -199,6 +199,9 @@ dependencies { // Library/extensions searching with Levenshtein distance implementation 'me.xdrop:fuzzywuzzy:1.4.0' + + // aria2c downloader + implementation 'com.github.LagradOst:Aria2cButton:master-SNAPSHOT' } task androidSourcesJar(type: Jar) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt index 49143498..dd3942f9 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt @@ -25,8 +25,11 @@ import com.lagradost.cloudstream3.utils.UIHelper import com.lagradost.cloudstream3.utils.UIHelper.hasPIPPermission import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode import com.lagradost.cloudstream3.utils.UIHelper.toPx +import com.lagradost.fetchbutton.aria2c.Aria2Settings +import com.lagradost.fetchbutton.aria2c.Aria2Starter import org.schabi.newpipe.extractor.NewPipe import java.util.* +import kotlin.concurrent.thread object CommonActivity { @MainThread @@ -129,6 +132,18 @@ object CommonActivity { act.updateLocale() act.updateTv() NewPipe.init(DownloaderTestImpl.getInstance()) + + thread { + Aria2Starter.start( + act, + Aria2Settings( + UUID.randomUUID().toString(), + 4337, + act.filesDir.path, + "${act.filesDir.path}/session" + ) + ) + } } private fun Activity.enterPIPMode() { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt index 3abd827e..71b2822d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt @@ -13,23 +13,17 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.google.android.material.button.MaterialButton import com.lagradost.cloudstream3.R -import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_DOWNLOAD import com.lagradost.cloudstream3.ui.download.DownloadButtonViewHolder import com.lagradost.cloudstream3.ui.download.DownloadClickEvent -import com.lagradost.cloudstream3.ui.download.EasyDownloadButton import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.utils.AppUtils.html import com.lagradost.cloudstream3.utils.UIHelper.setImage -import com.lagradost.cloudstream3.utils.VideoDownloadHelper -import com.lagradost.cloudstream3.utils.VideoDownloadManager +import com.lagradost.fetchbutton.aria2c.newUriRequest import kotlinx.android.synthetic.main.result_episode.view.* import kotlinx.android.synthetic.main.result_episode.view.episode_text -import kotlinx.android.synthetic.main.result_episode_large.view.* import kotlinx.android.synthetic.main.result_episode_large.view.episode_filler import kotlinx.android.synthetic.main.result_episode_large.view.episode_progress -import kotlinx.android.synthetic.main.result_episode_large.view.result_episode_download -import kotlinx.android.synthetic.main.result_episode_large.view.result_episode_progress_downloaded -import java.util.* +import kotlinx.android.synthetic.main.result_episode_large_tv.view.* const val ACTION_PLAY_EPISODE_IN_PLAYER = 1 const val ACTION_PLAY_EPISODE_IN_VLC_PLAYER = 2 @@ -62,17 +56,6 @@ class EpisodeAdapter( ) : RecyclerView.Adapter() { private var cardList: MutableList = mutableListOf() - private val mBoundViewHolders: HashSet = HashSet() - private fun getAllBoundViewHolders(): Set? { - return Collections.unmodifiableSet(mBoundViewHolders) - } - - fun killAdapter() { - getAllBoundViewHolders()?.forEach { view -> - view?.downloadButton?.dispose() - } - } - override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) { if (holder.itemView.hasFocus()) { holder.itemView.clearFocus() @@ -85,15 +68,6 @@ class EpisodeAdapter( } } - override fun onViewRecycled(holder: RecyclerView.ViewHolder) { - if (holder is DownloadButtonViewHolder) { - holder.downloadButton.dispose() - mBoundViewHolders.remove(holder) - //(holder.itemView as? FrameLayout?)?.descendantFocusability = - // ViewGroup.FOCUS_BLOCK_DESCENDANTS - } - } - override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder) { if (holder is DownloadButtonViewHolder) { //println("onViewAttachedToWindow = ${holder.absoluteAdapterPosition}") @@ -138,7 +112,6 @@ class EpisodeAdapter( when (holder) { is EpisodeCardViewHolder -> { holder.bind(cardList[position]) - mBoundViewHolders.add(holder) } } } @@ -153,17 +126,11 @@ class EpisodeAdapter( private val hasDownloadSupport: Boolean, private val clickCallback: (EpisodeClickEvent) -> Unit, private val downloadClickCallback: (DownloadClickEvent) -> Unit, - ) : RecyclerView.ViewHolder(itemView), DownloadButtonViewHolder { - override var downloadButton = EasyDownloadButton() - - var episodeDownloadBar: ContentLoadingProgressBar? = null - var episodeDownloadImage: ImageView? = null - var localCard: ResultEpisode? = null + ) : RecyclerView.ViewHolder(itemView) { + //override var downloadButton = EasyDownloadButton() @SuppressLint("SetTextI18n") fun bind(card: ResultEpisode) { - localCard = card - val isTrueTv = isTrueTvSettings() val (parentView, otherView) = if (card.poster == null) { @@ -181,9 +148,17 @@ class EpisodeAdapter( val episodeProgress: ContentLoadingProgressBar? = parentView.episode_progress val episodePoster: ImageView? = parentView.episode_poster - episodeDownloadBar = - parentView.result_episode_progress_downloaded - episodeDownloadImage = parentView.result_episode_download + val downloadButton = parentView.result_episode_download + + downloadButton.setPersistentId(card.id.toLong()) + downloadButton.isVisible = hasDownloadSupport + downloadButton.setDefaultClickListener { + listOf( + newUriRequest( + card.id.toLong(), "https://speed.hetzner.de/100MB.bin", "Hello World", + ) + ) + } val name = if (card.name == null) "${episodeText.context.getString(R.string.episode)} ${card.episode}" else "${card.episode}. ${card.name}" @@ -242,49 +217,6 @@ class EpisodeAdapter( return@setOnLongClickListener true } - - episodeDownloadImage?.isVisible = hasDownloadSupport - episodeDownloadBar?.isVisible = hasDownloadSupport - reattachDownloadButton() - } - - override fun reattachDownloadButton() { - downloadButton.dispose() - val card = localCard - if (hasDownloadSupport && card != null) { - if (episodeDownloadBar == null || - episodeDownloadImage == null - ) return - val downloadInfo = VideoDownloadManager.getDownloadFileInfoAndUpdateSettings( - itemView.context, - card.id - ) - - downloadButton.setUpButton( - downloadInfo?.fileLength, - downloadInfo?.totalBytes, - episodeDownloadBar ?: return, - episodeDownloadImage ?: return, - null, - VideoDownloadHelper.DownloadEpisodeCached( - card.name, - card.poster, - card.episode, - card.season, - card.id, - card.parentId, - card.rating, - card.description, - System.currentTimeMillis(), - ) - ) { - if (it.action == DOWNLOAD_ACTION_DOWNLOAD) { - clickCallback.invoke(EpisodeClickEvent(ACTION_DOWNLOAD_EPISODE, card)) - } else { - downloadClickCallback.invoke(it) - } - } - } } } } 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 5fc61146..082e334a 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 @@ -256,7 +256,6 @@ open class ResultFragment : ResultTrailerPlayer() { private var downloadButton: EasyDownloadButton? = null override fun onDestroyView() { updateUIListener = null - (result_episodes?.adapter as EpisodeAdapter?)?.killAdapter() downloadButton?.dispose() super.onDestroyView() diff --git a/app/src/main/res/drawable/circle_shape.xml b/app/src/main/res/drawable/circle_shape_cs3.xml similarity index 100% rename from app/src/main/res/drawable/circle_shape.xml rename to app/src/main/res/drawable/circle_shape_cs3.xml diff --git a/app/src/main/res/drawable/circular_progress_bar.xml b/app/src/main/res/drawable/circular_progress_bar_cs3.xml similarity index 100% rename from app/src/main/res/drawable/circular_progress_bar.xml rename to app/src/main/res/drawable/circular_progress_bar_cs3.xml diff --git a/app/src/main/res/drawable/circular_progress_bar_filled.xml b/app/src/main/res/drawable/circular_progress_bar_filled_cs3.xml similarity index 100% rename from app/src/main/res/drawable/circular_progress_bar_filled.xml rename to app/src/main/res/drawable/circular_progress_bar_filled_cs3.xml diff --git a/app/src/main/res/layout/download_child_episode.xml b/app/src/main/res/layout/download_child_episode.xml index f2633dd6..8cef5e7e 100644 --- a/app/src/main/res/layout/download_child_episode.xml +++ b/app/src/main/res/layout/download_child_episode.xml @@ -90,8 +90,8 @@ android:layout_width="40dp" android:layout_height="40dp" android:indeterminate="false" - android:progressDrawable="@drawable/circular_progress_bar" - android:background="@drawable/circle_shape" + android:progressDrawable="@drawable/circular_progress_bar_cs3" + android:background="@drawable/circle_shape_cs3" style="?android:attr/progressBarStyleHorizontal" android:max="100" android:layout_margin="5dp" diff --git a/app/src/main/res/layout/download_header_episode.xml b/app/src/main/res/layout/download_header_episode.xml index da4b3617..ead483e3 100644 --- a/app/src/main/res/layout/download_header_episode.xml +++ b/app/src/main/res/layout/download_header_episode.xml @@ -78,8 +78,8 @@ android:layout_height="40dp" android:id="@+id/download_header_progress_downloaded" android:indeterminate="false" - android:progressDrawable="@drawable/circular_progress_bar" - android:background="@drawable/circle_shape" + android:progressDrawable="@drawable/circular_progress_bar_cs3" + android:background="@drawable/circle_shape_cs3" style="?android:attr/progressBarStyleHorizontal" android:max="100" android:layout_margin="5dp" diff --git a/app/src/main/res/layout/fragment_result.xml b/app/src/main/res/layout/fragment_result.xml index d26c1b5a..48aeb72e 100644 --- a/app/src/main/res/layout/fragment_result.xml +++ b/app/src/main/res/layout/fragment_result.xml @@ -604,13 +604,13 @@ android:layout_height="25dp" android:layout_gravity="end|center_vertical" android:layout_margin="5dp" - android:background="@drawable/circle_shape" + android:background="@drawable/circle_shape_cs3" android:indeterminate="false" android:max="100" android:paddingStart="5dp" android:paddingEnd="5dp" android:progress="30" - android:progressDrawable="@drawable/circular_progress_bar_filled" + android:progressDrawable="@drawable/circular_progress_bar_filled_cs3" android:visibility="visible" /> - - - - + + \ No newline at end of file diff --git a/app/src/main/res/layout/result_episode_large.xml b/app/src/main/res/layout/result_episode_large.xml index 0aeedeea..6ead564a 100644 --- a/app/src/main/res/layout/result_episode_large.xml +++ b/app/src/main/res/layout/result_episode_large.xml @@ -1,151 +1,129 @@ + app:cardCornerRadius="@dimen/rounded_image_radius"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:foreground="?android:attr/selectableItemBackgroundBorderless" + android:orientation="vertical" + android:padding="10dp"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + android:layout_width="126dp" + android:layout_height="72dp" + android:foreground="@drawable/outline_drawable"> + android:foreground="?android:attr/selectableItemBackgroundBorderless" + android:nextFocusRight="@id/result_episode_download" + android:scaleType="centerCrop" + tools:src="@drawable/example_poster" /> + android:layout_width="36dp" + android:layout_height="36dp" + android:layout_gravity="center" + android:contentDescription="@string/play_episode" + android:src="@drawable/play_button" /> + android:id="@+id/episode_progress" + style="@android:style/Widget.Material.ProgressBar.Horizontal" + android:layout_width="match_parent" + android:layout_height="5dp" + android:layout_gravity="bottom" + android:layout_marginBottom="-1.5dp" + android:progressBackgroundTint="?attr/colorPrimary" + android:progressTint="?attr/colorPrimary" + tools:progress="50" /> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginStart="15dp" + android:layout_marginEnd="50dp" + android:orientation="vertical"> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal"> + android:id="@+id/episode_filler" + style="@style/SmallBlackButton" + android:layout_gravity="start" + android:layout_marginEnd="10dp" + android:text="@string/filler" /> + android:id="@+id/episode_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:textColor="?attr/textColor" + android:textStyle="bold" + tools:text="1. Jobless" /> + android:id="@+id/episode_rating" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="?attr/grayTextColor" + tools:text="Rated: 8.8" /> + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="end" + android:layout_marginStart="-50dp"> - - - + + + android:id="@+id/episode_descript" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ellipsize="end" + android:maxLines="4" + android:paddingTop="10dp" + android:paddingBottom="10dp" + android:textColor="?attr/grayTextColor" + tools:text="Jon and Daenerys arrive in Winterfell and are met with skepticism. Sam learns about the fate of his family. Cersei gives Euron the reward he aims for. Theon follows his heart. Jon and Daenerys arrive in Winterfell and are met with skepticism. Sam learns about the fate of his family. Cersei gives Euron the reward he aims for. Theon follows his heart." /> \ No newline at end of file