Skip to content

Commit 3f0ca7a

Browse files
authored
Merge pull request #566 from RedrockMobile/guoxiangrui/feature/update_libs
Guoxiangrui/feature/update libs
2 parents c5c7599 + 156109d commit 3f0ca7a

26 files changed

Lines changed: 273 additions & 286 deletions

File tree

build-logic/manager/proguard-rules.pro

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@
195195
volatile <fields>;
196196
}
197197

198-
# httpdns https://help.aliyun.com/document_detail/435252.html?spm=a2c4g.435261.0.0.ac114b46hmmXJI
199-
-keep class com.aliyun.ams.ipdetector.Inet64Util{*;}
200-
-keep class com.alibaba.sdk.android.**{*;}
201-
-keep class com.ut.**{*;}
202-
-keep class com.ta.**{*;}
203198
#-------------------------------------------------------------------------
204199

205200
#---------------------------------3.与js互相调用的类------------------------

build-logic/manager/src/main/kotlin/manager.app-android.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ android {
1515
targetSdk = libsEx.versions.`android-targetSdk`.toInt()
1616
versionCode = Config.versionCode
1717
versionName = Config.versionName
18-
// 添加以下两句代码,这是 LPhotoPicker 需要设置的东西
19-
renderscriptTargetApi = libsEx.versions.`android-targetSdk`.toInt() //版本号请与compileSdkVersion保持一致
20-
renderscriptSupportModeEnabled = true
2118
}
2219
buildTypes {
2320
release {

build-logic/manager/src/main/kotlin/manager.lib.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ kotlin {
2121
targetSdk = libsEx.versions.`android-targetSdk`.toInt()
2222
}
2323
androidResources {
24-
// 是否启动资源取决于是否还存在 androidMain/res 文件
25-
enable = project.projectDir.resolve("src").resolve("androidMain").resolve("res").exists()
24+
// 是否启动资源取决于是否还存在 /res 或 /composeResources 目录
25+
//noinspection WrongGradleMethod
26+
enable = project.projectDir.resolve("src").listFiles()
27+
?.filter { it.name.lowercase().endsWith("main") && it.isDirectory }
28+
?.any { it.resolve("res").exists() || it.resolve("composeResources").exists() }
29+
?: false
2630
// 命名规范设置,因为多模块相同资源名在打包时会合并,所以必须强制开启
2731
val paths = project.path.split(":").drop(1)
2832
if (paths.size == 1) {

cyxbs-components/account/src/commonMain/kotlin/com/cyxbs/components/account/AccountService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ object AccountService : IAccountService, IAccountEditService {
7676
private fun resetAccountCoroutineScope() {
7777
val oldScope = accountCoroutineScope
7878
val supervisor = SupervisorJob(appCoroutineScope.coroutineContext[Job])
79-
accountCoroutineScope = CoroutineScope(supervisor)
79+
accountCoroutineScope = CoroutineScope(supervisor + EmptyCoroutineExceptionHandler)
8080
oldScope.cancel()
8181
}
8282
}

cyxbs-components/config/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ kotlin {
1919
implementation(libs.material)
2020
implementation(libs.dialog) // 因为要设置 MaterialDialog 主题所以依赖
2121
implementation(libs.rxjava)
22-
implementation(libs.lPhotoPicker)
2322
}
2423
}
2524
}

cyxbs-components/config/src/androidMain/res/values/styles.xml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,6 @@
3737
<item name="cornerSize">50%</item>
3838
</style>
3939

40-
<style name="ConfigLPhotoTheme" parent="LPhotoTheme">
41-
<!--页面通用属性(图片选择、图片预览共用)-->
42-
<item name="l_pp_toolBar_height">56dp</item>
43-
<item name="l_pp_toolBar_backIcon">@drawable/config_ic_back</item><!--返回按钮资源-->
44-
<item name="l_pp_toolBar_title_size">16sp</item><!--toolBar上字体大小-->
45-
<item name="l_pp_bottomBar_height">50dp</item><!--底栏的高度-->
46-
<!--图片选择页面属性-->
47-
<item name="l_pp_status_bar_color">@color/config_photo_select_status_color
48-
</item><!--状态栏颜色-->
49-
<item name="l_pp_toolBar_background">@color/config_photo_select_status_color
50-
</item><!--toolBar颜色-->
51-
<item name="l_pp_picker_activity_bg">@color/config_window_background
52-
</item><!--activity背景颜色-->
53-
<item name="l_pp_toolBar_title_color">@color/config_level_two_font_color
54-
</item><!--(图片选择页面)顶部toolBar字体颜色-->
55-
<item name="l_pp_picker_bottomBar_background">@color/config_window_background
56-
</item><!--底栏的颜色,如果需要毛玻璃效果,颜色加上透明度-->
57-
<item name="l_pp_picker_bottomBar_enabled_text_color">#333333</item><!--底部按钮启用时的颜色-->
58-
59-
<!--图片分割线宽度-->
60-
61-
<!--圆形选择框样式(图片选择、图片预览共用,有特别说明的除外)-->
62-
<item name="l_pp_checkBox_color_tick" format="color">#00FF7F</item><!--勾勾颜色-->
63-
<item name="l_pp_checkBox_duration" format="integer">100</item><!--动画时间-->
64-
<item name="l_pp_checkBox_color_checked" format="color">@color/colorPrimary
65-
</item><!--选择后的背景色-->
66-
<item name="l_pp_checkBox_stroke_width" format="dimension">2dp</item><!--(仅预览页面)圆圈边框宽度-->
67-
<item name="l_pp_checkBox_tick_width" format="dimension">2dp</item><!--勾勾的线条宽度-->
68-
</style>
69-
7040
<style name="ConfigBottomSheetDialogTheme" parent="Theme.Design.BottomSheetDialog" tools:ignore="ResourceName">
7141
<!--dialog是否有边框-->
7242
<item name="android:windowFrame">@null</item>

cyxbs-pages/course/view/src/commonMain/composeResources/drawable/view_ic_touch_affair.xml renamed to cyxbs-components/config/src/commonMain/composeResources/drawable/config_ic_circle_add.xml

File renamed without changes.

cyxbs-components/config/src/commonMain/kotlin/com/cyxbs/components/config/res/ConfigRes.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cyxbs.components.config.res
22

33
import cyxbsmobile.cyxbs_components.config.generated.resources.Res
4+
import cyxbsmobile.cyxbs_components.config.generated.resources.config_ic_circle_add
45
import cyxbsmobile.cyxbs_components.config.generated.resources.config_ic_compose_app_logo
56
import cyxbsmobile.cyxbs_components.config.generated.resources.config_ic_compose_back
67
import cyxbsmobile.cyxbs_components.config.generated.resources.config_ic_compose_place_holder
@@ -16,4 +17,5 @@ object ConfigRes {
1617
fun configIcAppLogo() : DrawableResource = Res.drawable.config_ic_compose_app_logo
1718
fun configIcBack() : DrawableResource = Res.drawable.config_ic_compose_back
1819
fun configIcPlaceHolder() : DrawableResource = Res.drawable.config_ic_compose_place_holder
20+
fun configIcCircleAdd(): DrawableResource = Res.drawable.config_ic_circle_add
1921
}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
package com.cyxbs.components.utils.extensions
2+
3+
import android.net.Uri
4+
import androidx.activity.result.ActivityResultLauncher
5+
import androidx.activity.result.PickVisualMediaRequest
6+
import androidx.activity.result.contract.ActivityResultContracts
7+
import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.ImageOnly
8+
import androidx.fragment.app.Fragment
9+
import androidx.fragment.app.FragmentActivity
10+
11+
/**
12+
* Android 图片选择器工具类
13+
*
14+
* 使用 Android 官方的 Photo Picker API,无需申请存储权限
15+
* - Android 13+ (API 33+): 使用系统级 Photo Picker
16+
* - Android 13-: 自动降级为传统文件选择器
17+
*
18+
* @author GuoXiangrui
19+
* @time 2026/5/17
20+
*/
21+
22+
23+
/*
24+
* 如果你需要在多平台上使用图片选择器,则可以参考 map 模块中的 UploadPhotoDialog
25+
* 使用多平台文件选择库 FileKit https://github.com/vinceglb/FileKit
26+
*
27+
*
28+
* */
29+
30+
// ==================== Activity 扩展函数 ====================
31+
32+
/**
33+
* 注册多选图片的 ActivityResultLauncher
34+
*
35+
* @param maxImages 最大可选择图片数量,默认 9 张
36+
* @return ActivityResultLauncher<List<Uri>> 用于启动图片选择器
37+
*
38+
* 使用示例:
39+
* ```kotlin
40+
* private val pickImagesLauncher = registerForPickMultipleImages(5) { uris ->
41+
* // 处理选中的图片 URI 列表
42+
* if (uris.isNotEmpty()) {
43+
* handleSelectedImages(uris)
44+
* }
45+
* }
46+
*
47+
* // 启动选择器
48+
* pickImagesLauncher.launchPickImages()
49+
* ```
50+
*/
51+
fun FragmentActivity.registerForPickMultipleImages(
52+
maxImages: Int = 9,
53+
onResult: (List<Uri>) -> Unit
54+
): ActivityResultLauncher<PickVisualMediaRequest> {
55+
return registerForActivityResult(
56+
ActivityResultContracts.PickMultipleVisualMedia(maxImages)
57+
) { uris ->
58+
onResult(uris)
59+
}
60+
}
61+
62+
/**
63+
* 注册单选图片的 ActivityResultLauncher
64+
*
65+
* @return ActivityResultLauncher<Uri?> 用于启动图片选择器
66+
*
67+
* 使用示例:
68+
* ```kotlin
69+
* private val pickImageLauncher = registerForPickSingleImage { uri ->
70+
* // 处理选中的图片 URI
71+
* uri?.let {
72+
* handleSelectedImage(it)
73+
* }
74+
* }
75+
*
76+
* // 启动选择器
77+
* pickImageLauncher.launchPickImages()
78+
* ```
79+
*/
80+
fun FragmentActivity.registerForPickSingleImage(
81+
onResult: (Uri?) -> Unit
82+
): ActivityResultLauncher<PickVisualMediaRequest> {
83+
return registerForActivityResult(
84+
ActivityResultContracts.PickVisualMedia()
85+
) { uri ->
86+
onResult(uri)
87+
}
88+
}
89+
90+
// ==================== Fragment 扩展函数 ====================
91+
92+
/**
93+
* Fragment 中注册多选图片的 ActivityResultLauncher
94+
*
95+
* @param maxImages 最大可选择图片数量,默认 9 张
96+
* @return ActivityResultLauncher<List<Uri>> 用于启动图片选择器
97+
*/
98+
fun Fragment.registerForPickMultipleImages(
99+
maxImages: Int = 9,
100+
onResult: (List<Uri>) -> Unit
101+
): ActivityResultLauncher<PickVisualMediaRequest> {
102+
return registerForActivityResult(
103+
ActivityResultContracts.PickMultipleVisualMedia(maxImages)
104+
) { uris ->
105+
onResult(uris)
106+
}
107+
}
108+
109+
/**
110+
* Fragment 中注册单选图片的 ActivityResultLauncher
111+
*
112+
* @return ActivityResultLauncher<Uri?> 用于启动图片选择器
113+
*/
114+
fun Fragment.registerForPickSingleImage(
115+
onResult: (Uri?) -> Unit
116+
): ActivityResultLauncher<PickVisualMediaRequest> {
117+
return registerForActivityResult(
118+
ActivityResultContracts.PickVisualMedia()
119+
) { uri ->
120+
onResult(uri)
121+
}
122+
}
123+
124+
// ==================== 便捷启动函数 ====================
125+
126+
/**
127+
* 启动多选图片选择器(仅图片)
128+
*
129+
* 使用示例:
130+
* ```kotlin
131+
* pickImagesLauncher.launchPickImages()
132+
* ```
133+
*/
134+
fun ActivityResultLauncher<PickVisualMediaRequest>.launchPickImages() {
135+
this.launch(PickVisualMediaRequest(ImageOnly))
136+
}
137+
138+
/**
139+
* 启动多选图片选择器(图片和视频)
140+
*
141+
* 使用示例:
142+
* ```kotlin
143+
* pickMediaLauncher.launchPickImagesAndVideos()
144+
* ```
145+
*/
146+
fun ActivityResultLauncher<PickVisualMediaRequest>.launchPickImagesAndVideos() {
147+
this.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageAndVideo))
148+
}
149+
150+
/**
151+
* 启动多选图片选择器(仅视频)
152+
*
153+
* 使用示例:
154+
* ```kotlin
155+
* pickVideosLauncher.launchPickVideos()
156+
* ```
157+
*/
158+
fun ActivityResultLauncher<PickVisualMediaRequest>.launchPickVideos() {
159+
this.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.VideoOnly))
160+
}
161+
162+
/**
163+
* 启动多选图片选择器(指定 MIME 类型)
164+
*
165+
* @param mimeType MIME 类型,例如 "image/gif"
166+
*
167+
* 使用示例:
168+
* ```kotlin
169+
* pickGifLauncher.launchPickByMimeType("image/gif")
170+
* ```
171+
*/
172+
fun ActivityResultLauncher<PickVisualMediaRequest>.launchPickByMimeType(mimeType: String) {
173+
this.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.SingleMimeType(mimeType)))
174+
}

