Skip to content

Commit

Permalink
Merge pull request #82 from GuoXiCheng/dev
Browse files Browse the repository at this point in the history
update delete apk
  • Loading branch information
GuoXiCheng authored Nov 7, 2023
2 parents 09d5135 + a38ee33 commit 8914dc5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
env:
LATEST_VERSION: "1.4.4"
LATEST_VERSION: "1.4.5"

jobs:
build-and-deploy:
Expand Down
Binary file added apk/SKIP-v1.4.5.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk 24
targetSdk 32
versionCode 1
versionName "1.4.4"
versionName "1.4.5"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
22 changes: 8 additions & 14 deletions app/src/main/java/com/android/skip/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -254,26 +254,12 @@ class MainActivity : ComponentActivity() {
apkFile
)

// 创建并注册 BroadcastReceiver
val receiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_PACKAGE_ADDED) {
// 删除 APK 文件
apkFile.delete()
}
}
}
registerReceiver(receiver, IntentFilter(Intent.ACTION_PACKAGE_ADDED))

val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(apkUri, "application/vnd.android.package-archive")
intent.flags =
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
this.startActivity(intent)

// 取消注册 BroadcastReceiver
unregisterReceiver(receiver)

isUpdateAPKClicked = false
}
}
Expand All @@ -285,6 +271,14 @@ class MainActivity : ComponentActivity() {

val yaml = Yaml().load<List<PackageInfo>>(assets.open("skip_config.yaml"))
SkipConfigManager.setConfig(yaml)

// 清理临时文件
val directory = this.getExternalFilesDir(null)
directory?.let {
it.listFiles()?.forEach { file ->
file.delete()
}
}
}

override fun onResume() {
Expand Down

0 comments on commit 8914dc5

Please sign in to comment.