Skip to content

Commit 4ae052f

Browse files
committed
Merge branch 'dev' into release
# Conflicts: # app/build.gradle # gradle.properties # settings.gradle
2 parents 1c4d3ee + 1b02af8 commit 4ae052f

File tree

35 files changed

+1066
-39
lines changed

35 files changed

+1066
-39
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ local.properties
1818

1919
lint-baseline.xml
2020
full-r8-config.txt
21+
22+
# Http Client 的环境私有配置,可以忽略
23+
# http-client.private.env.json

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ MVVM 架构, 基于 Kotlin + JetPack 组件: Lifecycle + LiveData + ViewModel +
6161
- 浏览器 Scheme 跳转。打开浏览器时,使用自定义浏览器列表,包含系统浏览器列表之外的一些浏览器(而且不会出现什么 天猫、京东、微博、WPS 这些阿猫阿狗都来冒充浏览器的情况)
6262
- (系统浏览器列表规则是,当用户在系统设置了默认浏览器应用, 之后只能调起这一个默认浏览器)
6363
- (微信的方案似乎是,获取了可解析 http/https Scheme 的所有应用列表,然后自定义浏览器应用列表界面和App自己的默认浏览器逻辑)
64-
- (另外,小米 MIUI 12 有个 Bug,魔改它自己的默认浏览器到推荐位置后导致后面其他方式的索引差了一位,其他系统没有这个问题
64+
- (另外,小米 MIUI 12 有个 Bug,魔改它自己的默认浏览器到推荐位置后导致后面其它方式的索引差了一位,其它系统没有这个问题
6565
- 应用商店 Scheme 跳转
6666
- http/https Scheme 处理
6767
- 自定义 wanandroid Scheme 处理

app/build.gradle

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ android {
3434
namespace 'com.example.wan.android'
3535
// 确定编译应用时,项目代码可以使用哪些 API。不影响应用运行时的行为,只影响编译时可以访问到哪些类和方法
3636
compileSdk 35
37+
// compileSdkExtension 15
3738

3839
defaultConfig {
3940
applicationId "com.example.wan.android"
@@ -47,7 +48,7 @@ android {
4748

4849
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4950

50-
// resConfigs "zh"
51+
resConfigs "zh", "zh-rHK"//, "zh-rTW"
5152
ndk {
5253
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
5354
}
@@ -74,6 +75,7 @@ android {
7475

7576
/*
7677
signingConfigs {
78+
// https://developer.android.com/studio/publish/app-signing#secure_key
7779
config {
7880
storeFile file(rootProject.ext.sign.filePath)
7981
storePassword rootProject.ext.sign.storePassword
@@ -86,9 +88,9 @@ android {
8688
// https://developer.android.com/build/build-variants
8789
buildTypes {
8890
debug {
89-
debuggable true
90-
minifyEnabled false
91-
shrinkResources false
91+
debuggable true // 可调试
92+
minifyEnabled false // 代码压缩 (R8/ProGuard)
93+
shrinkResources false // 资源压缩 (shrinkResources)
9294
signingConfig signingConfigs.debug
9395
}
9496
release {
@@ -250,6 +252,11 @@ dependencies {
250252
// def composeBoMVersion = "2024.12.01"
251253
// def composeBoMVersion = "2025.01.01"
252254
// def composeBoMVersion = "2025.02.00"
255+
// def composeBoMVersion = "2025.03.01"
256+
// def composeBoMVersion = "2025.04.01"
257+
// def composeBoMVersion = "2025.05.01"
258+
// def composeBoMVersion = "2025.06.01"
259+
// def composeBoMVersion = "2025.07.01"
253260
implementation(platform("androidx.compose:compose-bom:${composeBoMVersion}"))
254261
androidTestImplementation(platform("androidx.compose:compose-bom:${composeBoMVersion}"))
255262
implementation("androidx.compose.runtime:runtime")
@@ -309,9 +316,11 @@ dependencies {
309316
implementation platform("org.jetbrains.kotlin:kotlin-bom:${kotlin_version}")
310317
implementation "com.google.android.material:material:1.12.0"
311318
implementation "androidx.appcompat:appcompat:1.7.0"
319+
// 1.16.0 需要 AGP 8.6.0+
312320
implementation "androidx.core:core-ktx:1.15.0"
313321
implementation "androidx.core:core-splashscreen:1.0.1"
314322
implementation "androidx.activity:activity-ktx:1.9.3"
323+
// 2.9.0 需要 AGP 8.6.0+
315324
def lifecycleVersion = "2.8.7"
316325
implementation "androidx.lifecycle:lifecycle-runtime-ktx:${lifecycleVersion}"
317326
implementation "androidx.lifecycle:lifecycle-livedata-ktx:${lifecycleVersion}"
@@ -322,10 +331,11 @@ dependencies {
322331
implementation "androidx.lifecycle:lifecycle-service:${lifecycleVersion}"
323332
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:${lifecycleVersion}"
324333
implementation "androidx.constraintlayout:constraintlayout:2.2.0"
334+
// viewpager2 1.1 新特性 registerFragmentTransactionCallback
325335
implementation "androidx.viewpager2:viewpager2:1.1.0"
326336
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:${lifecycleVersion}") // compose
327-
// 1.1 新特性 registerFragmentTransactionCallback
328-
def navigationVersion = "2.8.4"
337+
// 2.9.0 需要 AGP 8.6.0+
338+
def navigationVersion = "2.8.9"
329339
implementation "androidx.navigation:navigation-fragment-ktx:${navigationVersion}"
330340
implementation "androidx.navigation:navigation-ui-ktx:${navigationVersion}"
331341
implementation("androidx.navigation:navigation-compose:${navigationVersion}") // compose

app/src/main/java/com/example/wan/android/base/BaseViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ abstract class BaseViewModel : ViewModel(),
133133
}
134134
onLogout()
135135
}
136-
// 其他错误
136+
// 其它错误
137137
else -> {
138138
if (showErrorToast) {
139139
toast(exception.message)

app/src/main/java/com/example/wan/android/compose/ComposeActivity.kt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.example.wan.android.compose
22

3+
import android.app.LocaleConfig
4+
import android.app.LocaleManager
5+
import android.os.Build
36
import android.os.Bundle
7+
import android.os.LocaleList
48
import androidx.activity.ComponentActivity
59
import androidx.activity.compose.setContent
610
import androidx.activity.enableEdgeToEdge
@@ -33,12 +37,17 @@ import androidx.compose.ui.unit.sp
3337
import com.blankj.utilcode.util.ActivityUtils
3438
import com.example.wan.android.R
3539
import com.example.wan.android.compose.ui.theme.WanAndroidTheme
40+
import com.example.wan.android.constant.AppConst
3641
import com.example.wan.android.index.person.BookmarkActivity
3742
import com.example.wan.android.index.person.HistoryActivity
3843
import com.example.wan.android.index.setting.ManageSpaceActivity
44+
import com.example.wan.android.ui.dialog.AppDetailDialog
45+
import com.example.wan.android.utils.UserUtils
46+
import com.example.wan.android.utils.logi
3947
import com.example.wan.android.utils.px2dp
4048
import com.example.wan.android.utils.startBrowser
4149
import com.example.wan.android.utils.startUrl
50+
import com.example.wan.android.utils.toJson
4251
import com.example.wan.android.utils.toast
4352

4453
class ComposeActivity : ComponentActivity() {
@@ -90,6 +99,48 @@ fun PageList(name: String, modifier: Modifier = Modifier) {
9099
Spacer(modifier = Modifier.size(1.px2dp()))
91100
}
92101
item {
102+
// Test
103+
Row(
104+
horizontalArrangement = Arrangement.Center,
105+
modifier = Modifier
106+
.fillMaxWidth()
107+
.background(colorResource(id = R.color.wx_foreground))
108+
.clickable {
109+
// 测试
110+
toast("测试")
111+
112+
}
113+
.padding(16.dp)
114+
) {
115+
Text(
116+
text = "测试",
117+
fontSize = 18.sp,
118+
color = colorResource(id = R.color.primaryText)
119+
)
120+
}
121+
Spacer(modifier = Modifier.size(1.px2dp()))
122+
// DetailActivity
123+
Row(
124+
horizontalArrangement = Arrangement.Center,
125+
modifier = Modifier
126+
.fillMaxWidth()
127+
.background(colorResource(id = R.color.wx_foreground))
128+
.clickable {
129+
AppDetailDialog(
130+
context = context,
131+
env = AppConst.BASE_URL,
132+
uid = "${UserUtils.getSuperUserInfo()?.userInfo?.id ?: "null"}",
133+
).show()
134+
}
135+
.padding(16.dp)
136+
) {
137+
Text(
138+
text = "AppDetailDialog",
139+
fontSize = 18.sp,
140+
color = colorResource(id = R.color.primaryText)
141+
)
142+
}
143+
Spacer(modifier = Modifier.size(1.px2dp()))
93144
// AccountActivity
94145
Row(
95146
horizontalArrangement = Arrangement.Center,

app/src/main/java/com/example/wan/android/index/setting/SettingActivity.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import android.transition.TransitionInflater
1111
import androidx.appcompat.app.AppCompatDelegate
1212
import androidx.lifecycle.lifecycleScope
1313
import com.blankj.utilcode.util.AppUtils
14+
import com.blankj.utilcode.util.ClipboardUtils
1415
import com.blankj.utilcode.util.ConvertUtils
1516
import com.blankj.utilcode.util.FileUtils
1617
import com.blankj.utilcode.util.PathUtils
@@ -29,11 +30,13 @@ import com.example.wan.android.utils.MyAppUtils
2930
import com.example.wan.android.utils.UserUtils
3031
import com.example.wan.android.utils.ext.alert
3132
import com.example.wan.android.utils.ext.cancel
33+
import com.example.wan.android.utils.ext.neutral
3234
import com.example.wan.android.utils.ext.ok
3335
import com.example.wan.android.utils.ext.visible
3436
import com.example.wan.android.utils.getUri
3537
import com.example.wan.android.utils.getViewModel
3638
import com.example.wan.android.utils.toast
39+
import com.example.wan.android.utils.toastLong
3740
import kotlinx.coroutines.Dispatchers
3841
import kotlinx.coroutines.delay
3942
import kotlinx.coroutines.launch
@@ -181,8 +184,18 @@ class SettingActivity : VVMBaseActivity<SettingViewModel, ActivitySettingBinding
181184
}
182185
}
183186
binding.llSource.onClick {
184-
alert("APP 源码", "心急食唔到热豆腐") {
185-
ok {}
187+
val url = getString(R.string.repo_url)
188+
alert("APP 源码", "打开 URL: \n$url") {
189+
ok {
190+
WebActivity.start(url)
191+
}
192+
cancel {
193+
194+
}
195+
neutral("复制 URL") {
196+
ClipboardUtils.copyText(url)
197+
toastLong("复制成功:\n${url}")
198+
}
186199
}.show()
187200
}
188201
binding.llVersion.onClick {

app/src/main/java/com/example/wan/android/network/RetrofitClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object RetrofitClient {
4848
// .addNetworkInterceptor(CacheInterceptor())
4949
// 先添加的拦截器,会先处理请求,最后处理响应
5050
// 日志拦截器通常放在最前面,以便记录所有请求和响应的详细信息。
51-
// 缓存拦截器通常放在靠前的位置,以便在其他拦截器之前处理缓存逻辑
51+
// 缓存拦截器通常放在靠前的位置,以便在其它拦截器之前处理缓存逻辑
5252
.addInterceptor(LoggingInterceptor())
5353
.addInterceptor(CacheInterceptor())
5454
// .addInterceptor(HeaderInterceptor())

app/src/main/java/com/example/wan/android/ui/dialog/AppDetailDialog.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.widget.LinearLayout
1010
import android.widget.ScrollView
1111
import android.widget.TextView
1212
import com.example.wan.android.BuildConfig
13+
import com.example.wan.android.R
1314
import com.example.wan.android.utils.dp2pxInt
1415
import com.example.wan.android.utils.ext.setTypeface
1516
import java.text.SimpleDateFormat
@@ -98,6 +99,7 @@ class AppDetailDialog(context: Context?, val env: String = "", val uid: String =
9899
[flavor] ${BuildConfig.FLAVOR}${if (BuildConfig.DEBUG) "Debug" else "Release"}
99100
[env ] $env
100101
[uid ] $uid
102+
[lang ] ${(context.getString(R.string.values))}
101103
- App.Build -
102104
[commit] ${BuildConfig.COMMIT_ID}
103105
[gradle] ${BuildConfig.GRADLE_VERSION}
@@ -116,13 +118,20 @@ class AppDetailDialog(context: Context?, val env: String = "", val uid: String =
116118
[model ] ${Build.MODEL}
117119
[ver ] Android ${Build.VERSION.RELEASE}
118120
[api ] ${Build.VERSION.SDK_INT}
119-
[lang ] ${Locale.getDefault().language}
121+
[lang_t] ${Locale.getDefault().toLanguageTag()}
122+
[lang_n] ${Locale.getDefault().displayName}
120123
- System.Build -
121124
[host ] ${Build.HOST}
122125
[by ] ${Build.USER}
123126
[time ] ${SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault()).format(Build.TIME)}
124127
""".trimIndent()
125128
// @formatter:on
129+
130+
// 语言-文字-地区
131+
// language-script-country
132+
// [lang ] ${Locale.getDefault().language}
133+
// [script] ${Locale.getDefault().script}
134+
// [area ] ${Locale.getDefault().country}
126135
}
127136

128137
}

app/src/main/java/com/example/wan/android/utils/BrowserUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fun Context.startBrowser(url: String) {
111111
// 阿猫阿狗都说自己是浏览器(淘宝、京东、WPS...),不要系统默认解析的
112112
// addAll(resolvePkgList)
113113
}
114-
// TODO: 小米 MIUI 12 有 bug,魔改它自己的默认浏览器到推荐位置后导致后面其他方式的索引差了一位
114+
// TODO: 小米 MIUI 12 有 bug,魔改它自己的默认浏览器到推荐位置后导致后面其它方式的索引差了一位
115115
// TODO: 受不了 过滤掉
116116
.filter {
117117
it != AppPkg.Browser.pkg

0 commit comments

Comments
 (0)