mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 03:32:38 +08:00
This commit is contained in:
parent
69525c8966
commit
8cca22d697
|
@ -22,18 +22,16 @@ data class AppInfo(
|
|||
)
|
||||
|
||||
val selfAppInfo by lazy {
|
||||
app.packageManager.getPackageInfo(app.packageName, 0).toAppInfo()!!
|
||||
app.packageManager.getPackageInfo(app.packageName, 0).toAppInfo()
|
||||
}
|
||||
|
||||
/**
|
||||
* 平均单次调用时间 11ms
|
||||
*/
|
||||
fun PackageInfo.toAppInfo(): AppInfo? {
|
||||
applicationInfo ?: return null
|
||||
fun PackageInfo.toAppInfo(): AppInfo {
|
||||
val info = applicationInfo
|
||||
return AppInfo(
|
||||
id = packageName,
|
||||
name = applicationInfo.loadLabel(app.packageManager).toString(),
|
||||
icon = applicationInfo.loadIcon(app.packageManager),
|
||||
versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
longVersionCode
|
||||
} else {
|
||||
|
@ -41,8 +39,10 @@ fun PackageInfo.toAppInfo(): AppInfo? {
|
|||
versionCode.toLong()
|
||||
},
|
||||
versionName = versionName,
|
||||
isSystem = (ApplicationInfo.FLAG_SYSTEM and applicationInfo.flags) != 0,
|
||||
mtime = lastUpdateTime,
|
||||
hidden = app.packageManager.getLaunchIntentForPackage(packageName) == null
|
||||
hidden = app.packageManager.getLaunchIntentForPackage(packageName) == null,
|
||||
name = info?.run { loadLabel(app.packageManager).toString() } ?: packageName,
|
||||
icon = info?.loadIcon(app.packageManager),
|
||||
isSystem = info?.run { (ApplicationInfo.FLAG_SYSTEM and flags) != 0 } ?: false,
|
||||
)
|
||||
}
|
|
@ -83,9 +83,8 @@ private fun updateAppInfo(appId: String) {
|
|||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
null
|
||||
}
|
||||
val newAppInfo = info?.toAppInfo()
|
||||
if (newAppInfo != null) {
|
||||
newMap[appId] = newAppInfo
|
||||
if (info != null) {
|
||||
newMap[appId] = info.toAppInfo()
|
||||
} else {
|
||||
newMap.remove(appId)
|
||||
}
|
||||
|
@ -106,10 +105,7 @@ suspend fun initOrResetAppInfoCache() {
|
|||
withContext(Dispatchers.IO) {
|
||||
app.packageManager.getInstalledPackages(0).forEach { packageInfo ->
|
||||
if (!oldAppIds.contains(packageInfo.packageName)) {
|
||||
val info = packageInfo.toAppInfo()
|
||||
if (info != null) {
|
||||
appMap[packageInfo.packageName] = info
|
||||
}
|
||||
appMap[packageInfo.packageName] = packageInfo.toAppInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package li.songe.gkd.util
|
||||
|
||||
import android.graphics.Bitmap
|
||||
|
||||
fun Bitmap.isEmptyBitmap(): Boolean {
|
||||
val emptyBitmap = Bitmap.createBitmap(width, height, config)
|
||||
return this.sameAs(emptyBitmap)
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package li.songe.gkd.util
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.graphics.Bitmap
|
||||
import li.songe.gkd.META
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.jvm.jvmName
|
||||
|
@ -13,3 +14,15 @@ private val componentNameCache by lazy { HashMap<String, ComponentName>() }
|
|||
|
||||
val KClass<*>.componentName
|
||||
get() = componentNameCache.getOrPut(jvmName) { ComponentName(META.appId, jvmName) }
|
||||
|
||||
fun Bitmap.isEmptyBitmap(): Boolean {
|
||||
// png
|
||||
repeat(width) { x ->
|
||||
repeat(height) { y ->
|
||||
if (getPixel(x, y) != 0) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
|
@ -3,7 +3,7 @@ android.useAndroidX=true
|
|||
android.enableJetifier=true
|
||||
android.debug.obsoleteApi=true
|
||||
kotlin.code.style=official
|
||||
android_compileSdk=34
|
||||
android_targetSdk=34
|
||||
android_buildToolsVersion=34.0.0
|
||||
android_compileSdk=35
|
||||
android_targetSdk=35
|
||||
android_buildToolsVersion=35.0.0
|
||||
android_minSdk=26
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[versions]
|
||||
kotlin = "2.0.20"
|
||||
ksp = "2.0.20-1.0.25"
|
||||
android = "8.6.1"
|
||||
android = "8.7.0"
|
||||
compose = "1.7.3"
|
||||
rikka = "4.4.0"
|
||||
room = "2.6.1"
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
Loading…
Reference in New Issue
Block a user