From 4b87399ee690721e2c0b7dd8c9b4dbfacd28413c Mon Sep 17 00:00:00 2001 From: angrezichatterbox Date: Fri, 6 Sep 2024 16:14:51 +0530 Subject: [PATCH 1/7] feat:Migrated from Groovy to Kotlin Build configuration --- app/build.gradle | 156 ------------------------------------------- app/build.gradle.kts | 150 +++++++++++++++++++++++++++++++++++++++++ build.gradle | 42 ------------ build.gradle.kts | 44 ++++++++++++ settings.gradle | 1 - settings.gradle.kts | 2 + 6 files changed, 196 insertions(+), 199 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 36bf6b39..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,156 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' - id 'kotlin-kapt' - id("org.jmailen.kotlinter") - - -} - -def keystorePropertiesFile = rootProject.file("keystore.properties") -def keystoreProperties = new Properties() -if (keystorePropertiesFile.exists()) { - keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) -} - -android { - compileSdk 34 - - kotlinOptions { - jvmTarget = "1.8" - } - - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - buildFeatures { - viewBinding = true - buildConfig true - } - - defaultConfig { - applicationId "be.scri" - minSdk 26 - targetSdk 34 - versionCode 7 - versionName "1.0.0" - multiDexEnabled true - setProperty("archivesBaseName", "scribe") - vectorDrawables.useSupportLibrary = true - } - - signingConfigs { - if (keystorePropertiesFile.exists()) { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile file(keystoreProperties['storeFile']) - storePassword keystoreProperties['storePassword'] - } - } - } - - 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 {} - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - lint { - abortOnError false - checkReleaseBuilds false - } - - detekt { - toolVersion = "1.23.6" - buildUponDefaultConfig = true - allRules = true - } - - kotlinter { - failBuildWhenCannotAutoFormat = false - ignoreFailures = false - } - - namespace 'be.scri' -} - -dependencies { - implementation 'androidx.appcompat:appcompat:1.7.0' - implementation 'androidx.activity:activity-ktx:1.9.2' - implementation 'androidx.navigation:navigation-fragment-ktx:2.8.0' - implementation 'androidx.navigation:navigation-ui-ktx:2.8.0' - kapt 'androidx.room:room-compiler:2.6.1' - implementation 'androidx.room:room-runtime:2.6.1' - annotationProcessor 'androidx.room:room-compiler:2.6.1' - // Commons dependencies - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.documentfile:documentfile:1.0.1' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' - implementation "androidx.exifinterface:exifinterface:1.3.7" - implementation "androidx.biometric:biometric-ktx:1.2.0-alpha05" - implementation 'com.google.android.material:material:1.12.0' - implementation 'androidx.recyclerview:recyclerview:1.3.2' - implementation 'androidx.cardview:cardview:1.0.0' - implementation "androidx.viewpager2:viewpager2:1.1.0" - - api 'joda-time:joda-time:2.10.13' - api 'com.github.tibbi:RecyclerView-FastScroller:e7d3e150c4' - api 'com.github.tibbi:reprint:2cb206415d' - api 'androidx.core:core-ktx:1.13.1' - api 'androidx.appcompat:appcompat:1.7.0' - api 'com.google.android.material:material:1.12.0' - api 'com.google.code.gson:gson:2.10.1' - - api 'com.github.bumptech.glide:glide:4.12.0' - kapt 'com.github.bumptech.glide:compiler:4.12.0' - annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' -} - -task moveFromi18n { - def locales = ['de','es','sv','en-US'] - - locales.each { locale -> - def fromDir = "src/main/assets/i18n/Scribe-i18n/values/${locale}/" - def toDir = locale == 'en-US' ? "src/main/res/values/" : "src/main/res/values-${locale}/" - def sourceDir = file(fromDir) - - if (sourceDir.exists()) { - println "Preparing to move from $fromDir to $toDir" - doLast { - copy { - from fileTree(dir: fromDir) - into toDir - duplicatesStrategy = DuplicatesStrategy.INCLUDE - } - } - } else { - println "Source directory does not exist: $fromDir" - } - } -} - -tasks.named('preBuild').configure { - dependsOn tasks.named('moveFromi18n') -} - diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..808a167e --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,150 @@ +import java.util.Properties +import java.io.FileInputStream + + + +val keystorePropertiesFile = rootProject.file("keystore.properties") +val keystoreProperties = Properties().apply { + if (keystorePropertiesFile.exists()) { + load(FileInputStream(keystorePropertiesFile)) + } +} + +plugins { + id("com.android.application") + id("kotlin-android") + id("org.jmailen.kotlinter") + id("io.gitlab.arturbosch.detekt") + id("com.google.devtools.ksp") version "2.0.0-1.0.22" apply true +} +val kotlin_version by extra("2.0.0") + +android { + compileSdk = 34 + + defaultConfig { + applicationId = "be.scri" + minSdk = 26 + targetSdk = 34 + versionCode = 7 + versionName = "1.0.0" + multiDexEnabled = true + vectorDrawables.useSupportLibrary = true + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } + + buildFeatures { + viewBinding = true + buildConfig = true + } + + signingConfigs { + create("release") { + if (keystorePropertiesFile.exists()) { + keyAlias = keystoreProperties["keyAlias"].toString() + keyPassword = keystoreProperties["keyPassword"].toString() + storeFile = keystoreProperties["storeFile"]?.let { file(it) } + storePassword = keystoreProperties["storePassword"].toString() + } + } + } + + buildTypes { + getByName("debug") { + applicationIdSuffix = ".debug" + } + getByName("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + signingConfig = signingConfigs.getByName("release") + } + } + + flavorDimensions.add("variants") + productFlavors { + create("core") + create("fdroid") + } + + sourceSets { + getByName("main").java.srcDirs("src/main/kotlin") + } + + lint { + abortOnError = false + checkReleaseBuilds = false + } + + detekt { + toolVersion = "1.23.6" + buildUponDefaultConfig = true + allRules = true + } + + kotlinter { + failBuildWhenCannotAutoFormat = false + ignoreFailures = false + } + + namespace = "be.scri" +} + +dependencies { + implementation("androidx.appcompat:appcompat:1.7.0") + implementation("androidx.activity:activity-ktx:1.9.2") + implementation("androidx.navigation:navigation-fragment-ktx:2.8.0") + implementation("androidx.navigation:navigation-ui-ktx:2.8.0") + ksp("androidx.room:room-compiler:2.6.1") + implementation("androidx.room:room-runtime:2.6.1") + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.documentfile:documentfile:1.0.1") + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") + implementation("androidx.exifinterface:exifinterface:1.3.7") + implementation("androidx.biometric:biometric-ktx:1.2.0-alpha05") + implementation("com.google.android.material:material:1.12.0") + implementation("androidx.recyclerview:recyclerview:1.3.2") + implementation("androidx.cardview:cardview:1.0.0") + implementation("androidx.viewpager2:viewpager2:1.1.0") + + api("joda-time:joda-time:2.10.13") + api("com.github.tibbi:RecyclerView-FastScroller:e7d3e150c4") + api("com.github.tibbi:reprint:2cb206415d") + api("androidx.core:core-ktx:1.13.1") + api("com.google.code.gson:gson:2.10.1") + api("com.github.bumptech.glide:glide:4.14.2") + ksp("com.github.bumptech.glide:ksp:4.14.2") +} + + +tasks.register("moveFromi18n") { + val locales = listOf("de", "es", "sv", "en-US") + + locales.forEach { locale -> + val fromDir = "src/main/assets/i18n/Scribe-i18n/values/$locale/" + val toDir = if (locale == "en-US") "src/main/res/values/" else "src/main/res/values-$locale/" + val sourceDir = file(fromDir) + + if (sourceDir.exists()) { + println("Preparing to move from $fromDir to $toDir") + from(fileTree(fromDir)) + into(toDir) + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } else { + println("Source directory does not exist: $fromDir") + } + } +} + +tasks.named("preBuild").configure { + dependsOn(tasks.named("moveFromi18n")) +} + diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 694921b2..00000000 --- a/build.gradle +++ /dev/null @@ -1,42 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - ext.kotlin_version = '2.0.0' - - repositories { - google() - mavenCentral() - gradlePluginPortal() - maven { - url = uri("https://plugins.gradle.org/m2/") - } - - } - - dependencies { - classpath "com.android.tools.build:gradle:8.5.2" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6" - classpath "org.jlleitschuh.gradle:ktlint-gradle:12.1.1" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6" - classpath("org.jmailen.gradle:kotlinter-gradle:4.4.1") - - } -} - - - -apply plugin: "io.gitlab.arturbosch.detekt" -apply plugin: "org.jmailen.kotlinter" - -allprojects { - repositories { - google() - mavenCentral() - maven { url 'https://jitpack.io' } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..2903fd19 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,44 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + val kotlin_version = "2.0.0" + + repositories { + google() + mavenCentral() + gradlePluginPortal() + maven("https://plugins.gradle.org/m2/") + + } + + dependencies { + classpath("com.android.tools.build:gradle:8.5.2") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") + classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6") + classpath("org.jlleitschuh.gradle:ktlint-gradle:12.1.1") + classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.6") + classpath("org.jmailen.gradle:kotlinter-gradle:4.4.1") + + } +} + + + +apply(plugin= "io.gitlab.arturbosch.detekt") +apply(plugin = "org.jmailen.kotlinter") + +plugins { + id("com.google.devtools.ksp") version "2.0.0-1.0.22" apply false +} + +allprojects { + repositories { + google() + mavenCentral() + maven("https://jitpack.io") + } +} + +tasks.register("clean",Delete::class){ + delete(rootProject.buildDir) +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e7b4def4..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..30657ac0 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "Scribe-Android" +include(":app") From 7dd862d1062dbc289b566189231512bd5020bf47 Mon Sep 17 00:00:00 2001 From: angrezichatterbox Date: Fri, 6 Sep 2024 21:37:47 +0530 Subject: [PATCH 2/7] fix: Temporarily disabled detekt lint issues --- app/build.gradle.kts | 9 +++++---- detekt.yml | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 detekt.yml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 808a167e..f0f33df7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -37,9 +37,8 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = "1.8" - } + + buildFeatures { viewBinding = true @@ -86,7 +85,8 @@ android { detekt { toolVersion = "1.23.6" buildUponDefaultConfig = true - allRules = true + allRules = false + config = rootProject.files("detekt.yml") } kotlinter { @@ -97,6 +97,7 @@ android { namespace = "be.scri" } + dependencies { implementation("androidx.appcompat:appcompat:1.7.0") implementation("androidx.activity:activity-ktx:1.9.2") diff --git a/detekt.yml b/detekt.yml new file mode 100644 index 00000000..eda515c5 --- /dev/null +++ b/detekt.yml @@ -0,0 +1,21 @@ +style: + MagicNumber: + active: false + MaxLineLength: + active: false + LoopWithTooManyJumpStatements: + active: false + WildcardImport: + active: false + ReturnCount: + active: false + UnusedPrivateProperty: + active: false + UnusedParameter: + active: false + + + +complexity: + TooManyFunctions: + active: false From 5a95976530c64783bb112b97bb9b5ec5a8cac1b7 Mon Sep 17 00:00:00 2001 From: angrezichatterbox Date: Fri, 6 Sep 2024 21:50:50 +0530 Subject: [PATCH 3/7] fix:Disabled more detekt lint issues --- detekt.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/detekt.yml b/detekt.yml index eda515c5..8a236fff 100644 --- a/detekt.yml +++ b/detekt.yml @@ -13,7 +13,10 @@ style: active: false UnusedParameter: active: false - + FunctionOnlyReturningConstant: + active: false + UtilityClassWithPublicConstructor: + active: false complexity: From 9c43352f5adbe083c178da5b9fc557e6d732cf99 Mon Sep 17 00:00:00 2001 From: angrezichatterbox Date: Fri, 6 Sep 2024 22:47:20 +0530 Subject: [PATCH 4/7] fix:Corrected the order of the statements --- detekt.yml | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/detekt.yml b/detekt.yml index 8a236fff..e09f04d7 100644 --- a/detekt.yml +++ b/detekt.yml @@ -18,7 +18,48 @@ style: UtilityClassWithPublicConstructor: active: false - complexity: TooManyFunctions: active: false + NestedBlockDepth: + active: false + ComplexCondition: + active: false + LongParameterList: + active: false + LongMethod: + active: false + CyclomaticComplexMethod: + active: false + LargeClass: + active: false + +naming: + VariableNaming: + active: false + InvalidPackageDeclaration: + active: false + +potential-bugs: + ImplicitDefaultLocale: + active: false + +exceptions: + TooGenericExceptionCaught: + active: false + SwallowedException: + active: false + InstanceOfCheckForException: + active: false + +empty-blocks: + EmptyCatchBlock: + active: false + EmptyFunctionBlock: + active: false + +performance: + ForEachOnRange: + active: false + SpreadOperator: + active: false From 8b0a4a5d289a3bad81317a90a73f716e1e7ce773 Mon Sep 17 00:00:00 2001 From: angrezichatterbox Date: Sat, 7 Sep 2024 00:33:41 +0530 Subject: [PATCH 5/7] feat:Added toast for Period on double tap of space bar --- .../main/java/be/scri/fragments/LanguageSettingsFragment.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/be/scri/fragments/LanguageSettingsFragment.kt b/app/src/main/java/be/scri/fragments/LanguageSettingsFragment.kt index b729bc69..c113578f 100644 --- a/app/src/main/java/be/scri/fragments/LanguageSettingsFragment.kt +++ b/app/src/main/java/be/scri/fragments/LanguageSettingsFragment.kt @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button +import android.widget.Toast import androidx.activity.OnBackPressedCallback import androidx.activity.addCallback import androidx.fragment.app.Fragment @@ -119,6 +120,7 @@ class LanguageSettingsFragment : Fragment() { val editor = sharedPref.edit() editor.putBoolean("period_on_double_tap_$language", true) editor.apply() + Toast.makeText(requireContext(), "$language Period on Double Tap of Space Bar on ", Toast.LENGTH_SHORT).show() } private fun disablePeriodOnSpaceBarDoubleTap(language: String) { @@ -126,6 +128,7 @@ class LanguageSettingsFragment : Fragment() { val editor = sharedPref.edit() editor.putBoolean("period_on_double_tap_$language", false) editor.apply() + Toast.makeText(requireContext(), "$language Period on Double Tap of Space Bar on ", Toast.LENGTH_SHORT).show() } override fun onDestroyView() { From 12081c47bf2384985e31fd11e8b4f499f85d9916 Mon Sep 17 00:00:00 2001 From: Andrew Tavis McAllister Date: Fri, 6 Sep 2024 21:10:30 +0200 Subject: [PATCH 6/7] Minor refactoring for spacing --- app/build.gradle.kts | 8 -------- build.gradle.kts | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f0f33df7..3b9a13f7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,8 +1,6 @@ import java.util.Properties import java.io.FileInputStream - - val keystorePropertiesFile = rootProject.file("keystore.properties") val keystoreProperties = Properties().apply { if (keystorePropertiesFile.exists()) { @@ -37,9 +35,6 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - - - buildFeatures { viewBinding = true buildConfig = true @@ -97,7 +92,6 @@ android { namespace = "be.scri" } - dependencies { implementation("androidx.appcompat:appcompat:1.7.0") implementation("androidx.activity:activity-ktx:1.9.2") @@ -125,7 +119,6 @@ dependencies { ksp("com.github.bumptech.glide:ksp:4.14.2") } - tasks.register("moveFromi18n") { val locales = listOf("de", "es", "sv", "en-US") @@ -148,4 +141,3 @@ tasks.register("moveFromi18n") { tasks.named("preBuild").configure { dependsOn(tasks.named("moveFromi18n")) } - diff --git a/build.gradle.kts b/build.gradle.kts index 2903fd19..29defcf8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - val kotlin_version = "2.0.0" + val kotlin_version = "2.0.0" repositories { google() @@ -22,8 +22,6 @@ buildscript { } } - - apply(plugin= "io.gitlab.arturbosch.detekt") apply(plugin = "org.jmailen.kotlinter") From cfe2e4c48f27c5ab9c9fef4ddfdef3250fa29370 Mon Sep 17 00:00:00 2001 From: angrezichatterbox Date: Sat, 7 Sep 2024 00:48:45 +0530 Subject: [PATCH 7/7] fix:Added kotlin options jvm target --- app/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3b9a13f7..2d268530 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -35,6 +35,10 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } + kotlinOptions{ + jvmTarget = "1.8" + } + buildFeatures { viewBinding = true buildConfig = true