Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButton
import com.tpstreams.player.download.DownloadTracker
import androidx.media3.exoplayer.offline.Download
import android.widget.ImageView

class DownloadActionBottomSheet : BottomSheetDialogFragment() {

Expand Down Expand Up @@ -45,47 +46,45 @@ class DownloadActionBottomSheet : BottomSheetDialogFragment() {
private fun updateUI() {
val view = view ?: return

val titleTextView = view.findViewById<TextView>(R.id.title_text)
val messageTextView = view.findViewById<TextView>(R.id.message_text)
val downloadedLayout = view.findViewById<LinearLayout>(R.id.downloaded_layout)
val downloadingLayout = view.findViewById<LinearLayout>(R.id.downloading_layout)

when (downloadState) {
Download.STATE_COMPLETED -> {
titleTextView.text = getString(R.string.delete_download_title)
messageTextView.text = getString(R.string.delete_download_message)
downloadedLayout.visibility = View.VISIBLE
downloadingLayout.visibility = View.GONE
}
Download.STATE_DOWNLOADING -> {
titleTextView.text = getString(R.string.downloading_title)
messageTextView.text = getString(R.string.downloading_message)
downloadedLayout.visibility = View.GONE
downloadingLayout.visibility = View.VISIBLE

val pauseResumeButton = view.findViewById<MaterialButton>(R.id.pause_resume_button)
pauseResumeButton.text = getString(R.string.pause_download)
pauseResumeButton.setOnClickListener {
val pauseResumeContainer = view.findViewById<LinearLayout>(R.id.pause_resume_container)
val pauseResumeIcon = view.findViewById<ImageView>(R.id.pause_resume_icon)
val pauseResumeText = view.findViewById<TextView>(R.id.pause_resume_text)

pauseResumeIcon.setImageResource(R.drawable.ic_pause_download)
pauseResumeText.text = getString(R.string.pause_download)
pauseResumeContainer.setOnClickListener {
listener?.onPauseDownloadConfirmed()
dismiss()
}
}
Download.STATE_STOPPED -> {
titleTextView.text = getString(R.string.paused_download_title)
messageTextView.text = getString(R.string.paused_download_message)
downloadedLayout.visibility = View.GONE
downloadingLayout.visibility = View.VISIBLE

val pauseResumeButton = view.findViewById<MaterialButton>(R.id.pause_resume_button)
pauseResumeButton.text = getString(R.string.resume_download)
pauseResumeButton.setOnClickListener {
val pauseResumeContainer = view.findViewById<LinearLayout>(R.id.pause_resume_container)
val pauseResumeIcon = view.findViewById<ImageView>(R.id.pause_resume_icon)
val pauseResumeText = view.findViewById<TextView>(R.id.pause_resume_text)

pauseResumeIcon.setImageResource(R.drawable.ic_resume_download)
pauseResumeText.text = getString(R.string.resume_download)
pauseResumeContainer.setOnClickListener {
listener?.onResumeDownloadConfirmed()
dismiss()
}
}
else -> {
titleTextView.text = getString(R.string.download_status_title)
messageTextView.text = getString(R.string.download_status_message)
downloadedLayout.visibility = View.GONE
downloadingLayout.visibility = View.VISIBLE
}
Expand Down Expand Up @@ -122,16 +121,16 @@ class DownloadActionBottomSheet : BottomSheetDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// Setup delete button for downloaded content
val deleteButton = view.findViewById<MaterialButton>(R.id.delete_button)
deleteButton.setOnClickListener {
// Setup delete container for downloaded content
val downloadedDeleteContainer = view.findViewById<LinearLayout>(R.id.downloaded_delete_container)
downloadedDeleteContainer.setOnClickListener {
listener?.onDeleteDownloadConfirmed()
dismiss()
}

// Setup cancel button for downloading content
val cancelButton = view.findViewById<MaterialButton>(R.id.cancel_button)
cancelButton.setOnClickListener {
// Setup delete container for downloading content
val deleteContainer = view.findViewById<LinearLayout>(R.id.delete_container)
deleteContainer.setOnClickListener {
listener?.onCancelDownloadConfirmed()
dismiss()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class DownloadActions(private val view: TPStreamsPlayerView) {
return when {
downloadTracker.isDownloaded(assetId) -> "Downloaded"
downloadTracker.isDownloading(assetId) -> "Downloading"
downloadTracker.isPaused(assetId) -> "Paused"
downloadTracker.isPaused(assetId) -> "Downloading Paused"
else -> "Download"
}
}
Expand Down
5 changes: 5 additions & 0 deletions tpstreams-android-player/src/main/res/drawable/ic_delete.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="#FF000000" android:pathData="M280,840Q247,840 223.5,816.5Q200,793 200,760L200,240L160,240L160,160L360,160L360,120L600,120L600,160L800,160L800,240L760,240L760,760Q760,793 736.5,816.5Q713,840 680,840L280,840ZM680,240L280,240L280,760Q280,760 280,760Q280,760 280,760L680,760Q680,760 680,760Q680,760 680,760L680,240ZM360,680L440,680L440,320L360,320L360,680ZM520,680L600,680L600,320L520,320L520,680ZM280,240L280,240L280,760Q280,760 280,760Q280,760 280,760L280,760Q280,760 280,760Q280,760 280,760L280,240Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M360,640L440,640L440,320L360,320L360,640ZM520,640L600,640L600,320L520,320L520,640ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>

</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M280,680L680,680L680,600L280,600L280,680ZM480,560L640,400L584,344L520,406L520,240L440,240L440,406L376,344L320,400L480,560ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>

</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bg_bottom_sheet"
android:orientation="vertical"
android:paddingBottom="24dp">

<!-- Drag handle -->
Expand All @@ -16,82 +16,115 @@
android:layout_marginBottom="16dp"
android:background="#CCCCCC" />

<!-- Title -->
<TextView
android:id="@+id/title_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/download_status_title"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#212121"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp" />

<!-- Message -->
<TextView
android:id="@+id/message_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/download_status_message"
android:textSize="14sp"
android:textColor="#757575"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="24dp" />

<!-- Downloaded state layout -->
<LinearLayout
android:id="@+id/downloaded_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:orientation="vertical"
android:visibility="gone">

<!-- Delete button -->
<com.google.android.material.button.MaterialButton
android:id="@+id/delete_button"
<LinearLayout
android:id="@+id/downloaded_delete_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@string/delete"
android:textColor="#FFFFFF"
app:backgroundTint="#F44336" />
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">

<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_delete"
android:tint="#212121" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="24dp"
android:text="@string/delete"
android:textColor="#212121"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>

<!-- Downloading state layout -->
<LinearLayout
android:id="@+id/downloading_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">

android:layout_marginEnd="16dp"
android:orientation="vertical"
android:visibility="gone">

<!-- Pause/Resume button -->
<com.google.android.material.button.MaterialButton
android:id="@+id/pause_resume_button"
android:layout_width="0dp"
<LinearLayout
android:id="@+id/pause_resume_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="8dp"
android:text="@string/pause_download"
android:textColor="#FFFFFF"
app:backgroundTint="#2196F3" />

<!-- Cancel button -->
<com.google.android.material.button.MaterialButton
android:id="@+id/cancel_button"
android:layout_width="0dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">

<ImageView
android:id="@+id/pause_resume_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_pause_download"
android:tint="#212121" />

<TextView
android:id="@+id/pause_resume_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="24dp"
android:text="@string/pause_download"
android:textColor="#212121"
android:textSize="14sp" />
</LinearLayout>

<!-- Delete button -->
<LinearLayout
android:id="@+id/delete_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:text="@string/cancel_download"
android:textColor="#FFFFFF"
app:backgroundTint="#F44336" />
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">

<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_delete"
android:tint="#212121" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="24dp"
android:text="@string/delete"
android:textColor="#212121"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>

</LinearLayout>
8 changes: 4 additions & 4 deletions tpstreams-android-player/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
<string name="download_notification_channel_description">Video download notifications</string>
<string name="delete_download_title">Delete Download</string>
<string name="delete_download_message">Are you sure you want to delete this downloaded video?</string>
<string name="delete">DELETE</string>
<string name="delete">Delete from downloads</string>
<string name="downloading_title">Downloading</string>
<string name="downloading_message">Your video is currently downloading</string>
<string name="paused_download_title">Download Paused</string>
<string name="paused_download_message">Your download has been paused</string>
<string name="download_status_title">Download Status</string>
<string name="download_status_message">Manage your download</string>
<string name="pause_download">PAUSE</string>
<string name="resume_download">RESUME</string>
<string name="cancel_download">CANCEL</string>
<string name="pause_download">Pause</string>
<string name="resume_download">Resume</string>
<string name="cancel_download">Cancel</string>

<!-- Playback speed -->
<string name="playback_speed">Playback speed</string>
Expand Down