cyxbs-components/view/src/commonMain/kotlin/com/cyxbs/components/view/ui/BottomSheet.kt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ class BottomSheetState(
105105
now - new
106106
}
107107

108+
internal val bottomSheetSpring = spring(
109+
stiffness = Spring.StiffnessMediumLow,
110+
visibilityThreshold = 1F // 当距离目标 < 1px 时认为到达,如果不设置,会导致动画持续较久
111+
)
112+
108113
suspend fun expand() {
109114
if (state == BottomSheetValueState.Expanded) return
110115
val now = showHeight.floatValue
@@ -113,9 +118,7 @@ class BottomSheetState(
113118
setState(BottomSheetValueState.Scrolling)
114119
scrollableState.animateScrollBy(
115120
value = now - target,
116-
spring(
117-
stiffness = Spring.StiffnessMediumLow,
118-
)
121+
animationSpec = bottomSheetSpring,
119122
)
120123
}
121124
setState(BottomSheetValueState.Expanded)
@@ -129,9 +132,7 @@ class BottomSheetState(
129132
setState(BottomSheetValueState.Scrolling)
130133
scrollableState.animateScrollBy(
131134
value = now - target,
132-
spring(
133-
stiffness = Spring.StiffnessMediumLow,
134-
)
135+
animationSpec = bottomSheetSpring,
135136
)
136137
}
137138
setState(BottomSheetValueState.Collapsed)
@@ -145,9 +146,7 @@ class BottomSheetState(
145146
// hide 不触发 Scrolling 状态
146147
scrollableState.animateScrollBy(
147148
value = now - target,
148-
spring(
149-
stiffness = Spring.StiffnessMediumLow,
150-
)
149+
animationSpec = bottomSheetSpring,
151150
)
152151
}
153152
setState(BottomSheetValueState.Hide)
@@ -299,9 +298,7 @@ private fun BottomSheetContent(
299298
snapFlingBehavior(
300299
snapLayoutInfoProvider = BottomSheetSnapLayoutInfoProvider(bottomSheetState),
301300
decayAnimationSpec = decayAnimationSpec,
302-
snapAnimationSpec = spring(
303-
stiffness = Spring.StiffnessMediumLow,
304-
)
301+
snapAnimationSpec = bottomSheetState.bottomSheetSpring,
305302
)
306303
}
307304
Box(

0 commit comments

Comments
 (0)