I'm working to display share button when long press on a claim #1133.

(https://github.com/lbryio/lbry-android/issues/1133)

 So far, I've located the longClick method in the claimadapter.
 I put some Log.d messages to confirm that I can do something when I long press.
 Evreything's working so it looks like I can progress to implement a menu kind of selection for sharing.
This commit is contained in:
pixel 2021-09-28 23:08:22 -04:00
parent 159494f083
commit 1ed289b9ab
2 changed files with 38 additions and 0 deletions

View file

@ -2,12 +2,14 @@ package io.lbry.browser.adapter;
import android.content.Context;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.recyclerview.widget.RecyclerView;
@ -22,6 +24,7 @@ import java.util.List;
import java.util.Map;
import io.lbry.browser.R;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.listener.SelectionModeListener;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.LbryFile;
@ -32,6 +35,7 @@ import lombok.Getter;
import lombok.Setter;
public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.ViewHolder> {
private static final String TAG = ClaimListAdapter.class.getSimpleName();
private static final int VIEW_TYPE_STREAM = 1;
private static final int VIEW_TYPE_CHANNEL = 2;
private static final int VIEW_TYPE_FEATURED = 3; // featured search result
@ -369,6 +373,22 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
vh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
//THIS IS FOR SHARING THE VIDEO ON LONG PRESS
Toast.makeText(context, "LONG CLICKED: " + original.getTitle(), Toast.LENGTH_SHORT).show(); //Don't need, but it's nice to see it on the UI
Log.d(TAG, "LONG CLICKED: " + original.getTitle());
try{
String shareUrl = LbryUri.parse(
!Helper.isNullOrEmpty(original.getCanonicalUrl()) ? original.getCanonicalUrl() :
(!Helper.isNullOrEmpty(original.getShortUrl()) ? original.getShortUrl() : original.getPermanentUrl())).toTvString();
Log.d(TAG, "LONG CLICKED, SHARE " + shareUrl);
} catch (LbryUriException lbryUriException){
lbryUriException.printStackTrace();
}
if (!canEnterSelectionMode) {
return false;
}

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_claim_popup_share"
android:title="@string/share" />
<item android:id="@+id/menu_claim_popup_support"
android:title="@string/support" />
<item android:id="@+id/menu_claim_popup_repost"
android:title="@string/repost" />
<item android:id="@+id/menu_claim_popup_download"
android:title="@string/download" />
<item android:id="@+id/menu_claim_popup_report"
android:title="@string/report" />
</menu>