Skip to content

Commit cf50f6a

Browse files
committed
Migrate to viewbinding and kotlin gradle scripts
- Replaced kotlinx sythetic with viewbinding - Update build scripts to kotlin - Intoduced version catalog, similar to Commons - Updated kotlin from 1.7.10 to 1.9.0 - Updated room from 2.5.2 to 2.6.0-alpha02 (same as Commons) - Updated Android Gradle Plugin to 8.1.0
1 parent 311175d commit cf50f6a

36 files changed

+853
-604
lines changed

app/build.gradle

Lines changed: 0 additions & 78 deletions
This file was deleted.

app/build.gradle.kts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import java.io.FileInputStream
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
import org.jetbrains.kotlin.konan.properties.Properties
4+
5+
plugins {
6+
alias(libs.plugins.android)
7+
alias(libs.plugins.kotlinAndroid)
8+
alias(libs.plugins.ksp)
9+
alias(libs.plugins.kotlinSerialization)
10+
}
11+
12+
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
13+
val keystoreProperties = Properties()
14+
if (keystorePropertiesFile.exists()) {
15+
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
16+
}
17+
18+
android {
19+
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
20+
21+
defaultConfig {
22+
applicationId = libs.versions.app.version.appId.get()
23+
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
24+
targetSdk = project.libs.versions.app.build.targetSDK.get().toInt()
25+
versionName = project.libs.versions.app.version.versionName.get()
26+
versionCode = project.libs.versions.app.version.versionCode.get().toInt()
27+
setProperty("archivesBaseName", "notes")
28+
ksp {
29+
arg("room.schemaLocation", "$projectDir/schemas")
30+
}
31+
}
32+
33+
signingConfigs {
34+
if (keystorePropertiesFile.exists()) {
35+
register("release") {
36+
keyAlias = keystoreProperties.getProperty("keyAlias")
37+
keyPassword = keystoreProperties.getProperty("keyPassword")
38+
storeFile = file(keystoreProperties.getProperty("storeFile"))
39+
storePassword = keystoreProperties.getProperty("storePassword")
40+
}
41+
}
42+
}
43+
44+
buildFeatures {
45+
viewBinding = true
46+
buildConfig = true
47+
}
48+
49+
buildTypes {
50+
debug {
51+
applicationIdSuffix = ".debug"
52+
}
53+
release {
54+
isMinifyEnabled = true
55+
proguardFiles(
56+
getDefaultProguardFile("proguard-android-optimize.txt"),
57+
"proguard-rules.pro"
58+
)
59+
if (keystorePropertiesFile.exists()) {
60+
signingConfig = signingConfigs.getByName("release")
61+
}
62+
}
63+
}
64+
65+
flavorDimensions.add("variants")
66+
productFlavors {
67+
register("core")
68+
register("fdroid")
69+
register("prepaid")
70+
}
71+
72+
sourceSets {
73+
getByName("main").java.srcDirs("src/main/kotlin")
74+
}
75+
76+
compileOptions {
77+
val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString())
78+
sourceCompatibility = currentJavaVersionFromLibs
79+
targetCompatibility = currentJavaVersionFromLibs
80+
}
81+
82+
tasks.withType<KotlinCompile> {
83+
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
84+
}
85+
86+
namespace = libs.versions.app.version.appId.get()
87+
88+
lint {
89+
checkReleaseBuilds = false
90+
abortOnError = false
91+
}
92+
}
93+
94+
dependencies {
95+
implementation(libs.simple.tools.commons)
96+
implementation(libs.androidx.constraintlayout)
97+
implementation(libs.androidx.documentfile)
98+
implementation(libs.kotlinx.serialization.json)
99+
100+
implementation(libs.bundles.room)
101+
ksp(libs.androidx.room.compiler)
102+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 4,
5+
"identityHash": "e470b6e1411ee6659417cf4dbe54f453",
6+
"entities": [
7+
{
8+
"tableName": "notes",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `title` TEXT NOT NULL, `value` TEXT NOT NULL, `type` INTEGER NOT NULL, `path` TEXT NOT NULL, `protection_type` INTEGER NOT NULL, `protection_hash` TEXT NOT NULL)",
10+
"fields": [
11+
{
12+
"fieldPath": "id",
13+
"columnName": "id",
14+
"affinity": "INTEGER",
15+
"notNull": false
16+
},
17+
{
18+
"fieldPath": "title",
19+
"columnName": "title",
20+
"affinity": "TEXT",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "value",
25+
"columnName": "value",
26+
"affinity": "TEXT",
27+
"notNull": true
28+
},
29+
{
30+
"fieldPath": "type",
31+
"columnName": "type",
32+
"affinity": "INTEGER",
33+
"notNull": true
34+
},
35+
{
36+
"fieldPath": "path",
37+
"columnName": "path",
38+
"affinity": "TEXT",
39+
"notNull": true
40+
},
41+
{
42+
"fieldPath": "protectionType",
43+
"columnName": "protection_type",
44+
"affinity": "INTEGER",
45+
"notNull": true
46+
},
47+
{
48+
"fieldPath": "protectionHash",
49+
"columnName": "protection_hash",
50+
"affinity": "TEXT",
51+
"notNull": true
52+
}
53+
],
54+
"primaryKey": {
55+
"autoGenerate": true,
56+
"columnNames": [
57+
"id"
58+
]
59+
},
60+
"indices": [
61+
{
62+
"name": "index_notes_id",
63+
"unique": true,
64+
"columnNames": [
65+
"id"
66+
],
67+
"orders": [],
68+
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_notes_id` ON `${TABLE_NAME}` (`id`)"
69+
}
70+
],
71+
"foreignKeys": []
72+
},
73+
{
74+
"tableName": "widgets",
75+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `widget_id` INTEGER NOT NULL, `note_id` INTEGER NOT NULL, `widget_bg_color` INTEGER NOT NULL, `widget_text_color` INTEGER NOT NULL, `widget_show_title` INTEGER NOT NULL)",
76+
"fields": [
77+
{
78+
"fieldPath": "id",
79+
"columnName": "id",
80+
"affinity": "INTEGER",
81+
"notNull": false
82+
},
83+
{
84+
"fieldPath": "widgetId",
85+
"columnName": "widget_id",
86+
"affinity": "INTEGER",
87+
"notNull": true
88+
},
89+
{
90+
"fieldPath": "noteId",
91+
"columnName": "note_id",
92+
"affinity": "INTEGER",
93+
"notNull": true
94+
},
95+
{
96+
"fieldPath": "widgetBgColor",
97+
"columnName": "widget_bg_color",
98+
"affinity": "INTEGER",
99+
"notNull": true
100+
},
101+
{
102+
"fieldPath": "widgetTextColor",
103+
"columnName": "widget_text_color",
104+
"affinity": "INTEGER",
105+
"notNull": true
106+
},
107+
{
108+
"fieldPath": "widgetShowTitle",
109+
"columnName": "widget_show_title",
110+
"affinity": "INTEGER",
111+
"notNull": true
112+
}
113+
],
114+
"primaryKey": {
115+
"autoGenerate": true,
116+
"columnNames": [
117+
"id"
118+
]
119+
},
120+
"indices": [
121+
{
122+
"name": "index_widgets_widget_id",
123+
"unique": true,
124+
"columnNames": [
125+
"widget_id"
126+
],
127+
"orders": [],
128+
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_widgets_widget_id` ON `${TABLE_NAME}` (`widget_id`)"
129+
}
130+
],
131+
"foreignKeys": []
132+
}
133+
],
134+
"views": [],
135+
"setupQueries": [
136+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
137+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e470b6e1411ee6659417cf4dbe54f453')"
138+
]
139+
}
140+
}

0 commit comments

Comments
 (0)