diff options
author | Tony Tam <149837+tonytamsf@users.noreply.github.com> | 2022-01-15 01:44:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-15 10:44:14 +0100 |
commit | 27443bf2c8f0eaad5ffb4c3b03f9908d2c798b5c (patch) | |
tree | 650a64532aed3a0ceeb7d647ab62dd584b3a1458 /app/src/main | |
parent | 987dcfec3f82803cc7d895910c94310a6aa6265c (diff) | |
download | AntennaPod-27443bf2c8f0eaad5ffb4c3b03f9908d2c798b5c.zip |
handle mouse right click (#5625)
Diffstat (limited to 'app/src/main')
3 files changed, 47 insertions, 0 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java index f6b47d8e5..0ad7fa219 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java @@ -1,9 +1,12 @@ package de.danoeh.antennapod.adapter; import android.app.Activity; +import android.os.Build; import android.view.ContextMenu; +import android.view.InputDevice; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -85,6 +88,17 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol longPressedPosition = holder.getBindingAdapterPosition(); return false; }); + holder.itemView.setOnTouchListener((v, e) -> { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (e.isFromSource(InputDevice.SOURCE_MOUSE) + && e.getButtonState() == MotionEvent.BUTTON_SECONDARY) { + longPressedItem = getItem(holder.getBindingAdapterPosition()); + longPressedPosition = holder.getBindingAdapterPosition(); + return false; + } + } + return false; + }); if (inActionMode()) { holder.secondaryActionButton.setVisibility(View.GONE); @@ -162,6 +176,9 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol if (inActionMode()) { inflater.inflate(R.menu.multi_select_context_popup, menu); } else { + if (longPressedItem == null) { + return; + } inflater.inflate(R.menu.feeditemlist_context, menu); menu.setHeaderTitle(longPressedItem.getTitle()); FeedItemMenuHandler.onPrepareMenu(menu, longPressedItem, R.id.skip_episode_item); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index 34eb48b6b..51fc63f86 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -3,12 +3,15 @@ package de.danoeh.antennapod.adapter; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.view.ContextMenu; +import android.view.InputDevice; import android.view.LayoutInflater; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.preference.PreferenceManager; import android.util.TypedValue; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -208,6 +211,16 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder> holder.itemView.setOnClickListener(v -> itemAccess.onItemClick(position)); holder.itemView.setOnLongClickListener(v -> itemAccess.onItemLongClick(position)); + holder.itemView.setOnTouchListener((v, e) -> { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (e.isFromSource(InputDevice.SOURCE_MOUSE) + && e.getButtonState() == MotionEvent.BUTTON_SECONDARY) { + itemAccess.onItemLongClick(position); + return false; + } + } + return false; + }); } } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java index 21c5e1897..5ab354d05 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java @@ -4,11 +4,14 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.os.Build; import android.text.TextUtils; import android.view.ContextMenu; +import android.view.InputDevice; import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; @@ -120,6 +123,20 @@ public class SubscriptionsRecyclerAdapter extends SelectableAdapter<Subscription return false; }); + holder.itemView.setOnTouchListener((v, e) -> { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (e.isFromSource(InputDevice.SOURCE_MOUSE) + && e.getButtonState() == MotionEvent.BUTTON_SECONDARY) { + if (!inActionMode()) { + if (isFeed) { + longPressedPosition = holder.getBindingAdapterPosition(); + } + selectedItem = (NavDrawerData.DrawerItem) getItem(holder.getBindingAdapterPosition()); + } + } + } + return false; + }); holder.itemView.setOnClickListener(v -> { if (isFeed) { if (inActionMode()) { |