mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
feat: quick share action to add video to playlist
This commit is contained in:
parent
3e4f430369
commit
025539a245
@ -79,6 +79,22 @@
|
|||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".ui.activities.AddToPlaylistActivity"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true"
|
||||||
|
android:label="@string/addToPlaylist"
|
||||||
|
android:launchMode="singleTop"
|
||||||
|
android:theme="@style/Theme.Material3.DayNight.Dialog">
|
||||||
|
|
||||||
|
<intent-filter android:label="@string/addToPlaylist">
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="text/plain" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.DownloadActivity"
|
android:name=".ui.activities.DownloadActivity"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.github.libretube.ui.activities
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
|
import com.github.libretube.constants.IntentData
|
||||||
|
import com.github.libretube.helpers.IntentHelper
|
||||||
|
import com.github.libretube.ui.base.BaseActivity
|
||||||
|
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
||||||
|
|
||||||
|
class AddToPlaylistActivity: BaseActivity() {
|
||||||
|
override val isDialogActivity: Boolean = true
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
val videoId = intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
|
||||||
|
IntentHelper.resolveType(Intent(), it.toUri())
|
||||||
|
}?.getStringExtra(IntentData.videoId)
|
||||||
|
|
||||||
|
if (videoId == null) {
|
||||||
|
finishAndRemoveTask()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
supportFragmentManager.setFragmentResultListener(
|
||||||
|
AddToPlaylistDialog.ADD_TO_PLAYLIST_DIALOG_DISMISSED_KEY,
|
||||||
|
this
|
||||||
|
) { _, _ -> finish() }
|
||||||
|
|
||||||
|
AddToPlaylistDialog().apply {
|
||||||
|
arguments = bundleOf(IntentData.videoId to videoId)
|
||||||
|
}.show(supportFragmentManager, null)
|
||||||
|
}
|
||||||
|
}
|
@ -6,8 +6,10 @@ import android.content.DialogInterface
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.fragment.app.setFragmentResult
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
@ -133,4 +135,14 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||||||
appContext.toastFromMainDispatcher(R.string.fail)
|
appContext.toastFromMainDispatcher(R.string.fail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDismiss(dialog: DialogInterface) {
|
||||||
|
super.onDismiss(dialog)
|
||||||
|
|
||||||
|
setFragmentResult(ADD_TO_PLAYLIST_DIALOG_DISMISSED_KEY, bundleOf())
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val ADD_TO_PLAYLIST_DIALOG_DISMISSED_KEY = "add_to_playlist_dialog_dismissed"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user