apply plugin: 'com.android.application'

android {
	namespace "de.markusfisch.android.binaryeye"
	compileSdk sdk_version

	defaultConfig {
		minSdk 21
		targetSdk sdk_version

		versionCode 174
		versionName '1.74.3'
	}

	signingConfigs {
		release {
			keyAlias System.getenv('ANDROID_KEY_ALIAS')
			keyPassword System.getenv('ANDROID_KEY_PASSWORD')
			storePassword System.getenv('ANDROID_STORE_PASSWORD')
			def filePath = System.getenv('ANDROID_KEYFILE')
			storeFile filePath ? file(filePath) : null
		}
	}

	sourceSets {
		main.java.srcDirs += 'src/main/kotlin'
		androidTest.java.srcDirs += 'src/androidTest/kotlin'
		test.java.srcDirs += 'src/test/kotlin'
	}

	buildTypes {
		debug {
			applicationIdSuffix '.debug'
		}

		release {
			proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
			minifyEnabled true
			shrinkResources true
			signingConfig signingConfigs.release
		}
	}

	buildFeatures {
		buildConfig true
	}

	bundle {
		language {
			// To make the app bundle contain all language resources
			// so the in-app language setting works. Another solution
			// would be to use the PlayCore API to download language
			// resources on demand, but it makes much more sense to
			// simply include the ~60 kb than adding fragile code and
			// dependencies.
			enableSplit = false
		}
	}

	// Required since Gradle 8.
	compileOptions {
		sourceCompatibility = JavaVersion.VERSION_1_8
		targetCompatibility = JavaVersion.VERSION_1_8
	}
}

dependencies {
	// Kotlin
	implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
	implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.11.0"
	implementation 'org.jetbrains.kotlinx:kotlinx-datetime:0.8.0'
	implementation "androidx.core:core-ktx:1.17.0" // Keep for minSDK 21.

	// Support
	implementation "androidx.appcompat:appcompat:1.7.1"
	implementation "com.google.android.material:material:1.13.0" // Keep for minSDK 21.
	implementation "androidx.preference:preference:1.2.1"

	// External
	var camerax_version = '1.4.2' // Keep for minSDK 21.
	implementation "androidx.camera:camera-core:$camerax_version"
	implementation "androidx.camera:camera-camera2:$camerax_version"
	implementation "androidx.camera:camera-lifecycle:$camerax_version"
	implementation "androidx.camera:camera-view:$camerax_version"
	implementation 'com.github.markusfisch:ScalingImageView:1.4.3'
	implementation 'com.github.markusfisch:zxing-cpp:v3.0.2.7'
	implementation 'de.tsenger:vdstools:0.17.0'
	implementation 'org.bouncycastle:bcpkix-jdk15to18:1.84'

	// Testing
	testImplementation 'junit:junit:4.13.2'
	testImplementation 'org.robolectric:robolectric:4.16.1'

	// Debugging
	debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
}
