Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
55f97bca
提交
55f97bca
authored
3月 27, 2020
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug while requesting permission
上级
1d0b6a1c
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
51 行增加
和
8 行删除
+51
-8
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+6
-1
FluwxShareHandler.kt
...ain/kotlin/com/jarvan/fluwx/handlers/FluwxShareHandler.kt
+8
-6
PermissionHandler.kt
...ain/kotlin/com/jarvan/fluwx/handlers/PermissionHandler.kt
+35
-0
AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+1
-0
pubspec.lock
example/pubspec.lock
+1
-1
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
55f97bca
...
@@ -27,7 +27,9 @@ public class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
...
@@ -27,7 +27,9 @@ public class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
WXAPiHandler
.
setContext
(
registrar
.
activeContext
())
WXAPiHandler
.
setContext
(
registrar
.
activeContext
())
channel
.
setMethodCallHandler
(
FluwxPlugin
().
apply
{
channel
.
setMethodCallHandler
(
FluwxPlugin
().
apply
{
this
.
authHandler
=
authHandler
this
.
authHandler
=
authHandler
this
.
shareHandler
=
FluwxShareHandlerCompat
(
registrar
)
this
.
shareHandler
=
FluwxShareHandlerCompat
(
registrar
).
apply
{
permissionHandler
=
PermissionHandler
(
registrar
.
activity
())
}
})
})
}
}
}
}
...
@@ -66,13 +68,16 @@ public class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
...
@@ -66,13 +68,16 @@ public class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}
}
override
fun
onDetachedFromActivity
()
{
override
fun
onDetachedFromActivity
()
{
shareHandler
?.
permissionHandler
=
null
}
}
override
fun
onReattachedToActivityForConfigChanges
(
binding
:
ActivityPluginBinding
)
{
override
fun
onReattachedToActivityForConfigChanges
(
binding
:
ActivityPluginBinding
)
{
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
}
}
override
fun
onAttachedToActivity
(
binding
:
ActivityPluginBinding
)
{
override
fun
onAttachedToActivity
(
binding
:
ActivityPluginBinding
)
{
WXAPiHandler
.
setContext
(
binding
.
activity
.
applicationContext
)
WXAPiHandler
.
setContext
(
binding
.
activity
.
applicationContext
)
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
}
}
override
fun
onDetachedFromActivityForConfigChanges
()
{
override
fun
onDetachedFromActivityForConfigChanges
()
{
...
...
android/src/main/kotlin/com/jarvan/fluwx/handlers/FluwxShareHandler.kt
浏览文件 @
55f97bca
...
@@ -7,7 +7,6 @@ import android.content.res.AssetFileDescriptor
...
@@ -7,7 +7,6 @@ import android.content.res.AssetFileDescriptor
import
android.net.Uri
import
android.net.Uri
import
android.text.TextUtils
import
android.text.TextUtils
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
androidx.fragment.app.Fragment
import
com.jarvan.fluwx.io.ImagesIO
import
com.jarvan.fluwx.io.ImagesIO
import
com.jarvan.fluwx.io.ImagesIOIml
import
com.jarvan.fluwx.io.ImagesIOIml
import
com.jarvan.fluwx.io.WeChatImage
import
com.jarvan.fluwx.io.WeChatImage
...
@@ -42,6 +41,8 @@ internal class FluwxShareHandlerEmbedding(private val flutterAssets: FlutterPlug
...
@@ -42,6 +41,8 @@ internal class FluwxShareHandlerEmbedding(private val flutterAssets: FlutterPlug
}
}
override
val
job
:
Job
=
Job
()
override
val
job
:
Job
=
Job
()
override
var
permissionHandler
:
PermissionHandler
?
=
null
}
}
internal
class
FluwxShareHandlerCompat
(
private
val
registrar
:
PluginRegistry
.
Registrar
)
:
FluwxShareHandler
{
internal
class
FluwxShareHandlerCompat
(
private
val
registrar
:
PluginRegistry
.
Registrar
)
:
FluwxShareHandler
{
...
@@ -58,6 +59,7 @@ internal class FluwxShareHandlerCompat(private val registrar: PluginRegistry.Reg
...
@@ -58,6 +59,7 @@ internal class FluwxShareHandlerCompat(private val registrar: PluginRegistry.Reg
override
val
context
:
Context
=
registrar
.
context
().
applicationContext
override
val
context
:
Context
=
registrar
.
context
().
applicationContext
override
val
job
:
Job
=
Job
()
override
val
job
:
Job
=
Job
()
override
var
permissionHandler
:
PermissionHandler
?
=
null
}
}
internal
interface
FluwxShareHandler
:
CoroutineScope
{
internal
interface
FluwxShareHandler
:
CoroutineScope
{
...
@@ -89,7 +91,7 @@ internal interface FluwxShareHandler : CoroutineScope {
...
@@ -89,7 +91,7 @@ internal interface FluwxShareHandler : CoroutineScope {
}
}
private
fun
shareText
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
private
fun
shareText
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
val
textObj
=
WXTextObject
(
call
.
argument
<
String
?>
(
"source"
))
val
textObj
=
WXTextObject
(
call
.
argument
(
"source"
))
val
msg
=
WXMediaMessage
()
val
msg
=
WXMediaMessage
()
msg
.
mediaObject
=
textObj
msg
.
mediaObject
=
textObj
val
req
=
SendMessageToWX
.
Req
()
val
req
=
SendMessageToWX
.
Req
()
...
@@ -136,7 +138,7 @@ internal interface FluwxShareHandler : CoroutineScope {
...
@@ -136,7 +138,7 @@ internal interface FluwxShareHandler : CoroutineScope {
if
(
ContextCompat
.
checkSelfPermission
(
context
,
Manifest
.
permission_group
.
STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
ContextCompat
.
checkSelfPermission
(
context
,
Manifest
.
permission_group
.
STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
setImagePath
(
sourceByteArray
.
toExternalCacheFile
(
context
,
sourceImage
.
suffix
)
?.
absolutePath
)
setImagePath
(
sourceByteArray
.
toExternalCacheFile
(
context
,
sourceImage
.
suffix
)
?.
absolutePath
)
}
else
{
}
else
{
Fragment
().
requestPermissions
(
arrayOf
(
Manifest
.
permission_group
.
STORAGE
),
12121
)
permissionHandler
?.
requestStoragePermission
(
)
}
}
}
}
}
}
...
@@ -283,8 +285,7 @@ internal interface FluwxShareHandler : CoroutineScope {
...
@@ -283,8 +285,7 @@ internal interface FluwxShareHandler : CoroutineScope {
val
job
:
Job
val
job
:
Job
fun
onDestroy
()
{
var
permissionHandler
:
PermissionHandler
?
job
.
cancel
()
}
fun
onDestroy
()
=
job
.
cancel
()
}
}
\ No newline at end of file
android/src/main/kotlin/com/jarvan/fluwx/handlers/PermissionHandler.kt
0 → 100644
浏览文件 @
55f97bca
package
com.jarvan.fluwx.handlers
import
android.Manifest
import
android.app.Activity
import
android.app.Fragment
import
android.os.Build
/***
* Created by mo on 2020/3/27
* 冷风如刀,以大地为砧板,视众生为鱼肉。
* 万里飞雪,将穹苍作烘炉,熔万物为白银。
**/
class
PermissionHandler
(
private
val
activity
:
Activity
?)
{
private
val
tag
=
"Fragment_TAG"
private
val
fragment
:
Fragment
=
Fragment
()
fun
requestStoragePermission
()
{
val
currentFragment
=
oldFragment
?:
fragment
activity
?.
run
{
val
ft
=
fragmentManager
.
beginTransaction
()
ft
.
add
(
currentFragment
,
tag
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
ft
.
commitNow
()
}
else
{
ft
.
commit
()
}
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
currentFragment
.
requestPermissions
(
arrayOf
(
Manifest
.
permission_group
.
STORAGE
),
12121
)
}
}
}
private
val
oldFragment
get
()
=
activity
?.
fragmentManager
?.
findFragmentByTag
(
tag
)
}
\ No newline at end of file
example/android/app/src/main/AndroidManifest.xml
浏览文件 @
55f97bca
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
In most cases you can leave this as-is, but you if you want to provide
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
FlutterApplication and put your custom class here. -->
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<application
<application
android:name=
"io.flutter.app.FlutterApplication"
android:name=
"io.flutter.app.FlutterApplication"
android:label=
"fluwx_example"
android:label=
"fluwx_example"
...
...
example/pubspec.lock
浏览文件 @
55f97bca
...
@@ -80,7 +80,7 @@ packages:
...
@@ -80,7 +80,7 @@ packages:
path: ".."
path: ".."
relative: true
relative: true
source: path
source: path
version: "2.0.5"
version: "2.0.5
+1
"
image:
image:
dependency: transitive
dependency: transitive
description:
description:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论