Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
a40a414e
提交
a40a414e
authored
4月 23, 2023
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Android load configurations from yaml.
上级
96cb5439
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
216 行增加
和
93 行删除
+216
-93
build.gradle
android/build.gradle
+34
-4
build.gradle.kts.bak
android/build.gradle.kts.bak
+56
-0
AndroidManifest.xml
android/src/main/AndroidManifest.xml
+14
-0
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+13
-11
FluwxRequestHandler.kt
...n/kotlin/com/jarvan/fluwx/handlers/FluwxRequestHandler.kt
+23
-35
WXAPiHandler.kt
...src/main/kotlin/com/jarvan/fluwx/handlers/WXAPiHandler.kt
+6
-7
FluwxExtensions.kt
...src/main/kotlin/com/jarvan/fluwx/utils/FluwxExtensions.kt
+56
-0
FluwxWXEntryActivity.kt
...ain/kotlin/com/jarvan/fluwx/wxapi/FluwxWXEntryActivity.kt
+6
-24
AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+0
-12
pubspec.yaml
example/pubspec.yaml
+8
-0
没有找到文件。
android/build.gradle
浏览文件 @
a40a414e
import
org.yaml.snakeyaml.Yaml
group
'com.jarvan.fluwx'
group
'com.jarvan.fluwx'
version
'1.0-SNAPSHOT'
version
'1.0-SNAPSHOT'
...
@@ -9,7 +11,8 @@ buildscript {
...
@@ -9,7 +11,8 @@ buildscript {
}
}
dependencies
{
dependencies
{
classpath
'com.android.tools.build:gradle:7.3.0'
classpath
'com.android.tools.build:gradle:7.3.1'
classpath
"org.yaml:snakeyaml:2.0"
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
}
}
...
@@ -23,10 +26,9 @@ allprojects {
...
@@ -23,10 +26,9 @@ allprojects {
apply
plugin:
'com.android.library'
apply
plugin:
'com.android.library'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android'
android
{
android
{
namespace
"com.jarvan.fluwx"
namespace
"com.jarvan.fluwx"
compileSdk
Version
31
compileSdk
31
sourceSets
{
sourceSets
{
main
.
java
.
srcDirs
+=
'src/main/kotlin'
main
.
java
.
srcDirs
+=
'src/main/kotlin'
...
@@ -36,6 +38,7 @@ android {
...
@@ -36,6 +38,7 @@ android {
defaultConfig
{
defaultConfig
{
minSdkVersion
16
minSdkVersion
16
consumerProguardFiles
'consumer-proguard-rules.txt'
consumerProguardFiles
'consumer-proguard-rules.txt'
manifestPlaceholders
=
loadManifestPlaceholder
()
}
}
dependencies
{
dependencies
{
...
@@ -54,9 +57,36 @@ android {
...
@@ -54,9 +57,36 @@ android {
testLogging
{
testLogging
{
events
"passed"
,
"skipped"
,
"failed"
,
"standardOut"
,
"standardError"
events
"passed"
,
"skipped"
,
"failed"
,
"standardOut"
,
"standardError"
outputs
.
upToDateWhen
{
false
}
outputs
.
upToDateWhen
{
false
}
showStandardStreams
=
true
showStandardStreams
=
true
}
}
}
}
}
}
}
}
Map
loadManifestPlaceholder
()
{
def
path
=
rootProject
.
projectDir
.
parent
+
File
.
separator
+
"pubspec.yaml"
InputStream
input
=
new
FileInputStream
(
new
File
(
path
))
Yaml
yaml
=
new
Yaml
()
Map
projectConfig
=
yaml
.
load
(
input
)
String
appId
=
""
String
interruptWxRequest
=
"true"
String
flutterActivity
=
""
Map
fluwx
=
(
Map
)
projectConfig
.
get
(
"fluwx"
)
if
(
fluwx
)
{
Map
android
=
(
Map
)
fluwx
.
get
(
"android"
)
if
(
android
)
{
def
iwr
=
android
.
get
(
"interrupt_wx_request"
)
if
(
iwr
)
{
interruptWxRequest
=
(
String
)
iwr
}
def
activity
=
android
.
get
(
"flutter_activity"
)
if
(
activity
)
{
flutterActivity
=
(
String
)
activity
}
}
}
return
[
"WeChatAppId"
:
appId
,
"InterruptWeChatRequestByFluwx"
:
interruptWxRequest
,
"FluwxFlutterActivity"
:
flutterActivity
]
}
android/build.gradle.kts.bak
0 → 100644
浏览文件 @
a40a414e
group = "com.jarvan.fluwx"
version = "1.0-SNAPSHOT"
plugins {
id("com.android.library")
kotlin("android")
}
allprojects {
repositories {
google()
mavenCentral()
}
}
android {
namespace = "com.jarvan.fluwx"
compileSdk = 31
sourceSets {
val main by getting
main.java.srcDirs("src/main/kotlin")
val test by getting
test.java.srcDirs("src/test/kotlin")
}
defaultConfig {
minSdk = 16
consumerProguardFile("consumer-proguard-rules.txt")
}
testOptions {
unitTests.all {
it.useJUnitPlatform()
it.testLogging {
events("passed", "skipped", "failed", "standardOut", "standardError")
showStandardStreams = true
it.outputs.upToDateWhen {
false
}
}
}
}
}
dependencies {
api("com.tencent.mm.opensdk:wechat-sdk-android:6.8.24")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
implementation("id.zelory:compressor:3.0.1")
implementation("com.squareup.okhttp3:okhttp:4.10.0")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.mockito:mockito-core:5.0.0")
}
android/src/main/AndroidManifest.xml
浏览文件 @
a40a414e
...
@@ -11,6 +11,19 @@
...
@@ -11,6 +11,19 @@
</queries>
</queries>
<application>
<application>
<meta-data
android:name=
"WeChatAppId"
android:value=
"${WeChatAppId}"
/>
<meta-data
android:name=
"InterruptWeChatRequestByFluwx"
android:value=
"${InterruptWeChatRequestByFluwx}"
/>
<meta-data
android:name=
"FluwxFlutterActivity"
android:value=
"${FluwxFlutterActivity}"
/>
<activity
<activity
android:name=
".wxapi.FluwxWXEntryActivity"
android:name=
".wxapi.FluwxWXEntryActivity"
android:exported=
"false"
android:exported=
"false"
...
@@ -25,6 +38,7 @@
...
@@ -25,6 +38,7 @@
android:targetActivity=
"com.jarvan.fluwx.wxapi.FluwxWXEntryActivity"
android:targetActivity=
"com.jarvan.fluwx.wxapi.FluwxWXEntryActivity"
android:taskAffinity=
"${applicationId}"
android:taskAffinity=
"${applicationId}"
android:theme=
"@style/DisablePreviewTheme"
/>
android:theme=
"@style/DisablePreviewTheme"
/>
<activity-alias
<activity-alias
android:name=
"${applicationId}.wxapi.WXPayEntryActivity"
android:name=
"${applicationId}.wxapi.WXPayEntryActivity"
android:exported=
"true"
android:exported=
"true"
...
...
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
a40a414e
...
@@ -36,26 +36,23 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -36,26 +36,23 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
private
var
context
:
Context
?
=
null
private
var
context
:
Context
?
=
null
private
fun
handelIntent
(
intent
:
Intent
)
{
private
fun
handelIntent
(
intent
:
Intent
)
{
val
action
=
intent
.
action
intent
.
getStringExtra
(
FluwxRequestHandler
.
KEY_FLUWX_REQUEST_INFO_EXT_MSG
)
?.
let
{
val
dataString
=
intent
.
dataString
extMsg
=
it
if
(
Intent
.
ACTION_VIEW
==
action
)
{
extMsg
=
dataString
}
}
}
}
override
fun
onAttachedToEngine
(
@NonNull
flutterPluginBinding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
override
fun
onAttachedToEngine
(
flutterPluginBinding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
val
channel
=
MethodChannel
(
flutterPluginBinding
.
binaryMessenger
,
"com.jarvanmo/fluwx"
)
val
channel
=
MethodChannel
(
flutterPluginBinding
.
binaryMessenger
,
"com.jarvanmo/fluwx"
)
channel
.
setMethodCallHandler
(
this
)
channel
.
setMethodCallHandler
(
this
)
fluwxChannel
=
channel
fluwxChannel
=
channel
context
=
flutterPluginBinding
.
applicationContext
context
=
flutterPluginBinding
.
applicationContext
authHandler
=
FluwxAuthHandler
(
channel
)
authHandler
=
FluwxAuthHandler
(
channel
)
shareHandler
=
FluwxShareHandlerEmbedding
(
shareHandler
=
FluwxShareHandlerEmbedding
(
flutterPluginBinding
.
flutterAssets
,
flutterPluginBinding
.
flutterAssets
,
flutterPluginBinding
.
applicationContext
flutterPluginBinding
.
applicationContext
)
)
}
}
override
fun
onMethodCall
(
@NonNull
call
:
MethodCall
,
@NonNull
result
:
Result
)
{
override
fun
onMethodCall
(
call
:
MethodCall
,
result
:
Result
)
{
callingChannel
=
fluwxChannel
callingChannel
=
fluwxChannel
when
{
when
{
call
.
method
==
"registerApp"
->
WXAPiHandler
.
registerApp
(
call
,
result
,
context
)
call
.
method
==
"registerApp"
->
WXAPiHandler
.
registerApp
(
call
,
result
,
context
)
...
@@ -75,12 +72,13 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -75,12 +72,13 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
call
.
method
==
"isWeChatInstalled"
->
WXAPiHandler
.
checkWeChatInstallation
(
result
)
call
.
method
==
"isWeChatInstalled"
->
WXAPiHandler
.
checkWeChatInstallation
(
result
)
call
.
method
==
"getExtMsg"
->
getExtMsg
(
result
)
call
.
method
==
"getExtMsg"
->
getExtMsg
(
result
)
call
.
method
==
"openWeChatCustomerServiceChat"
->
openWeChatCustomerServiceChat
(
call
.
method
==
"openWeChatCustomerServiceChat"
->
openWeChatCustomerServiceChat
(
call
,
call
,
result
result
)
)
call
.
method
==
"checkSupportOpenBusinessView"
->
WXAPiHandler
.
checkSupportOpenBusinessView
(
call
.
method
==
"checkSupportOpenBusinessView"
->
WXAPiHandler
.
checkSupportOpenBusinessView
(
result
result
)
)
call
.
method
==
"openBusinessView"
->
openBusinessView
(
call
,
result
)
call
.
method
==
"openBusinessView"
->
openBusinessView
(
call
,
result
)
call
.
method
==
"openWeChatInvoice"
->
openWeChatInvoice
(
call
,
result
);
call
.
method
==
"openWeChatInvoice"
->
openWeChatInvoice
(
call
,
result
);
...
@@ -104,7 +102,9 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -104,7 +102,9 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
request
.
timeStamp
=
System
.
currentTimeMillis
().
toString
()
request
.
timeStamp
=
System
.
currentTimeMillis
().
toString
()
request
.
nonceStr
=
System
.
currentTimeMillis
().
toString
()
request
.
nonceStr
=
System
.
currentTimeMillis
().
toString
()
request
.
signType
=
"SHA1"
request
.
signType
=
"SHA1"
request
.
cardSign
=
WXApiUtils
.
createSign
(
request
.
appId
,
request
.
nonceStr
,
request
.
timeStamp
,
request
.
cardType
)
request
.
cardSign
=
WXApiUtils
.
createSign
(
request
.
appId
,
request
.
nonceStr
,
request
.
timeStamp
,
request
.
cardType
)
val
done
=
WXAPiHandler
.
wxApi
?.
sendReq
(
request
)
val
done
=
WXAPiHandler
.
wxApi
?.
sendReq
(
request
)
result
.
success
(
done
)
result
.
success
(
done
)
}
}
...
@@ -122,11 +122,13 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -122,11 +122,13 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
override
fun
onReattachedToActivityForConfigChanges
(
binding
:
ActivityPluginBinding
)
{
override
fun
onReattachedToActivityForConfigChanges
(
binding
:
ActivityPluginBinding
)
{
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
handelIntent
(
binding
.
activity
.
intent
)
handelIntent
(
binding
.
activity
.
intent
)
FluwxRequestHandler
.
handleRequestInfoFromIntent
(
binding
.
activity
.
intent
)
}
}
override
fun
onAttachedToActivity
(
binding
:
ActivityPluginBinding
)
{
override
fun
onAttachedToActivity
(
binding
:
ActivityPluginBinding
)
{
// WXAPiHandler.setContext(binding.activity.applicationContext)
// WXAPiHandler.setContext(binding.activity.applicationContext)
handelIntent
(
binding
.
activity
.
intent
)
handelIntent
(
binding
.
activity
.
intent
)
FluwxRequestHandler
.
handleRequestInfoFromIntent
(
binding
.
activity
.
intent
)
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
}
}
...
...
android/src/main/kotlin/com/jarvan/fluwx/handlers/FluwxRequestHandler.kt
浏览文件 @
a40a414e
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
com.jarvan.fluwx.handlers
package
com.jarvan.fluwx.handlers
import
android.app.Activity
import
android.app.Activity
import
android.content.ActivityNotFoundException
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
...
@@ -24,13 +25,15 @@ import android.os.Bundle
...
@@ -24,13 +25,15 @@ import android.os.Bundle
import
android.util.Log
import
android.util.Log
import
androidx.core.content.ContextCompat.startActivity
import
androidx.core.content.ContextCompat.startActivity
import
com.jarvan.fluwx.FluwxPlugin
import
com.jarvan.fluwx.FluwxPlugin
import
com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_BUNDLE
import
com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_EXT_MSG
import
com.jarvan.fluwx.utils.startFlutterActivity
import
com.tencent.mm.opensdk.modelbase.BaseReq
import
com.tencent.mm.opensdk.modelbase.BaseReq
import
com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX
import
com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX
import
java.security.cert.Extension
import
java.security.cert.Extension
object
FluwxRequestHandler
{
object
FluwxRequestHandler
{
private
const
val
KEY_FLUWX_REQUEST_INFO_BUNDLE
=
"KEY_FLUWX_REQUEST_INFO_BUNDLE"
var
customOnReqDelegate
:
((
baseReq
:
BaseReq
,
activity
:
Activity
)
->
Unit
)?
=
null
var
customOnReqDelegate
:
((
baseReq
:
BaseReq
,
activity
:
Activity
)
->
Unit
)?
=
null
...
@@ -43,7 +46,8 @@ object FluwxRequestHandler {
...
@@ -43,7 +46,8 @@ object FluwxRequestHandler {
}
}
}
}
private
fun
handleShowMessageFromWXBundle
(
bundle
:
Bundle
)
=
handleWXShowMessageFromWX
(
ShowMessageFromWX
.
Req
(
bundle
))
private
fun
handleShowMessageFromWXBundle
(
bundle
:
Bundle
)
=
handleWXShowMessageFromWX
(
ShowMessageFromWX
.
Req
(
bundle
))
private
fun
handleRequest
(
req
:
BaseReq
)
{
private
fun
handleRequest
(
req
:
BaseReq
)
{
when
(
req
)
{
when
(
req
)
{
...
@@ -66,22 +70,21 @@ object FluwxRequestHandler {
...
@@ -66,22 +70,21 @@ object FluwxRequestHandler {
// com.tencent.mm.opensdk.constants.ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX = 4
// com.tencent.mm.opensdk.constants.ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX = 4
if
(!
WXAPiHandler
.
coolBoot
)
{
if
(!
WXAPiHandler
.
coolBoot
)
{
handleRequest
(
baseReq
)
handleRequest
(
baseReq
)
startSpecifiedActivity
(
defaultFlutterActivityAction
(
activity
),
activity
=
activity
)
activity
.
startFlutterActivity
(
)
}
else
{
}
else
{
when
(
baseReq
)
{
when
(
baseReq
)
{
is
ShowMessageFromWX
.
Req
->
{
is
ShowMessageFromWX
.
Req
->
{
try
{
activity
.
startFlutterActivity
(
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
"wechatextmsg://${activity.packageName}/?extmsg=${baseReq.message.messageExt}"
))
wxRequestBundle
=
Bundle
().
apply
{
val
bundle
=
Bundle
()
baseReq
.
toBundle
(
this
)
baseReq
.
toBundle
(
bundle
)
},
intent
.
putExtra
(
KEY_FLUWX_REQUEST_INFO_BUNDLE
,
bundle
)
bundle
=
Bundle
().
apply
{
activity
.
startActivity
(
intent
)
putString
(
activity
.
finish
()
KEY_FLUWX_REQUEST_INFO_EXT_MSG
,
baseReq
.
message
.
messageExt
)
})
WXAPiHandler
.
coolBoot
=
false
WXAPiHandler
.
coolBoot
=
false
}
catch
(
e
:
Exception
)
{
Log
.
i
(
"fluwx"
,
"call scheme error:${e.toString()}"
)
}
}
}
}
}
}
}
...
@@ -91,32 +94,18 @@ object FluwxRequestHandler {
...
@@ -91,32 +94,18 @@ object FluwxRequestHandler {
fun
onReq
(
baseReq
:
BaseReq
,
activity
:
Activity
)
{
fun
onReq
(
baseReq
:
BaseReq
,
activity
:
Activity
)
{
try
{
try
{
val
packageManager
=
activity
.
packageManager
val
packageManager
=
activity
.
packageManager
val
appInfo
=
packageManager
.
getApplicationInfo
(
activity
.
packageName
,
PackageManager
.
GET_META_DATA
)
val
appInfo
=
packageManager
.
getApplicationInfo
(
val
defaultHandle
=
appInfo
.
metaData
.
getBoolean
(
"handleWeChatRequestByFluwx"
,
true
)
activity
.
packageName
,
PackageManager
.
GET_META_DATA
)
val
defaultHandle
=
appInfo
.
metaData
.
getBoolean
(
"InterruptWeChatRequestByFluwx"
,
true
)
if
(
defaultHandle
)
{
if
(
defaultHandle
)
{
defaultOnReqDelegate
(
baseReq
,
activity
)
defaultOnReqDelegate
(
baseReq
,
activity
)
}
else
{
}
else
{
customOnReqDelegate
?.
invoke
(
baseReq
,
activity
)
customOnReqDelegate
?.
invoke
(
baseReq
,
activity
)
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
Log
.
i
(
"Fluwx"
,
"can't load meta-data handleWeChatRequestByFluwx"
)
Log
.
i
(
"Fluwx"
,
"can't load meta-data InterruptWeChatRequestByFluwx"
)
}
}
private
fun
startSpecifiedActivity
(
action
:
String
,
activity
:
Activity
,
bundle
:
Bundle
?
=
null
,
bundleKey
:
String
?
=
null
)
{
Intent
(
action
).
run
{
bundleKey
?.
let
{
putExtra
(
bundleKey
,
bundle
)
}
addFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
)
activity
.
packageManager
?.
let
{
resolveActivity
(
it
)
?.
also
{
activity
.
startActivity
(
this
)
activity
.
finish
()
}
}
}
}
}
}
private
fun
defaultFlutterActivityAction
(
context
:
Context
):
String
=
"${context.packageName}.FlutterActivity"
}
}
\ No newline at end of file
android/src/main/kotlin/com/jarvan/fluwx/handlers/WXAPiHandler.kt
浏览文件 @
a40a414e
...
@@ -92,7 +92,7 @@ object WXAPiHandler : ILog {
...
@@ -92,7 +92,7 @@ object WXAPiHandler : ILog {
wxApi
?.
isWXAppInstalled
!=
true
->
{
wxApi
?.
isWXAppInstalled
!=
true
->
{
result
.
error
(
"WeChat Not Installed"
,
"Please install the WeChat first"
,
null
)
result
.
error
(
"WeChat Not Installed"
,
"Please install the WeChat first"
,
null
)
}
}
wxApi
?.
wxAppSupportAPI
?:
0
<
Build
.
OPEN_BUSINESS_VIEW_SDK_INT
->
{
(
wxApi
?.
wxAppSupportAPI
?:
0
)
<
Build
.
OPEN_BUSINESS_VIEW_SDK_INT
->
{
result
.
error
(
"WeChat Not Supported"
,
"Please upgrade the WeChat version"
,
null
)
result
.
error
(
"WeChat Not Supported"
,
"Please upgrade the WeChat version"
,
null
)
}
}
else
->
{
else
->
{
...
@@ -108,20 +108,19 @@ object WXAPiHandler : ILog {
...
@@ -108,20 +108,19 @@ object WXAPiHandler : ILog {
}
}
fun
startLog
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
fun
startLog
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
wxApi
?.
setLogImpl
(
this
)
;
wxApi
?.
setLogImpl
(
this
)
result
.
success
(
true
)
;
result
.
success
(
true
)
}
}
fun
stopLog
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
fun
stopLog
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
wxApi
?.
setLogImpl
(
null
);
wxApi
?.
setLogImpl
(
null
)
result
.
success
(
true
);
result
.
success
(
true
)
}
}
override
fun
d
(
p0
:
String
?,
p1
:
String
?)
{
override
fun
d
(
p0
:
String
?,
p1
:
String
?)
{
when
{
when
{
p1
!=
null
->
{
p1
!=
null
->
{
Log
.
d
(
p0
,
p1
)
;
Log
.
d
(
p0
,
p1
)
}
}
}
}
}
}
...
...
android/src/main/kotlin/com/jarvan/fluwx/utils/FluwxExtensions.kt
0 → 100644
浏览文件 @
a40a414e
package
com.jarvan.fluwx.utils
import
android.app.Activity
import
android.content.ActivityNotFoundException
import
android.content.Context
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.os.Bundle
import
android.util.Log
internal
const
val
KEY_FLUWX_REQUEST_INFO_EXT_MSG
=
"KEY_FLUWX_REQUEST_INFO_EXT_MSG"
internal
const
val
KEY_FLUWX_REQUEST_INFO_BUNDLE
=
"KEY_FLUWX_REQUEST_INFO_BUNDLE"
internal
fun
Activity
.
startFlutterActivity
(
wxRequestBundle
:
Bundle
?
=
null
,
bundle
:
Bundle
?
=
null
,
)
{
flutterActivityIntent
()
?.
also
{
intent
->
intent
.
addFluwxExtras
()
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
)
bundle
?.
let
{
intent
.
putExtras
(
it
)
}
wxRequestBundle
?.
let
{
intent
.
putExtra
(
KEY_FLUWX_REQUEST_INFO_BUNDLE
,
it
)
}
try
{
startActivity
(
intent
)
}
catch
(
e
:
ActivityNotFoundException
)
{
Log
.
w
(
"fluwx"
,
"Can not start activity for Intent: $intent"
)
}
finally
{
finish
()
}
}
}
internal
fun
Context
.
flutterActivityIntent
():
Intent
?
{
val
appInfo
=
packageManager
.
getApplicationInfo
(
packageName
,
PackageManager
.
GET_META_DATA
)
val
flutterActivity
=
appInfo
.
metaData
.
getString
(
"FluwxFlutterActivity"
,
""
)
return
if
(
flutterActivity
.
isBlank
())
{
packageManager
.
getLaunchIntentForPackage
(
packageName
)
}
else
{
Intent
().
also
{
it
.
setClassName
(
this
,
"${packageName}.$flutterActivity"
)
}
}
}
internal
fun
Intent
.
addFluwxExtras
()
{
putExtra
(
"fluwx_payload_from_fluwx"
,
true
)
}
\ No newline at end of file
android/src/main/kotlin/com/jarvan/fluwx/wxapi/FluwxWXEntryActivity.kt
浏览文件 @
a40a414e
...
@@ -22,6 +22,8 @@ import android.os.Bundle
...
@@ -22,6 +22,8 @@ import android.os.Bundle
import
com.jarvan.fluwx.handlers.FluwxResponseHandler
import
com.jarvan.fluwx.handlers.FluwxResponseHandler
import
com.jarvan.fluwx.handlers.FluwxRequestHandler
import
com.jarvan.fluwx.handlers.FluwxRequestHandler
import
com.jarvan.fluwx.handlers.WXAPiHandler
import
com.jarvan.fluwx.handlers.WXAPiHandler
import
com.jarvan.fluwx.utils.flutterActivityIntent
import
com.jarvan.fluwx.utils.startFlutterActivity
import
com.tencent.mm.opensdk.modelbase.BaseReq
import
com.tencent.mm.opensdk.modelbase.BaseReq
import
com.tencent.mm.opensdk.modelbase.BaseResp
import
com.tencent.mm.opensdk.modelbase.BaseResp
import
com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
import
com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
...
@@ -38,19 +40,18 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
...
@@ -38,19 +40,18 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
try
{
try
{
if
(!
WXAPiHandler
.
wxApiRegistered
)
{
if
(!
WXAPiHandler
.
wxApiRegistered
)
{
val
appInfo
=
packageManager
.
getApplicationInfo
(
packageName
,
PackageManager
.
GET_META_DATA
)
val
appInfo
=
packageManager
.
getApplicationInfo
(
packageName
,
PackageManager
.
GET_META_DATA
)
val
wechatAppId
=
appInfo
.
metaData
.
getString
(
"
w
eChatAppId"
)
val
wechatAppId
=
appInfo
.
metaData
.
getString
(
"
W
eChatAppId"
)
if
(
wechatAppId
!=
null
)
{
if
(
wechatAppId
!=
null
)
{
WXAPiHandler
.
setupWxApi
(
wechatAppId
,
this
)
WXAPiHandler
.
setupWxApi
(
wechatAppId
,
this
)
WXAPiHandler
.
coolBoot
=
true
WXAPiHandler
.
coolBoot
=
true
}
else
{
}
else
{
Log
.
e
(
"fluwx"
,
"can't load meta-data weChatAppId"
)
Log
.
w
(
"fluwx"
,
"can't load meta-data weChatAppId"
)
}
}
}
}
WXAPiHandler
.
wxApi
?.
handleIntent
(
intent
,
this
)
WXAPiHandler
.
wxApi
?.
handleIntent
(
intent
,
this
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
startSpecifiedActivity
(
defaultFlutterActivityAction
())
this
.
startFlutterActivity
()
finish
()
}
}
}
}
...
@@ -63,8 +64,7 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
...
@@ -63,8 +64,7 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
WXAPiHandler
.
wxApi
?.
handleIntent
(
intent
,
this
)
WXAPiHandler
.
wxApi
?.
handleIntent
(
intent
,
this
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
startSpecifiedActivity
(
defaultFlutterActivityAction
())
this
.
startFlutterActivity
()
finish
()
}
}
}
}
...
@@ -80,21 +80,4 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
...
@@ -80,21 +80,4 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
FluwxResponseHandler
.
handleResponse
(
resp
)
FluwxResponseHandler
.
handleResponse
(
resp
)
finish
()
finish
()
}
}
private
fun
startSpecifiedActivity
(
action
:
String
,
bundle
:
Bundle
?
=
null
,
bundleKey
:
String
?
=
null
)
{
Intent
(
action
).
run
{
bundleKey
?.
let
{
putExtra
(
bundleKey
,
bundle
)
}
addFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
)
packageManager
?.
let
{
resolveActivity
(
packageManager
)
?.
also
{
startActivity
(
this
)
finish
()
}
}
}
}
private
fun
defaultFlutterActivityAction
():
String
=
"$packageName.FlutterActivity"
}
}
\ No newline at end of file
example/android/app/src/main/AndroidManifest.xml
浏览文件 @
a40a414e
...
@@ -36,18 +36,6 @@
...
@@ -36,18 +36,6 @@
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
<intent-filter>
<action
android:name=
"${applicationId}.FlutterActivity"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<data
android:host=
"${applicationId}"
android:path=
"/"
android:scheme=
"wechatextmsg"
/>
</intent-filter>
</activity>
</activity>
<!-- Don't delete the meta-data below.
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
...
...
example/pubspec.yaml
浏览文件 @
a40a414e
...
@@ -82,3 +82,11 @@ flutter:
...
@@ -82,3 +82,11 @@ flutter:
#
#
# For details regarding fonts from package dependencies,
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
# see https://flutter.dev/custom-fonts/#from-packages
fluwx
:
app_id
:
123456
android
:
interrupt_wx_request
:
true
flutter_activity
:
MainActivity
ios
:
uni_link
:
hello
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论