@@ -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
@@ -28,7 +26,6 @@ import com.xwray.groupie.viewbinding.GroupieViewHolder
2826import io.reactivex.rxjava3.disposables.CompositeDisposable
2927import org.schabi.newpipe.R
3028import org.schabi.newpipe.database.feed.model.FeedGroupEntity.Companion.GROUP_ALL_ID
31- import org.schabi.newpipe.databinding.DialogTitleBinding
3229import org.schabi.newpipe.databinding.FeedItemCarouselBinding
3330import org.schabi.newpipe.databinding.FragmentSubscriptionBinding
3431import org.schabi.newpipe.error.ErrorInfo
@@ -53,12 +50,14 @@ import org.schabi.newpipe.local.subscription.workers.SubscriptionExportWorker
5350import org.schabi.newpipe.local.subscription.workers.SubscriptionImportInput
5451import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard
5552import org.schabi.newpipe.streams.io.StoredFileHelper
53+ import org.schabi.newpipe.ui.components.menu.LongPressAction
54+ import org.schabi.newpipe.ui.components.menu.LongPressable
55+ import org.schabi.newpipe.ui.components.menu.openLongPressMenuInActivity
5656import org.schabi.newpipe.ui.emptystate.setEmptyStateComposable
5757import org.schabi.newpipe.util.NavigationHelper
5858import org.schabi.newpipe.util.OnClickGesture
5959import org.schabi.newpipe.util.ServiceHelper
6060import org.schabi.newpipe.util.ThemeHelper.getGridSpanCountChannels
61- import org.schabi.newpipe.util.external_communication.ShareUtils
6261import java.text.SimpleDateFormat
6362import java.util.Date
6463import java.util.Locale
@@ -329,31 +328,14 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
329328 }
330329
331330 private fun showLongTapDialog (selectedItem : ChannelInfoItem ) {
332- val commands = arrayOf(
333- getString(R .string.share),
334- getString(R .string.open_in_browser),
335- getString(R .string.unsubscribe)
331+ openLongPressMenuInActivity(
332+ requireActivity(),
333+ LongPressable .fromChannelInfoItem(selectedItem),
334+ LongPressAction .fromChannelInfoItem(
335+ item = selectedItem,
336+ onUnsubscribe = { deleteChannel(selectedItem) }
337+ )
336338 )
337-
338- val actions = DialogInterface .OnClickListener { _, i ->
339- when (i) {
340- 0 -> ShareUtils .shareText(
341- requireContext(), selectedItem.name, selectedItem.url, selectedItem.thumbnails
342- )
343- 1 -> ShareUtils .openUrlInBrowser(requireContext(), selectedItem.url)
344- 2 -> deleteChannel(selectedItem)
345- }
346- }
347-
348- val dialogTitleBinding = DialogTitleBinding .inflate(LayoutInflater .from(requireContext()))
349- dialogTitleBinding.root.isSelected = true
350- dialogTitleBinding.itemTitleView.text = selectedItem.name
351- dialogTitleBinding.itemAdditionalDetails.visibility = View .GONE
352-
353- AlertDialog .Builder (requireContext())
354- .setCustomTitle(dialogTitleBinding.root)
355- .setItems(commands, actions)
356- .show()
357339 }
358340
359341 private fun deleteChannel (selectedItem : ChannelInfoItem ) {
0 commit comments