@@ -2,7 +2,6 @@ package org.schabi.newpipe.local.subscription
22
33import android.app.Activity
44import android.content.Context
5- import android.content.DialogInterface
65import android.os.Bundle
76import android.os.Parcelable
87import android.view.LayoutInflater
@@ -17,7 +16,6 @@ import android.widget.Toast
1716import androidx.activity.result.ActivityResult
1817import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
1918import androidx.annotation.StringRes
20- import androidx.appcompat.app.AlertDialog
2119import androidx.lifecycle.ViewModelProvider
2220import androidx.recyclerview.widget.GridLayoutManager
2321import com.evernote.android.state.State
@@ -31,7 +29,6 @@ import java.util.Date
3129import java.util.Locale
3230import org.schabi.newpipe.R
3331import org.schabi.newpipe.database.feed.model.FeedGroupEntity.Companion.GROUP_ALL_ID
34- import org.schabi.newpipe.databinding.DialogTitleBinding
3532import org.schabi.newpipe.databinding.FeedItemCarouselBinding
3633import org.schabi.newpipe.databinding.FragmentSubscriptionBinding
3734import org.schabi.newpipe.error.ErrorInfo
@@ -56,12 +53,14 @@ import org.schabi.newpipe.local.subscription.workers.SubscriptionExportWorker
5653import org.schabi.newpipe.local.subscription.workers.SubscriptionImportInput
5754import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard
5855import org.schabi.newpipe.streams.io.StoredFileHelper
56+ import org.schabi.newpipe.ui.components.menu.LongPressAction
57+ import org.schabi.newpipe.ui.components.menu.LongPressable
58+ import org.schabi.newpipe.ui.components.menu.openLongPressMenuInActivity
5959import org.schabi.newpipe.ui.emptystate.setEmptyStateComposable
6060import org.schabi.newpipe.util.NavigationHelper
6161import org.schabi.newpipe.util.OnClickGesture
6262import org.schabi.newpipe.util.ServiceHelper
6363import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountChannels
64- import org.schabi.newpipe.util.external_communication.ShareUtils
6564
6665class SubscriptionFragment : BaseStateFragment <SubscriptionState >() {
6766 private var _binding : FragmentSubscriptionBinding ? = null
@@ -334,36 +333,14 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
334333 }
335334
336335 private fun showLongTapDialog (selectedItem : ChannelInfoItem ) {
337- val commands = arrayOf(
338- getString(R .string.share),
339- getString(R .string.open_in_browser),
340- getString(R .string.unsubscribe)
336+ openLongPressMenuInActivity(
337+ requireActivity(),
338+ LongPressable .fromChannelInfoItem(selectedItem),
339+ LongPressAction .fromChannelInfoItem(
340+ item = selectedItem,
341+ onUnsubscribe = { deleteChannel(selectedItem) }
342+ )
341343 )
342-
343- val actions = DialogInterface .OnClickListener { _, i ->
344- when (i) {
345- 0 -> ShareUtils .shareText(
346- requireContext(),
347- selectedItem.name,
348- selectedItem.url,
349- selectedItem.thumbnails
350- )
351-
352- 1 -> ShareUtils .openUrlInBrowser(requireContext(), selectedItem.url)
353-
354- 2 -> deleteChannel(selectedItem)
355- }
356- }
357-
358- val dialogTitleBinding = DialogTitleBinding .inflate(LayoutInflater .from(requireContext()))
359- dialogTitleBinding.root.isSelected = true
360- dialogTitleBinding.itemTitleView.text = selectedItem.name
361- dialogTitleBinding.itemAdditionalDetails.visibility = View .GONE
362-
363- AlertDialog .Builder (requireContext())
364- .setCustomTitle(dialogTitleBinding.root)
365- .setItems(commands, actions)
366- .show()
367344 }
368345
369346 private fun deleteChannel (selectedItem : ChannelInfoItem ) {
0 commit comments