From af411a61ae62b37565117957fdecdfdbc855b07d Mon Sep 17 00:00:00 2001 From: Harshal Lele Date: Tue, 4 Feb 2020 16:40:57 +0530 Subject: [PATCH 1/4] added ability to copy comments on long press --- .../holder/CommentsMiniInfoItemHolder.java | 29 ++++++++++++++++++- app/src/main/res/values/settings_keys.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/content_settings.xml | 6 ++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java index 4d94ec392..4b1d1bdae 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java @@ -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() { diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 1a7d61dae..90edd0ef8 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -159,6 +159,7 @@ show_play_with_kodi show_next_video show_comments + copy_comment_long_press stream_info_selected_tab show_hold_to_append en diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dab9bde10..ca5a7527f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -76,6 +76,7 @@ Load thumbnails Show comments Disable to stop showing comments + Copy comment on long press Turn off to prevent loading thumbnails, saving data and memory usage. Changes clear both in-memory and on-disk image cache. Image cache wiped Wipe cached metadata diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 197c14487..d1080bb4d 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -65,6 +65,12 @@ android:title="@string/show_comments_title" android:summary="@string/show_comments_summary"/> + + Date: Tue, 4 Feb 2020 18:01:39 +0530 Subject: [PATCH 2/4] removed settings entry --- .../holder/CommentsMiniInfoItemHolder.java | 26 +++++++------------ app/src/main/res/values/settings_keys.xml | 1 - app/src/main/res/values/strings.xml | 1 - app/src/main/res/xml/content_settings.xml | 5 ---- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java index 4b1d1bdae..592378dc0 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java @@ -3,7 +3,6 @@ package org.schabi.newpipe.info_list.holder; 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; @@ -128,25 +127,20 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder { } }); - 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) { - 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; - 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() { diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 90edd0ef8..1a7d61dae 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -159,7 +159,6 @@ show_play_with_kodi show_next_video show_comments - copy_comment_long_press stream_info_selected_tab show_hold_to_append en diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ca5a7527f..dab9bde10 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -76,7 +76,6 @@ Load thumbnails Show comments Disable to stop showing comments - Copy comment on long press Turn off to prevent loading thumbnails, saving data and memory usage. Changes clear both in-memory and on-disk image cache. Image cache wiped Wipe cached metadata diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index d1080bb4d..2187b4a3c 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -65,11 +65,6 @@ android:title="@string/show_comments_title" android:summary="@string/show_comments_summary"/> - Date: Wed, 5 Feb 2020 14:48:39 +0530 Subject: [PATCH 3/4] Update CommentsMiniInfoItemHolder.java Co-Authored-By: yausername <5203007+yausername@users.noreply.github.com> --- .../newpipe/info_list/holder/CommentsMiniInfoItemHolder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java index 592378dc0..58f1ab90d 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java @@ -134,7 +134,7 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder { ClipboardManager clipboardManager = (ClipboardManager) itemBuilder.getContext() .getSystemService(Context.CLIPBOARD_SERVICE); - clipboardManager.setPrimaryClip(ClipData.newPlainText(null,itemContentView.getText())); + clipboardManager.setPrimaryClip(ClipData.newPlainText(null,commentText)); Toast.makeText(itemBuilder.getContext(), R.string.msg_copied, Toast.LENGTH_SHORT).show(); return true; From 34e31807fc864ae99511ded080323aa723dcad56 Mon Sep 17 00:00:00 2001 From: harshlele <45959248+harshlele@users.noreply.github.com> Date: Thu, 6 Feb 2020 18:33:06 +0530 Subject: [PATCH 4/4] removed empty line --- app/src/main/res/xml/content_settings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 2187b4a3c..197c14487 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -65,7 +65,6 @@ android:title="@string/show_comments_title" android:summary="@string/show_comments_summary"/> -