Skip to content
Permalink
Browse files

Issue#637: Implement copy to clip body of post (#682)

* Implement post text copy

* Put string to strings.xml and CZ loc

* repair string macro

* repair string translate

* Updated

* Updated

* Updated

* revert bug
  • Loading branch information...
MichalFerencsik authored and QuantumBadger committed Oct 12, 2019
1 parent 29434fd commit c5d49e2491df51cb0dfebdf6de581fc2ffa0bdd7
@@ -18,7 +18,7 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.quantumbadger.redreader"
android:versionCode="87"
android:versionCode="88"
android:versionName="1.9.10"
android:installLocation="auto">

@@ -299,6 +299,25 @@ public void run() {
existingShortcutPreferences
).apply();
}

if(lastVersion <= 87){
// + Context menu of post header will now appear also on post self-text long click
// + "Copy Self-Text" context menu item added

final Set<String> existingPostContextItems = PrefsUtility.getStringSet(
R.string.pref_menus_post_context_items_key,
R.array.pref_menus_post_context_items_return,
this,
sharedPreferences
);

existingPostContextItems.add("copy_selftext");

sharedPreferences.edit().putStringSet(
getString(R.string.pref_menus_post_context_items_key),
existingPostContextItems
).apply();
}
}

} else {
@@ -514,6 +514,14 @@ public void onClick(View v) {
}
});
}

paddingLayout.setOnLongClickListener(new View.OnLongClickListener(){
@Override
public boolean onLongClick(View v) {
RedditPreparedPost.showActionMenu(getActivity(), mPost);
return true;
}
});
// TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128));

mCommentListingManager.addPostSelfText(paddingLayout);
@@ -19,6 +19,8 @@

import android.Manifest;
import android.app.AlertDialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -30,7 +32,6 @@
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.ClipboardManager;
import android.text.SpannableStringBuilder;
import android.util.Log;
import android.view.LayoutInflater;
@@ -114,6 +115,7 @@
ACTION_MENU(R.string.action_actionmenu),
SAVE_IMAGE(R.string.action_save_image),
COPY(R.string.action_copy),
COPY_SELFTEXT(R.string.action_copy_selftext),
SELFTEXT_LINKS(R.string.action_selftext_links),
BACK(R.string.action_back),
BLOCK(R.string.action_block_subreddit),
@@ -277,6 +279,7 @@ public static void showActionMenu(
if(itemPref.contains(Action.SHARE_COMMENTS)) menu.add(new RPVMenuItem(activity, R.string.action_share_comments, Action.SHARE_COMMENTS));
if(itemPref.contains(Action.SHARE_IMAGE) && post.mIsProbablyAnImage) menu.add(new RPVMenuItem(activity, R.string.action_share_image, Action.SHARE_IMAGE));
if(itemPref.contains(Action.COPY)) menu.add(new RPVMenuItem(activity, R.string.action_copy, Action.COPY));
if(itemPref.contains(Action.COPY_SELFTEXT)) menu.add(new RPVMenuItem(activity, R.string.action_copy_selftext, Action.COPY_SELFTEXT));
if(itemPref.contains(Action.USER_PROFILE)) menu.add(new RPVMenuItem(activity, R.string.action_user_profile, Action.USER_PROFILE));
if(itemPref.contains(Action.PROPERTIES)) menu.add(new RPVMenuItem(activity, R.string.action_properties, Action.PROPERTIES));

@@ -463,8 +466,22 @@ public void onClick(DialogInterface dialog, int which) {

case COPY: {

ClipboardManager manager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
manager.setText(post.src.getUrl());
ClipboardManager clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
if(clipboardManager != null) {
ClipData data = ClipData.newPlainText(post.src.getAuthor(), post.src.getUrl());
clipboardManager.setPrimaryClip(data);
}
break;
}

case COPY_SELFTEXT:{
ClipboardManager clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
if(clipboardManager != null) {
ClipData data = ClipData.newPlainText(post.src.getAuthor(), post.src.getRawSelfText());
clipboardManager.setPrimaryClip(data);

General.quickToast(activity.getApplicationContext(), R.string.post_text_copied_to_clipboard);
}
break;
}

@@ -970,4 +970,8 @@

<!-- 2018-09-11 -->
<string name="pref_behaviour_hide_read_posts_title">Skrýt přečtené články</string>

<!-- 2019-10-01 -->
<string name="post_text_copied_to_clipboard">Příspěvek zkopírován do schránky</string>

</resources>
@@ -397,6 +397,7 @@
<item>@string/action_share_comments</item>
<item>@string/action_share_image</item>
<item>@string/action_copy</item>
<item>@string/action_copy_selftext</item>
<item>@string/action_user_profile</item>
<item>@string/action_properties</item>
<item>@string/action_edit</item>
@@ -421,6 +422,7 @@
<item>share_comments</item>
<item>share_image</item>
<item>copy</item>
<item>copy_selftext</item>>
<item>user_profile</item>
<item>properties</item>
<item>edit</item>
@@ -1114,8 +1114,9 @@

<string name="prefs_category_images_video">Images/Video</string>

<!-- 2019-10-04 -->

<string name="notification_channel_name_reddit_messages">Incoming Reddit Messages</string>


<!-- 2019-10-05 -->
<string name="post_text_copied_to_clipboard">Post copied to clipboard</string>
<string name="action_copy_selftext">Copy Self-Text</string>
</resources>

0 comments on commit c5d49e2

Please sign in to comment.
You can’t perform that action at this time.