From 9426459ff196fdcd4264ad2740922f329f19891e Mon Sep 17 00:00:00 2001 From: darken Date: Thu, 30 May 2024 14:23:33 +0200 Subject: [PATCH 1/7] Build process: Compile against Android 15 Preview --- app/build.gradle.kts | 12 ++++++++++-- buildSrc/src/main/java/ProjectConfigPlugin.kt | 6 ++++-- buildSrc/src/main/java/ProjectExtensions.kt | 6 +++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2bb1e6f77..53b16a9d7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,13 +12,21 @@ apply(plugin = "androidx.navigation.safeargs.kotlin") val commitHashProvider = providers.of(CommitHashValueSource::class) {} android { - compileSdk = projectConfig.compileSdk + if (projectConfig.compileSdkPreview != null) { + compileSdkPreview = projectConfig.compileSdkPreview + } else { + compileSdk = projectConfig.compileSdk + } defaultConfig { namespace = projectConfig.packageName minSdk = projectConfig.minSdk - targetSdk = projectConfig.targetSdk + if (projectConfig.targetSdkPreview != null) { + targetSdkPreview = projectConfig.targetSdkPreview + } else { + targetSdk = projectConfig.targetSdk + } versionCode = projectConfig.version.code.toInt() versionName = projectConfig.version.name diff --git a/buildSrc/src/main/java/ProjectConfigPlugin.kt b/buildSrc/src/main/java/ProjectConfigPlugin.kt index cb943d30f..003408ccf 100644 --- a/buildSrc/src/main/java/ProjectConfigPlugin.kt +++ b/buildSrc/src/main/java/ProjectConfigPlugin.kt @@ -8,8 +8,10 @@ open class ProjectConfig { val packageName = "eu.darken.sdmse" val minSdk = 26 - val compileSdk = 34 - val targetSdk = 34 + val compileSdk = 35 + val compileSdkPreview: String? = null + val targetSdk = 35 + val targetSdkPreview: String? = null lateinit var version: Version diff --git a/buildSrc/src/main/java/ProjectExtensions.kt b/buildSrc/src/main/java/ProjectExtensions.kt index fe53bf64b..af881e29a 100644 --- a/buildSrc/src/main/java/ProjectExtensions.kt +++ b/buildSrc/src/main/java/ProjectExtensions.kt @@ -21,7 +21,11 @@ private fun LibraryExtension.kotlinOptions(configure: Action): (this as org.gradle.api.plugins.ExtensionAware).extensions.configure("kotlinOptions", configure) fun LibraryExtension.setupLibraryDefaults(projectConfig: ProjectConfig) { - compileSdk = projectConfig.compileSdk + if (projectConfig.compileSdkPreview != null) { + compileSdkPreview = projectConfig.compileSdkPreview + } else { + compileSdk = projectConfig.compileSdk + } defaultConfig { minSdk = projectConfig.minSdk From ed5250e95af484e329434cf15dcb09a97dc8820a Mon Sep 17 00:00:00 2001 From: darken Date: Wed, 13 Nov 2024 12:45:39 +0100 Subject: [PATCH 2/7] Adjust to SDK changes --- .../java/eu/darken/sdmse/common/ContextExtensions.kt | 10 ++++++++-- .../darken/sdmse/common/updater/FossUpdateChecker.kt | 4 ++-- .../eu/darken/sdmse/common/coil/PathPreviewFetcher.kt | 3 ++- .../sdmse/common/debug/recorder/core/RecorderModule.kt | 3 ++- .../java/eu/darken/sdmse/main/core/CurriculumVitae.kt | 5 +++-- .../darken/sdmse/main/core/release/ReleaseManager.kt | 3 ++- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app-common/src/main/java/eu/darken/sdmse/common/ContextExtensions.kt b/app-common/src/main/java/eu/darken/sdmse/common/ContextExtensions.kt index 47913e50d..7047a9d2e 100644 --- a/app-common/src/main/java/eu/darken/sdmse/common/ContextExtensions.kt +++ b/app-common/src/main/java/eu/darken/sdmse/common/ContextExtensions.kt @@ -3,11 +3,15 @@ package eu.darken.sdmse.common import android.annotation.SuppressLint import android.content.Context import android.content.Intent +import android.content.pm.PackageInfo import android.content.pm.PackageManager import android.content.res.ColorStateList import android.content.res.TypedArray import android.util.TypedValue -import androidx.annotation.* +import androidx.annotation.AttrRes +import androidx.annotation.ColorInt +import androidx.annotation.ColorRes +import androidx.annotation.PluralsRes import androidx.core.content.ContextCompat import eu.darken.sdmse.common.debug.logging.log import okio.Source @@ -77,4 +81,6 @@ fun Context.getSpanCount(widthDp: Int = 390): Int { return max(count, 1).also { log { "getSpanCount($screenWidthDp/$widthDp)=$it" } } -} \ No newline at end of file +} + +fun Context.getPackageInfo(): PackageInfo = packageManager.getPackageInfo(packageName, 0) \ No newline at end of file diff --git a/app/src/foss/java/eu/darken/sdmse/common/updater/FossUpdateChecker.kt b/app/src/foss/java/eu/darken/sdmse/common/updater/FossUpdateChecker.kt index 3651a4fa4..82623eea3 100644 --- a/app/src/foss/java/eu/darken/sdmse/common/updater/FossUpdateChecker.kt +++ b/app/src/foss/java/eu/darken/sdmse/common/updater/FossUpdateChecker.kt @@ -11,6 +11,7 @@ import eu.darken.sdmse.common.debug.logging.Logging.Priority.WARN import eu.darken.sdmse.common.debug.logging.asLog import eu.darken.sdmse.common.debug.logging.log import eu.darken.sdmse.common.debug.logging.logTag +import eu.darken.sdmse.common.getPackageInfo import eu.darken.sdmse.common.pkgs.features.getInstallerInfo import java.time.Duration import java.time.Instant @@ -96,8 +97,7 @@ class FossUpdateChecker @Inject constructor( override fun isEnabledByDefault(): Boolean { val pm = context.packageManager - val installers: Set = pm - .getPackageInfo(context.packageName, 0) + val installers: Set = context.getPackageInfo() .getInstallerInfo(pm) .allInstallers .map { it.id.name } diff --git a/app/src/main/java/eu/darken/sdmse/common/coil/PathPreviewFetcher.kt b/app/src/main/java/eu/darken/sdmse/common/coil/PathPreviewFetcher.kt index 5423468a8..35a9eac79 100644 --- a/app/src/main/java/eu/darken/sdmse/common/coil/PathPreviewFetcher.kt +++ b/app/src/main/java/eu/darken/sdmse/common/coil/PathPreviewFetcher.kt @@ -1,6 +1,7 @@ package eu.darken.sdmse.common.coil import android.content.Context +import android.content.pm.ApplicationInfo import android.content.pm.PackageManager import androidx.core.content.ContextCompat import coil.ImageLoader @@ -69,7 +70,7 @@ class PathPreviewFetcher @Inject constructor( .takeIf { it.canRead() } ?.let { pacMan.getPackageArchiveInfo(it.path, PackageManager.GET_META_DATA) } ?.let { - it.applicationInfo.apply { + (it.applicationInfo ?: ApplicationInfo()).apply { sourceDir = file.path publicSourceDir = file.path } diff --git a/app/src/main/java/eu/darken/sdmse/common/debug/recorder/core/RecorderModule.kt b/app/src/main/java/eu/darken/sdmse/common/debug/recorder/core/RecorderModule.kt index 9bb101e09..67d2dced8 100644 --- a/app/src/main/java/eu/darken/sdmse/common/debug/recorder/core/RecorderModule.kt +++ b/app/src/main/java/eu/darken/sdmse/common/debug/recorder/core/RecorderModule.kt @@ -21,6 +21,7 @@ import eu.darken.sdmse.common.debug.logging.log import eu.darken.sdmse.common.debug.logging.logTag import eu.darken.sdmse.common.debug.recorder.ui.RecorderActivity import eu.darken.sdmse.common.flow.DynamicStateFlow +import eu.darken.sdmse.common.getPackageInfo import eu.darken.sdmse.common.startServiceCompat import eu.darken.sdmse.main.core.CurriculumVitae import kotlinx.coroutines.CoroutineScope @@ -141,7 +142,7 @@ class RecorderModule @Inject constructor( } private suspend fun logInfos() { - val pkgInfo = context.packageManager.getPackageInfo(context.packageName, 0)!! + val pkgInfo = context.getPackageInfo() log(TAG, INFO) { "APILEVEL: ${BuildWrap.VERSION.SDK_INT}" } log(TAG, INFO) { "Build.FINGERPRINT: ${BuildWrap.FINGERPRINT}" } log(TAG, INFO) { "Build.MANUFACTOR: ${Build.MANUFACTURER}" } diff --git a/app/src/main/java/eu/darken/sdmse/main/core/CurriculumVitae.kt b/app/src/main/java/eu/darken/sdmse/main/core/CurriculumVitae.kt index 9dd3fcc61..f85735c32 100644 --- a/app/src/main/java/eu/darken/sdmse/main/core/CurriculumVitae.kt +++ b/app/src/main/java/eu/darken/sdmse/main/core/CurriculumVitae.kt @@ -15,6 +15,7 @@ import eu.darken.sdmse.common.debug.logging.Logging.Priority.VERBOSE import eu.darken.sdmse.common.debug.logging.Logging.Priority.WARN import eu.darken.sdmse.common.debug.logging.log import eu.darken.sdmse.common.debug.logging.logTag +import eu.darken.sdmse.common.getPackageInfo import io.github.z4kn4fein.semver.Version import io.github.z4kn4fein.semver.VersionFormatException import kotlinx.coroutines.CoroutineScope @@ -36,7 +37,7 @@ class CurriculumVitae @Inject constructor( private val dataStore: DataStore get() = context.dataStore - private val usPkgInfo: PackageInfo by lazy { context.packageManager.getPackageInfo(context.packageName, 0) } + private val usPkgInfo: PackageInfo by lazy { context.getPackageInfo() } private val _updateHistory = dataStore.createValue("stats.update.history", emptyList(), moshi) private val _installedFirst = dataStore.createValue("stats.install.first", null, moshi) @@ -100,7 +101,7 @@ class CurriculumVitae @Inject constructor( log(TAG) { "Current version history is $history" } val lastVersion = history.lastOrNull() - val current = usPkgInfo.versionName + val current = usPkgInfo.versionName!! if (lastVersion != current) { val versionHistory = history + current log(TAG) { "Update happened, new version history is $versionHistory" } diff --git a/app/src/main/java/eu/darken/sdmse/main/core/release/ReleaseManager.kt b/app/src/main/java/eu/darken/sdmse/main/core/release/ReleaseManager.kt index 965490c07..b8f359111 100644 --- a/app/src/main/java/eu/darken/sdmse/main/core/release/ReleaseManager.kt +++ b/app/src/main/java/eu/darken/sdmse/main/core/release/ReleaseManager.kt @@ -7,6 +7,7 @@ import eu.darken.sdmse.common.debug.logging.Logging.Priority.ERROR import eu.darken.sdmse.common.debug.logging.Logging.Priority.INFO import eu.darken.sdmse.common.debug.logging.log import eu.darken.sdmse.common.debug.logging.logTag +import eu.darken.sdmse.common.getPackageInfo import eu.darken.sdmse.main.core.CurriculumVitae import io.github.z4kn4fein.semver.Version import io.github.z4kn4fein.semver.VersionFormatException @@ -23,7 +24,7 @@ class ReleaseManager @Inject constructor( ) { private val ourVersion: Version by lazy { - val versionName = context.packageManager.getPackageInfo(context.packageName, 0).versionName + val versionName = context.getPackageInfo().versionName!! try { Version.parse(versionName, strict = false).also { log(TAG) { "Current version is $it" } } } catch (e: VersionFormatException) { From d440d2804383f64a267ad21886b7776d21888ace Mon Sep 17 00:00:00 2001 From: darken Date: Wed, 13 Nov 2024 13:24:52 +0100 Subject: [PATCH 3/7] Opt out of windowOptOutEdgeToEdgeEnforcement --- app/src/main/res/values-night/themes.xml | 4 +++- app/src/main/res/values/themes.xml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 9b3d1efb5..7fff26e26 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,4 +1,4 @@ - +