Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
flutter_plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林生雨
flutter_plugin
Commits
e82a2366
Commit
e82a2366
authored
Nov 04, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
c5323c5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
89 deletions
+84
-89
workspace.xml
.idea/workspace.xml
+8
-9
GengmeiFlutterPlugin.kt
...om/example/gengmei_flutter_plugin/GengmeiFlutterPlugin.kt
+76
-80
No files found.
.idea/workspace.xml
View file @
e82a2366
...
@@ -6,8 +6,7 @@
...
@@ -6,8 +6,7 @@
</component>
</component>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"5be6bbb5-7d6e-4540-a24f-d2b3bf78b3ba"
name=
"Default Changelist"
comment=
""
>
<list
default=
"true"
id=
"5be6bbb5-7d6e-4540-a24f-d2b3bf78b3ba"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/android/src/main/java/com/example/gengmei_flutter_plugin/GengmeiFlutterPlugin.kt"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/android/src/main/java/com/example/gengmei_flutter_plugin/GengmeiFlutterPlugin.kt"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/.idea/workspace.xml"
afterDir=
"false"
/>
</list>
</list>
<ignored
path=
"$PROJECT_DIR$/.dart_tool/"
/>
<ignored
path=
"$PROJECT_DIR$/.dart_tool/"
/>
<ignored
path=
"$PROJECT_DIR$/.idea/"
/>
<ignored
path=
"$PROJECT_DIR$/.idea/"
/>
...
@@ -111,7 +110,7 @@
...
@@ -111,7 +110,7 @@
<file
pinned=
"false"
current-in-tab=
"true"
>
<file
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart"
>
<entry
file=
"file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
48
7"
>
<state
relative-caret-position=
"
15
7"
>
<caret
line=
"32"
selection-start-line=
"32"
selection-end-line=
"32"
/>
<caret
line=
"32"
selection-start-line=
"32"
selection-end-line=
"32"
/>
<folding>
<folding>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
...
@@ -203,8 +202,8 @@
...
@@ -203,8 +202,8 @@
</option>
</option>
</component>
</component>
<component
name=
"ProjectFrameBounds"
>
<component
name=
"ProjectFrameBounds"
>
<option
name=
"x"
value=
"
29
"
/>
<option
name=
"x"
value=
"
82
"
/>
<option
name=
"y"
value=
"
23
"
/>
<option
name=
"y"
value=
"
89
"
/>
<option
name=
"width"
value=
"1440"
/>
<option
name=
"width"
value=
"1440"
/>
<option
name=
"height"
value=
"811"
/>
<option
name=
"height"
value=
"811"
/>
</component>
</component>
...
@@ -294,9 +293,9 @@
...
@@ -294,9 +293,9 @@
<servers
/>
<servers
/>
</component>
</component>
<component
name=
"ToolWindowManager"
>
<component
name=
"ToolWindowManager"
>
<frame
x=
"
11"
y=
"135
"
width=
"1440"
height=
"811"
extended-state=
"0"
/>
<frame
x=
"
82"
y=
"89
"
width=
"1440"
height=
"811"
extended-state=
"0"
/>
<layout>
<layout>
<window_info
active=
"true"
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.19742489"
/>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.19742489"
/>
<window_info
id=
"Captures"
order=
"1"
side_tool=
"true"
/>
<window_info
id=
"Captures"
order=
"1"
side_tool=
"true"
/>
<window_info
id=
"Structure"
order=
"2"
side_tool=
"true"
/>
<window_info
id=
"Structure"
order=
"2"
side_tool=
"true"
/>
<window_info
id=
"Image Layers"
order=
"3"
/>
<window_info
id=
"Image Layers"
order=
"3"
/>
...
@@ -311,7 +310,7 @@
...
@@ -311,7 +310,7 @@
<window_info
anchor=
"bottom"
id=
"Android Profiler"
order=
"3"
show_stripe_button=
"false"
/>
<window_info
anchor=
"bottom"
id=
"Android Profiler"
order=
"3"
show_stripe_button=
"false"
/>
<window_info
anchor=
"bottom"
id=
"Logcat"
order=
"4"
weight=
"0.68194443"
/>
<window_info
anchor=
"bottom"
id=
"Logcat"
order=
"4"
weight=
"0.68194443"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"5"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"5"
/>
<window_info
a
nchor=
"bottom"
id=
"Terminal"
order=
"6"
visible=
"true"
weight=
"0.22253129
"
/>
<window_info
a
ctive=
"true"
anchor=
"bottom"
id=
"Terminal"
order=
"6"
visible=
"true"
weight=
"0.3838665
"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"7"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"7"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Flutter Performance"
order=
"8"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Flutter Performance"
order=
"8"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
...
@@ -623,7 +622,7 @@
...
@@ -623,7 +622,7 @@
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart"
>
<entry
file=
"file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
48
7"
>
<state
relative-caret-position=
"
15
7"
>
<caret
line=
"32"
selection-start-line=
"32"
selection-end-line=
"32"
/>
<caret
line=
"32"
selection-start-line=
"32"
selection-end-line=
"32"
/>
<folding>
<folding>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
<element
signature=
"e#0#20#0"
expanded=
"true"
/>
...
...
android/src/main/java/com/example/gengmei_flutter_plugin/GengmeiFlutterPlugin.kt
View file @
e82a2366
...
@@ -100,6 +100,82 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -100,6 +100,82 @@ class GengmeiFlutterPlugin : MethodCallHandler {
})
})
resign
.
addRequestPermissionsResultListener
{
id
,
permissions
,
grantResults
->
if
(
grantResults
.
size
>
0
)
{
var
givePremission
=
true
;
grantResults
.
forEach
{
Log
.
e
(
"lsy"
,
" ${it} ${PackageManager.PERMISSION_GRANTED}"
)
if
(
it
!=
PackageManager
.
PERMISSION_GRANTED
)
{
givePremission
=
false
;
}
}
if
(
givePremission
)
{
premissionHandler
?.
run
{
this
.
OK
()
}
}
else
{
Toast
.
makeText
(
resign
.
context
().
applicationContext
,
"请同意权限"
,
Toast
.
LENGTH_SHORT
).
show
()
premissionHandler
?.
run
{
this
.
error
(
"没有权限!!"
)
}
}
}
else
{
Toast
.
makeText
(
resign
.
context
().
applicationContext
,
"请同意权限"
,
Toast
.
LENGTH_SHORT
).
show
()
premissionHandler
?.
run
{
this
.
error
(
"没有权限!!"
)
}
}
true
;
}
resign
.
addActivityResultListener
{
requestCode
,
resultCode
,
intent
->
Log
.
e
(
"lsy"
,
" LSY ACTIVITY RESULT ${nativeImage?.exists()} ${requestCode} "
)
when
(
requestCode
)
{
CAMERA_REQUEST_CODE
->
{
if
(
resultCode
==
RESULT_OK
)
{
if
(
nativeImage
!=
null
&&
nativeImage
!!
.
exists
())
{
ImageRespository
.
getInstance
().
scareImg
(
nativeImage
!!
.
absolutePath
).
subscribe
({
val
map
=
HashMap
<
String
,
Any
>()
map
.
put
(
"realPath"
,
it
.
first
)
map
.
put
(
"path"
,
it
.
second
)
map
.
put
(
"isVideo"
,
"F"
)
map
.
put
(
"folderName"
,
"GengmeiAlbum"
)
// try {
// MediaStore.Images.Media.insertImage(resign.context().applicationContext.getContentResolver(),
// nativeImage!!.absolutePath, getFileName(nativeImage!!.absolutePath), null);
// } catch ( e: FileNotFoundException) {
// e.printStackTrace();
// }
// 最后通知图库更新
resign
.
context
().
applicationContext
.
sendBroadcast
(
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
,
Uri
.
fromFile
(
nativeImage
)))
ImageRespository
.
getInstance
().
recordImageListMap
.
add
(
0
,
map
)
ResultManager
.
getInstance
().
resultSuccess
(
gotoNativeCameraKey
,
map
);
},
{
DebugUtil
.
printStackTrace
(
it
)
}).
addTo
(
disposable
)
}
else
{
ResultManager
.
getInstance
().
resultSuccess
(
gotoNativeCameraKey
,
HashMap
<
String
,
Any
>());
}
// nativeImage?.run {
// }
// result?.run {
// if (nativeImage != null) {
// this.success(nativeImage!!.absolutePath);
// } else {
// this.success("");
// }
// }
}
else
{
ResultManager
.
getInstance
().
resultSuccess
(
gotoNativeCameraKey
,
""
);
// result?.run {
// this.success("")
// }
}
}
}
false
};
}
}
}
}
...
@@ -319,84 +395,6 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -319,84 +395,6 @@ class GengmeiFlutterPlugin : MethodCallHandler {
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
private
fun
checkPermission
(
listener
:
PermissionListener
)
{
private
fun
checkPermission
(
listener
:
PermissionListener
)
{
resign
.
addRequestPermissionsResultListener
{
id
,
permissions
,
grantResults
->
if
(
grantResults
.
size
>
0
)
{
var
givePremission
=
true
;
grantResults
.
forEach
{
Log
.
e
(
"lsy"
,
" ${it} ${PackageManager.PERMISSION_GRANTED}"
)
if
(
it
!=
PackageManager
.
PERMISSION_GRANTED
)
{
givePremission
=
false
;
}
}
if
(
givePremission
)
{
premissionHandler
?.
run
{
this
.
OK
()
}
}
else
{
Toast
.
makeText
(
resign
.
context
().
applicationContext
,
"请同意权限"
,
Toast
.
LENGTH_SHORT
).
show
()
premissionHandler
?.
run
{
this
.
error
(
"没有权限!!"
)
}
}
}
else
{
Toast
.
makeText
(
resign
.
context
().
applicationContext
,
"请同意权限"
,
Toast
.
LENGTH_SHORT
).
show
()
premissionHandler
?.
run
{
this
.
error
(
"没有权限!!"
)
}
}
true
;
}
resign
.
addActivityResultListener
{
requestCode
,
resultCode
,
intent
->
when
(
requestCode
)
{
CAMERA_REQUEST_CODE
->
{
if
(
resultCode
==
RESULT_OK
)
{
Log
.
e
(
"lsy"
,
" LSY ACTIVITY RESULT ${nativeImage?.exists()} "
)
if
(
nativeImage
!=
null
&&
nativeImage
!!
.
exists
())
{
ImageRespository
.
getInstance
().
scareImg
(
nativeImage
!!
.
absolutePath
).
subscribe
({
val
map
=
HashMap
<
String
,
Any
>()
map
.
put
(
"realPath"
,
it
.
first
)
map
.
put
(
"path"
,
it
.
second
)
map
.
put
(
"isVideo"
,
"F"
)
map
.
put
(
"folderName"
,
"GengmeiAlbum"
)
// try {
// MediaStore.Images.Media.insertImage(resign.context().applicationContext.getContentResolver(),
// nativeImage!!.absolutePath, getFileName(nativeImage!!.absolutePath), null);
// } catch ( e: FileNotFoundException) {
// e.printStackTrace();
// }
// 最后通知图库更新
resign
.
context
().
applicationContext
.
sendBroadcast
(
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
,
Uri
.
fromFile
(
nativeImage
)))
ImageRespository
.
getInstance
().
recordImageListMap
.
add
(
0
,
map
)
ResultManager
.
getInstance
().
resultSuccess
(
gotoNativeCameraKey
,
map
);
},
{
DebugUtil
.
printStackTrace
(
it
)
}).
addTo
(
disposable
)
}
else
{
ResultManager
.
getInstance
().
resultSuccess
(
gotoNativeCameraKey
,
HashMap
<
String
,
Any
>());
}
// nativeImage?.run {
// }
// result?.run {
// if (nativeImage != null) {
// this.success(nativeImage!!.absolutePath);
// } else {
// this.success("");
// }
// }
}
else
{
ResultManager
.
getInstance
().
resultSuccess
(
gotoNativeCameraKey
,
""
);
// result?.run {
// this.success("")
// }
}
}
}
true
};
premissionHandler
=
listener
premissionHandler
=
listener
val
activity
=
resign
.
activity
()
val
activity
=
resign
.
activity
()
val
writePremission
=
activity
.
checkSelfPermission
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
val
writePremission
=
activity
.
checkSelfPermission
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
...
@@ -422,8 +420,6 @@ class GengmeiFlutterPlugin : MethodCallHandler {
...
@@ -422,8 +420,6 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// Toast.makeText(activity.applicationContext, "授权成功!", Toast.LENGTH_SHORT).show();
// Toast.makeText(activity.applicationContext, "授权成功!", Toast.LENGTH_SHORT).show();
listener
.
OK
()
listener
.
OK
()
}
}
}
}
interface
PermissionListener
{
interface
PermissionListener
{
...
...
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