Skip to content

Commit

Permalink
clientapp: Android: Use hilt and room
Browse files Browse the repository at this point in the history
  • Loading branch information
Royna2544 committed Jul 1, 2024
1 parent e2db4ba commit 0a516e4
Show file tree
Hide file tree
Showing 26 changed files with 549 additions and 296 deletions.
2 changes: 1 addition & 1 deletion clientapp/android/.idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

263 changes: 263 additions & 0 deletions clientapp/android/.idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions clientapp/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.androidx.room)
alias(libs.plugins.com.google.devtools.ksp)
alias(libs.plugins.com.google.dagger.hilt.android)
}

android {
Expand Down Expand Up @@ -59,6 +60,13 @@ android {
excludes += "META-INF/LICENSE-notice.md"
}
}
room {
schemaDirectory("$projectDir/schemas")
}
}

ksp {
arg("room.generateKotlin", "true")
}

dependencies {
Expand All @@ -73,9 +81,14 @@ dependencies {
implementation(libs.androidx.preference.ktx)
implementation(libs.androidx.fragment.ktx)
implementation(libs.androidx.window)
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
implementation(libs.hilt)

testImplementation(libs.junit)
ksp(libs.androidx.room.compiler)
ksp(libs.hilt.compiler)

testImplementation(libs.junit)
androidTestImplementation(libs.junit)
androidTestImplementation(libs.junit.jupiter)
androidTestImplementation(libs.androidx.espresso.core)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "6780e511c5a2371a71169f6bd0de9e12",
"entities": [
{
"tableName": "ChatIDEntry",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`chat_id` INTEGER NOT NULL, `chat_name` TEXT NOT NULL, PRIMARY KEY(`chat_id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "chat_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "chat_name",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"chat_id"
]
},
"indices": [
{
"name": "index_ChatIDEntry_chat_name",
"unique": true,
"columnNames": [
"chat_name"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_ChatIDEntry_chat_name` ON `${TABLE_NAME}` (`chat_name`)"
}
],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6780e511c5a2371a71169f6bd0de9e12')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package com.royna.tgbotclient

import android.app.Application
import com.royna.tgbotclient.ui.settings.TgClientSettings
import com.royna.tgbotclient.util.DeviceUtils
import com.royna.tgbotclient.util.Logging
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class ClientApplication : Application() {
override fun onCreate() {
super.onCreate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import com.royna.tgbotclient.pm.IStoragePermission
import com.royna.tgbotclient.pm.StoragePermissionPreR
import com.royna.tgbotclient.pm.StoragePermissionR
import com.royna.tgbotclient.ui.settings.SettingsActivity
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
private lateinit var appBarConfiguration: AppBarConfiguration
private lateinit var binding: ActivityMainBinding
Expand Down
Loading

0 comments on commit 0a516e4

Please sign in to comment.