added ability to copy comments on long press
This commit is contained in:
parent
471ce4a24b
commit
af411a61ae
4 changed files with 36 additions and 1 deletions
|
|
@ -1,9 +1,16 @@
|
|||
package org.schabi.newpipe.info_list.holder;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import org.jsoup.helper.StringUtil;
|
||||
import org.schabi.newpipe.R;
|
||||
|
|
@ -120,6 +127,26 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
|
|||
itemBuilder.getOnCommentsSelectedListener().selected(item);
|
||||
}
|
||||
});
|
||||
|
||||
boolean copyCommentOnLongPress = PreferenceManager.getDefaultSharedPreferences(
|
||||
itemBuilder.getContext()).getBoolean(itemBuilder.getContext().getString(R.string.copy_comment_long_press),
|
||||
false);
|
||||
|
||||
if(copyCommentOnLongPress){
|
||||
|
||||
itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
|
||||
ClipboardManager clipboardManager = (ClipboardManager) itemBuilder.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipboardManager.setPrimaryClip(ClipData.newPlainText(null,itemContentView.getText()));
|
||||
Toast.makeText(itemBuilder.getContext(), R.string.msg_copied, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ellipsize() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue