├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── logo.png
│ │ │ ├── drawable
│ │ │ │ ├── custom_dialog_background.xml
│ │ │ │ └── shape_input.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── themes.xml
│ │ │ ├── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ └── layout
│ │ │ │ ├── activity_web_view.xml
│ │ │ │ ├── dialog_shortcut_creation.xml
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── ddd
│ │ │ │ └── pwa
│ │ │ │ └── browser
│ │ │ │ ├── LAUNCH_MODE.java
│ │ │ │ ├── LauncherShortcutActivity.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── WebViewActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── ddd
│ │ │ └── pwa
│ │ │ └── browser
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── ddd
│ │ └── pwa
│ │ └── browser
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── .idea
├── .gitignore
├── codeStyles
│ ├── codeStyleConfig.xml
│ └── Project.xml
├── compiler.xml
├── render.experimental.xml
├── encodings.xml
├── vcs.xml
├── misc.xml
└── gradle.xml
├── version.properties
├── .gitmodules
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── settings.gradle
├── gradle.properties
├── gradlew.bat
├── .github
└── workflows
│ └── build.yml
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /release
3 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/version.properties:
--------------------------------------------------------------------------------
1 | #Tue Apr 23 12:31:42 CST 2024
2 | versionName=1.0.9
3 | versionCode=109
4 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "keystore"]
2 | path = keystore
3 | url = https://github.com/cikezhu/android-keystore.git
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cikezhu/PwaBrowser/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cikezhu/PwaBrowser/HEAD/app/src/main/res/mipmap-hdpi/logo.png
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/render.experimental.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_dialog_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Feb 03 08:55:21 CST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 | /.idea/.name
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PwaBrowser
2 | 在android平台实现等同IOS平台 safe-area-inset-top 的界面效果
3 | 
4 | 
5 |
--------------------------------------------------------------------------------
/app/src/main/java/ddd/pwa/browser/LAUNCH_MODE.java:
--------------------------------------------------------------------------------
1 | package ddd.pwa.browser;
2 |
3 | public enum LAUNCH_MODE {
4 | GET_URL_DETAIL(0),
5 | SHOW_URL_PAGE(1);
6 |
7 | private final int intValue;
8 |
9 | LAUNCH_MODE(int intValue) {
10 | this.intValue = intValue;
11 | }
12 |
13 | public int getIntValue() {
14 | return intValue;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/test/java/ddd/pwa/browser/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package ddd.pwa.browser
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #2196F3
4 | #03A9F4
5 | #3F51B5
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 | #1E293B
11 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
10 |
11 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 沉浸浏览
3 | TODO
4 | WebViewActivity
5 |
6 | First Fragment
7 | Second Fragment
8 | Next
9 | Previous
10 |
11 | Hello first fragment
12 | Hello second fragment. Arg: %1$s
13 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | maven { url 'https://maven.aliyun.com/repository/google' }
5 | maven { url 'https://maven.aliyun.com/repository/public' }
6 | google()
7 | mavenCentral()
8 | }
9 | }
10 | dependencyResolutionManagement {
11 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
12 | repositories {
13 | maven { url 'https://maven.aliyun.com/repository/google' }
14 | maven { url 'https://maven.aliyun.com/repository/public' }
15 | google()
16 | mavenCentral()
17 | }
18 | }
19 | rootProject.name = "PwaBrowser"
20 | include ':app'
21 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/ddd/pwa/browser/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package ddd.pwa.browser
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("ddd.pwa.browser", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
20 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_shortcut_creation.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
24 |
25 |
33 |
34 |
44 |
45 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/java/ddd/pwa/browser/LauncherShortcutActivity.kt:
--------------------------------------------------------------------------------
1 | package ddd.pwa.browser
2 |
3 | import android.app.ActivityManager
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.os.Bundle
7 | import android.util.Log
8 | import androidx.appcompat.app.AppCompatActivity
9 |
10 |
11 | class LauncherShortcutActivity : AppCompatActivity() {
12 | override fun onCreate(savedInstanceState: Bundle?) {
13 | super.onCreate(savedInstanceState)
14 | if (intent.hasExtra("mode") && intent.hasExtra("url")) {
15 | val newIntent = createIntent(intent)
16 | if (newIntent != null) {
17 | newIntent.putExtra("mode", intent.getIntExtra("mode", LAUNCH_MODE.SHOW_URL_PAGE.intValue))
18 | newIntent.putExtra("url", intent.getStringExtra("url"))
19 | newIntent.putExtra("name", intent.getStringExtra("name"))
20 | newIntent.putExtra("full", intent.getBooleanExtra("full", true))
21 | startActivity(newIntent)
22 | }
23 | }
24 | finish()
25 | }
26 |
27 | private fun createIntent(i: Intent): Intent? {
28 | val intent = Intent(applicationContext, WebViewActivity::class.java)
29 | intent.action = Intent.ACTION_MAIN
30 | // 检查当前是否已经存在该Activity的实例
31 | val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
32 | for (appTask in activityManager.appTasks) {
33 | val recentTaskInfo = appTask.taskInfo
34 | val subTaskIntent = recentTaskInfo.baseIntent
35 | if (subTaskIntent.component == intent.component) {
36 | // 已经存在该Activity的任务,检查ID是否相同
37 | if (subTaskIntent.hasExtra("url") && subTaskIntent.getStringExtra("url") == i.getStringExtra("url")) {
38 | // ID相同,不需要创建新的任务
39 | Log.e("createIntent", "ID相同,不需要创建新的任务")
40 | appTask.moveToFront()
41 | return null
42 | }
43 | }
44 | }
45 | // 不存在该Activity的实例,需要创建新的任务
46 | Log.e("createIntent", "不存在该Activity的实例,需要创建新的任务")
47 | intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
48 | return intent
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
29 |
30 |
36 |
37 |
38 |
39 |
42 |
50 |
51 |
59 |
60 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
37 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
55 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | xmlns:android
18 |
19 | ^$
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | xmlns:.*
29 |
30 | ^$
31 |
32 |
33 | BY_NAME
34 |
35 |
36 |
37 |
38 |
39 |
40 | .*:id
41 |
42 | http://schemas.android.com/apk/res/android
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | .*:name
52 |
53 | http://schemas.android.com/apk/res/android
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | name
63 |
64 | ^$
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | style
74 |
75 | ^$
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | .*
85 |
86 | ^$
87 |
88 |
89 | BY_NAME
90 |
91 |
92 |
93 |
94 |
95 |
96 | .*
97 |
98 | http://schemas.android.com/apk/res/android
99 |
100 |
101 | ANDROID_ATTRIBUTE_ORDER
102 |
103 |
104 |
105 |
106 |
107 |
108 | .*
109 |
110 | .*
111 |
112 |
113 | BY_NAME
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | }
5 |
6 | tasks.withType(JavaCompile) {
7 | options.encoding = "UTF-8"
8 | }
9 |
10 | // 读取前面配置的keystore.properties
11 | def keyProps = new Properties()
12 | def keyPropsFile = rootProject.file('keystore/keystore.properties')
13 | if (keyPropsFile.exists()) {
14 | keyProps.load(new FileInputStream(keyPropsFile))
15 | }
16 |
17 | // 读取version.properties
18 | def versionProps = new Properties()
19 | def versionPropsFile = rootProject.file('version.properties')
20 | if (versionPropsFile.exists()) {
21 | versionProps.load(new FileInputStream(versionPropsFile))
22 | }
23 |
24 | android {
25 | namespace 'ddd.pwa.browser'
26 | compileSdk 33
27 |
28 | defaultConfig {
29 | applicationId "ddd.pwa.browser"
30 | minSdk 26
31 | targetSdk 33
32 | versionCode versionProps['versionCode'].toInteger()
33 | versionName versionProps['versionName']
34 |
35 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
36 | }
37 |
38 | // 签名
39 | signingConfigs {
40 | release {
41 | keyAlias keyProps['keyAlias']
42 | keyPassword keyProps['keyPassword']
43 | storeFile keyProps['storeFile'] ? file(keyProps['storeFile']) : null
44 | storePassword keyProps['storePassword']
45 | }
46 | }
47 |
48 | buildTypes {
49 | release {
50 | minifyEnabled false
51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
52 | signingConfig signingConfigs.release //配置签名文件
53 | }
54 | }
55 | compileOptions {
56 | sourceCompatibility JavaVersion.VERSION_11
57 | targetCompatibility JavaVersion.VERSION_11
58 | }
59 | kotlinOptions {
60 | jvmTarget = '1.8'
61 | }
62 | buildFeatures {
63 | viewBinding true
64 | }
65 | }
66 |
67 | dependencies {
68 |
69 | implementation 'androidx.core:core-ktx:1.7.0'
70 | implementation 'androidx.appcompat:appcompat:1.4.1'
71 | implementation 'com.google.android.material:material:1.5.0'
72 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
73 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
74 | implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1'
75 | implementation 'androidx.navigation:navigation-ui-ktx:2.4.1'
76 | testImplementation 'junit:junit:4.13.2'
77 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
78 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
79 | }
80 |
81 | task updatever {
82 | group 'help'
83 | description '构建新版本'
84 | doLast {
85 | println("---自动升级版本号---\n")
86 | if (versionPropsFile.exists()) {
87 | versionProps.load(new FileInputStream(versionPropsFile))
88 | }
89 | String oldVersionCode = versionProps['versionCode']
90 | String oldVersionName = versionProps['versionName']
91 | if (oldVersionCode == null || oldVersionName == null ||
92 | oldVersionCode.isEmpty() || oldVersionName.isEmpty()) {
93 | println("error:版本号不能为空")
94 | return
95 | }
96 | versionProps['versionCode'] = String.valueOf(versionProps['versionCode'].toInteger() + 1)
97 | String str = versionProps['versionName'].toString()
98 | versionProps['versionName'] = str.substring(0, str.lastIndexOf('.') + 1) +
99 | (str.substring(str.lastIndexOf('.') + 1).toInteger() + 1)
100 | String tip =
101 | "版本号从$oldVersionName($oldVersionCode)升级到${versionProps['versionName']}(${versionProps['versionCode']})"
102 | println(tip)
103 |
104 | def writer = new FileWriter(versionPropsFile)
105 | versionProps.store(writer, null)
106 | writer.flush()
107 | writer.close()
108 | def tag = "v${versionProps['versionName']}"
109 | cmdExecute("git pull")
110 | cmdExecute("git add ./version.properties")
111 | cmdExecute("git commit -m \"版本号升级为:$tag\"")
112 | cmdExecute("git push github")
113 | cmdExecute("git tag $tag")
114 | cmdExecute("git push github $tag")
115 | }
116 | }
117 |
118 | void cmdExecute(String cmd) {
119 | println "\n执行$cmd"
120 | println cmd.execute().text
121 | }
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | # 触发器
4 | on:
5 | # 新增:网页手动触发
6 | workflow_dispatch:
7 | inputs:
8 | version_tag:
9 | description: '要创建和编译的版本标签 (例如: v1.0.1)'
10 | required: true
11 | type: string
12 | default: 'v1.0.0'
13 | # 原有触发器保持不变
14 | push:
15 | tags:
16 | - v*
17 | pull_request:
18 | tags:
19 | - v*
20 |
21 | jobs:
22 | build:
23 | runs-on: ubuntu-latest
24 | permissions:
25 | contents: write # 添加权限以创建Release
26 |
27 | steps:
28 | - name: 处理手动触发标签
29 | if: github.event_name == 'workflow_dispatch'
30 | run: |
31 | TAG_NAME="${{ github.event.inputs.version_tag }}"
32 | echo "手动触发,目标标签:$TAG_NAME"
33 | # 检查标签格式
34 | if [[ ! $TAG_NAME =~ ^v.*$ ]]; then
35 | echo "错误:标签名应以 'v' 开头"
36 | exit 1
37 | fi
38 | # 将手动输入的标签名存储到环境变量,供后续步骤使用
39 | echo "MANUAL_TAG=$TAG_NAME" >> $GITHUB_ENV
40 |
41 | # 更新:使用 checkout@v4
42 | - name: Checkout code
43 | uses: actions/checkout@v4
44 | with:
45 | ref: ${{ env.MANUAL_TAG || github.ref }}
46 | fetch-depth: 0 # 获取完整历史记录以便查找标签
47 |
48 | - name: 为手动触发生成伪标签引用
49 | if: github.event_name == 'workflow_dispatch'
50 | run: |
51 | echo "设置临时引用以便生成更新日志..."
52 | # 找出最新的一个真实标签作为"旧标签"的参照
53 | LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
54 | if [ -n "$LATEST_TAG" ]; then
55 | echo "找到最新标签: $LATEST_TAG"
56 | echo "SIMULATED_BASE_REF=$LATEST_TAG" >> $GITHUB_ENV
57 | else
58 | echo "未找到任何现有标签,这可能是第一次发布。"
59 | echo "SIMULATED_BASE_REF=" >> $GITHUB_ENV
60 | fi
61 |
62 | # 更新:使用 setup-java@v4
63 | - name: Set up JDK 11
64 | uses: actions/setup-java@v4
65 | with:
66 | java-version: '11'
67 | distribution: 'temurin'
68 |
69 | # 获取打包秘钥
70 | # 更新:使用 checkout@v4
71 | - name: Checkout Android Keystore
72 | uses: actions/checkout@v4
73 | with:
74 | repository: cikezhu/android-keystore
75 | token: ${{ secrets.TOKEN }}
76 | path: keystore
77 |
78 | # 获取上一次的TAG
79 | - name: Get commit messages
80 | id: get_old_tag
81 | run: |
82 | # 判断触发方式,决定如何获取"上一个TAG"
83 | if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
84 | # 手动触发:使用我们之前找到的最新标签
85 | OLD_TAG="${{ env.SIMULATED_BASE_REF }}"
86 | echo "手动触发模式,上一个TAG: $OLD_TAG"
87 | else
88 | # 自动触发(推送标签):沿用原有逻辑
89 | oldCommit=$(git rev-list --tags --skip=1 --max-count=1 2>/dev/null || echo "")
90 | if [ -n "$oldCommit" ]; then
91 | oldTag=$(git describe --tags --abbrev=0 $oldCommit 2>/dev/null || echo "")
92 | echo "自动触发模式,上一个TAG: $oldTag"
93 | OLD_TAG="$oldTag"
94 | else
95 | echo "自动触发模式,未找到上一个TAG"
96 | OLD_TAG=""
97 | fi
98 | fi
99 | echo "old_tag=$OLD_TAG" >> $GITHUB_OUTPUT
100 | echo "最终用于生成更新日志的old_tag: $OLD_TAG"
101 |
102 | # 生成更新日志
103 | - name: Generate changelog
104 | id: changelog
105 | uses: metcalfc/changelog-generator@v4.3.1
106 | with:
107 | myToken: ${{ secrets.GITHUB_TOKEN }}
108 | base-ref: ${{ steps.get_old_tag.outputs.old_tag }}
109 |
110 | # 打包release
111 | - name: Build with Gradle
112 | run: bash ./gradlew assembleRelease
113 |
114 | # 创建release - 更新到现代方法
115 | - name: Create Release
116 | id: create_release
117 | if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
118 | # 更新:使用现代release action
119 | uses: softprops/action-gh-release@v1
120 | with:
121 | tag_name: ${{ github.event.inputs.version_tag || github.ref_name }}
122 | name: Release ${{ github.event.inputs.version_tag || github.ref_name }}
123 | body: |
124 | # 手动触发发布
125 | ${{ github.event.inputs.version_tag && format('**手动触发版本:{0}**', github.event.inputs.version_tag) || '' }}
126 |
127 | ${{ steps.changelog.outputs.changelog }}
128 |
129 | *工作流触发方式:${{ github.event_name == 'workflow_dispatch' && '网页手动操作' || 'Git标签推送' }}*
130 | draft: false
131 | prerelease: false
132 | generate_release_notes: false
133 |
134 | # 获取apk版本号
135 | - name: Get Version Name
136 | uses: actions/github-script@v6 # 更新到v6
137 | id: get-version
138 | with:
139 | script: |
140 | // 根据触发类型决定版本号来源
141 | if (context.payload.inputs) {
142 | // 手动触发:使用输入的version_tag
143 | const manualTag = context.payload.inputs.version_tag;
144 | console.log(`手动触发,使用标签: ${manualTag}`);
145 | return manualTag.replace('refs/tags/', '');
146 | } else {
147 | // 自动触发:从GITHUB_REF提取
148 | const str = process.env.GITHUB_REF;
149 | const tag = str.substring(str.lastIndexOf('/') + 1);
150 | console.log(`自动触发,从REF提取标签: ${tag}`);
151 | return tag;
152 | }
153 | result-encoding: string
154 |
155 | # 上传至release的资源 - 更新到现代方法
156 | - name: Upload Release Asset
157 | # 更新:使用与Create Release相同的action
158 | if: steps.create_release.outputs.upload_url
159 | uses: softprops/action-gh-release@v1
160 | with:
161 | files: |
162 | app/build/outputs/apk/release/app-release.apk
163 | tag_name: ${{ github.event.inputs.version_tag || github.ref_name }}
164 |
165 | # 存档打包的文件 - 关键修复:更新到 upload-artifact@v4
166 | - name: Archive production artifacts
167 | # 更新:使用 upload-artifact@v4
168 | uses: actions/upload-artifact@v4
169 | with:
170 | name: build-${{ github.event.inputs.version_tag || github.ref_name }}
171 | path: |
172 | app/build/outputs/apk/release/*.apk
173 | app/build/outputs/mapping/release/*.txt
174 | app/build/outputs/mapping/release/*.map
175 | retention-days: 30 # 可选:设置产物保留天数
176 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/java/ddd/pwa/browser/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package ddd.pwa.browser
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Intent
5 | import android.content.pm.ShortcutInfo
6 | import android.content.pm.ShortcutManager
7 | import android.graphics.Bitmap
8 | import android.graphics.BitmapFactory
9 | import android.graphics.drawable.ColorDrawable
10 | import android.graphics.drawable.Icon
11 | import android.net.Uri
12 | import android.os.Bundle
13 | import android.provider.MediaStore
14 | import android.util.Log
15 | import android.view.LayoutInflater
16 | import android.view.inputmethod.InputMethodManager
17 | import android.widget.Button
18 | import android.widget.EditText
19 | import android.widget.ImageView
20 | import android.widget.TextView
21 | import android.widget.Toast
22 | import androidx.activity.result.ActivityResult
23 | import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
24 | import androidx.appcompat.app.AlertDialog
25 | import androidx.appcompat.app.AppCompatActivity
26 | import kotlinx.coroutines.*
27 | import java.io.ByteArrayOutputStream
28 | import java.security.MessageDigest
29 |
30 |
31 | class MainActivity : AppCompatActivity() {
32 | private lateinit var shortcutLogo: Bitmap
33 | private lateinit var shortcutIcon: ImageView
34 | private val mTAG: String = "MainActivity"
35 | private val mScope = MainScope()
36 | private val webViewLauncher = registerForActivityResult(
37 | StartActivityForResult()
38 | ) { result: ActivityResult ->
39 | if (result.resultCode == RESULT_OK) {
40 | val data = result.data
41 | Log.e(mTAG, data.toString())
42 | val url = data!!.getStringExtra("url")
43 | val name = data.getStringExtra("name")
44 | val full = data.getBooleanExtra("full", true)
45 | @Suppress("DEPRECATION") val logo = data.getParcelableExtra("logo")
46 | if (url !== null && name !== null && logo !== null) {
47 | showShortcutCreationDialog(name, url, logo, full)
48 | }
49 | }
50 | }
51 | private val iconLauncher = registerForActivityResult(
52 | StartActivityForResult()
53 | ) { result: ActivityResult ->
54 | if (result.resultCode == RESULT_OK) {
55 | val data = result.data
56 | if (data != null) {
57 | val selectedImageUri: Uri? = data.data
58 | selectedImageUri?.let {
59 | val inputStream = this.contentResolver.openInputStream(it)
60 | shortcutLogo = BitmapFactory.decodeStream(inputStream)
61 | shortcutIcon.setImageBitmap(shortcutLogo)
62 | inputStream?.close()
63 | }
64 | }
65 | }
66 | }
67 |
68 | @SuppressLint("SetTextI18n")
69 | override fun onCreate(savedInstanceState: Bundle?) {
70 | super.onCreate(savedInstanceState)
71 | setContentView(R.layout.activity_main)
72 | // 绑定组件
73 | val myInputUrl: EditText = findViewById(R.id.input_url)
74 | val myVersion: TextView = findViewById(R.id.version)
75 | @Suppress("DEPRECATION") val packageInfo = packageManager.getPackageInfo(packageName, 0)
76 | myVersion.text = "v${packageInfo.versionName} by: 叮叮当"
77 | val myChangeUrl: Button = findViewById(R.id.button_change_url)
78 | myChangeUrl.setOnClickListener {
79 | Log.d(mTAG, "initialize: " + myChangeUrl.text.toString())
80 | // 隐藏输入法
81 | val inputMethodManager: InputMethodManager =
82 | applicationContext.getSystemService(
83 | INPUT_METHOD_SERVICE
84 | ) as InputMethodManager
85 | inputMethodManager.hideSoftInputFromWindow(myInputUrl.windowToken, 0)
86 | // 前往webView获取参数
87 | val hostUrl = myInputUrl.text.toString()
88 | if (hostUrl != "") {
89 | Toast.makeText(applicationContext,"正在连接..",Toast.LENGTH_SHORT).show()
90 | val intent = Intent(this@MainActivity, WebViewActivity::class.java)
91 | intent.putExtra("mode", LAUNCH_MODE.GET_URL_DETAIL.intValue)
92 | intent.putExtra("url", hostUrl)
93 | webViewLauncher.launch(intent)
94 | } else {
95 | Toast.makeText(applicationContext,"请输入网址> http(s)://....",Toast.LENGTH_SHORT).show()
96 | }
97 | }
98 | }
99 |
100 | private fun addShortcut(name: String, url: String, logo: Bitmap, full: Boolean) {
101 | // 添加快捷方式到桌面
102 | mScope.launch(Dispatchers.Main) {
103 | // 创建快捷方式
104 | val shortcutInfo = ShortcutInfo.Builder(applicationContext, LAUNCH_MODE.SHOW_URL_PAGE.intValue.toString() + name + url + generateUniqueValueFromBitmap(logo))
105 | .setShortLabel(name)
106 | .setIcon(Icon.createWithBitmap(logo))
107 | .setIntent(Intent(applicationContext, LauncherShortcutActivity::class.java).apply {
108 | action = Intent.ACTION_MAIN
109 | putExtra("mode", LAUNCH_MODE.SHOW_URL_PAGE.intValue)
110 | putExtra("url", url)
111 | putExtra("name", name)
112 | putExtra("full", full)
113 | })
114 | .build()
115 | val shortcutManager = getSystemService(ShortcutManager::class.java)
116 | shortcutManager.requestPinShortcut(shortcutInfo, null)
117 | }
118 | }
119 |
120 | private fun generateUniqueValueFromBitmap(logo: Bitmap): String {
121 | val byteArrayOutputStream = ByteArrayOutputStream()
122 | logo.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
123 | val byteArray = byteArrayOutputStream.toByteArray()
124 |
125 | val messageDigest = MessageDigest.getInstance("MD5")
126 | messageDigest.update(byteArray)
127 | val digest = messageDigest.digest()
128 |
129 | // 将字节数组转换为十六进制字符串
130 | val hexString = StringBuilder()
131 | for (byte in digest) {
132 | val hex = Integer.toHexString(0xFF and byte.toInt())
133 | if (hex.length == 1) {
134 | hexString.append('0')
135 | }
136 | hexString.append(hex)
137 | }
138 |
139 | return hexString.toString()
140 | }
141 | private fun showShortcutCreationDialog(name: String, url: String, logo: Bitmap, full: Boolean) {
142 | shortcutLogo = logo
143 | val alertDialogBuilder = AlertDialog.Builder(this)
144 | // 创建布局
145 | val layoutInflater = LayoutInflater.from(this)
146 | val dialogView = layoutInflater.inflate(R.layout.dialog_shortcut_creation, null)
147 | val nameInput = dialogView.findViewById(R.id.shortcut_name)
148 | nameInput.setText(name)
149 | // 选择图标的按钮
150 | shortcutIcon = dialogView.findViewById(R.id.shortcut_icon)
151 | shortcutIcon.setImageBitmap(logo)
152 | shortcutIcon.setOnClickListener {
153 | // 启动图片选择器
154 | val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
155 | iconLauncher.launch(intent)
156 | }
157 | // 显示弹窗
158 | val alertDialog = alertDialogBuilder.setView(dialogView).create()
159 | alertDialog.window?.setBackgroundDrawable(ColorDrawable(0))
160 | alertDialog.show()
161 | // 确定按钮
162 | val shortcutConfirm = dialogView.findViewById