From 418fbd3b5c0d36b4a3231e41bff78decd7cab9b1 Mon Sep 17 00:00:00 2001 From: torrentcome Date: Tue, 16 May 2017 17:56:35 +0200 Subject: [PATCH] (share) add share functionality - get the text shared and put it on the Clipboard - pass by the same way that past for Download the information --- .../main/java/com/keylesspalace/tusky/ComposeActivity.java | 3 +++ .../main/java/com/keylesspalace/tusky/util/ParserUtils.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 7f7a31b96..29ff64b09 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -390,6 +390,9 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm int left = Math.min(start, end); int right = Math.max(start, end); textEditor.getText().replace(left, right, text, 0, text.length()); + + parser.putInClipboardManager(this, text); + textEditor.onPaste(); } } } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ParserUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/ParserUtils.java index 215765261..9c1eed333 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ParserUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/ParserUtils.java @@ -43,6 +43,12 @@ public class ParserUtils { return null; } + public void putInClipboardManager(Context context, String string) { + ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("", string); + clipboard.setPrimaryClip(clip); + } + // parse the HTML page private HeaderInfo parsePageHeaderInfo(String urlStr) throws Exception { Connection con = Jsoup.connect(urlStr);