Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some compilation fixes #213

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 52 additions & 54 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
id("kotlin-parcelize")
id("com.google.devtools.ksp")
}
apply(plugin = "dagger.hilt.android.plugin")
apply(plugin = "androidx.navigation.safeargs.kotlin")
Expand All @@ -26,6 +26,11 @@ android {
buildConfigField("String", "GITSHA", "\"${lastCommitHash()}\"")
}

buildFeatures {
buildConfig = true
viewBinding = true
}

signingConfigs {
val basePath = File(System.getProperty("user.home"), ".appconfig/${packageName}")
create("releaseFoss") {
Expand All @@ -41,7 +46,6 @@ android {
create("foss") {
dimension = "version"
signingConfig = signingConfigs["releaseFoss"]
// The info block is encrypted and can only be read by google
dependenciesInfo {
includeInApk = false
includeInBundle = false
Expand Down Expand Up @@ -92,19 +96,15 @@ android {
val variantOutputImpl = this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
val variantName: String = variantOutputImpl.name

if (listOf("release", "beta").any { variantName.toLowerCase().contains(it) }) {
if (listOf("release", "beta").any { variantName.lowercase().contains(it) }) {
val outputFileName = packageName +
"-v${defaultConfig.versionName}-${defaultConfig.versionCode}" +
"-${variantName.toUpperCase()}-${lastCommitHash()}.apk"
"-${variantName.uppercase()}-${lastCommitHash()}.apk"

variantOutputImpl.outputFileName = outputFileName
}
}

buildFeatures {
viewBinding = true
}

compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -114,12 +114,11 @@ android {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi",
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
"-Xuse-experimental=kotlin.time.ExperimentalTime",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.time.ExperimentalTime"
"-opt-in=kotlin.ExperimentalStdlibApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
"-opt-in=kotlin.time.ExperimentalTime",
"-opt-in=kotlin.RequiresOptIn"
)
}

Expand All @@ -146,7 +145,7 @@ android {

dependencies {
// https://developer.android.com/studio/write/java8-support
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")

implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.Kotlin.core}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.Kotlin.coroutines}")
Expand All @@ -162,71 +161,70 @@ dependencies {
implementation("com.google.dagger:dagger:${Versions.Dagger.core}")
implementation("com.google.dagger:dagger-android:${Versions.Dagger.core}")

kapt("com.google.dagger:dagger-compiler:${Versions.Dagger.core}")
kapt("com.google.dagger:dagger-android-processor:${Versions.Dagger.core}")
ksp("com.google.dagger:dagger-compiler:${Versions.Dagger.core}") // Replace kapt with ksp
ksp("com.google.dagger:dagger-android-processor:${Versions.Dagger.core}") // Replace kapt with ksp

implementation("com.google.dagger:hilt-android:${Versions.Dagger.core}")
kapt("com.google.dagger:hilt-android-compiler:${Versions.Dagger.core}")
ksp("com.google.dagger:hilt-android-compiler:${Versions.Dagger.core}") // Replace kapt with ksp

testImplementation("com.google.dagger:hilt-android-testing:${Versions.Dagger.core}")
kaptTest("com.google.dagger:hilt-android-compiler:${Versions.Dagger.core}")
kspTest("com.google.dagger:hilt-android-compiler:${Versions.Dagger.core}") // Replace kapt with ksp

androidTestImplementation("com.google.dagger:hilt-android-testing:${Versions.Dagger.core}")
kaptAndroidTest("com.google.dagger:hilt-android-compiler:${Versions.Dagger.core}")
kspAndroidTest("com.google.dagger:hilt-android-compiler:${Versions.Dagger.core}") // Replace kapt with ksp

val moshiVersion = "1.15.1"
implementation("com.squareup.moshi:moshi:$moshiVersion")
implementation("com.squareup.moshi:moshi-adapters:$moshiVersion")
kapt("com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion")
ksp("com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion") // Replace kapt with ksp

implementation("com.squareup.okio:okio:3.1.0")
implementation("com.squareup.okio:okio:3.9.0")

implementation("io.coil-kt:coil:2.4.0")
implementation("io.coil-kt:coil:2.7.0")

"gplayImplementation"("com.android.billingclient:billing:6.2.1")
"gplayImplementation"("com.android.billingclient:billing:7.1.1")

// Support libs
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.annotation:annotation:1.8.0")
implementation("androidx.annotation:annotation:1.9.1")

implementation("androidx.activity:activity-ktx:1.9.0")
implementation("androidx.fragment:fragment-ktx:1.8.1")
implementation("androidx.activity:activity-ktx:1.9.3")
implementation("androidx.fragment:fragment-ktx:1.8.5")

implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.3")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.3")
implementation("androidx.lifecycle:lifecycle-process:2.8.3")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.3")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.7")
implementation("androidx.lifecycle:lifecycle-process:2.8.7")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.7")

implementation("androidx.navigation:navigation-fragment-ktx:${Versions.AndroidX.Navigation.core}")
implementation("androidx.navigation:navigation-ui-ktx:${Versions.AndroidX.Navigation.core}")
androidTestImplementation("androidx.navigation:navigation-testing:${Versions.AndroidX.Navigation.core}")

implementation("androidx.preference:preference-ktx:1.2.1")

implementation("androidx.core:core-splashscreen:1.0.0-alpha02")
implementation("androidx.core:core-splashscreen:1.0.1")

// implementation("androidx.work:work-runtime:${Versions.AndroidX.WorkManager.core}")
// testImplementation("androidx.work:work-testing:${Versions.AndroidX.WorkManager.core}")
// implementation("androidx.work:work-runtime:${Versions.AndroidX.WorkManager.core}")
// testImplementation("androidx.work:work-testing:${Versions.AndroidX.WorkManager.core}")

implementation("com.google.android.flexbox:flexbox:3.0.0")

// UI
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("com.google.android.material:material:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
implementation("com.google.android.material:material:1.12.0")

// Testing
testImplementation("junit:junit:4.13.2")
testImplementation("org.junit.vintage:junit-vintage-engine:5.8.2")
testImplementation("androidx.test:core-ktx:1.4.0")
testImplementation("androidx.test:core-ktx:1.6.1")

testImplementation("io.mockk:mockk:1.12.4")
androidTestImplementation("io.mockk:mockk-android:1.12.4")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.2")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.3")

testImplementation("io.kotest:kotest-runner-junit5:5.3.0")
testImplementation("io.kotest:kotest-assertions-core-jvm:5.3.0")
Expand All @@ -236,15 +234,15 @@ dependencies {

testImplementation("android.arch.core:core-testing:1.1.1")
androidTestImplementation("android.arch.core:core-testing:1.1.1")
debugImplementation("androidx.test:core-ktx:1.4.0")

androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")

androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test:rules:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.4.0")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.4.0")
androidTestImplementation("androidx.test.espresso.idling:idling-concurrent:3.4.0")
}
debugImplementation("androidx.test:core-ktx:1.6.1")

androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")

androidTestImplementation("androidx.test:runner:1.6.2")
androidTestImplementation("androidx.test:rules:1.6.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.6.1")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.6.1")
androidTestImplementation("androidx.test.espresso.idling:idling-concurrent:3.6.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PrimaryProfilePkg(

override val requestedPermissions: Collection<UsesPermission> by lazy {
val base = packageInfo.requestedPermissions?.mapIndexed { index, permissionId ->
val flags = packageInfo.requestedPermissionsFlags[index]
val flags = packageInfo.requestedPermissionsFlags?.get(index) ?: 0
UsesPermission.WithState(id = Permission.Id(permissionId), flags = flags)
} ?: emptyList()

Expand Down Expand Up @@ -97,4 +97,4 @@ suspend fun getNormalPkgs(ipcFunnel: IPCFunnel): Collection<BasePkg> {
.map { async { it.toNormalPkg(ipcFunnel) } }
.awaitAll()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ enum class BatteryOptimization {

suspend fun PackageInfo.determineBatteryOptimization(ipcFunnel: IPCFunnel): BatteryOptimization {
if (!hasApiLevel(23)) return BatteryOptimization.IGNORED
if (requestedPermissions == null) return BatteryOptimization.MANAGED_BY_SYSTEM
if (requestedPermissions.none { it == APerm.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS.id.value }) {
val permissions = requestedPermissions ?: return BatteryOptimization.MANAGED_BY_SYSTEM
if (permissions.none { it == APerm.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS.id.value }) {
return BatteryOptimization.MANAGED_BY_SYSTEM
}

Expand All @@ -24,4 +24,4 @@ suspend fun PackageInfo.determineBatteryOptimization(ipcFunnel: IPCFunnel): Batt
} else {
BatteryOptimization.OPTIMIZED
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/eu/darken/myperm/main/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MainActivity : Activity2() {
super.onCreate(savedInstanceState)

val splashScreen = installSplashScreen()
splashScreen.setKeepVisibleCondition { showSplashScreen && savedInstanceState == null }
splashScreen.setKeepOnScreenCondition { showSplashScreen && savedInstanceState == null }

ui = MainActivityBinding.inflate(layoutInflater)
setContentView(ui.root)
Expand Down
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url = uri("https://plugins.gradle.org/m2/") } // Add this repository
}
dependencies {
classpath("com.android.tools.build:gradle:8.7.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin.core}")
classpath("com.google.dagger:hilt-android-gradle-plugin:${Versions.Dagger.core}")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:${Versions.AndroidX.Navigation.core}")
classpath("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:2.0.21-1.0.28") // Ensure correct KSP classpath
}
}

allprojects {
repositories {
google()
mavenCentral()
maven { url = uri("https://plugins.gradle.org/m2/") } // Add this repository
}
}

tasks.register("clean").configure {
delete("build")
}
}
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ repositories {
}
dependencies {
implementation("com.android.tools.build:gradle:8.7.3")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21") // Update Kotlin Gradle plugin version
implementation("com.squareup:javapoet:1.13.0")
}
}
30 changes: 18 additions & 12 deletions buildSrc/src/main/java/ProjectConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import java.util.Properties

object ProjectConfig {
const val minSdk = 21
const val compileSdk = 34
const val targetSdk = 34
const val compileSdk = 35
const val targetSdk = 35

object Version {
val versionProperties = Properties().apply {
Expand All @@ -25,7 +25,7 @@ object ProjectConfig {
}
}

fun lastCommitHash(): String = Runtime.getRuntime().exec("git rev-parse --short HEAD").let { process ->
fun lastCommitHash(): String = ProcessBuilder("git", "rev-parse", "--short", "HEAD").start().let { process ->
process.waitFor()
val output = process.inputStream.use { input ->
input.bufferedReader().use {
Expand All @@ -47,10 +47,16 @@ fun LibraryExtension.setupLibraryDefaults() {

defaultConfig {
minSdk = ProjectConfig.minSdk
targetSdk = ProjectConfig.targetSdk

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
}

lint {
targetSdk = ProjectConfig.targetSdk
}

buildTypes {
Expand All @@ -69,14 +75,14 @@ fun LibraryExtension.setupLibraryDefaults() {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
"-Xuse-experimental=kotlin.time.ExperimentalTime",
"-Xopt-in=kotlin.RequiresOptIn"
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
"-opt-in=kotlin.time.ExperimentalTime",
"-opt-in=kotlin.RequiresOptIn"
)
}

fun Packaging.() {
packaging {
resources.excludes += "DebugProbesKt.bin"
}
}
Expand Down Expand Up @@ -108,4 +114,4 @@ fun com.android.build.api.dsl.SigningConfig.setupCredentials(
keyPassword = props.getProperty("release.keyPassword")
}
}
}
}
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false