Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
98790f7c
提交
98790f7c
authored
5月 15, 2023
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor app_id generate
上级
0176e8c3
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
47 行增加
和
23 行删除
+47
-23
build.gradle
android/build.gradle
+44
-8
AndroidManifest.xml
android/src/main/AndroidManifest.xml
+0
-4
FluwxWXEntryActivity.kt
...ain/kotlin/com/jarvan/fluwx/wxapi/FluwxWXEntryActivity.kt
+3
-3
AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+0
-8
没有找到文件。
android/build.gradle
浏览文件 @
98790f7c
...
@@ -3,6 +3,8 @@ import org.yaml.snakeyaml.Yaml
...
@@ -3,6 +3,8 @@ import org.yaml.snakeyaml.Yaml
group
'com.jarvan.fluwx'
group
'com.jarvan.fluwx'
version
'1.0-SNAPSHOT'
version
'1.0-SNAPSHOT'
Map
projectYaml
=
loadPubspec
()
buildscript
{
buildscript
{
ext
.
kotlin_version
=
'1.7.10'
ext
.
kotlin_version
=
'1.7.10'
repositories
{
repositories
{
...
@@ -31,14 +33,14 @@ android {
...
@@ -31,14 +33,14 @@ android {
compileSdk
31
compileSdk
31
sourceSets
{
sourceSets
{
main
.
java
.
srcDirs
+=
'src/main/kotlin'
main
.
java
.
srcDirs
+=
[
'src/main/kotlin'
,
"${buildDir}/generated/main/kotlin"
]
test
.
java
.
srcDirs
+=
'src/test/kotlin'
test
.
java
.
srcDirs
+=
'src/test/kotlin'
}
}
defaultConfig
{
defaultConfig
{
minSdkVersion
16
minSdkVersion
16
consumerProguardFiles
'consumer-proguard-rules.txt'
consumerProguardFiles
'consumer-proguard-rules.txt'
manifestPlaceholders
=
loadManifestPlaceholder
()
manifestPlaceholders
=
loadManifestPlaceholder
(
projectYaml
)
}
}
dependencies
{
dependencies
{
...
@@ -64,12 +66,16 @@ android {
...
@@ -64,12 +66,16 @@ android {
}
}
}
}
Map
load
ManifestPlaceholder
()
{
Map
load
Pubspec
()
{
def
path
=
rootProject
.
projectDir
.
parent
+
File
.
separator
+
"pubspec.yaml"
def
path
=
rootProject
.
projectDir
.
parent
+
File
.
separator
+
"pubspec.yaml"
InputStream
input
=
new
FileInputStream
(
new
File
(
path
))
InputStream
input
=
new
FileInputStream
(
new
File
(
path
))
Yaml
yaml
=
new
Yaml
()
Yaml
yaml
=
new
Yaml
()
Map
projectConfig
=
yaml
.
load
(
input
)
Map
projectConfig
=
yaml
.
load
(
input
)
String
appId
=
""
return
projectConfig
}
static
def
loadManifestPlaceholder
(
Map
projectConfig
)
{
String
interruptWxRequest
=
"true"
String
interruptWxRequest
=
"true"
String
flutterActivity
=
""
String
flutterActivity
=
""
String
debugLogging
=
"disabled"
String
debugLogging
=
"disabled"
...
@@ -95,8 +101,37 @@ Map loadManifestPlaceholder() {
...
@@ -95,8 +101,37 @@ Map loadManifestPlaceholder() {
}
}
return
[
"WeChatAppId"
:
appId
,
return
[
"InterruptWeChatRequestByFluwx"
:
interruptWxRequest
,
"InterruptWeChatRequestByFluwx"
:
interruptWxRequest
,
"FluwxFlutterActivity"
:
flutterActivity
,
"FluwxFlutterActivity"
:
flutterActivity
,
"WeChatDebugLogging"
:
debugLogging
]
"WeChatDebugLogging"
:
debugLogging
]
}
tasks
.
register
(
"generateFluwxHelperFile"
)
{
Map
config
=
loadPubspec
()
Map
fluwx
=
(
Map
)
config
.
get
(
"fluwx"
)
if
(
fluwx
)
{
String
appId
=
(
String
)
fluwx
.
get
(
"app_id"
)
if
(
appId
==
null
)
{
appId
=
""
}
File
generateFolder
=
new
File
(
"${buildDir}/generated/main/kotlin/com/jarvan/fluwx"
)
String
template
=
"package com.jarvan.fluwx\n"
+
"// auto generated\n"
+
"object FluwxHelper {\n"
+
" val appId:String =\"&&PLACEHOLDER&&\";\n"
+
"}"
if
(!
generateFolder
.
exists
())
{
generateFolder
.
mkdirs
()
}
file
(
"${generateFolder.absolutePath}/FluwxHelper.kt"
).
text
=
template
.
replace
(
"&&PLACEHOLDER&&"
,
appId
)
}
}
}
tasks
.
named
(
"build"
).
configure
{
dependsOn
(
"generateFluwxHelperFile"
)
}
\ No newline at end of file
android/src/main/AndroidManifest.xml
浏览文件 @
98790f7c
...
@@ -12,10 +12,6 @@
...
@@ -12,10 +12,6 @@
<application>
<application>
<meta-data
android:name=
"WeChatAppId"
android:value=
"${WeChatAppId}"
/>
<meta-data
<meta-data
android:name=
"InterruptWeChatRequestByFluwx"
android:name=
"InterruptWeChatRequestByFluwx"
android:value=
"${InterruptWeChatRequestByFluwx}"
/>
android:value=
"${InterruptWeChatRequestByFluwx}"
/>
...
...
android/src/main/kotlin/com/jarvan/fluwx/wxapi/FluwxWXEntryActivity.kt
浏览文件 @
98790f7c
...
@@ -19,6 +19,7 @@ import android.app.Activity
...
@@ -19,6 +19,7 @@ import android.app.Activity
import
android.content.Intent
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.os.Bundle
import
android.os.Bundle
import
com.jarvan.fluwx.FluwxHelper
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
...
@@ -39,9 +40,8 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
...
@@ -39,9 +40,8 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
try
{
try
{
if
(!
WXAPiHandler
.
wxApiRegistered
)
{
if
(!
WXAPiHandler
.
wxApiRegistered
)
{
val
appInfo
=
packageManager
.
getApplicationInfo
(
packageName
,
PackageManager
.
GET_META_DATA
)
val
wechatAppId
=
FluwxHelper
.
appId
val
wechatAppId
=
appInfo
.
metaData
.
getString
(
"WeChatAppId"
)
if
(
wechatAppId
.
isNotBlank
())
{
if
(
wechatAppId
!=
null
)
{
WXAPiHandler
.
setupWxApi
(
wechatAppId
,
this
)
WXAPiHandler
.
setupWxApi
(
wechatAppId
,
this
)
WXAPiHandler
.
coolBoot
=
true
WXAPiHandler
.
coolBoot
=
true
}
else
{
}
else
{
...
...
example/android/app/src/main/AndroidManifest.xml
浏览文件 @
98790f7c
...
@@ -16,14 +16,6 @@
...
@@ -16,14 +16,6 @@
android:icon=
"@mipmap/ic_launcher"
android:icon=
"@mipmap/ic_launcher"
android:label=
"fluwx_example"
>
android:label=
"fluwx_example"
>
<meta-data
android:name=
"weChatAppId"
android:value=
"12345678"
/>
<meta-data
android:name=
"handleWeChatRequestByFluwx"
android:value=
"true"
/>
<activity
<activity
android:name=
".MainActivity"
android:name=
".MainActivity"
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论