From 289f79a909b2eb60eb6e9f05515e67bb3987f283 Mon Sep 17 00:00:00 2001 From: hongui Date: Thu, 2 Mar 2023 10:39:02 +0800 Subject: [PATCH] rename apk remove toast at first --- app/build.gradle | 35 ++++++++++--------- .../lee/fastair/viewmodel/HomeViewModel.kt | 6 ++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 443d6d1..ffe0742 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,6 @@ -plugins{ +import java.text.SimpleDateFormat + +plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id("com.google.devtools.ksp") version "1.8.0-1.0.8" @@ -22,6 +24,13 @@ android { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + applicationVariants.all { variant -> + variant.outputs.all { + output -> + def name = "${variant.applicationId}_${variant.getVersionName()}_${new SimpleDateFormat('yyyy_MM_dd_HH_mm').format(System.currentTimeMillis())}.apk" + outputFileName = name + } + } } } @@ -29,32 +38,24 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - packagingOptions { - jniLibs { - excludes += ['META-INF/*'] - } - resources { - excludes += ['META-INF/*'] - } - } namespace 'com.mob.lee.fastair' } -task clearAssets(type: Delete){ - def path="${projectDir}/src/main/assets" - def target=fileTree(dir: path,exclude:['about.html','help.html']) - delete(target,"$path/app") +task clearAssets(type: Delete) { + def path = "${projectDir}/src/main/assets" + def target = fileTree(dir: path, exclude: ['about.html', 'help.html']) + delete(target, "$path/app") } -task frontEnd(type:Exec){ +task frontEnd(type: Exec) { dependsOn(clearAssets) workingDir("${rootDir}/FastSvelte") - commandLine('npm.cmd','run','build') + commandLine('npm.cmd', 'run', 'build') } -task toAssets(type: Copy){ - def path="${projectDir}/src/main/assets" +task toAssets(type: Copy) { + def path = "${projectDir}/src/main/assets" dependsOn(frontEnd) from("${rootDir}/FastSvelte/build") into(path) diff --git a/app/src/main/java/com/mob/lee/fastair/viewmodel/HomeViewModel.kt b/app/src/main/java/com/mob/lee/fastair/viewmodel/HomeViewModel.kt index 7fae17c..11511e3 100644 --- a/app/src/main/java/com/mob/lee/fastair/viewmodel/HomeViewModel.kt +++ b/app/src/main/java/com/mob/lee/fastair/viewmodel/HomeViewModel.kt @@ -49,7 +49,9 @@ class HomeViewModel : AppViewModel() { fragment, Manifest.permission.MANAGE_EXTERNAL_STORAGE ) { - fragment.requireContext().errorToast(R.string.no_permission_to_scan) + if(!it) { + fragment.requireContext().errorToast(R.string.no_permission_to_scan) + } } }.setNegativeButton(R.string.exit) { _, _ -> fragment.mParent?.finish() @@ -60,7 +62,7 @@ class HomeViewModel : AppViewModel() { } else { withPermission( fragment, - Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE, action = { hasPermission -> if (hasPermission) { fetch(fragment.context)