Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin migration - part 2 #1728

Merged
merged 19 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 20 additions & 3 deletions fe2-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'org.sonarqube'
apply plugin: 'jacoco'
apply plugin: 'dagger.hilt.android.plugin'
Expand Down Expand Up @@ -268,13 +269,15 @@ dependencies {

// ================= Hilt ===================
implementation "com.google.dagger:hilt-android:$hilt_version"
annotationProcessor "com.google.dagger:hilt-compiler:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"

// Hilt for Robolectric tests
testImplementation "com.google.dagger:hilt-android-testing:$hilt_version"
testAnnotationProcessor "com.google.dagger:hilt-android-compiler:$hilt_version"
kaptTest "com.google.dagger:hilt-android-compiler:$hilt_version"

// Hilt for instrumented tests
androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_version"
androidTestAnnotationProcessor "com.google.dagger:hilt-android-compiler:$hilt_version"
kaptAndroidTest "com.google.dagger:hilt-android-compiler:$hilt_version"

// =========== Various Security =============
implementation 'io.github.novacrypto:BIP39:2019.01.27'
Expand Down Expand Up @@ -315,6 +318,10 @@ dependencies {
implementation "androidx.room:room-rxjava2:$room_version"
testImplementation "androidx.room:room-testing:$room_version"

// ============= Room (Kotlin) ===============
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"

// ================= SLF4J =================
testImplementation "org.slf4j:slf4j-api:$slf4j_version"
testImplementation "org.slf4j:slf4j-simple:$slf4j_version"
Expand All @@ -325,10 +332,16 @@ dependencies {
// ================= Pretty Time =================
implementation 'org.ocpsoft.prettytime:prettytime:5.0.4.Final'

// ================ Emoji ==================
implementation 'com.vdurmont:emoji-java:5.1.1'

// ================ Kotlin ========================
implementation 'androidx.core:core-ktx:1.12.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'org.jetbrains.kotlin:kotlin-test'

// =============== Encrypt Preferences =================
implementation "androidx.security:security-crypto-ktx:1.1.0-alpha06"

// ============= Test Framework ============
debugImplementation 'junit:junit:4.13.2'
Expand All @@ -351,3 +364,7 @@ dependencies {
// We use a special version of mockito that has the capability to mock final classes in android tests
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.28.1'
}

kapt {
correctErrorTypes true
}
21 changes: 17 additions & 4 deletions fe2-android/app/schemas/detekt/detekt-config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
build:
maxIssues: 20
# Very large number as we don't want the build to fail (SonarCloud will then collect the issues on the CI)
maxIssues: 50
weights:
# Set to 0 the weight of issues on comments
comments: 0

complexity:
# Set to 16 the maximum number of functions in a class, file, interface or object
TooManyFunctions:
active: true
thresholdInFiles: 16
thresholdInClasses: 16
thresholdInInterfaces: 16
thresholdInObjects: 16
ignoreDeprecated: true
ignorePrivate: false
ignoreOverridden: false
# Set to 10 the maximum number of params of a function
LongParameterList:
functionThreshold: 11
constructorThreshold: 11
# Set to 150 the maximum number of lines for a single function
LongMethod:
threshold: 150
CyclomaticComplexMethod:
threshold: 20

exceptions:
# Deactivating permanently the following exception as it doesn't allow to
Expand Down Expand Up @@ -44,3 +51,9 @@ style:
# Allow TODOs in the codebase by deactivating the following rule
ForbiddenComment:
active: false
MagicNumber:
active: false

naming:
VariableNaming:
active: false
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class SingleEvent<T>(content: T?) {

init {
requireNotNull(content) { "null values not allowed in an Event" }

mContent = content
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.github.dedis.popstellar.di

import android.app.Application
import androidx.room.Room.databaseBuilder
import com.github.dedis.popstellar.repository.database.AppDatabase
import com.github.dedis.popstellar.repository.database.CustomTypeConverters
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object AppDatabaseModule {
private const val DATABASE_NAME = "POP-Database"

@JvmStatic
@Provides
@Singleton
fun provideAppDatabase(application: Application): AppDatabase {
/*
Injecting the DataRegistry (or the Gson directly) would create a dependency cycle,
since AppDatabase -> Gson -> DataRegistry -> Handlers -> Repositories -> AppDatabase.
In order to avoid overcomplicated solutions here it's created a DataRegistry with null handlers,
as the only function needed is the one to get the object's type for the Gson serializer
*/
return databaseBuilder(application, AppDatabase::class.java, DATABASE_NAME)
.addTypeConverter(
CustomTypeConverters(
JsonModule.provideGson(DataRegistryModule.provideDataRegistryForGson())))
.fallbackToDestructiveMigration()
.allowMainThreadQueries()
.build()
}
}

This file was deleted.

Loading
Loading