Commit e82a2366 authored by 林生雨's avatar 林生雨

commit

parent c5323c5a
......@@ -6,8 +6,7 @@
</component>
<component name="ChangeListManager">
<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$/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" />
<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" />
</list>
<ignored path="$PROJECT_DIR$/.dart_tool/" />
<ignored path="$PROJECT_DIR$/.idea/" />
......@@ -111,7 +110,7 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="487">
<state relative-caret-position="157">
<caret line="32" selection-start-line="32" selection-end-line="32" />
<folding>
<element signature="e#0#20#0" expanded="true" />
......@@ -203,8 +202,8 @@
</option>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="29" />
<option name="y" value="23" />
<option name="x" value="82" />
<option name="y" value="89" />
<option name="width" value="1440" />
<option name="height" value="811" />
</component>
......@@ -294,9 +293,9 @@
<servers />
</component>
<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>
<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="Structure" order="2" side_tool="true" />
<window_info id="Image Layers" order="3" />
......@@ -311,7 +310,7 @@
<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="Debug" order="5" />
<window_info anchor="bottom" id="Terminal" order="6" visible="true" weight="0.22253129" />
<window_info active="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="Flutter Performance" order="8" side_tool="true" />
<window_info anchor="bottom" id="Version Control" order="9" />
......@@ -623,7 +622,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/lib/gengmei_flutter_plugin.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="487">
<state relative-caret-position="157">
<caret line="32" selection-start-line="32" selection-end-line="32" />
<folding>
<element signature="e#0#20#0" expanded="true" />
......
......@@ -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 {
@TargetApi(Build.VERSION_CODES.M)
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
val activity = resign.activity()
val writePremission = activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
......@@ -422,8 +420,6 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// Toast.makeText(activity.applicationContext, "授权成功!", Toast.LENGTH_SHORT).show();
listener.OK()
}
}
interface PermissionListener {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment