fix: build pipeline and migrate to gradle kts and version catalogs

This commit is contained in:
FunkyMuse 2023-07-31 12:31:48 +02:00
parent 7254053395
commit e039919274
16 changed files with 198 additions and 134 deletions

View File

@ -1,83 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 33
defaultConfig {
applicationId "com.simplemobiletools.camera"
minSdkVersion 29
targetSdkVersion 33
versionCode 87
versionName "5.7.0"
setProperty("archivesBaseName", "camera")
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
if (keystorePropertiesFile.exists()) {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
}
buildFeatures {
buildConfig true
viewBinding true
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (keystorePropertiesFile.exists()) {
signingConfig signingConfigs.release
}
}
}
flavorDimensions "variants"
productFlavors {
core {}
fdroid {}
prepaid {}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:fad9b2cdb0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation "androidx.exifinterface:exifinterface:1.3.5"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
implementation 'androidx.window:window:1.1.0-alpha03'
def camerax_version = '1.2.0-rc01'
implementation "androidx.camera:camera-core:$camerax_version"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-video:$camerax_version"
implementation "androidx.camera:camera-extensions:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:$camerax_version"
}

97
app/build.gradle.kts Normal file
View File

@ -0,0 +1,97 @@
import java.io.FileInputStream
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.konan.properties.Properties
plugins {
alias(libs.plugins.android)
alias(libs.plugins.kotlinAndroid)
}
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
android {
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
defaultConfig {
applicationId = libs.versions.app.version.appId.get()
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
targetSdk = project.libs.versions.app.build.targetSDK.get().toInt()
versionName = project.libs.versions.app.version.versionName.get()
versionCode = project.libs.versions.app.version.versionCode.get().toInt()
setProperty("archivesBaseName", "camera")
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
if (keystorePropertiesFile.exists()) {
register("release") {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
}
}
buildFeatures {
viewBinding = true
buildConfig = true
}
buildTypes {
debug {
applicationIdSuffix = ".debug"
}
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
if (keystorePropertiesFile.exists()) {
signingConfig = signingConfigs.getByName("release")
}
}
}
flavorDimensions.add("variants")
productFlavors {
register("core")
register("fdroid")
register("prepaid")
}
sourceSets {
getByName("main").java.srcDirs("src/main/kotlin")
}
compileOptions {
val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString())
sourceCompatibility = currentJavaVersionFromLibs
targetCompatibility = currentJavaVersionFromLibs
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
}
namespace = "com.simplemobiletools.camera"
lint {
checkReleaseBuilds = false
abortOnError = false
}
}
dependencies {
implementation(libs.simple.tools.commons)
implementation(libs.bundles.androidx.camera)
implementation(libs.androidx.documentfile)
implementation(libs.androidx.exifinterface)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.window)
}

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.simplemobiletools.camera"
android:installLocation="auto">
<uses-feature

View File

@ -77,7 +77,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
else -> throw IllegalStateException("Unsupported tab position ${tab.position}")
}
} else {
toast(R.string.no_audio_permissions)
toast(com.simplemobiletools.commons.R.string.no_audio_permissions)
selectPhotoTab()
if (isVideoCaptureIntent()) {
finish()
@ -235,7 +235,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
if (grantedRecordAudioPermission) {
initializeCamera(false)
} else {
toast(R.string.no_audio_permissions)
toast(com.simplemobiletools.commons.R.string.no_audio_permissions)
if (isThirdPartyIntent()) {
finish()
} else {
@ -247,12 +247,12 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
}
} else {
toast(R.string.no_storage_permissions)
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
finish()
}
}
} else {
toast(R.string.no_camera_permissions)
toast(com.simplemobiletools.commons.R.string.no_camera_permissions)
finish()
}
}
@ -314,7 +314,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
topMargin = safeInsetTop
}
val marginBottom = safeInsetBottom + navigationBarHeight + resources.getDimensionPixelSize(R.dimen.bigger_margin)
val marginBottom = safeInsetBottom + navigationBarHeight + resources.getDimensionPixelSize(com.simplemobiletools.commons.R.dimen.bigger_margin)
binding.shutter.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = marginBottom
@ -861,7 +861,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun setButtonColors(button: MaterialButton) {
val primaryColor = getProperPrimaryColor()
val states = arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked))
val iconColors = intArrayOf(ContextCompat.getColor(this, R.color.md_grey_white), primaryColor)
val iconColors = intArrayOf(ContextCompat.getColor(this, com.simplemobiletools.commons.R.color.md_grey_white), primaryColor)
button.iconTint = ColorStateList(states, iconColors)
}

View File

@ -66,7 +66,7 @@ class SettingsActivity : SimpleActivity() {
private fun refreshMenuItems() {
binding.settingsToolbar.menu.apply {
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)
}
}
@ -125,9 +125,9 @@ class SettingsActivity : SimpleActivity() {
FAQItem(R.string.faq_1_title, R.string.faq_1_text)
)
if (!resources.getBoolean(R.bool.hide_google_relations)) {
faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons))
faqItems.add(FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons))
if (!resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)) {
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_2_title_commons, com.simplemobiletools.commons.R.string.faq_2_text_commons))
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_6_title_commons, com.simplemobiletools.commons.R.string.faq_6_text_commons))
}
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
@ -183,7 +183,7 @@ class SettingsActivity : SimpleActivity() {
if (checkLocationPermission()) {
updateSavePhotoVideoLocationConfig(true)
} else {
OpenDeviceSettingsDialog(activity = this@SettingsActivity, message = getString(R.string.allow_location_permission))
OpenDeviceSettingsDialog(activity = this@SettingsActivity, message = getString(com.simplemobiletools.commons.R.string.allow_location_permission))
}
}
}

View File

@ -98,13 +98,15 @@ class PhotoProcessor(
try {
image = Bitmap.createBitmap(image, 0, 0, image.width, image.height, matrix, false)
} catch (e: OutOfMemoryError) {
activity.toast(R.string.out_of_memory_error)
activity.toast(com.simplemobiletools.commons.R.string.out_of_memory_error)
}
}
}
try {
image.compress(Bitmap.CompressFormat.JPEG, activity.config.photoQuality, fos)
if (fos != null) {
image.compress(Bitmap.CompressFormat.JPEG, activity.config.photoQuality, fos)
}
if (!isThirdPartyIntent) {
activity.saveImageRotation(path, totalRotation)
}

View File

@ -63,7 +63,7 @@ data class MySize(val width: Int, val height: Int, val isFullScreen: Boolean = f
isNineteenToEight() -> "19:8"
isSquare() -> "1:1"
isTwoToOne() -> "2:1"
else -> context.resources.getString(R.string.other)
else -> context.resources.getString(com.simplemobiletools.commons.R.string.other)
}
@DrawableRes

View File

@ -51,7 +51,7 @@ enum class VideoQuality(val width: Int, val height: Int) {
isNineteenToEight() -> "19:8"
isSquare() -> "1:1"
isTwoToOne() -> "2:1"
else -> context.resources.getString(R.string.other)
else -> context.resources.getString(com.simplemobiletools.commons.R.string.other)
}
@DrawableRes

View File

@ -65,7 +65,7 @@ class ShadowDrawable(context: Context, private val drawable: Drawable, @StyleRes
if (styleResId != 0) {
val obtainStyledAttributes = context.obtainStyledAttributes(styleResId, R.styleable.ShadowDrawable)
shadowColor =
obtainStyledAttributes.getColor(R.styleable.ShadowDrawable_android_shadowColor, ContextCompat.getColor(context, R.color.md_grey_400_dark))
obtainStyledAttributes.getColor(R.styleable.ShadowDrawable_android_shadowColor, ContextCompat.getColor(context, com.simplemobiletools.commons.R.color.md_grey_400_dark))
shadowDx = obtainStyledAttributes.getFloat(R.styleable.ShadowDrawable_android_shadowDx, 0f).toInt()
shadowDy = obtainStyledAttributes.getFloat(R.styleable.ShadowDrawable_android_shadowDy, 0f).toInt()
val shadowRadius = obtainStyledAttributes.getFloat(R.styleable.ShadowDrawable_android_shadowRadius, 0.0f).coerceAtLeast(0.0f)

View File

@ -1,30 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

4
build.gradle.kts Normal file
View File

@ -0,0 +1,4 @@
plugins {
alias(libs.plugins.android).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
}

View File

@ -1,2 +1,11 @@
android.enableJetifier=true
org.gradle.jvmargs=-Xmx4g -XX:+UseGCOverheadLimit -XX:GCTimeLimit=10 -Dfile.encoding=UTF-8 -XX:+UseParallelGC
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.vfs.watch=true
org.gradle.configureondemand=true
org.gradle.unsafe.configuration-cache=true
org.gradle.unsafe.configuration-cache-problems=warn
android.nonTransitiveRClass=true

51
gradle/libs.versions.toml Normal file
View File

@ -0,0 +1,51 @@
[versions]
#jetbrains
kotlin = "1.9.0"
#Androidx
androidx-document-file = "1.0.1"
androidx-exif-interface = "1.3.6"
androidx-lifecycle = "2.6.1"
androidx-window = "1.2.0-beta01"
androidx-camera = "1.3.0-beta02"
androidx-ktx = "2.6.1"
#Simple tools
lifecycleRuntimeKtx = "2.6.1"
simple-commons = "53ad279f5e"
#Gradle
gradlePlugins-agp = "8.1.0"
#build
app-build-compileSDKVersion = "34"
app-build-targetSDK = "33"
app-build-minimumSDK = "23"
app-build-javaVersion = "VERSION_17"
app-build-kotlinJVMTarget = "17"
#versioning
app-version-appId = "com.simplemobiletools.camera"
app-version-versionCode = "87"
app-version-versionName = "5.7.0"
[libraries]
#Android X
androidx-camera-core = { module = "androidx.camera:camera-core", version.ref = "androidx-camera" }
androidx-camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "androidx-camera" }
androidx-camera-video = { module = "androidx.camera:camera-video", version.ref = "androidx-camera" }
androidx-camera-extensions = { module = "androidx.camera:camera-extensions", version.ref = "androidx-camera" }
androidx-camera-lifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "androidx-camera" }
androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "androidx-camera" }
androidx-window = { module = "androidx.window:window", version.ref = "androidx-window" }
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-ktx" }
androidx-exifinterface = { module = "androidx.exifinterface:exifinterface", version.ref = "androidx-exif-interface" }
androidx-documentfile = { module = "androidx.documentfile:documentfile", version.ref = "androidx-document-file" }
#Simple Mobile Tools
simple-tools-commons = { module = "com.github.SimpleMobileTools:Simple-Commons", version.ref = "simple-commons" }
[bundles]
androidx-camera = [
"androidx-camera-core",
"androidx-camera-camera2",
"androidx-camera-video",
"androidx-camera-extensions",
"androidx-camera-lifecycle",
"androidx-camera-view"
]
[plugins]
android = { id = "com.android.application", version.ref = "gradlePlugins-agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }

View File

@ -1,6 +1,6 @@
#Thu Nov 05 21:17:11 CET 2020
#Mon Jul 31 10:49:23 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip

View File

@ -1 +0,0 @@
include ':app'

16
settings.gradle.kts Normal file
View File

@ -0,0 +1,16 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { setUrl("https://jitpack.io") }
}
}
include(":app")