Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fluttet_clipboard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
fluttet_clipboard
Commits
a146ef59
Commit
a146ef59
authored
Jul 16, 2021
by
汪林玲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
清空粘贴板
parent
6ada195c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
android/src/main/java/com/qiaomeng/flutter/fluttet_clipboard/Handler.java
.../java/com/qiaomeng/flutter/fluttet_clipboard/Handler.java
+9
-4
No files found.
android/src/main/java/com/qiaomeng/flutter/fluttet_clipboard/Handler.java
View file @
a146ef59
...
...
@@ -4,6 +4,7 @@ import android.content.ClipData;
import
android.content.ClipDescription
;
import
android.content.ClipboardManager
;
import
android.content.Context
;
import
android.text.TextUtils
;
public
class
Handler
{
private
Context
context
;
...
...
@@ -18,7 +19,6 @@ public class Handler {
if
(
data
==
null
)
{
return
""
;
}
if
((
c
.
getPrimaryClipDescription
()
!=
null
&&
c
.
getPrimaryClipDescription
().
hasMimeType
(
ClipDescription
.
MIMETYPE_TEXT_PLAIN
))
||
data
.
getDescription
().
hasMimeType
(
ClipDescription
.
MIMETYPE_TEXT_PLAIN
))
{
String
str
=
data
.
getItemAt
(
0
).
getText
().
toString
();
return
str
;
...
...
@@ -28,14 +28,19 @@ public class Handler {
}
public
void
setText
(
String
text
)
{
if
(
text
==
null
)
{
text
=
""
;
}
ClipboardManager
c
=
(
ClipboardManager
)
context
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
ClipboardManager
c
lipboard
=
(
ClipboardManager
)
context
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
ClipData
clipData
=
ClipData
.
newPlainText
(
null
,
text
);
c
.
setPrimaryClip
(
clipData
);
clipboard
.
setPrimaryClip
(
clipData
);
try
{
if
(
TextUtils
.
isEmpty
(
text
)){
clipboard
.
clearPrimaryClip
();
}
}
catch
(
Exception
e
){
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment