mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
added ability to copy comments on long press
This commit is contained in:
parent
471ce4a24b
commit
af411a61ae
@ -1,9 +1,16 @@
|
|||||||
package org.schabi.newpipe.info_list.holder;
|
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.text.util.Linkify;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import org.jsoup.helper.StringUtil;
|
import org.jsoup.helper.StringUtil;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
@ -120,6 +127,26 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
|
|||||||
itemBuilder.getOnCommentsSelectedListener().selected(item);
|
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() {
|
private void ellipsize() {
|
||||||
|
@ -159,6 +159,7 @@
|
|||||||
<string name="show_play_with_kodi_key" translatable="false">show_play_with_kodi</string>
|
<string name="show_play_with_kodi_key" translatable="false">show_play_with_kodi</string>
|
||||||
<string name="show_next_video_key" translatable="false">show_next_video</string>
|
<string name="show_next_video_key" translatable="false">show_next_video</string>
|
||||||
<string name="show_comments_key" translatable="false">show_comments</string>
|
<string name="show_comments_key" translatable="false">show_comments</string>
|
||||||
|
<string name="copy_comment_long_press" translatable="false">copy_comment_long_press</string>
|
||||||
<string name="stream_info_selected_tab_key" translatable="false">stream_info_selected_tab</string>
|
<string name="stream_info_selected_tab_key" translatable="false">stream_info_selected_tab</string>
|
||||||
<string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string>
|
<string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string>
|
||||||
<string name="default_language_value">en</string>
|
<string name="default_language_value">en</string>
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
<string name="download_thumbnail_title">Load thumbnails</string>
|
<string name="download_thumbnail_title">Load thumbnails</string>
|
||||||
<string name="show_comments_title">Show comments</string>
|
<string name="show_comments_title">Show comments</string>
|
||||||
<string name="show_comments_summary">Disable to stop showing comments</string>
|
<string name="show_comments_summary">Disable to stop showing comments</string>
|
||||||
|
<string name="copy_comment_long_press_title">Copy comment on long press</string>
|
||||||
<string name="download_thumbnail_summary">Turn off to prevent loading thumbnails, saving data and memory usage. Changes clear both in-memory and on-disk image cache.</string>
|
<string name="download_thumbnail_summary">Turn off to prevent loading thumbnails, saving data and memory usage. Changes clear both in-memory and on-disk image cache.</string>
|
||||||
<string name="thumbnail_cache_wipe_complete_notice">Image cache wiped</string>
|
<string name="thumbnail_cache_wipe_complete_notice">Image cache wiped</string>
|
||||||
<string name="metadata_cache_wipe_title">Wipe cached metadata</string>
|
<string name="metadata_cache_wipe_title">Wipe cached metadata</string>
|
||||||
|
@ -65,6 +65,12 @@
|
|||||||
android:title="@string/show_comments_title"
|
android:title="@string/show_comments_title"
|
||||||
android:summary="@string/show_comments_summary"/>
|
android:summary="@string/show_comments_summary"/>
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/copy_comment_long_press"
|
||||||
|
android:title="@string/copy_comment_long_press_title"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
android:summary="@string/import_data_summary"
|
android:summary="@string/import_data_summary"
|
||||||
|
Loading…
Reference in New Issue
Block a user