Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShareExtend
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
李增强
ShareExtend
Commits
b24c80ad
Commit
b24c80ad
authored
4 years ago
by
zhouteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add extraText option for Android when sharing image or file
parent
dffcb800
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
21 deletions
+48
-21
android/src/main/java/com/zt/shareextend/ShareExtendPlugin.java
...d/src/main/java/com/zt/shareextend/ShareExtendPlugin.java
+6
-4
lib/share_extend.dart
lib/share_extend.dart
+42
-17
No files found.
android/src/main/java/com/zt/shareextend/ShareExtendPlugin.java
View file @
b24c80ad
...
...
@@ -34,6 +34,7 @@ public class ShareExtendPlugin implements MethodChannel.MethodCallHandler, Plugi
private
String
type
;
private
String
sharePanelTitle
;
private
String
subject
;
private
String
extraText
;
public
static
void
registerWith
(
Registrar
registrar
)
{
MethodChannel
channel
=
new
MethodChannel
(
registrar
.
messenger
(),
CHANNEL
);
...
...
@@ -58,14 +59,15 @@ public class ShareExtendPlugin implements MethodChannel.MethodCallHandler, Plugi
type
=
call
.
argument
(
"type"
);
sharePanelTitle
=
call
.
argument
(
"sharePanelTitle"
);
subject
=
call
.
argument
(
"subject"
);
share
(
list
,
type
,
sharePanelTitle
,
subject
);
extraText
=
call
.
argument
(
"extraText"
);
share
(
list
,
type
,
sharePanelTitle
,
subject
,
extraText
);
result
.
success
(
null
);
}
else
{
result
.
notImplemented
();
}
}
private
void
share
(
List
<
String
>
list
,
String
type
,
String
sharePanelTitle
,
String
subject
)
{
private
void
share
(
List
<
String
>
list
,
String
type
,
String
sharePanelTitle
,
String
subject
,
String
extraText
)
{
ArrayList
<
Uri
>
uriList
=
new
ArrayList
<>();;
if
(
list
==
null
||
list
.
isEmpty
())
{
...
...
@@ -86,7 +88,7 @@ public class ShareExtendPlugin implements MethodChannel.MethodCallHandler, Plugi
return
;
}
}
shareIntent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
extraText
);
for
(
String
path
:
list
)
{
File
f
=
new
File
(
path
);
Uri
uri
=
ShareUtils
.
getUriForFile
(
getContext
(),
f
);
...
...
@@ -139,7 +141,7 @@ public class ShareExtendPlugin implements MethodChannel.MethodCallHandler, Plugi
@Override
public
boolean
onRequestPermissionsResult
(
int
requestCode
,
String
[]
perms
,
int
[]
grantResults
)
{
if
(
requestCode
==
CODE_ASK_PERMISSION
&&
grantResults
.
length
>
0
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
share
(
list
,
type
,
sharePanelTitle
,
subject
);
share
(
list
,
type
,
sharePanelTitle
,
subject
,
extraText
);
}
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
lib/share_extend.dart
View file @
b24c80ad
...
...
@@ -14,44 +14,69 @@ class ShareExtend {
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'com.zt.shareextend/share_extend'
);
///
/// [sharePositionOrigin] only supports ios
/// method to share with system ui
/// It uses the ACTION_SEND Intent on Android and UIActivityViewController
/// on iOS.
/// [list] can be text or path list
/// [type] "text", "image" ,"file"
/// [sharePositionOrigin] only supports iPad os
/// [sharePanelTitle] only supports android (some devices may not support)
/// [subject] Intent.EXTRA_SUBJECT on Android and "subject" on iOS.
/// [extraText] only supports android for Intent.EXTRA_TEXT when sharing image or file.
///
static
Future
<
void
>
shareMultiple
(
List
<
String
>
list
,
String
type
,
{
Rect
sharePositionOrigin
,
String
sharePanelTitle
,
String
subject
})
{
{
Rect
sharePositionOrigin
,
String
sharePanelTitle
,
String
subject
=
""
,
String
extraText
=
""
})
{
assert
(
list
!=
null
&&
list
.
isNotEmpty
);
return
_shareInner
(
list
,
type
,
sharePositionOrigin:
sharePositionOrigin
,
subject:
subject
,
sharePanelTitle:
sharePanelTitle
);
sharePanelTitle:
sharePanelTitle
,
extraText:
extraText
);
}
/// method to share with system ui
/// It uses the ACTION_SEND Intent on Android and UIActivityViewController
/// on iOS.
/// [list] can be text or path list
/// [type] "text", "image" ,"file"
/// [sharePositionOrigin] only supports iPad os
/// [sharePanelTitle] only supports android (some devices may not support)
/// [subject] Intent.EXTRA_SUBJECT on Android and "subject" on iOS.
/// [extraText] only supports android for Intent.EXTRA_TEXT when sharing image or file.
///
static
Future
<
void
>
share
(
String
text
,
String
type
,
{
Rect
sharePositionOrigin
,
String
sharePanelTitle
,
String
subject
=
""
})
{
{
Rect
sharePositionOrigin
,
String
sharePanelTitle
,
String
subject
=
""
,
String
extraText
=
""
})
{
assert
(
text
!=
null
);
assert
(
text
.
isNotEmpty
);
List
<
String
>
list
=
[
text
];
return
_shareInner
(
list
,
type
,
return
_shareInner
(
list
,
type
,
sharePositionOrigin:
sharePositionOrigin
,
sharePanelTitle:
sharePanelTitle
,
subject:
subject
);
subject:
subject
,
extraText:
extraText
,
);
}
/// method to share with system ui
/// It uses the ACTION_SEND Intent on Android and UIActivityViewController
/// on iOS.
/// [list] can be text or path list
/// [type] "text", "image" ,"file"
/// [sharePositionOrigin] only supports ios
///
static
Future
<
void
>
_shareInner
(
List
<
String
>
list
,
String
type
,
{
Rect
sharePositionOrigin
,
String
sharePanelTitle
,
String
subject
})
{
{
Rect
sharePositionOrigin
,
String
sharePanelTitle
,
String
subject
,
String
extraText
})
{
assert
(
list
!=
null
&&
list
.
isNotEmpty
);
final
Map
<
String
,
dynamic
>
params
=
<
String
,
dynamic
>{
'list'
:
list
,
'type'
:
type
,
'sharePanelTitle'
:
sharePanelTitle
,
'subject'
:
subject
'subject'
:
subject
,
'extraText'
:
extraText
};
if
(
sharePositionOrigin
!=
null
)
{
params
[
'originX'
]
=
sharePositionOrigin
.
left
;
...
...
This diff is collapsed.
Click to expand it.
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