Skip to content

Commit d819a91

Browse files
committed
Long press to share clipboard content
1 parent da1a892 commit d819a91

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

app/src/main/java/org/fcitx/fcitx5/android/input/clipboard/ClipboardAdapter.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ abstract class ClipboardAdapter(
111111
menu.item(R.string.edit, R.drawable.ic_baseline_edit_24, iconTint) {
112112
onEdit(entry.id)
113113
}
114+
menu.item(R.string.share, R.drawable.ic_baseline_share_24, iconTint) {
115+
onShare(entry)
116+
}
114117
menu.item(R.string.delete, R.drawable.ic_baseline_delete_24, iconTint) {
115118
onDelete(entry.id)
116119
}
@@ -143,6 +146,8 @@ abstract class ClipboardAdapter(
143146

144147
abstract fun onEdit(id: Int)
145148

149+
abstract fun onShare(entry: ClipboardEntry)
150+
146151
abstract fun onDelete(id: Int)
147152

148153
}

app/src/main/java/org/fcitx/fcitx5/android/input/clipboard/ClipboardWindow.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package org.fcitx.fcitx5.android.input.clipboard
66

77
import android.annotation.SuppressLint
8+
import android.content.Intent
89
import android.view.View
910
import android.view.ViewGroup
1011
import android.widget.FrameLayout
@@ -103,6 +104,17 @@ class ClipboardWindow : InputWindow.ExtendedInputWindow<ClipboardWindow>() {
103104
AppUtil.launchClipboardEdit(context, id)
104105
}
105106

107+
override fun onShare(entry: ClipboardEntry) {
108+
val target = Intent(Intent.ACTION_SEND).apply {
109+
type = "text/plain"
110+
putExtra(Intent.EXTRA_TEXT, entry.text)
111+
}
112+
val chooser = Intent.createChooser(target, null).apply {
113+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
114+
}
115+
service.startActivity(chooser)
116+
}
117+
106118
override fun onDelete(id: Int) {
107119
service.lifecycleScope.launch {
108120
ClipboardManager.delete(id)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="#ffffff"
8+
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
9+
</vector>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,5 @@
303303
<string name="move_cursor_to_end">Move cursor to end</string>
304304
<string name="open_input_method_settings">Open input method settings</string>
305305
<string name="delete_all">Delete all</string>
306+
<string name="share">Share</string>
306307
</resources>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy