From 889570ebc2a2d5e3d7d506ff89634bd4f993db89 Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Wed, 21 Dec 2022 23:22:44 -0600 Subject: [PATCH 01/10] Init buildSrc --- buildSrc/build.gradle.kts | 7 +++++++ buildSrc/src/main/java/ProjectProperties.kt | 13 +++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/java/ProjectProperties.kt diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..b22ed73 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() +} \ No newline at end of file diff --git a/buildSrc/src/main/java/ProjectProperties.kt b/buildSrc/src/main/java/ProjectProperties.kt new file mode 100644 index 0000000..7539710 --- /dev/null +++ b/buildSrc/src/main/java/ProjectProperties.kt @@ -0,0 +1,13 @@ +import org.gradle.api.JavaVersion + +object ProjectProperties { + const val COMPILE_SDK = 33 + const val TARGET_SDK = COMPILE_SDK + const val MIN_SDK = 21 + const val APPLICATION_ID = "com.jxareas.xpensor" + + const val IS_MINIFY_ENABLED = false + const val JVM_TARGET = "1.8" + val JAVA_VERSION = JavaVersion.VERSION_1_8 + +} \ No newline at end of file From 35e38f85a80168e6fc6f3fb7a3b1fb413f6ae3c1 Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 01:18:24 -0600 Subject: [PATCH 02/10] Migrate App Buildscript to KTS --- app/build.gradle | 161 -------------------- app/build.gradle.kts | 131 ++++++++++++++++ app/proguard-rules.pro | 2 +- buildSrc/src/main/java/BuildPlugins.kt | 17 +++ buildSrc/src/main/java/Dependencies.kt | 107 +++++++++++++ buildSrc/src/main/java/ProjectProperties.kt | 23 +++ buildSrc/src/main/java/Versions.kt | 32 ++++ 7 files changed, 311 insertions(+), 162 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts create mode 100644 buildSrc/src/main/java/BuildPlugins.kt create mode 100644 buildSrc/src/main/java/Dependencies.kt create mode 100644 buildSrc/src/main/java/Versions.kt diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 0f754ef..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,161 +0,0 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' - id 'kotlin-kapt' - id 'androidx.navigation.safeargs' - id 'dagger.hilt.android.plugin' - id 'kotlinx-serialization' - id 'kotlin-parcelize' -} - -def apikeyPropertiesFile = rootProject.file("local.properties") -def apikeyProperties = new Properties() -apikeyProperties.load(new FileInputStream(apikeyPropertiesFile)) - -android { - compileSdk rootProject.COMPILE_SDK - - defaultConfig { - namespace "com.jxareas.xpensor" - minSdk rootProject.MIN_SDK - targetSdk rootProject.TARGET_SDK - versionCode 1 - versionName "1.0" - - buildConfigField("String", "CURRENCY_API_KEY", apikeyProperties['CURRENCY_API_KEY']) - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - viewBinding true - } - android { - compileOptions { - coreLibraryDesugaringEnabled true - } - } -} - -dependencies { - - // Support Libraries - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation "androidx.fragment:fragment-ktx:$fragment_ktx" - - // Desugaring - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' - - // Testing Dependencies - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - - // Material Design - implementation "com.google.android.material:material:$material" - - // Cardview - implementation "androidx.cardview:cardview:$cardview_version" - - // Drawer Layout - implementation "androidx.drawerlayout:drawerlayout:$drawer_layout_version" - - // Constraint Layout - implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version" - - // Swipe Refresh Layout - implementation "androidx.swiperefreshlayout:swiperefreshlayout:$swipe_refresh_layout_version" - - // Sliding Pane Layout - implementation "androidx.slidingpanelayout:slidingpanelayout:$sliding_pane_layout_version" - - // RecyclerView - implementation "androidx.recyclerview:recyclerview:$recycler_view_version" - - // RecyclerView Selection - implementation "androidx.recyclerview:recyclerview-selection:$recycler_view_selection_version" - - // Viewpager 2 - implementation "androidx.viewpager2:viewpager2:$viewpager_2_version" - - // Kotlin Coroutines - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" - - // Dagger-Hilt - implementation "com.google.dagger:hilt-android:$dagger_hilt" - kapt "com.google.dagger:hilt-compiler:$dagger_hilt" - - // Data Store - implementation "androidx.datastore:datastore:$data_store_version" - - // Paging - implementation "androidx.paging:paging-runtime:$paging_version" - // Navigation - implementation "androidx.navigation:navigation-fragment:$nav_version" - implementation "androidx.navigation:navigation-ui:$nav_version" - - // Lifecycle - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" - - // ROOM - implementation "androidx.room:room-runtime:$room_version" - implementation "androidx.room:room-ktx:$room_version" - kapt "androidx.room:room-compiler:$room_version" - - // Preferences - implementation "androidx.preference:preference:$preference_version" - - // Retrofit - implementation "com.squareup.retrofit2:retrofit:$retrofit_version" - implementation "com.squareup.okhttp3:logging-interceptor:$ok_http3_logging_version" - // Moshi Converter - implementation "com.squareup.retrofit2:converter-moshi:$moshi_converter" - - // Moshi - implementation "com.squareup.moshi:moshi:$moshi" - implementation "com.squareup.moshi:moshi-kotlin:$moshi" - - - // Gson - implementation "com.google.code.gson:gson:$gson_version" - implementation "com.squareup.retrofit2:converter-gson:$gson_version" - - // Kotlin Serialization - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialization_version" - implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:$kotlin_serialization_converter_version" - - // CameraX - implementation "androidx.camera:camera-core:$camerax_version" - implementation "androidx.camera:camera-camera2:$camerax_version" - - // Palette - implementation "androidx.palette:palette:$palette_version" - - // Lottie - implementation "com.airbnb.android:lottie:$lottie_version" - - // Work Manager - implementation "androidx.work:work-runtime:$work_version" - implementation "androidx.work:work-runtime-ktx:$work_version" - - // MPAndroidChart - implementation "com.github.PhilJay:MPAndroidChart:$mp_android_chart_version" - - // Splash Screen API - implementation "androidx.core:core-splashscreen:$splash_screen_version" -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..1472148 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,131 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties + +plugins { + id(BuildPlugins.ANDROID_APPLICATION_PLUGIN) + id(BuildPlugins.JETBRAINS_KOTLIN_ANDROID_PLUGIN) + id(BuildPlugins.KOTLIN_KAPT) + id(BuildPlugins.SAFE_ARGS) + id(BuildPlugins.KOTLIN_PARCELIZE) + id(BuildPlugins.DAGGER_HILT) +} + +android { + compileSdk = ProjectProperties.COMPILE_SDK + + defaultConfig { + namespace = ProjectProperties.APPLICATION_ID + minSdk = ProjectProperties.MIN_SDK + targetSdk = ProjectProperties.TARGET_SDK + versionCode = ProjectProperties.VERSION_CODE + versionName = ProjectProperties.VERSION_NAME + multiDexEnabled = ProjectProperties.IS_MULTIDEX_ENABLED + vectorDrawables.useSupportLibrary = true + testInstrumentationRunner = ProjectProperties.TEST_RUNNER + + + val currencyApiKey = ProjectProperties.CURRENCY_API_KEY + val currencyApiToken: String = gradleLocalProperties(rootDir).getProperty(currencyApiKey) + buildConfigField("String", currencyApiKey, currencyApiToken) + } + + buildTypes { + getByName(ProjectProperties.RELEASE_BUILD_TYPE) { + isMinifyEnabled = ProjectProperties.IS_MINIFY_ENABLED + } + getByName(ProjectProperties.DEBUG_BUILD_TYPE) { + proguardFiles( + getDefaultProguardFile(ProjectProperties.PROGUARD_NAME), + ProjectProperties.PROGUARD_FILE + ) + } + } + compileOptions { + sourceCompatibility = ProjectProperties.JAVA_VERSION + targetCompatibility = ProjectProperties.JAVA_VERSION + } + kotlinOptions { + jvmTarget = ProjectProperties.JVM_TARGET + } + buildFeatures { + viewBinding = ProjectProperties.IS_VIEW_BINDING_ENABLED + } + android { + compileOptions { + isCoreLibraryDesugaringEnabled = ProjectProperties.IS_CORE_LIBRARY_DESUGARING_ENABLED + } + } +} + +dependencies { + + // Support Libraries + implementation(Dependencies.Android.KOTLIN_CORE) + implementation(Dependencies.Android.APP_COMPAT) + implementation(Dependencies.Android.LEGACY_SUPPORT) + implementation(Dependencies.Android.FRAGMENT_KTX) + + // Desugaring + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5") + + // Testing Dependencies + testImplementation(Dependencies.Testing.JUNIT) + androidTestImplementation(Dependencies.Testing.JUNIT_ANDROID) + androidTestImplementation(Dependencies.Testing.ESPRESSO_ANDROID) + + // AndroidX + implementation(Dependencies.Android.SPLASH_SCREEN) + implementation(Dependencies.Android.MATERIAL) + implementation(Dependencies.Android.CARDVIEW) + implementation(Dependencies.Android.CARDVIEW) + implementation(Dependencies.Android.SWIPE_REFRESH_LAYOUT) + implementation(Dependencies.Android.RECYCLERVIEW) + implementation(Dependencies.Android.VIEWPAGER2) + + // Kotlin Coroutines + implementation(Dependencies.Kotlin.KOTLINX_COROUTINES) + + // Dagger-Hilt + implementation(Dependencies.Dagger.HILT) + kapt(Dependencies.Dagger.HILT_COMPILER) + + // Data Store + implementation(Dependencies.DataStore.DATA_STORE) + + // Navigation + implementation(Dependencies.Navigation.NAVIGATION_FRAGMENT_KTX) + implementation(Dependencies.Navigation.NAVIGATION_UI_KTX) + + // Lifecycle + implementation(Dependencies.Android.LIFECYCLE_VIEWMODEL_KTX) + implementation(Dependencies.Android.LIFECYCLE_LIVE_DATA_KTX) + + // ROOM + implementation(Dependencies.Room.ROOM_RUNTIME) + implementation(Dependencies.Room.ROOM_KTX) + kapt(Dependencies.Room.ROOM_COMPILER) + + // Preferences + implementation(Dependencies.Preference.PREFERENCEX) + + // OkHttp3 + implementation(Dependencies.Square.OKHTTP_CLIENT) + implementation(Dependencies.Square.LOGGING_INTERCEPTOR) + // Retrofit + implementation(Dependencies.Square.RETROFIT) + implementation(Dependencies.Square.MOSHI_CONVERTER) + // Moshi + implementation(Dependencies.Square.MOSHI) + + // Palette + implementation(Dependencies.Android.PALETTE) + + // Lottie + implementation(Dependencies.AirBnb.LOTTIE) + + // Work Manager + implementation(Dependencies.WorkManager.WORK_MANAGER_RUNTIME) + implementation(Dependencies.WorkManager.WORK_MANAGER_RUNTIME_KTX) + + // MPAndroidChart + implementation(Dependencies.PhilJay.MP_ANDROID_CHART) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..ff59496 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/buildSrc/src/main/java/BuildPlugins.kt b/buildSrc/src/main/java/BuildPlugins.kt new file mode 100644 index 0000000..91097a3 --- /dev/null +++ b/buildSrc/src/main/java/BuildPlugins.kt @@ -0,0 +1,17 @@ +object BuildPlugins { + const val ANDROID_APPLICATION_PLUGIN = "com.android.application" + const val JETBRAINS_KOTLIN_ANDROID_PLUGIN = "org.jetbrains.kotlin.android" + const val KOTLIN_KAPT = "kotlin-kapt" + const val KTLINT = "org.jlleitschuh.gradle.ktlint" + const val KOTLIN_PARCELIZE = "kotlin-parcelize" + const val SAFE_ARGS = "androidx.navigation.safeargs" + const val DAGGER_HILT = "dagger.hilt.android.plugin" + + private const val TOOLS_BUILD_VERSION = "7.1.3" + const val TOOLS_BUILD_GRADLE = + "com.android.tools.build:gradle:$TOOLS_BUILD_VERSION" + + private const val KOTLIN_GRADLE = "1.6.10" + const val KOTLIN_GRADLE_PLUGIN = + "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_GRADLE" +} \ No newline at end of file diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt new file mode 100644 index 0000000..f3e2f4b --- /dev/null +++ b/buildSrc/src/main/java/Dependencies.kt @@ -0,0 +1,107 @@ +object Dependencies { + object Kotlin { + const val KOTLINX_COROUTINES = + "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.KOTLINX_COROUTINES}" + } + + object Android { + + const val KOTLIN_CORE = + "androidx.core:core-ktx:${Versions.KOTLIN_CORE_KTX}" + + const val APP_COMPAT = "androidx.appcompat:appcompat:${Versions.APP_COMPAT}" + const val LEGACY_SUPPORT = + "androidx.legacy:legacy-support-v4:${Versions.LEGACY_SUPPORT_VERSION}" + + const val ROOM_RUNTIME = "androidx.room:room-runtime:${Versions.ROOM}" + const val ROOM_KTX = "androidx.room:room-ktx:${Versions.ROOM}" + const val ROOM_COMPILER = "androidx.room:room-compiler:${Versions.ROOM}" + + const val SPLASH_SCREEN = "androidx.core:core-splashscreen:${Versions.SPLASH_SCREEN}" + const val FRAGMENT_KTX = "androidx.fragment:fragment-ktx:${Versions.FRAGMENT_KTX}" + const val MATERIAL = + "com.google.android.material:material:${Versions.MATERIAL}" + const val CARDVIEW = "androidx.cardview:cardview:${Versions.CARDVIEW}" + + const val CONSTRAINT_LAYOUT = + "androidx.constraintlayout:constraintlayout:${Versions.CONSTRAINT_LAYOUT}" + const val SWIPE_REFRESH_LAYOUT = + "androidx.swiperefreshlayout:swiperefreshlayout:${Versions.SWIPE_REFRESH_LAYOUT}" + + const val RECYCLERVIEW = + "androidx.recyclerview:recyclerview:${Versions.RECYCLERVIEW}" + const val VIEWPAGER2 = "androidx.viewpager2:viewpager2:${Versions.VIEWPAGER2}" + + const val LIFECYCLE_LIVE_DATA_KTX = + "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.LIFECYCLE_KTX_VERSION}" + const val LIFECYCLE_VIEWMODEL_KTX = + "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.LIFECYCLE_KTX_VERSION}" + const val PALETTE = "androidx.palette:palette:${Versions.PALETTE}" + } + + object Testing { + const val JUNIT = "junit:junit:${Versions.JUNIT}" + const val JUNIT_ANDROID = "androidx.test.ext:junit:${Versions.JUNIT_ANDROID_EXT}" + const val ESPRESSO_ANDROID = + "androidx.test.espresso:espresso-core:${Versions.ESPRESSO_ANDROID_CORE}" + } + + object Navigation { + const val NAVIGATION_SAFE_ARGS = + "androidx.navigation:navigation-safe-args-gradle-plugin:${Versions.NAVIGATION}" + const val NAVIGATION_FRAGMENT_KTX = + "androidx.navigation:navigation-fragment-ktx:${Versions.NAVIGATION}" + const val NAVIGATION_UI_KTX = "androidx.navigation:navigation-ui-ktx:${Versions.NAVIGATION}" + } + + object DataStore { + const val DATA_STORE = + "androidx.datastore:datastore:${Versions.DATA_STORE}" + } + + object Dagger { + const val HILT = + "com.google.dagger:hilt-android:${Versions.DAGGER_HILT}" + const val HILT_PLUGIN = + "com.google.dagger:hilt-android-gradle-plugin:${Versions.DAGGER_HILT}" + const val HILT_COMPILER = + "com.google.dagger:hilt-compiler:${Versions.DAGGER_HILT}" + } + + object Room { + const val ROOM_RUNTIME = "androidx.room:room-runtime:${Versions.ROOM}" + const val ROOM_KTX = "androidx.room:room-ktx:${Versions.ROOM}" + const val ROOM_COMPILER = "androidx.room:room-compiler:${Versions.ROOM}" + } + + object Preference { + const val PREFERENCEX = "androidx.preference:preference:${Versions.PREFERENCE}" + } + + object Square { + const val OKHTTP_CLIENT = "com.squareup.okhttp3:okhttp:${Versions.OKHTTP3}" + const val LOGGING_INTERCEPTOR = + "com.squareup.okhttp3:logging-interceptor:${Versions.HTTP_LOGGING_INTERCEPTOR}" + + const val RETROFIT = "com.squareup.retrofit2:retrofit:${Versions.RETROFIT2}" + const val MOSHI = "com.squareup.moshi:moshi-kotlin:${Versions.MOSHI}" + const val MOSHI_CONVERTER = + "com.squareup.retrofit2:converter-moshi:${Versions.MOSHI_CONVERTER}" + } + + object WorkManager { + const val WORK_MANAGER_RUNTIME = "androidx.work:work-runtime:${Versions.WORK_MANAGER}" + const val WORK_MANAGER_RUNTIME_KTX = + "androidx.work:work-runtime-ktx:${Versions.WORK_MANAGER}" + } + + object AirBnb { + const val LOTTIE = "com.airbnb.android:lottie:${Versions.LOTTIE}" + } + + object PhilJay { + const val MP_ANDROID_CHART = + "com.github.PhilJay:MPAndroidChart:${Versions.MP_ANDROID_CHART}" + } + +} \ No newline at end of file diff --git a/buildSrc/src/main/java/ProjectProperties.kt b/buildSrc/src/main/java/ProjectProperties.kt index 7539710..5c86810 100644 --- a/buildSrc/src/main/java/ProjectProperties.kt +++ b/buildSrc/src/main/java/ProjectProperties.kt @@ -1,13 +1,36 @@ import org.gradle.api.JavaVersion object ProjectProperties { + // SDK const val COMPILE_SDK = 33 const val TARGET_SDK = COMPILE_SDK const val MIN_SDK = 21 + + // Application const val APPLICATION_ID = "com.jxareas.xpensor" + const val VERSION_CODE = 1 + const val VERSION_NAME = "1.0" + + // ProGuard + const val PROGUARD_NAME = "proguard-android.txt" + const val PROGUARD_FILE = "proguard-rules.pro" + // Configuration + const val IS_MULTIDEX_ENABLED = true const val IS_MINIFY_ENABLED = false + const val IS_VIEW_BINDING_ENABLED = true + const val IS_CORE_LIBRARY_DESUGARING_ENABLED = true + + // Java + const val TEST_RUNNER = "androidx.test.runner.AndroidJUnitRunner" const val JVM_TARGET = "1.8" val JAVA_VERSION = JavaVersion.VERSION_1_8 + // BuildTypes + const val RELEASE_BUILD_TYPE = "release" + const val DEBUG_BUILD_TYPE = "debug" + + // API Keys + const val CURRENCY_API_KEY = "CURRENCY_API_KEY" + } \ No newline at end of file diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt new file mode 100644 index 0000000..84be84f --- /dev/null +++ b/buildSrc/src/main/java/Versions.kt @@ -0,0 +1,32 @@ +object Versions { + const val KOTLIN_CORE_KTX = "1.7.0" + const val KOTLINX_COROUTINES = "1.6.0" + const val APP_COMPAT = "1.4.1" + const val LEGACY_SUPPORT_VERSION = "1.0.0" + const val ROOM = "2.4.2" + const val SPLASH_SCREEN = "1.0.0" + const val NAVIGATION = "2.4.1" + const val SWIPE_REFRESH_LAYOUT = "1.1.0" + const val FRAGMENT_KTX = "1.5.5" + const val MATERIAL = "1.7.0" + const val CARDVIEW = "1.0.0" + const val CONSTRAINT_LAYOUT = "2.1.4" + const val RECYCLERVIEW = "1.2.1" + const val VIEWPAGER2 = "1.0.0" + const val DAGGER_HILT = "2.43.2" + const val DATA_STORE = "1.0.0" + const val LIFECYCLE_KTX_VERSION = "2.5.1" + const val PREFERENCE = "1.2.0" + const val RETROFIT2 = "2.9.0" + const val OKHTTP3 = "4.10.0" + const val HTTP_LOGGING_INTERCEPTOR = "5.0.0-alpha.3" + const val MOSHI = "1.12.0" + const val MOSHI_CONVERTER = "2.9.0" + const val PALETTE = "1.0.0" + const val LOTTIE = "5.0.3" + const val MP_ANDROID_CHART = "v3.1.0" + const val WORK_MANAGER = "2.7.1" + const val JUNIT = "4.13.2" + const val JUNIT_ANDROID_EXT = "1.1.3" + const val ESPRESSO_ANDROID_CORE = "3.4.0" +} \ No newline at end of file From 2c129016c27980ba014d8fee51a741cae884d953 Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 02:07:39 -0600 Subject: [PATCH 03/10] Migrate Project Buildscript to KTS --- app/build.gradle.kts | 4 +- build.gradle | 59 --------------------- build.gradle.kts | 25 +++++++++ buildSrc/src/main/java/BuildPlugins.kt | 5 +- buildSrc/src/main/java/ProjectProperties.kt | 4 ++ settings.gradle => settings.gradle.kts | 5 +- 6 files changed, 36 insertions(+), 66 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts rename settings.gradle => settings.gradle.kts (75%) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1472148..1327a7b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,8 +1,8 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties plugins { - id(BuildPlugins.ANDROID_APPLICATION_PLUGIN) - id(BuildPlugins.JETBRAINS_KOTLIN_ANDROID_PLUGIN) + id(BuildPlugins.ANDROID_APPLICATION) + id(BuildPlugins.JETBRAINS_KOTLIN_ANDROID) id(BuildPlugins.KOTLIN_KAPT) id(BuildPlugins.SAFE_ARGS) id(BuildPlugins.KOTLIN_PARCELIZE) diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 4b4f7e6..0000000 --- a/build.gradle +++ /dev/null @@ -1,59 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - - ext { - COMPILE_SDK = 32 - MIN_SDK = 21 - TARGET_SDK = 32 - - kotlin_version = "1.6.10" - fragment_ktx = "1.5.3" - kotlin_coroutines_version = "1.6.0" - kotlin_serialization_version = "1.2.2" - kotlin_serialization_converter_version = "0.8.0" - dagger_hilt = "2.43.2" - material = "1.6.1" - cardview_version = "1.0.0" - drawer_layout_version = "1.1.1" - gson_version = "2.9.0" - preference_version = "1.2.0" - constraint_layout_version = "2.1.4" - lifecycle_version = "2.4.1" - camerax_version = "1.1.0-beta02" - lottie_version = "5.0.3" - nav_version = "2.4.1" - mp_android_chart_version = "v3.1.0" - splash_screen_version = "1.0.0" - moshi = "1.12.0" - moshi_converter = "2.9.0" - recycler_view_version = "1.2.1" - recycler_view_selection_version = "1.1.0" - paging_version = "3.1.1" - swipe_refresh_layout_version = "1.1.0" - sliding_pane_layout_version = "1.2.0" - retrofit_version = "2.9.0" - work_version = "2.7.1" - palette_version = "1.0.0" - ok_http3_logging_version = "5.0.0-alpha.3" - room_version = "2.4.2" - data_store_version = "1.0.0" - viewpager_2_version = "1.0.0" - } - - dependencies { - classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" - classpath "com.google.dagger:hilt-android-gradle-plugin:$dagger_hilt" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - } - -} - -plugins { - id 'com.android.application' version '7.2.2' apply false - id 'com.android.library' version '7.2.2' apply false - id 'org.jetbrains.kotlin.android' version '1.7.10' apply false -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..3b1f577 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,25 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + dependencies { + classpath(BuildPlugins.TOOLS_BUILD_GRADLE) + classpath(BuildPlugins.KOTLIN_GRADLE_PLUGIN) + classpath(Dependencies.Navigation.NAVIGATION_SAFE_ARGS) + classpath(Dependencies.Dagger.HILT_PLUGIN) + } +} + +plugins { + id(BuildPlugins.ANDROID_LIBRARY) + .version(ProjectProperties.ANDROID_VERSION) + .apply(false) + id(BuildPlugins.ANDROID_APPLICATION) + .version(ProjectProperties.ANDROID_VERSION) + .apply(false) + id(BuildPlugins.JETBRAINS_KOTLIN_ANDROID) + .version(ProjectProperties.KOTLIN_VERSION) + .apply(false) +} + +tasks.register("clean", Delete::class) { + delete(rootProject.buildDir) +} \ No newline at end of file diff --git a/buildSrc/src/main/java/BuildPlugins.kt b/buildSrc/src/main/java/BuildPlugins.kt index 91097a3..5be3f90 100644 --- a/buildSrc/src/main/java/BuildPlugins.kt +++ b/buildSrc/src/main/java/BuildPlugins.kt @@ -1,6 +1,7 @@ object BuildPlugins { - const val ANDROID_APPLICATION_PLUGIN = "com.android.application" - const val JETBRAINS_KOTLIN_ANDROID_PLUGIN = "org.jetbrains.kotlin.android" + const val ANDROID_APPLICATION = "com.android.application" + const val ANDROID_LIBRARY = "com.android.library" + const val JETBRAINS_KOTLIN_ANDROID = "org.jetbrains.kotlin.android" const val KOTLIN_KAPT = "kotlin-kapt" const val KTLINT = "org.jlleitschuh.gradle.ktlint" const val KOTLIN_PARCELIZE = "kotlin-parcelize" diff --git a/buildSrc/src/main/java/ProjectProperties.kt b/buildSrc/src/main/java/ProjectProperties.kt index 5c86810..8e8fdf2 100644 --- a/buildSrc/src/main/java/ProjectProperties.kt +++ b/buildSrc/src/main/java/ProjectProperties.kt @@ -6,6 +6,10 @@ object ProjectProperties { const val TARGET_SDK = COMPILE_SDK const val MIN_SDK = 21 + // Android & Kotlin Versions + const val ANDROID_VERSION = "7.2.2" + const val KOTLIN_VERSION = "1.7.10" + // Application const val APPLICATION_ID = "com.jxareas.xpensor" const val VERSION_CODE = 1 diff --git a/settings.gradle b/settings.gradle.kts similarity index 75% rename from settings.gradle rename to settings.gradle.kts index a1da3f1..a9b1684 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -1,6 +1,5 @@ pluginManagement { repositories { - maven { url 'https://jitpack.io' } gradlePluginPortal() google() mavenCentral() @@ -11,8 +10,8 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url 'https://jitpack.io' } + maven(url = uri("https://jitpack.io")) } } rootProject.name = "Xpensor" -include ':app' +include(":app") From a8905f2ddb3e24e3dd1d2638e9c0c5f98f3e3224 Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 14:25:43 -0600 Subject: [PATCH 04/10] Add KtLint Configuration --- app/build.gradle.kts | 23 +++++++++++--- .../java/com/jxareas/xpensor/XpensorApp.kt | 5 ++- .../common/extensions/FragmentExtensions.kt | 12 +++---- .../common/extensions/ImageViewExtensions.kt | 6 ++-- .../common/extensions/ViewExtensions.kt | 4 +-- .../jxareas/xpensor/common/utils/DateUtils.kt | 14 +++------ .../xpensor/common/utils/OnBindViewHolder.kt | 4 +-- .../common/utils/OnToolbarMenuItemClick.kt | 2 +- .../xpensor/common/utils/PreferenceUtils.kt | 6 +--- .../core/data/database/XpensorDatabase.kt | 6 ++-- .../data/local/converters/DateConverter.kt | 3 +- .../data/local/converters/TimeConverter.kt | 3 +- .../xpensor/core/domain/mapper/Mapper.kt | 2 +- .../xpensor/core/domain/model/Domain.kt | 2 +- .../xpensor/core/presentation/MainActivity.kt | 19 +++++------- .../core/presentation/MainActivityEvent.kt | 2 +- .../presentation/MainActivityViewModel.kt | 10 ++---- .../java/com/jxareas/xpensor/di/AppModule.kt | 2 +- .../xpensor/di/modules/AccountModule.kt | 4 +-- .../xpensor/di/modules/CategoryModule.kt | 5 +-- .../xpensor/di/modules/ConverterModule.kt | 7 ++--- .../xpensor/di/modules/NetworkModule.kt | 8 ++--- .../xpensor/di/modules/PreferencesModule.kt | 3 +- .../xpensor/di/modules/TransactionModule.kt | 4 +-- .../accounts/data/local/dao/AccountDao.kt | 2 +- .../data/local/entity/AccountEntity.kt | 2 +- .../data/mapper/AccountEntityMapper.kt | 11 ++++--- .../data/repository/AccountRepositoryImpl.kt | 4 +-- .../features/accounts/domain/model/Account.kt | 2 +- .../domain/model/AccountWithDetails.kt | 2 +- .../domain/repository/AccountRepository.kt | 2 +- .../domain/usecase/AddAccountUseCase.kt | 3 +- .../domain/usecase/DeleteAccountUseCase.kt | 3 +- .../domain/usecase/GetAccountsUseCase.kt | 5 ++- .../domain/usecase/UpdateAccountUseCase.kt | 3 +- .../presentation/mapper/AccountUiMapper.kt | 6 ++-- .../accounts/presentation/model/AccountUi.kt | 2 +- .../accounts/presentation/ui/AccountEvent.kt | 2 +- .../presentation/ui/AccountsFragment.kt | 20 +++++++----- .../presentation/ui/AccountsViewModel.kt | 5 ++- .../ui/actions/AccountActionsBottomSheet.kt | 8 ++--- .../ui/actions/AccountActionsEvent.kt | 2 +- .../ui/actions/AccountActionsViewModel.kt | 5 ++- .../ui/actions/add/AddAccountFragment.kt | 25 +++++++++------ .../ui/actions/add/AddAccountViewModel.kt | 6 ++-- .../ui/actions/edit/EditAccountEvent.kt | 2 +- .../ui/actions/edit/EditAccountFragment.kt | 27 +++++++++------- .../ui/actions/edit/EditAccountViewModel.kt | 6 ++-- .../filter/AccountFilterDialogFragment.kt | 6 ++-- .../ui/actions/filter/AccountFilterEvent.kt | 2 +- .../actions/filter/AccountFilterViewModel.kt | 5 ++- .../ui/actions/menu/AddAccountMenu.kt | 3 +- .../ui/actions/menu/ApplyChangesMenu.kt | 4 +-- .../ui/adapter/AccountDiffCallback.kt | 3 +- .../ui/adapter/AccountsListAdapter.kt | 10 +++--- .../ui/adapter/AccountsViewHolder.kt | 3 +- .../authentication/domain/model/PinCode.kt | 2 +- .../usecase/AddUserAuthenticationPin.kt | 4 +-- .../usecase/GetAuthenticationPinUseCase.kt | 5 ++- .../presentation/ui/AuthenticationActivity.kt | 20 +++++------- .../presentation/ui/AuthenticationEvent.kt | 2 +- .../ui/AuthenticationViewModel.kt | 6 ++-- .../chart/presentation/ui/ChartEvent.kt | 2 +- .../chart/presentation/ui/ChartFragment.kt | 13 ++++---- .../chart/presentation/ui/ChartViewModel.kt | 8 ++--- .../converter/data/api/ConverterApi.kt | 4 +-- .../data/api/constants/ApiConstants.kt | 4 +-- .../converter/data/api/dto/BaseCurrencyDto.kt | 2 +- .../converter/data/api/dto/CurrencyDto.kt | 2 +- .../data/api/dto/CurrencyRatesDto.kt | 2 +- .../interceptor/AuthenticationInterceptor.kt | 5 ++- .../data/mapper/BaseCurrencyDtoMapper.kt | 2 +- .../data/mapper/CurrencyDtoMapper.kt | 4 +-- .../data/mapper/CurrencyRatesDtoMapper.kt | 9 +++--- .../repository/ConverterRepositoryImpl.kt | 3 +- .../converter/domain/model/BaseCurrency.kt | 2 +- .../converter/domain/model/Currencies.kt | 2 +- .../converter/domain/model/Currency.kt | 2 +- .../domain/model/CurrencyComparison.kt | 2 +- .../converter/domain/model/CurrencyRates.kt | 2 +- .../domain/repository/ConverterRepository.kt | 2 +- .../domain/usecase/ConvertCurrencyUseCase.kt | 6 ++-- .../presentation/ui/ConversionState.kt | 10 +++--- .../presentation/ui/ConverterFragment.kt | 21 ++++++------- .../presentation/ui/ConverterViewModel.kt | 10 ++---- .../presentation/ui/CurrencyConverterEvent.kt | 5 +-- .../date/presentation/ui/DateSelectedEvent.kt | 2 +- .../ui/DateSelectorDialogFragment.kt | 7 ++--- .../presentation/ui/DateSelectorViewModel.kt | 10 +++--- .../presentation/ui/menu/SelectDateMenu.kt | 2 +- .../features/settings/ui/SettingsActivity.kt | 3 +- .../features/settings/ui/SettingsFragment.kt | 28 ++++++++--------- .../data/local/dao/CategoryDao.kt | 14 ++++++--- .../data/local/dao/TransactionDao.kt | 31 ++++++++++++------- .../data/local/entity/CategoryEntity.kt | 2 +- .../data/local/entity/TransactionEntity.kt | 8 ++--- .../data/local/views/CategoryView.kt | 2 +- .../data/local/views/TransactionView.kt | 2 +- .../local/views/TransactionsByDateView.kt | 2 +- .../data/mapper/CategoryViewMapper.kt | 9 +++--- .../mapper/TransactionAmountPerDayMapper.kt | 2 +- .../data/mapper/TransactionMapper.kt | 11 ++++--- .../data/mapper/TransactionViewMapper.kt | 11 ++++--- .../data/repository/CategoryRepositoryImpl.kt | 8 ++--- .../repository/TransactionRepositoryImpl.kt | 8 ++--- .../transactions/domain/model/Category.kt | 3 +- .../domain/model/CategoryWithDetails.kt | 2 +- .../transactions/domain/model/Transaction.kt | 4 +-- .../domain/model/TransactionAmountPerDay.kt | 2 +- .../domain/model/TransactionWithDetails.kt | 2 +- .../domain/repository/CategoryRepository.kt | 8 ++--- .../repository/TransactionRepository.kt | 5 ++- .../domain/usecase/AddTransactionUseCase.kt | 5 ++- .../usecase/DeleteTransactionUseCase.kt | 6 ++-- .../domain/usecase/GetCategoriesUseCase.kt | 8 ++--- .../domain/usecase/GetTransactionsUseCase.kt | 6 ++-- .../usecase/GetTransactionsWithDayUseCase.kt | 6 ++-- .../usecase/ValidateTransactionUseCase.kt | 3 +- .../presentation/mapper/CategoryUiMapper.kt | 3 +- .../mapper/CategoryWithAmountUiMapper.kt | 2 +- .../presentation/model/CategoryUi.kt | 2 +- .../model/CategoryWithAmountUi.kt | 2 +- .../presentation/ui/TransactionEvent.kt | 3 +- .../presentation/ui/TransactionState.kt | 2 +- .../presentation/ui/TransactionsFragment.kt | 31 +++++++++++-------- .../presentation/ui/TransactionsViewModel.kt | 16 ++-------- .../actions/add/AddTransactionBottomSheet.kt | 10 +++--- .../ui/actions/add/AddTransactionViewModel.kt | 7 ++--- .../actions/add/event/AddTransactionEvent.kt | 2 +- .../category/SelectCategoryBottomSheet.kt | 23 ++++++++------ .../category/SelectCategoryViewModel.kt | 9 ++---- .../category/adapter/CategoryAdapter.kt | 10 +++--- .../category/adapter/CategoryDiffCallback.kt | 3 +- .../category/adapter/CategoryViewHolder.kt | 4 +-- .../category/event/SelectCategoryEvent.kt | 2 +- .../ui/adapter/TransactionAdapter.kt | 25 ++++++++------- .../ui/adapter/TransactionDiffCallback.kt | 5 ++- .../ui/adapter/TransactionViewHolder.kt | 12 +++---- .../ui/adapter/TransactionsByDayViewHolder.kt | 8 ++--- app/src/main/res/navigation/nav_graph.xml | 2 +- app/src/main/res/values/strings.xml | 1 + build.gradle.kts | 3 ++ buildSrc/src/main/java/Dependencies.kt | 7 ++--- buildSrc/src/main/java/Versions.kt | 2 ++ 144 files changed, 433 insertions(+), 495 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1327a7b..a9ee6ea 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,4 +1,5 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties +import org.jlleitschuh.gradle.ktlint.reporter.ReporterType plugins { id(BuildPlugins.ANDROID_APPLICATION) @@ -7,6 +8,7 @@ plugins { id(BuildPlugins.SAFE_ARGS) id(BuildPlugins.KOTLIN_PARCELIZE) id(BuildPlugins.DAGGER_HILT) + id(BuildPlugins.KTLINT) } android { @@ -22,7 +24,6 @@ android { vectorDrawables.useSupportLibrary = true testInstrumentationRunner = ProjectProperties.TEST_RUNNER - val currencyApiKey = ProjectProperties.CURRENCY_API_KEY val currencyApiToken: String = gradleLocalProperties(rootDir).getProperty(currencyApiKey) buildConfigField("String", currencyApiKey, currencyApiToken) @@ -56,6 +57,20 @@ android { } } +tasks.getByPath("preBuild").dependsOn("ktlintFormat") + +ktlint { + android.set(true) + ignoreFailures.set(false) + disabledRules.add("no-wildcard-imports") + reporters { + reporter(ReporterType.PLAIN) + reporter(ReporterType.HTML) + reporter(ReporterType.JSON) + reporter(ReporterType.CHECKSTYLE) + } +} + dependencies { // Support Libraries @@ -65,7 +80,7 @@ dependencies { implementation(Dependencies.Android.FRAGMENT_KTX) // Desugaring - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5") + coreLibraryDesugaring(Dependencies.Android.DESUGARING_CORE_LIB) // Testing Dependencies testImplementation(Dependencies.Testing.JUNIT) @@ -76,7 +91,7 @@ dependencies { implementation(Dependencies.Android.SPLASH_SCREEN) implementation(Dependencies.Android.MATERIAL) implementation(Dependencies.Android.CARDVIEW) - implementation(Dependencies.Android.CARDVIEW) + implementation(Dependencies.Android.CONSTRAINT_LAYOUT) implementation(Dependencies.Android.SWIPE_REFRESH_LAYOUT) implementation(Dependencies.Android.RECYCLERVIEW) implementation(Dependencies.Android.VIEWPAGER2) @@ -128,4 +143,4 @@ dependencies { // MPAndroidChart implementation(Dependencies.PhilJay.MP_ANDROID_CHART) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/XpensorApp.kt b/app/src/main/java/com/jxareas/xpensor/XpensorApp.kt index c1fd9e9..bb4916a 100644 --- a/app/src/main/java/com/jxareas/xpensor/XpensorApp.kt +++ b/app/src/main/java/com/jxareas/xpensor/XpensorApp.kt @@ -19,12 +19,11 @@ class XpensorApp : Application() { .getString(THEME_PREFERENCE_KEY, THEME_DEFAULT) AppCompatDelegate.setDefaultNightMode( - when(selectedTheme) { + when (selectedTheme) { THEME_LIGHT -> AppCompatDelegate.MODE_NIGHT_NO THEME_DARK -> AppCompatDelegate.MODE_NIGHT_YES else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM } ) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/common/extensions/FragmentExtensions.kt b/app/src/main/java/com/jxareas/xpensor/common/extensions/FragmentExtensions.kt index 57c70a3..a462621 100644 --- a/app/src/main/java/com/jxareas/xpensor/common/extensions/FragmentExtensions.kt +++ b/app/src/main/java/com/jxareas/xpensor/common/extensions/FragmentExtensions.kt @@ -5,9 +5,6 @@ import android.util.TypedValue import android.widget.Toast import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment -import androidx.navigation.fragment.DialogFragmentNavigator -import androidx.navigation.fragment.FragmentNavigator -import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.DividerItemDecoration import com.google.android.material.snackbar.Snackbar import com.jxareas.xpensor.R @@ -38,9 +35,10 @@ fun Fragment.showSnackbar( .show() } -fun Fragment.getCurrentDestination() = - (findNavController().currentDestination as? FragmentNavigator.Destination)?.className - ?: (findNavController().currentDestination as? DialogFragmentNavigator.Destination)?.className +// fun Fragment.getCurrentDestination() = +// (findNavController().currentDestination as? FragmentNavigator.Destination)?.className +// ?: +// (findNavController().currentDestination as? DialogFragmentNavigator.Destination)?.className fun Fragment.getThemeColor(color: Int): Int { val value = TypedValue() @@ -50,4 +48,4 @@ fun Fragment.getThemeColor(color: Int): Int { fun toast(context: Context?, text: String) { Toast.makeText(context, text, Toast.LENGTH_LONG).show() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/common/extensions/ImageViewExtensions.kt b/app/src/main/java/com/jxareas/xpensor/common/extensions/ImageViewExtensions.kt index 58f2afb..1f29700 100644 --- a/app/src/main/java/com/jxareas/xpensor/common/extensions/ImageViewExtensions.kt +++ b/app/src/main/java/com/jxareas/xpensor/common/extensions/ImageViewExtensions.kt @@ -27,7 +27,9 @@ private val mapOfDrawables = mapOf( fun getImageViewTint(imageView: ImageView): String { val colorInt = imageView.imageTintList?.defaultColor - return if (colorInt != null) String.format("#%06X", 0xFFFFFF and colorInt) else PreferenceUtils.MAIN_COLOR + return if (colorInt != null) + String.format("#%06X", 0xFFFFFF and colorInt) + else PreferenceUtils.MAIN_COLOR } fun ImageView.setIcon(id: Int) { @@ -43,4 +45,4 @@ fun ImageView.setTint(@ColorRes colorRes: Int) { fun ImageView.setTint(value: String?) { DrawableCompat.setTint(this.drawable, Color.parseColor(value ?: PreferenceUtils.MAIN_COLOR)) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/common/extensions/ViewExtensions.kt b/app/src/main/java/com/jxareas/xpensor/common/extensions/ViewExtensions.kt index 78a9c32..44a095c 100644 --- a/app/src/main/java/com/jxareas/xpensor/common/extensions/ViewExtensions.kt +++ b/app/src/main/java/com/jxareas/xpensor/common/extensions/ViewExtensions.kt @@ -6,9 +6,9 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.annotation.IntegerRes import androidx.viewbinding.ViewBinding +import com.jxareas.xpensor.common.utils.DateUtils.toAmountFormat import com.jxareas.xpensor.databinding.ListItemCategoryBinding import com.jxareas.xpensor.features.transactions.domain.model.CategoryWithDetails -import com.jxareas.xpensor.common.utils.DateUtils.toAmountFormat internal inline infix operator fun ViewGroup.invoke( crossinline bindingInflater: LayoutInflater.(parent: ViewGroup, attachToParent: Boolean) -> VB, @@ -16,11 +16,9 @@ internal inline infix operator fun ViewGroup.invoke( bindingInflater.invoke(layoutInflater, this, false) } - fun Resources.getLong(@IntegerRes integerRes: Int): Long = getInteger(integerRes).toLong() - fun ListItemCategoryBinding.setCategoryAttributes( details: CategoryWithDetails, currency: String?, diff --git a/app/src/main/java/com/jxareas/xpensor/common/utils/DateUtils.kt b/app/src/main/java/com/jxareas/xpensor/common/utils/DateUtils.kt index 1833e9d..4cb458d 100644 --- a/app/src/main/java/com/jxareas/xpensor/common/utils/DateUtils.kt +++ b/app/src/main/java/com/jxareas/xpensor/common/utils/DateUtils.kt @@ -2,13 +2,8 @@ package com.jxareas.xpensor.common.utils import java.text.DecimalFormat import java.text.SimpleDateFormat -import java.time.Instant -import java.time.LocalDate -import java.time.LocalTime -import java.time.ZoneId -import java.time.ZoneOffset -import java.util.Date -import java.util.Locale +import java.time.* +import java.util.* import kotlin.math.absoluteValue object DateUtils { @@ -19,7 +14,8 @@ object DateUtils { getCurrentLocalDate() to getCurrentLocalDate() fun Double.toAmountFormat(withMinus: Boolean): String = - DecimalFormat(if (withMinus || this < 0) "โ€”######.##" else "######.##").format(this.absoluteValue) + DecimalFormat(if (withMinus || this < 0) "โ€”######.##" else "######.##") + .format(this.absoluteValue) fun getCurrentLocalDate(): LocalDate = LocalDate.parse( SimpleDateFormat("yyyy-MM-dd", Locale.US).format(Date()) @@ -38,4 +34,4 @@ object DateUtils { fun String.asLocalDate(): LocalDate = LocalDate.parse(this) const val DAY_IN_MS: Long = 1000 * 60 * 60 * 24 -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/common/utils/OnBindViewHolder.kt b/app/src/main/java/com/jxareas/xpensor/common/utils/OnBindViewHolder.kt index 577ceb6..f70743a 100644 --- a/app/src/main/java/com/jxareas/xpensor/common/utils/OnBindViewHolder.kt +++ b/app/src/main/java/com/jxareas/xpensor/common/utils/OnBindViewHolder.kt @@ -2,5 +2,5 @@ package com.jxareas.xpensor.common.utils @FunctionalInterface fun interface OnBindViewHolder { - fun bind(item : T) -} \ No newline at end of file + fun bind(item: T) +} diff --git a/app/src/main/java/com/jxareas/xpensor/common/utils/OnToolbarMenuItemClick.kt b/app/src/main/java/com/jxareas/xpensor/common/utils/OnToolbarMenuItemClick.kt index b7d74aa..fb1dc49 100644 --- a/app/src/main/java/com/jxareas/xpensor/common/utils/OnToolbarMenuItemClick.kt +++ b/app/src/main/java/com/jxareas/xpensor/common/utils/OnToolbarMenuItemClick.kt @@ -4,4 +4,4 @@ package com.jxareas.xpensor.common.utils fun interface OnToolbarMenuItemClick { operator fun invoke() = onToolbarMenuItemClick() fun onToolbarMenuItemClick() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/common/utils/PreferenceUtils.kt b/app/src/main/java/com/jxareas/xpensor/common/utils/PreferenceUtils.kt index 310402d..4007f0f 100644 --- a/app/src/main/java/com/jxareas/xpensor/common/utils/PreferenceUtils.kt +++ b/app/src/main/java/com/jxareas/xpensor/common/utils/PreferenceUtils.kt @@ -15,8 +15,4 @@ object PreferenceUtils { const val AUTH_CODE_PREFERENCE_KEY = "auth_code" const val FIRST_TIME_PREFERENCE_KEY = "first_time" - - - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/core/data/database/XpensorDatabase.kt b/app/src/main/java/com/jxareas/xpensor/core/data/database/XpensorDatabase.kt index 1352799..1fd1d87 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/data/database/XpensorDatabase.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/data/database/XpensorDatabase.kt @@ -3,13 +3,13 @@ package com.jxareas.xpensor.core.data.database import androidx.room.Database import androidx.room.RoomDatabase import androidx.room.TypeConverters +import com.jxareas.xpensor.core.data.database.XpensorDatabase.Companion.DATABASE_VERSION import com.jxareas.xpensor.core.data.local.converters.DateConverter import com.jxareas.xpensor.core.data.local.converters.TimeConverter import com.jxareas.xpensor.features.accounts.data.local.dao.AccountDao +import com.jxareas.xpensor.features.accounts.data.local.entity.AccountEntity import com.jxareas.xpensor.features.transactions.data.local.dao.CategoryDao import com.jxareas.xpensor.features.transactions.data.local.dao.TransactionDao -import com.jxareas.xpensor.core.data.database.XpensorDatabase.Companion.DATABASE_VERSION -import com.jxareas.xpensor.features.accounts.data.local.entity.AccountEntity import com.jxareas.xpensor.features.transactions.data.local.entity.CategoryEntity import com.jxareas.xpensor.features.transactions.data.local.entity.TransactionEntity @@ -29,4 +29,4 @@ abstract class XpensorDatabase : RoomDatabase() { const val DATABASE_VERSION = 1 const val DATABASE_NAME = "xpensor.db" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/core/data/local/converters/DateConverter.kt b/app/src/main/java/com/jxareas/xpensor/core/data/local/converters/DateConverter.kt index af5d75a..fcd5847 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/data/local/converters/DateConverter.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/data/local/converters/DateConverter.kt @@ -14,5 +14,4 @@ class DateConverter { fun toLocalDate(data: String): LocalDate { return LocalDate.parse(data) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/core/data/local/converters/TimeConverter.kt b/app/src/main/java/com/jxareas/xpensor/core/data/local/converters/TimeConverter.kt index 9020e8a..4222b92 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/data/local/converters/TimeConverter.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/data/local/converters/TimeConverter.kt @@ -14,5 +14,4 @@ class TimeConverter { fun toLocalTime(data: String): LocalTime { return LocalTime.parse(data) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/core/domain/mapper/Mapper.kt b/app/src/main/java/com/jxareas/xpensor/core/domain/mapper/Mapper.kt index f3d4d05..1b61f64 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/domain/mapper/Mapper.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/domain/mapper/Mapper.kt @@ -7,4 +7,4 @@ interface Mapper { fun mapToDomain(destination: D): S fun mapFromList(entityList: List): List = entityList.map(this::mapFromDomain) fun mapToList(domainList: List): List = domainList.map(this::mapToDomain) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/core/domain/model/Domain.kt b/app/src/main/java/com/jxareas/xpensor/core/domain/model/Domain.kt index 1b69c8a..b0aea5d 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/domain/model/Domain.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/domain/model/Domain.kt @@ -1,3 +1,3 @@ package com.jxareas.xpensor.core.domain.model -interface Domain \ No newline at end of file +interface Domain diff --git a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivity.kt b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivity.kt index a4add04..6a07ba4 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivity.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivity.kt @@ -12,12 +12,12 @@ import androidx.navigation.ui.setupActionBarWithNavController import androidx.navigation.ui.setupWithNavController import com.jxareas.xpensor.NavGraphDirections import com.jxareas.xpensor.R -import com.jxareas.xpensor.databinding.ActivityMainBinding import com.jxareas.xpensor.common.utils.DateUtils.getCurrentLocalDate +import com.jxareas.xpensor.databinding.ActivityMainBinding import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.flow.collectLatest import java.time.format.DateTimeFormatter import java.time.format.FormatStyle +import kotlinx.coroutines.flow.collectLatest @AndroidEntryPoint class MainActivity : AppCompatActivity() { @@ -36,15 +36,16 @@ class MainActivity : AppCompatActivity() { get() = setOf(R.id.accountsFragment, R.id.converterFragment) private val topLevelDestinationIds: Set - get() = setOf(R.id.converterFragment, + get() = setOf( + R.id.converterFragment, R.id.accountsFragment, R.id.transactionsFragment, R.id.dateSelectorDialogFragment, R.id.accountFilterDialogFragment, R.id.selectCategoryBottomSheet, R.id.addTransactionBottomSheet, - R.id.chartFragment) - + R.id.chartFragment + ) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -73,7 +74,7 @@ class MainActivity : AppCompatActivity() { getString(R.string.all_time) else if (currentDateRange.second == null) "${currentDateRange.first?.format(datePattern)} - ${ - getCurrentLocalDate().format(datePattern) + getCurrentLocalDate().format(datePattern) }" else currentDateRange.first?.format(datePattern) @@ -100,8 +101,6 @@ class MainActivity : AppCompatActivity() { is MainActivityEvent.OpenTheSelectAccountDialog -> navController.navigate(NavGraphDirections.actionGlobalAccountFilterDialog()) } - - } } } @@ -134,7 +133,6 @@ class MainActivity : AppCompatActivity() { val isNonFilterableFragment = destinationId in nonFilterableFragmentIds moreButton.visibility = if (isNonFilterableFragment) View.GONE else View.VISIBLE toolbarInfoBox.isEnabled = !isNonFilterableFragment - } private fun changeNavigationVisibility(visibility: Int) { @@ -147,5 +145,4 @@ class MainActivity : AppCompatActivity() { override fun onSupportNavigateUp(): Boolean = navController.navigateUp() || super.onSupportNavigateUp() - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityEvent.kt b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityEvent.kt index 1bb84dd..2674442 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityEvent.kt @@ -3,4 +3,4 @@ package com.jxareas.xpensor.core.presentation sealed class MainActivityEvent { object OpenTheSettingsScreen : MainActivityEvent() object OpenTheSelectAccountDialog : MainActivityEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityViewModel.kt b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityViewModel.kt index d12325e..2e6fc59 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityViewModel.kt @@ -11,6 +11,8 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.GetAccountsUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel +import java.time.LocalDate +import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -18,8 +20,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import java.time.LocalDate -import javax.inject.Inject @HiltViewModel class MainActivityViewModel @Inject constructor( @@ -66,15 +66,11 @@ class MainActivityViewModel @Inject constructor( _events.emit(MainActivityEvent.OpenTheSelectAccountDialog) } - fun onUpdateSelectedAccount(account: AccountUi?) = launchScoped { _selectedAccount.value = account } - fun onUpdateCurrentDateRange(begin: LocalDate?, end: LocalDate?) = launchScoped { _selectedDateRange.value = begin to end } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/di/AppModule.kt b/app/src/main/java/com/jxareas/xpensor/di/AppModule.kt index ae9494e..b8c87ea 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/AppModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/AppModule.kt @@ -27,4 +27,4 @@ object AppModule { XpensorDatabase.DATABASE_NAME ).createFromAsset("database/xpensor.db").build() } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/di/modules/AccountModule.kt b/app/src/main/java/com/jxareas/xpensor/di/modules/AccountModule.kt index 664e890..734840c 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/modules/AccountModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/modules/AccountModule.kt @@ -25,7 +25,5 @@ interface AccountModule { @Singleton fun provideAccountDao(database: XpensorDatabase): AccountDao = database.accountDao - } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/di/modules/CategoryModule.kt b/app/src/main/java/com/jxareas/xpensor/di/modules/CategoryModule.kt index 1895bbd..3842df2 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/modules/CategoryModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/modules/CategoryModule.kt @@ -11,7 +11,6 @@ import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import javax.inject.Singleton - @Module @InstallIn(SingletonComponent::class) interface CategoryModule { @@ -26,7 +25,5 @@ interface CategoryModule { @Singleton fun provideCategoryDao(database: XpensorDatabase): CategoryDao = database.categoryDao - } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/di/modules/ConverterModule.kt b/app/src/main/java/com/jxareas/xpensor/di/modules/ConverterModule.kt index 9bff09a..3a5e396 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/modules/ConverterModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/modules/ConverterModule.kt @@ -8,9 +8,9 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton import retrofit2.Retrofit import retrofit2.create -import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) @@ -26,8 +26,5 @@ interface ConverterModule { @Singleton fun provideConverterService(retrofit: Retrofit): ConverterApi = retrofit.create() - } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/di/modules/NetworkModule.kt b/app/src/main/java/com/jxareas/xpensor/di/modules/NetworkModule.kt index 045988f..793c999 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/modules/NetworkModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/modules/NetworkModule.kt @@ -8,11 +8,11 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit import retrofit2.converter.moshi.MoshiConverterFactory -import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) @@ -30,7 +30,6 @@ class NetworkModule { level = HttpLoggingInterceptor.Level.BODY } - @Provides @Singleton fun provideHttpClient(loggingInterceptor: HttpLoggingInterceptor): OkHttpClient = @@ -47,7 +46,4 @@ class NetworkModule { .client(okHttpClient) .addConverterFactory(moshi) .build() - - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/di/modules/PreferencesModule.kt b/app/src/main/java/com/jxareas/xpensor/di/modules/PreferencesModule.kt index 8fbc71f..8d5e4ab 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/modules/PreferencesModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/modules/PreferencesModule.kt @@ -18,5 +18,4 @@ object PreferencesModule { @Provides fun providePreferences(@ApplicationContext context: Context): SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/di/modules/TransactionModule.kt b/app/src/main/java/com/jxareas/xpensor/di/modules/TransactionModule.kt index 9903250..8b4b2fd 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/modules/TransactionModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/modules/TransactionModule.kt @@ -25,7 +25,5 @@ interface TransactionModule { @Singleton fun provideTransactionDao(database: XpensorDatabase): TransactionDao = database.transactionDao - } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/data/local/dao/AccountDao.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/data/local/dao/AccountDao.kt index 1cafd66..fa13dd0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/data/local/dao/AccountDao.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/data/local/dao/AccountDao.kt @@ -29,4 +29,4 @@ interface AccountDao { @Delete suspend fun deleteAccount(account: AccountEntity) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/data/local/entity/AccountEntity.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/data/local/entity/AccountEntity.kt index 547122f..939856a 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/data/local/entity/AccountEntity.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/data/local/entity/AccountEntity.kt @@ -17,4 +17,4 @@ data class AccountEntity( companion object { const val EMPTY_ID = 0 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/data/mapper/AccountEntityMapper.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/data/mapper/AccountEntityMapper.kt index dc40b2d..40507a4 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/data/mapper/AccountEntityMapper.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/data/mapper/AccountEntityMapper.kt @@ -14,11 +14,14 @@ class AccountEntityMapper @Inject constructor() : Mapper> = repository.getAccounts() - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/domain/usecase/UpdateAccountUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/domain/usecase/UpdateAccountUseCase.kt index acc6c57..567979d 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/domain/usecase/UpdateAccountUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/domain/usecase/UpdateAccountUseCase.kt @@ -10,5 +10,4 @@ class UpdateAccountUseCase @Inject constructor(private val repository: AccountRe suspend operator fun invoke(account: AccountWithDetails) = repository.updateAccount(account) - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/mapper/AccountUiMapper.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/mapper/AccountUiMapper.kt index f55c21b..3900dc0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/mapper/AccountUiMapper.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/mapper/AccountUiMapper.kt @@ -13,7 +13,8 @@ class AccountUiMapper @Inject constructor() : Mapper { val totalNumberOfAccounts = viewModel.accounts.value.size val openAccountBottomSheetAction = - NavGraphDirections.actionGlobalAccountActions(event.account, - totalNumberOfAccounts) + NavGraphDirections.actionGlobalAccountActions( + event.account, + totalNumberOfAccounts + ) findNavController().navigate(openAccountBottomSheetAction) } } @@ -94,12 +96,14 @@ class AccountsFragment : Fragment() { private fun setupMenu() { val menuHost: MenuHost = requireActivity() - menuHost.addMenuProvider(AddAccountMenu { - viewModel.onAddNewAccountButtonClick() - }, viewLifecycleOwner, Lifecycle.State.STARTED) + menuHost.addMenuProvider( + AddAccountMenu { + viewModel.onAddNewAccountButtonClick() + }, + viewLifecycleOwner, Lifecycle.State.STARTED + ) } - private fun setupRecyclerView() = binding.recyclerViewAccounts.run { adapter = accountsListAdapter addItemDecoration( @@ -125,4 +129,4 @@ class AccountsFragment : Fragment() { super.onDestroyView() _binding = null } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsViewModel.kt index e3abc76..f2965c8 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsViewModel.kt @@ -7,6 +7,7 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.GetAccountsUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -14,7 +15,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import javax.inject.Inject @HiltViewModel class AccountsViewModel @Inject constructor( @@ -50,5 +50,4 @@ class AccountsViewModel @Inject constructor( } .launchIn(viewModelScope) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsBottomSheet.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsBottomSheet.kt index 16afaf3..3252cb0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsBottomSheet.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsBottomSheet.kt @@ -62,7 +62,6 @@ class AccountActionsBottomSheet : BottomSheetDialogFragment() { } viewModel.removeAccount(args.selectedAccount) dismiss() - } is AccountActionsEvent.ShowDeleteAccountDialog -> { buildAlertDialog().show() @@ -70,11 +69,10 @@ class AccountActionsBottomSheet : BottomSheetDialogFragment() { is AccountActionsEvent.NavigateToEditAccountsScreen -> { val editAccountDirection = AccountActionsBottomSheetDirections - .actionAccountActionsBottomSheetFragmentToEditAccountFragment(args.selectedAccount) + .actionAccountBottomSheetToEditAccount(args.selectedAccount) findNavController().navigate(editAccountDirection) } } - } } } @@ -88,7 +86,6 @@ class AccountActionsBottomSheet : BottomSheetDialogFragment() { } .setNegativeButton(getString(R.string.cancel)) { _, _ -> this@AccountActionsBottomSheet.dismiss() - } .setOnCancelListener { this@AccountActionsBottomSheet.dismiss() @@ -109,5 +106,4 @@ class AccountActionsBottomSheet : BottomSheetDialogFragment() { super.onDestroyView() _binding = null } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsEvent.kt index e254ec6..efe325c 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsEvent.kt @@ -6,4 +6,4 @@ sealed class AccountActionsEvent { data class NavigateToEditAccountsScreen(val account: AccountUi) : AccountActionsEvent() data class ShowDeleteAccountDialog(val account: AccountUi) : AccountActionsEvent() object DeleteAccount : AccountActionsEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsViewModel.kt index bb377e6..cdf7de4 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsViewModel.kt @@ -6,9 +6,9 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.DeleteAccountUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -import javax.inject.Inject @HiltViewModel class AccountActionsViewModel @Inject constructor( @@ -35,5 +35,4 @@ class AccountActionsViewModel @Inject constructor( fun onDeleteAccountConfirmation() = launchScoped { _events.emit(AccountActionsEvent.DeleteAccount) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountFragment.kt index 657396d..2832494 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountFragment.kt @@ -66,18 +66,22 @@ class AddAccountFragment : Fragment() { is AddAccountEvent.CreateNewAccount -> { val name = binding.textInputLayoutName.editText?.text.toString().trim() if (name.isEmpty()) { - toast(requireContext(), - getString(R.string.account_empty_name_error)) + toast( + requireContext(), + getString(R.string.account_empty_name_error) + ) } else { val amount = binding.textInputLayoutMoneyAmount.editText?.text.toString() .toDoubleOrNull() ?: 0.0 val account = - AccountUi(name = name, + AccountUi( + name = name, amount = amount, color = color, - id = AccountUi.EMPTY_ID) + id = AccountUi.EMPTY_ID + ) viewModel.addAccount(account).also { findNavController().navigateUp() } } } @@ -86,7 +90,6 @@ class AddAccountFragment : Fragment() { color = addAccountEvent.color } } - } } } @@ -110,16 +113,18 @@ class AddAccountFragment : Fragment() { color15.setOnClickListener { viewModel.onSelectColorButtonClick(it as ImageView) } } - private fun setupMenu() { val menuHost: MenuHost = requireActivity() - menuHost.addMenuProvider(ApplyChangesMenu { - viewModel.onApplyChangesButtonClick() - }, viewLifecycleOwner, Lifecycle.State.STARTED) + menuHost.addMenuProvider( + ApplyChangesMenu { + viewModel.onApplyChangesButtonClick() + }, + viewLifecycleOwner, Lifecycle.State.STARTED + ) } override fun onDestroyView() { super.onDestroyView() _binding = null } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountViewModel.kt index fdf931e..d67d433 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountViewModel.kt @@ -8,9 +8,9 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.AddAccountUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -import javax.inject.Inject @HiltViewModel class AddAccountViewModel @Inject constructor( @@ -32,6 +32,4 @@ class AddAccountViewModel @Inject constructor( val color = getImageViewTint(image) _events.emit(AddAccountEvent.SelectAccountColor(color)) } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountEvent.kt index c161c37..c50158c 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountEvent.kt @@ -3,4 +3,4 @@ package com.jxareas.xpensor.features.accounts.presentation.ui.actions.edit sealed class EditAccountEvent { object UpdateAccount : EditAccountEvent() data class UpdateCurrentColor(val color: String) : EditAccountEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountFragment.kt index 7a5c555..215950d 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountFragment.kt @@ -17,12 +17,12 @@ import androidx.navigation.fragment.navArgs import com.google.android.material.transition.MaterialFade import com.google.android.material.transition.MaterialSharedAxis import com.jxareas.xpensor.R -import com.jxareas.xpensor.databinding.FragmentEditAccountBinding -import com.jxareas.xpensor.features.accounts.presentation.ui.actions.menu.ApplyChangesMenu -import com.jxareas.xpensor.common.utils.DateUtils.toAmountFormat +import com.jxareas.xpensor.common.extensions.getLong import com.jxareas.xpensor.common.extensions.setTint import com.jxareas.xpensor.common.extensions.toast -import com.jxareas.xpensor.common.extensions.getLong +import com.jxareas.xpensor.common.utils.DateUtils.toAmountFormat +import com.jxareas.xpensor.databinding.FragmentEditAccountBinding +import com.jxareas.xpensor.features.accounts.presentation.ui.actions.menu.ApplyChangesMenu import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest @@ -33,7 +33,6 @@ class EditAccountFragment : Fragment() { private val binding: FragmentEditAccountBinding get() = _binding!! - private val args by navArgs() private val viewModel: EditAccountViewModel by viewModels() @@ -51,7 +50,6 @@ class EditAccountFragment : Fragment() { } } - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -105,17 +103,22 @@ class EditAccountFragment : Fragment() { val account = args.editableAccount binding.run { - textInputLayoutName.editText?.setText(account.name) - textInputLayoutMoneyAmount.editText?.setText(account.amount.toAmountFormat(withMinus = false)) + textInputLayoutName.editText + ?.setText(account.name) + textInputLayoutMoneyAmount.editText + ?.setText(account.amount.toAmountFormat(withMinus = false)) selectedColor.setTint(account.color) } } private fun setupMenu() { val menuHost: MenuHost = requireActivity() - menuHost.addMenuProvider(ApplyChangesMenu { - viewModel.onApplyChanges() - }, viewLifecycleOwner, Lifecycle.State.STARTED) + menuHost.addMenuProvider( + ApplyChangesMenu { + viewModel.onApplyChanges() + }, + viewLifecycleOwner, Lifecycle.State.STARTED + ) } private fun setupListeners() = binding.run { @@ -141,4 +144,4 @@ class EditAccountFragment : Fragment() { super.onDestroyView() _binding = null } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountViewModel.kt index c0bc6be..a3112c0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountViewModel.kt @@ -8,9 +8,9 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.UpdateAccountUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -import javax.inject.Inject @HiltViewModel class EditAccountViewModel @Inject constructor( @@ -32,6 +32,4 @@ class EditAccountViewModel @Inject constructor( val color = getImageViewTint(image) _events.emit(EditAccountEvent.UpdateCurrentColor(color)) } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterDialogFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterDialogFragment.kt index 8de27f5..f2be961 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterDialogFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterDialogFragment.kt @@ -16,8 +16,8 @@ import com.jxareas.xpensor.core.presentation.MainActivityViewModel import com.jxareas.xpensor.databinding.DialogFragmentAccountFilterBinding import com.jxareas.xpensor.features.accounts.presentation.ui.adapter.AccountsListAdapter import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.flow.collectLatest import javax.inject.Inject +import kotlinx.coroutines.flow.collectLatest @AndroidEntryPoint class AccountFilterDialogFragment : DialogFragment() { @@ -95,6 +95,4 @@ class AccountFilterDialogFragment : DialogFragment() { super.onDestroyView() _binding = null } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterEvent.kt index ffa541d..b58f840 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterEvent.kt @@ -4,4 +4,4 @@ import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi sealed class AccountFilterEvent { data class SelectAccount(val account: AccountUi) : AccountFilterEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterViewModel.kt index 2eada88..25fe2d8 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterViewModel.kt @@ -7,6 +7,7 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.GetAccountsUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -14,7 +15,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import javax.inject.Inject @HiltViewModel class AccountFilterViewModel @Inject constructor( @@ -49,5 +49,4 @@ class AccountFilterViewModel @Inject constructor( fun getTotalAccountsAmount(): Double = _accounts.value.sumOf(AccountUi::amount) - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/menu/AddAccountMenu.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/menu/AddAccountMenu.kt index 6ae2b53..d7490f7 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/menu/AddAccountMenu.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/menu/AddAccountMenu.kt @@ -7,7 +7,6 @@ import androidx.core.view.MenuProvider import com.jxareas.xpensor.R import com.jxareas.xpensor.common.utils.OnToolbarMenuItemClick - class AddAccountMenu(private val onItemClicked: OnToolbarMenuItemClick) : MenuProvider { override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) = menuInflater.inflate(R.menu.accounts_menu, menu) @@ -17,4 +16,4 @@ class AddAccountMenu(private val onItemClicked: OnToolbarMenuItemClick) : MenuPr R.id.add_new_account -> true.also { onItemClicked() } else -> false } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/menu/ApplyChangesMenu.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/menu/ApplyChangesMenu.kt index 429b412..ce5825e 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/menu/ApplyChangesMenu.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/menu/ApplyChangesMenu.kt @@ -12,8 +12,8 @@ class ApplyChangesMenu(private val onItemClicked: OnToolbarMenuItemClick) : Menu menuInflater.inflate(R.menu.apply_changes_menu, menu) override fun onMenuItemSelected(menuItem: MenuItem): Boolean = - when(menuItem.itemId) { + when (menuItem.itemId) { R.id.apply_changes -> true.also { onItemClicked() } else -> false } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountDiffCallback.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountDiffCallback.kt index 3821fa0..32a8757 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountDiffCallback.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountDiffCallback.kt @@ -10,5 +10,4 @@ object AccountDiffCallback : DiffUtil.ItemCallback() { override fun areContentsTheSame(oldItem: AccountUi, newItem: AccountUi): Boolean = oldItem.hashCode() == newItem.hashCode() - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountsListAdapter.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountsListAdapter.kt index 7a1ba9b..bfec656 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountsListAdapter.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountsListAdapter.kt @@ -24,8 +24,10 @@ class AccountsListAdapter @Inject constructor( } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountsViewHolder = - AccountsViewHolder(preferences, - parent invoke ListItemAccountBinding::inflate).apply { + AccountsViewHolder( + preferences, + parent invoke ListItemAccountBinding::inflate + ).apply { val account by lazy { currentList[bindingAdapterPosition] } itemView.setOnClickListener { onClickListener?.onClick(account) @@ -36,8 +38,6 @@ class AccountsListAdapter @Inject constructor( this.onClickListener = onClickListener } - override fun onBindViewHolder(holder: AccountsViewHolder, position: Int) = holder.bind(currentList[position]) - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountsViewHolder.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountsViewHolder.kt index 3bb628b..15d6680 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountsViewHolder.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/adapter/AccountsViewHolder.kt @@ -21,5 +21,4 @@ class AccountsViewHolder( textViewCurrency.text = preferences.getString(CURRENCY_PREFERENCE_KEY, MAIN_CURRENCY) iconBackground.setTint(item.color) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/model/PinCode.kt b/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/model/PinCode.kt index 0990a09..1fd5553 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/model/PinCode.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/model/PinCode.kt @@ -6,4 +6,4 @@ value class PinCode(val code: String) { const val EMPTY_CODE = "" const val MAX_CODE_LENGTH = 4 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/usecase/AddUserAuthenticationPin.kt b/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/usecase/AddUserAuthenticationPin.kt index 83fbbb1..8f5bf0a 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/usecase/AddUserAuthenticationPin.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/usecase/AddUserAuthenticationPin.kt @@ -13,6 +13,4 @@ class AddUserAuthenticationPin @Inject constructor(private val preferences: Shar .putString(PreferenceUtils.AUTH_CODE_PREFERENCE_KEY, pinCode) .putBoolean(PreferenceUtils.FIRST_TIME_PREFERENCE_KEY, false) .apply() - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/usecase/GetAuthenticationPinUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/usecase/GetAuthenticationPinUseCase.kt index ccd1272..1de4cb3 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/usecase/GetAuthenticationPinUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/authentication/domain/usecase/GetAuthenticationPinUseCase.kt @@ -1,8 +1,8 @@ package com.jxareas.xpensor.features.authentication.domain.usecase import android.content.SharedPreferences -import com.jxareas.xpensor.features.authentication.domain.model.PinCode import com.jxareas.xpensor.common.utils.PreferenceUtils +import com.jxareas.xpensor.features.authentication.domain.model.PinCode import dagger.hilt.android.scopes.ViewModelScoped import javax.inject.Inject @@ -15,5 +15,4 @@ class GetAuthenticationPinUseCase @Inject constructor(private val preferences: S ?: PinCode.EMPTY_CODE return PinCode(code) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationActivity.kt b/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationActivity.kt index 988b146..8edfae9 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationActivity.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationActivity.kt @@ -4,11 +4,7 @@ import android.animation.ObjectAnimator import android.app.ActivityManager import android.content.Context import android.content.Intent -import android.os.Build -import android.os.Bundle -import android.os.VibrationEffect -import android.os.Vibrator -import android.os.VibratorManager +import android.os.* import android.view.View import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.AnticipateOvershootInterpolator @@ -21,10 +17,10 @@ import androidx.core.splashscreen.SplashScreenViewProvider import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import com.jxareas.xpensor.R -import com.jxareas.xpensor.databinding.ActivityAuthenticationBinding -import com.jxareas.xpensor.core.presentation.MainActivity import com.jxareas.xpensor.common.extensions.getLong import com.jxareas.xpensor.common.extensions.setTint +import com.jxareas.xpensor.core.presentation.MainActivity +import com.jxareas.xpensor.databinding.ActivityAuthenticationBinding import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collectLatest @@ -107,7 +103,6 @@ class AuthenticationActivity : AppCompatActivity() { .scaleYBy(SPLASH_ICON_VIEW_ANIMATION_SCALE) .withEndAction(reverseIconAnimation) .start() - } private fun setupEventCollector() = binding.run { @@ -153,12 +148,11 @@ class AuthenticationActivity : AppCompatActivity() { buttonBackspace.isClickable = true buttonForgotCode.isClickable = true - } } - is AuthenticationEvent.EraseAppData -> { - (getSystemService(ACTIVITY_SERVICE) as ActivityManager).clearApplicationUserData() - } + is AuthenticationEvent.EraseAppData -> + (getSystemService(ACTIVITY_SERVICE) as ActivityManager) + .clearApplicationUserData() is AuthenticationEvent.SetNewPinCode -> { textViewEnterPin.text = getString(R.string.set_the_pin) } @@ -222,4 +216,4 @@ class AuthenticationActivity : AppCompatActivity() { .create() alert.show() } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationEvent.kt index 39c91a5..6c0ddbd 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationEvent.kt @@ -7,4 +7,4 @@ sealed class AuthenticationEvent { object EraseAppData : AuthenticationEvent() object SetNewPinCode : AuthenticationEvent() object RepeatPinCode : AuthenticationEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationViewModel.kt index 23b5a57..add7eb5 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationViewModel.kt @@ -9,12 +9,12 @@ import com.jxareas.xpensor.features.authentication.domain.model.PinCode import com.jxareas.xpensor.features.authentication.domain.usecase.AddUserAuthenticationPin import com.jxareas.xpensor.features.authentication.domain.usecase.GetAuthenticationPinUseCase import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import javax.inject.Inject @HiltViewModel class AuthenticationViewModel @Inject constructor( @@ -87,6 +87,4 @@ class AuthenticationViewModel @Inject constructor( fun isAppLaunchedFirstTime(): Boolean = preferences.getBoolean(FIRST_TIME_PREFERENCE_KEY, true) - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartEvent.kt index d80b731..32bd5d2 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartEvent.kt @@ -2,4 +2,4 @@ package com.jxareas.xpensor.features.chart.presentation.ui sealed class ChartEvent { object DateSelected : ChartEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartFragment.kt index b0c18c5..e9851e9 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartFragment.kt @@ -97,8 +97,6 @@ class ChartFragment : Fragment() { viewModel.onUpdateSelectedAccount(account) } } - - } private fun navigateToSelectDateDialogFragment() { @@ -109,9 +107,12 @@ class ChartFragment : Fragment() { private fun setupMenu() { val menuHost: MenuHost = requireActivity() - menuHost.addMenuProvider(SelectDateMenu { - viewModel.onSelectedDateClick() - }, viewLifecycleOwner, Lifecycle.State.STARTED) + menuHost.addMenuProvider( + SelectDateMenu { + viewModel.onSelectedDateClick() + }, + viewLifecycleOwner, Lifecycle.State.STARTED + ) } private fun setupCollectors() { @@ -190,4 +191,4 @@ class ChartFragment : Fragment() { super.onDestroyView() _binding = null } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartViewModel.kt index c14998a..bfa040c 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartViewModel.kt @@ -9,6 +9,8 @@ import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import com.jxareas.xpensor.features.transactions.domain.model.CategoryWithDetails import com.jxareas.xpensor.features.transactions.domain.usecase.GetCategoriesUseCase import dagger.hilt.android.lifecycle.HiltViewModel +import java.time.LocalDate +import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -16,8 +18,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import java.time.LocalDate -import javax.inject.Inject @HiltViewModel class ChartViewModel @Inject constructor( @@ -66,6 +66,4 @@ class ChartViewModel @Inject constructor( _selectedAccountUi.value = account launchGetCategoriesJob() } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/ConverterApi.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/ConverterApi.kt index d41e9d1..b0a1503 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/ConverterApi.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/ConverterApi.kt @@ -7,10 +7,8 @@ import retrofit2.http.Query interface ConverterApi { - @GET("api/v2/latest") suspend fun getCurrencyRates( @Query("base_currency") base: String, ): Response - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/constants/ApiConstants.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/constants/ApiConstants.kt index 0a770e0..f48ba64 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/constants/ApiConstants.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/constants/ApiConstants.kt @@ -4,8 +4,6 @@ import com.jxareas.xpensor.BuildConfig object ApiConstants { - const val CURRENCY_API_BASE_URL = "https://freecurrencyapi.net/" const val CURRENCY_KEY = BuildConfig.CURRENCY_API_KEY - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/BaseCurrencyDto.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/BaseCurrencyDto.kt index c0693da..076bd2b 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/BaseCurrencyDto.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/BaseCurrencyDto.kt @@ -5,4 +5,4 @@ import com.squareup.moshi.Json data class BaseCurrencyDto( @Json(name = "base_currency") val base: String, -) \ No newline at end of file +) diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/CurrencyDto.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/CurrencyDto.kt index 0abf77c..4550fe0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/CurrencyDto.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/CurrencyDto.kt @@ -5,4 +5,4 @@ import com.squareup.moshi.Json data class CurrencyDto( @Json(name = "data") val rates: CurrencyRatesDto, val baseCurrency: BaseCurrencyDto, -) \ No newline at end of file +) diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/CurrencyRatesDto.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/CurrencyRatesDto.kt index a9a5652..a64125c 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/CurrencyRatesDto.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/dto/CurrencyRatesDto.kt @@ -8,4 +8,4 @@ data class CurrencyRatesDto( @Json(name = "NIO") val nio: Double = 1.0, @Json(name = "CRC") val crc: Double = 1.0, @Json(name = "GBP") val gbp: Double = 1.0, -) \ No newline at end of file +) diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/interceptor/AuthenticationInterceptor.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/interceptor/AuthenticationInterceptor.kt index 5820820..2688bc1 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/interceptor/AuthenticationInterceptor.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/interceptor/AuthenticationInterceptor.kt @@ -1,9 +1,9 @@ package com.jxareas.xpensor.features.converter.data.api.interceptor import com.jxareas.xpensor.features.converter.data.api.constants.ApiConstants +import javax.inject.Singleton import okhttp3.Interceptor import okhttp3.Response -import javax.inject.Singleton @Singleton object AuthenticationInterceptor : Interceptor { @@ -21,5 +21,4 @@ object AuthenticationInterceptor : Interceptor { return chain.proceed(newRequest) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/data/mapper/BaseCurrencyDtoMapper.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/data/mapper/BaseCurrencyDtoMapper.kt index 50a4a89..f38caa3 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/data/mapper/BaseCurrencyDtoMapper.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/data/mapper/BaseCurrencyDtoMapper.kt @@ -14,4 +14,4 @@ class BaseCurrencyDtoMapper @Inject constructor() : Mapper { override fun mapFromDomain(source: CurrencyRates): CurrencyRatesDto = - CurrencyRatesDto(source.usd.rate, + CurrencyRatesDto( + source.usd.rate, source.eur.rate, source.nio.rate, source.crc.rate, - source.gbp.rate) + source.gbp.rate + ) override fun mapToDomain(destination: CurrencyRatesDto): CurrencyRates = CurrencyRates( @@ -26,5 +28,4 @@ class CurrencyRatesDtoMapper @Inject constructor() : Mapper -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/domain/usecase/ConvertCurrencyUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/domain/usecase/ConvertCurrencyUseCase.kt index d10bfc2..b2b2cf3 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/domain/usecase/ConvertCurrencyUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/domain/usecase/ConvertCurrencyUseCase.kt @@ -23,7 +23,7 @@ class ConvertCurrencyUseCase @Inject constructor(private val repository: Convert when (val response = repository.getCurrencyRates(from)) { is Resource.Success -> { val rates = response.data?.currencyRates - if(rates != null) { + if (rates != null) { val currencyRate = when (to) { Currencies.USD.name -> rates.usd Currencies.EUR.name -> rates.eur @@ -37,6 +37,4 @@ class ConvertCurrencyUseCase @Inject constructor(private val repository: Convert } is Resource.Error -> NO_INTERNET_CONNECTION } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConversionState.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConversionState.kt index 5130981..525ef0b 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConversionState.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConversionState.kt @@ -1,8 +1,8 @@ package com.jxareas.xpensor.features.converter.presentation.ui sealed class ConversionState { - class Ready(val result: String) : ConversionState() - class Error(val error: String) : ConversionState() - object Loading : ConversionState() - object Idle : ConversionState() -} \ No newline at end of file + class Ready(val result: String) : ConversionState() + class Error(val error: String) : ConversionState() + object Loading : ConversionState() + object Idle : ConversionState() +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterFragment.kt index 7833272..4da89ec 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterFragment.kt @@ -13,10 +13,9 @@ import com.google.android.material.transition.MaterialArcMotion import com.google.android.material.transition.MaterialFade import com.google.android.material.transition.MaterialSharedAxis import com.jxareas.xpensor.R -import com.jxareas.xpensor.databinding.FragmentConverterBinding -import com.jxareas.xpensor.common.extensions.getCurrentDestination -import com.jxareas.xpensor.common.extensions.toast import com.jxareas.xpensor.common.extensions.getLong +import com.jxareas.xpensor.common.extensions.toast +import com.jxareas.xpensor.databinding.FragmentConverterBinding import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest @@ -94,19 +93,18 @@ class ConverterFragment : Fragment() { lifecycleScope.launchWhenStarted { viewModel.events.collectLatest { currencyConverterEvent -> when (currencyConverterEvent) { - is CurrencyConverterEvent.Convert -> handleConvertEvent() - is CurrencyConverterEvent.Swap -> handleSwapEvent() - is CurrencyConverterEvent.OpenTheAddTransactionSheet -> handleOpenTransactionSheetEvent() + is CurrencyConverterEvent.Convert -> + handleConvertEvent() + is CurrencyConverterEvent.Swap -> + handleSwapEvent() + is CurrencyConverterEvent.OpenTheAddTransactionSheet -> + handleOpenTransactionSheetEvent() } - } } } private fun handleOpenTransactionSheetEvent() { - if (getCurrentDestination() == this@ConverterFragment.javaClass.name) { - // TODO: NavDirection Navigation - } } private fun handleSwapEvent() { @@ -132,5 +130,4 @@ class ConverterFragment : Fragment() { super.onDestroyView() _binding = null } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterViewModel.kt index db4e4e9..1d4fdf6 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterViewModel.kt @@ -1,15 +1,15 @@ package com.jxareas.xpensor.features.converter.presentation.ui import androidx.lifecycle.ViewModel -import com.jxareas.xpensor.features.converter.domain.usecase.ConvertCurrencyUseCase import com.jxareas.xpensor.common.extensions.launchScoped import com.jxareas.xpensor.common.utils.DateUtils.toAmountFormat +import com.jxareas.xpensor.features.converter.domain.usecase.ConvertCurrencyUseCase import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow -import javax.inject.Inject @HiltViewModel class ConverterViewModel @Inject constructor( @@ -38,15 +38,11 @@ class ConverterViewModel @Inject constructor( } } - fun onSwapButtonClick() = launchScoped { _events.emit(CurrencyConverterEvent.Swap) } - fun onConvertButtonClick() = launchScoped { _events.emit(CurrencyConverterEvent.Convert) } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/CurrencyConverterEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/CurrencyConverterEvent.kt index 9dd1ab9..043a794 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/CurrencyConverterEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/CurrencyConverterEvent.kt @@ -5,5 +5,6 @@ import com.jxareas.xpensor.features.accounts.domain.model.AccountWithDetails sealed class CurrencyConverterEvent { object Convert : CurrencyConverterEvent() object Swap : CurrencyConverterEvent() - data class OpenTheAddTransactionSheet(val account: AccountWithDetails, val amount: Float) : CurrencyConverterEvent() -} \ No newline at end of file + data class OpenTheAddTransactionSheet(val account: AccountWithDetails, val amount: Float) : + CurrencyConverterEvent() +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectedEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectedEvent.kt index 6eb6a79..02ac1a5 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectedEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectedEvent.kt @@ -7,4 +7,4 @@ sealed class DateSelectedEvent { object Year : DateSelectedEvent() object AllTime : DateSelectedEvent() object CustomDate : DateSelectedEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorDialogFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorDialogFragment.kt index 77d6857..75cc0da 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorDialogFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorDialogFragment.kt @@ -10,10 +10,10 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import com.google.android.material.datepicker.MaterialDatePicker import com.jxareas.xpensor.R -import com.jxareas.xpensor.databinding.DialogFragmentDateSelectorBinding -import com.jxareas.xpensor.core.presentation.MainActivityViewModel import com.jxareas.xpensor.common.utils.DateUtils.DAY_IN_MS import com.jxareas.xpensor.common.utils.DateUtils.toLocalDate +import com.jxareas.xpensor.core.presentation.MainActivityViewModel +import com.jxareas.xpensor.databinding.DialogFragmentDateSelectorBinding import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest @@ -109,5 +109,4 @@ class DateSelectorDialogFragment : DialogFragment() { super.onDestroyView() _binding = null } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorViewModel.kt index ecce6e4..6b01f23 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorViewModel.kt @@ -7,10 +7,10 @@ import com.jxareas.xpensor.common.utils.DateUtils.getCurrentLocalDate import com.jxareas.xpensor.common.utils.DateUtils.toLocalDate import com.jxareas.xpensor.common.utils.DateUtils.toMilliseconds import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.flow.asSharedFlow import java.time.LocalDate import javax.inject.Inject +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.asSharedFlow @HiltViewModel class DateSelectorViewModel @Inject constructor() : ViewModel() { @@ -20,7 +20,8 @@ class DateSelectorViewModel @Inject constructor() : ViewModel() { fun getDate(daysAgo: Int = 0): LocalDate = if (daysAgo != 0) - ((getCurrentLocalDate()).toMilliseconds() + DAY_IN_MS - (daysAgo * DAY_IN_MS)).toLocalDate() + ((getCurrentLocalDate()).toMilliseconds() + DAY_IN_MS - (daysAgo * DAY_IN_MS)) + .toLocalDate() else getCurrentLocalDate() fun onSelectDate() = launchScoped { @@ -46,5 +47,4 @@ class DateSelectorViewModel @Inject constructor() : ViewModel() { fun onSelectAllTime() = launchScoped { _events.emit(DateSelectedEvent.AllTime) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/menu/SelectDateMenu.kt b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/menu/SelectDateMenu.kt index af9fc31..53c6077 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/menu/SelectDateMenu.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/menu/SelectDateMenu.kt @@ -19,4 +19,4 @@ class SelectDateMenu(private val onToolbarMenuItemClick: OnToolbarMenuItemClick) } else -> false } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsActivity.kt b/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsActivity.kt index 59a3130..f7bd337 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsActivity.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsActivity.kt @@ -36,5 +36,4 @@ class SettingsActivity : AppCompatActivity() { super.onPause() overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsFragment.kt index 2abe408..16ae051 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsFragment.kt @@ -10,19 +10,19 @@ import com.jxareas.xpensor.common.utils.PreferenceUtils.THEME_LIGHT import com.jxareas.xpensor.common.utils.PreferenceUtils.THEME_PREFERENCE_KEY class SettingsFragment : PreferenceFragmentCompat() { - override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - setPreferencesFromResource(R.xml.root_preferences, rootKey) - - findPreference(THEME_PREFERENCE_KEY)?.setOnPreferenceChangeListener { _, newValue -> - AppCompatDelegate.setDefaultNightMode( - when (newValue) { - THEME_LIGHT -> AppCompatDelegate.MODE_NIGHT_NO - THEME_DARK -> AppCompatDelegate.MODE_NIGHT_YES - else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM - } - ) - true - } + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { + setPreferencesFromResource(R.xml.root_preferences, rootKey) + findPreference(THEME_PREFERENCE_KEY)?.setOnPreferenceChangeListener { + _, newValue -> + AppCompatDelegate.setDefaultNightMode( + when (newValue) { + THEME_LIGHT -> AppCompatDelegate.MODE_NIGHT_NO + THEME_DARK -> AppCompatDelegate.MODE_NIGHT_YES + else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + } + ) + true } - } \ No newline at end of file + } +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/CategoryDao.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/CategoryDao.kt index 6e2666a..9cd5049 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/CategoryDao.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/CategoryDao.kt @@ -3,24 +3,28 @@ package com.jxareas.xpensor.features.transactions.data.local.dao import androidx.room.Dao import androidx.room.Query import com.jxareas.xpensor.features.transactions.data.local.views.CategoryView -import kotlinx.coroutines.flow.Flow import java.time.LocalDate +import kotlinx.coroutines.flow.Flow @Dao interface CategoryDao { - @Query(""" + @Query( + """ SELECT id, name, icon, icon_color, ifnull((SELECT SUM(amount) FROM transactions WHERE categories.id = category_id AND date >= :from AND date <= :to), 0) AS category_amount FROM categories GROUP BY id - """) + """ + ) fun getCategoryViews(from: LocalDate, to: LocalDate): Flow> - @Query(""" + @Query( + """ SELECT id, name, icon, icon_color, ifnull((SELECT SUM(amount) FROM transactions WHERE categories.id = category_id AND date >= :from AND date <= :to AND account_id = :id), 0) AS category_amount FROM categories GROUP BY id - """) + """ + ) fun getCategoryViewsForAccount( from: LocalDate, to: LocalDate, diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/TransactionDao.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/TransactionDao.kt index 79a4d60..ef2704e 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/TransactionDao.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/TransactionDao.kt @@ -7,13 +7,14 @@ import androidx.room.Query import com.jxareas.xpensor.features.transactions.data.local.entity.TransactionEntity import com.jxareas.xpensor.features.transactions.data.local.views.TransactionView import com.jxareas.xpensor.features.transactions.data.local.views.TransactionsByDateView -import kotlinx.coroutines.flow.Flow import java.time.LocalDate +import kotlinx.coroutines.flow.Flow @Dao interface TransactionDao { - @Query(""" + @Query( + """ SELECT transactions.id, transactions.note, transactions.amount, transactions.date, transactions.time, categories.id AS category_id, categories.name AS category_name, accounts.id AS account_id, accounts.name AS account_name, categories.icon, categories.icon_color @@ -21,10 +22,12 @@ interface TransactionDao { JOIN accounts ON accounts.id = transactions.account_id JOIN categories ON categories.id = transactions.category_id WHERE date >= :from AND date <= :to ORDER BY date ASC, time ASC - """) + """ + ) fun getTransactionViews(from: LocalDate, to: LocalDate): Flow> - @Query(""" + @Query( + """ SELECT transactions.id, transactions.note, transactions.amount, transactions.date, transactions.time, categories.id AS category_id, categories.name AS category_name, accounts.id AS account_id, accounts.name AS account_name, categories.icon, categories.icon_color @@ -32,29 +35,35 @@ interface TransactionDao { JOIN accounts ON accounts.id = transactions.account_id JOIN categories ON categories.id = transactions.category_id WHERE date >= :from AND date <= :to AND account_id = :id ORDER BY date ASC, time ASC - """) + """ + ) fun getTransactionViewsForAccount( from: LocalDate, to: LocalDate, id: Int, ): Flow> - @Query(""" + @Query( + """ SELECT date, SUM(amount) AS amount_per_day FROM transactions WHERE date >= :from AND date <= :to GROUP BY date ORDER BY date ASC - """) - fun getTransactionAmountsPerDay(from: LocalDate, to: LocalDate): Flow> + """ + ) + fun getTransactionAmountsPerDay(from: LocalDate, to: LocalDate): + Flow> - @Query(""" + @Query( + """ SELECT date, SUM(amount) AS amount_per_day FROM transactions WHERE date >= :from AND date <= :to AND account_id = :id GROUP BY date ORDER BY date ASC - """) + """ + ) fun getTransactionAmountsPerDayForAccount( from: LocalDate, to: LocalDate, @@ -66,4 +75,4 @@ interface TransactionDao { @Query("DELETE FROM transactions WHERE id = :id") suspend fun deleteTransactionById(id: Int) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/entity/CategoryEntity.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/entity/CategoryEntity.kt index 9fb5be5..42528ac 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/entity/CategoryEntity.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/entity/CategoryEntity.kt @@ -12,4 +12,4 @@ data class CategoryEntity( val icon: Int, @ColumnInfo(name = "icon_color") val iconColor: String, -) \ No newline at end of file +) diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/entity/TransactionEntity.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/entity/TransactionEntity.kt index f47b34c..4e00025 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/entity/TransactionEntity.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/entity/TransactionEntity.kt @@ -5,9 +5,9 @@ import androidx.room.Entity import androidx.room.ForeignKey import androidx.room.ForeignKey.CASCADE import androidx.room.PrimaryKey -import com.jxareas.xpensor.features.accounts.data.local.entity.AccountEntity import com.jxareas.xpensor.common.utils.DateUtils.getCurrentLocalDate import com.jxareas.xpensor.common.utils.DateUtils.getCurrentLocalTime +import com.jxareas.xpensor.features.accounts.data.local.entity.AccountEntity import java.time.LocalDate import java.time.LocalTime @@ -35,8 +35,8 @@ data class TransactionEntity( val amount: Double, val date: LocalDate = getCurrentLocalDate(), val time: LocalTime = getCurrentLocalTime(), - @ColumnInfo(name="account_id") + @ColumnInfo(name = "account_id") val accountId: Int, - @ColumnInfo(name="category_id") + @ColumnInfo(name = "category_id") val categoryId: Int -) \ No newline at end of file +) diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/CategoryView.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/CategoryView.kt index 690ace9..e66bf91 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/CategoryView.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/CategoryView.kt @@ -15,4 +15,4 @@ data class CategoryView( val iconColor: String, @ColumnInfo(name = "category_amount") val amount: Double -) : Parcelable \ No newline at end of file +) : Parcelable diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/TransactionView.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/TransactionView.kt index cf11849..a4781d0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/TransactionView.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/TransactionView.kt @@ -21,4 +21,4 @@ data class TransactionView( val icon: Int, @ColumnInfo(name = "icon_color") val iconColor: String -) \ No newline at end of file +) diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/TransactionsByDateView.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/TransactionsByDateView.kt index 2680327..86a2507 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/TransactionsByDateView.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/views/TransactionsByDateView.kt @@ -8,4 +8,4 @@ data class TransactionsByDateView( val transactionDate: LocalDate, @ColumnInfo(name = "amount_per_day") val amountPerDay: Double, -) \ No newline at end of file +) diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/mapper/CategoryViewMapper.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/mapper/CategoryViewMapper.kt index d6daa21..2815c5a 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/mapper/CategoryViewMapper.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/mapper/CategoryViewMapper.kt @@ -19,11 +19,12 @@ class CategoryViewMapper @Inject constructor() : Mapper { +class TransactionMapper @Inject constructor() : Mapper { override fun mapFromDomain(source: Transaction): TransactionEntity = - TransactionEntity(source.id, + TransactionEntity( + source.id, source.note, source.amount, source.date, source.time, source.accountId, - source.categoryId) + source.categoryId + ) override fun mapToDomain(destination: TransactionEntity): Transaction = Transaction( @@ -26,5 +28,4 @@ class TransactionMapper @Inject constructor(): Mapper { +class TransactionViewMapper @Inject constructor() : + Mapper { override fun mapFromDomain(source: TransactionWithDetails): TransactionView = TransactionView( @@ -33,10 +34,12 @@ class TransactionViewMapper @Inject constructor() : Mapper> = dao.getCategoryViews(from, to) .map { categoryViews -> categoryViewMapper.mapToList(categoryViews) } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/TransactionRepositoryImpl.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/TransactionRepositoryImpl.kt index 78f1b48..b3aa42a 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/TransactionRepositoryImpl.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/TransactionRepositoryImpl.kt @@ -8,10 +8,10 @@ import com.jxareas.xpensor.features.transactions.domain.model.Transaction import com.jxareas.xpensor.features.transactions.domain.model.TransactionAmountPerDay import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails import com.jxareas.xpensor.features.transactions.domain.repository.TransactionRepository -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map import java.time.LocalDate import javax.inject.Inject +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map class TransactionRepositoryImpl @Inject constructor( private val dao: TransactionDao, @@ -42,7 +42,6 @@ class TransactionRepositoryImpl @Inject constructor( dao.getTransactionAmountsPerDay(from, to) .map { transactions -> transactionAmountPerDayMapper.mapToList(transactions) } - override fun getTransactionAmountsPerDayForAccount( from: LocalDate, to: LocalDate, @@ -56,5 +55,4 @@ class TransactionRepositoryImpl @Inject constructor( override suspend fun deleteTransactionById(transactionId: Int) = dao.deleteTransactionById(transactionId) - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/Category.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/Category.kt index 16562aa..6ec7184 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/Category.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/Category.kt @@ -2,10 +2,9 @@ package com.jxareas.xpensor.features.transactions.domain.model import com.jxareas.xpensor.core.domain.model.Domain - data class Category( val id: Int, val name: String, val icon: Int, val iconColor: String, -) : Domain \ No newline at end of file +) : Domain diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/CategoryWithDetails.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/CategoryWithDetails.kt index 4cbdf15..17420d6 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/CategoryWithDetails.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/CategoryWithDetails.kt @@ -5,4 +5,4 @@ import com.jxareas.xpensor.core.domain.model.Domain data class CategoryWithDetails( val category: Category, val amount: Double, -) : Domain \ No newline at end of file +) : Domain diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/Transaction.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/Transaction.kt index 4db3832..6a06ce1 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/Transaction.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/Transaction.kt @@ -1,7 +1,7 @@ package com.jxareas.xpensor.features.transactions.domain.model -import com.jxareas.xpensor.core.domain.model.Domain import com.jxareas.xpensor.common.utils.DateUtils +import com.jxareas.xpensor.core.domain.model.Domain import java.time.LocalDate import java.time.LocalTime @@ -13,4 +13,4 @@ data class Transaction( val time: LocalTime = DateUtils.getCurrentLocalTime(), val accountId: Int, val categoryId: Int, -) : Domain \ No newline at end of file +) : Domain diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/TransactionAmountPerDay.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/TransactionAmountPerDay.kt index 4fe7f1b..fe7dad2 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/TransactionAmountPerDay.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/TransactionAmountPerDay.kt @@ -6,4 +6,4 @@ import java.time.LocalDate data class TransactionAmountPerDay( val transactionDate: LocalDate, val amountPerDay: Double, -) : Domain \ No newline at end of file +) : Domain diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/TransactionWithDetails.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/TransactionWithDetails.kt index 3d82c28..aa3e194 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/TransactionWithDetails.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/model/TransactionWithDetails.kt @@ -13,4 +13,4 @@ data class TransactionWithDetails( val time: LocalTime, val category: Category, val account: Account, -) : Domain \ No newline at end of file +) : Domain diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/CategoryRepository.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/CategoryRepository.kt index 9d221fd..4b878a0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/CategoryRepository.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/CategoryRepository.kt @@ -1,13 +1,13 @@ package com.jxareas.xpensor.features.transactions.domain.repository import com.jxareas.xpensor.features.transactions.domain.model.CategoryWithDetails -import kotlinx.coroutines.flow.Flow import java.time.LocalDate +import kotlinx.coroutines.flow.Flow interface CategoryRepository { - fun getCategoryViewsFromAccount(from: LocalDate, to: LocalDate, id: Int): Flow> + fun getCategoryViewsFromAccount(from: LocalDate, to: LocalDate, id: Int): + Flow> fun getCategoryViews(from: LocalDate, to: LocalDate): Flow> - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/TransactionRepository.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/TransactionRepository.kt index 6b69f20..15530ca 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/TransactionRepository.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/TransactionRepository.kt @@ -3,8 +3,8 @@ package com.jxareas.xpensor.features.transactions.domain.repository import com.jxareas.xpensor.features.transactions.domain.model.Transaction import com.jxareas.xpensor.features.transactions.domain.model.TransactionAmountPerDay import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails -import kotlinx.coroutines.flow.Flow import java.time.LocalDate +import kotlinx.coroutines.flow.Flow interface TransactionRepository { @@ -30,5 +30,4 @@ interface TransactionRepository { suspend fun insertTransaction(transaction: Transaction) suspend fun deleteTransactionById(transactionId: Int) - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/AddTransactionUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/AddTransactionUseCase.kt index e792039..ef8f892 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/AddTransactionUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/AddTransactionUseCase.kt @@ -1,7 +1,7 @@ package com.jxareas.xpensor.features.transactions.domain.usecase -import com.jxareas.xpensor.features.transactions.domain.model.Transaction import com.jxareas.xpensor.features.accounts.domain.repository.AccountRepository +import com.jxareas.xpensor.features.transactions.domain.model.Transaction import com.jxareas.xpensor.features.transactions.domain.repository.TransactionRepository import dagger.hilt.android.scopes.ViewModelScoped import javax.inject.Inject @@ -19,5 +19,4 @@ class AddTransactionUseCase @Inject constructor( transactionRepository.insertTransaction(transaction) } } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/DeleteTransactionUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/DeleteTransactionUseCase.kt index bcf4ab2..5b67135 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/DeleteTransactionUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/DeleteTransactionUseCase.kt @@ -1,7 +1,7 @@ package com.jxareas.xpensor.features.transactions.domain.usecase -import com.jxareas.xpensor.features.transactions.data.local.views.TransactionView import com.jxareas.xpensor.features.accounts.domain.repository.AccountRepository +import com.jxareas.xpensor.features.transactions.data.local.views.TransactionView import com.jxareas.xpensor.features.transactions.domain.repository.TransactionRepository import dagger.hilt.android.scopes.ViewModelScoped import javax.inject.Inject @@ -20,7 +20,5 @@ class DeleteTransactionUseCase @Inject constructor( accountRepository.updateAccountAmount(transaction.accountId, updatedAmount) transactionRepository.deleteTransactionById(transaction.id) } - } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetCategoriesUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetCategoriesUseCase.kt index 7f8b635..d5bc4b0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetCategoriesUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetCategoriesUseCase.kt @@ -6,8 +6,8 @@ import com.jxareas.xpensor.features.accounts.domain.model.AccountWithDetails import com.jxareas.xpensor.features.transactions.domain.model.CategoryWithDetails import com.jxareas.xpensor.features.transactions.domain.repository.CategoryRepository import dagger.hilt.android.scopes.ViewModelScoped -import kotlinx.coroutines.flow.Flow import javax.inject.Inject +import kotlinx.coroutines.flow.Flow @ViewModelScoped class GetCategoriesUseCase @Inject constructor( @@ -15,7 +15,7 @@ class GetCategoriesUseCase @Inject constructor( ) { operator fun invoke(dateRange: DateRange, account: AccountWithDetails?): - Flow> { + Flow> { val minDate = dateRange.first ?: DateUtils.DEFAULT_LOCAL_DATE val maxDate = dateRange.second ?: DateUtils.getCurrentLocalDate() @@ -23,7 +23,5 @@ class GetCategoriesUseCase @Inject constructor( return if (account == null) repository.getCategoryViews(minDate, maxDate) else repository.getCategoryViewsFromAccount(minDate, maxDate, account.id) - } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsUseCase.kt index 99202e7..0a6e8d6 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsUseCase.kt @@ -6,8 +6,8 @@ import com.jxareas.xpensor.features.accounts.domain.model.AccountWithDetails import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails import com.jxareas.xpensor.features.transactions.domain.repository.TransactionRepository import dagger.hilt.android.scopes.ViewModelScoped -import kotlinx.coroutines.flow.Flow import javax.inject.Inject +import kotlinx.coroutines.flow.Flow @ViewModelScoped class GetTransactionsUseCase @Inject constructor( @@ -25,7 +25,5 @@ class GetTransactionsUseCase @Inject constructor( return if (account == null) repository.getTransactionDetails(minDate, maxDate) else repository.getTransactionDetailsFromAccount(minDate, maxDate, account.id) - } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsWithDayUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsWithDayUseCase.kt index 3a70848..1250c9a 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsWithDayUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsWithDayUseCase.kt @@ -8,8 +8,8 @@ import com.jxareas.xpensor.features.transactions.domain.repository.TransactionRe import dagger.Module import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import kotlinx.coroutines.flow.first import javax.inject.Inject +import kotlinx.coroutines.flow.first @Module @InstallIn(SingletonComponent::class) @@ -47,7 +47,5 @@ class GetTransactionsWithDayUseCase @Inject constructor( result.add(amountsPerDay[index]) } return result.reversed() - } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/ValidateTransactionUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/ValidateTransactionUseCase.kt index 39626bb..9fa4907 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/ValidateTransactionUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/ValidateTransactionUseCase.kt @@ -16,5 +16,4 @@ class ValidateTransactionUseCase @Inject constructor( account.amount > transaction.amount else false } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/mapper/CategoryUiMapper.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/mapper/CategoryUiMapper.kt index 413b8ef..5084a01 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/mapper/CategoryUiMapper.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/mapper/CategoryUiMapper.kt @@ -23,5 +23,4 @@ class CategoryUiMapper @Inject constructor() : Mapper { icon = destination.icon, iconColor = destination.iconColor, ) - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/mapper/CategoryWithAmountUiMapper.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/mapper/CategoryWithAmountUiMapper.kt index c7528ed..b6ab173 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/mapper/CategoryWithAmountUiMapper.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/mapper/CategoryWithAmountUiMapper.kt @@ -22,4 +22,4 @@ class CategoryWithAmountUiMapper @Inject constructor( category = categoryMapper.mapToDomain(destination.category), amount = destination.amount, ) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/model/CategoryUi.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/model/CategoryUi.kt index 6d4329a..54e196a 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/model/CategoryUi.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/model/CategoryUi.kt @@ -9,4 +9,4 @@ data class CategoryUi( val name: String, val icon: Int, val iconColor: String, -) : Parcelable \ No newline at end of file +) : Parcelable diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/model/CategoryWithAmountUi.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/model/CategoryWithAmountUi.kt index f2a77f2..93e35b7 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/model/CategoryWithAmountUi.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/model/CategoryWithAmountUi.kt @@ -7,4 +7,4 @@ import kotlinx.parcelize.Parcelize data class CategoryWithAmountUi( val category: CategoryUi, val amount: Double, -) : Parcelable \ No newline at end of file +) : Parcelable diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionEvent.kt index eb718d1..acaa433 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionEvent.kt @@ -8,5 +8,4 @@ sealed class TransactionEvent { data class OpenTheAddTransactionSheet(val account: AccountUi) : TransactionEvent() data class ShowTheDeleteTransactionDialog(val transaction: TransactionView) : TransactionEvent() data class DeleteTransaction(val transaction: TransactionView) : TransactionEvent() - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionState.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionState.kt index ed3b81c..03e1f18 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionState.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionState.kt @@ -4,4 +4,4 @@ sealed class TransactionState { data class Ready(val transactions: List) : TransactionState() object Loading : TransactionState() object Idle : TransactionState() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsFragment.kt index 1458892..af9e1b0 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsFragment.kt @@ -28,8 +28,8 @@ import com.jxareas.xpensor.features.date.presentation.ui.menu.SelectDateMenu import com.jxareas.xpensor.features.transactions.data.local.views.TransactionView import com.jxareas.xpensor.features.transactions.presentation.ui.adapter.TransactionAdapter import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.flow.collectLatest import javax.inject.Inject +import kotlinx.coroutines.flow.collectLatest @AndroidEntryPoint class TransactionsFragment : Fragment() { @@ -60,9 +60,9 @@ class TransactionsFragment : Fragment() { } } - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, + inflater: LayoutInflater, + container: ViewGroup?, savedInstanceState: Bundle?, ): View { _binding = FragmentTransactionsBinding.inflate(layoutInflater) @@ -119,7 +119,12 @@ class TransactionsFragment : Fragment() { MaterialAlertDialogBuilder(requireContext()) .setIcon(R.drawable.ic_warning) .setTitle(R.string.delete_transaction_alert_title) - .setMessage("From: ${transaction.categoryName}\nTo: ${transaction.accountName}\nAmount: ${transaction.amount}") + .setMessage( + getString( + R.string.transaction_summary_dialog, transaction.categoryName, + transaction.accountName, transaction.amount.toString() + ) + ) .setPositiveButton(getString(R.string.confirm)) { _, _ -> viewModel.onDeleteTransactionConfirm(transaction) isAlertShowing = false @@ -135,11 +140,11 @@ class TransactionsFragment : Fragment() { private fun navigateToAddTransactionSheet(accountUi: AccountUi) { val direction = TransactionsFragmentDirections.actionTransactionsFragmentToSelectCategoryBottomSheet( - accountUi) + accountUi + ) findNavController().navigate(direction) } - private fun navigateToSelectDialogFragment() { val direction = TransactionsFragmentDirections.actionTransactionsFragmentToDateSelectorDialogFragment() @@ -148,9 +153,12 @@ class TransactionsFragment : Fragment() { private fun setupDate() { val menuHost: MenuHost = requireActivity() - menuHost.addMenuProvider(SelectDateMenu { - viewModel.onSelectedDateClick() - }, viewLifecycleOwner, Lifecycle.State.STARTED) + menuHost.addMenuProvider( + SelectDateMenu { + viewModel.onSelectedDateClick() + }, + viewLifecycleOwner, Lifecycle.State.STARTED + ) } private fun setupCollectors() { @@ -169,7 +177,6 @@ class TransactionsFragment : Fragment() { } is TransactionState.Idle -> Unit } - } } @@ -190,6 +197,4 @@ class TransactionsFragment : Fragment() { super.onDestroyView() _binding = null } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsViewModel.kt index 577bf7c..7d28853 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsViewModel.kt @@ -11,15 +11,10 @@ import com.jxareas.xpensor.features.transactions.domain.usecase.DeleteTransactio import com.jxareas.xpensor.features.transactions.domain.usecase.GetTransactionsUseCase import com.jxareas.xpensor.features.transactions.domain.usecase.GetTransactionsWithDayUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.asSharedFlow -import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach import java.time.LocalDate import javax.inject.Inject +import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.* @HiltViewModel class TransactionsViewModel @Inject constructor( @@ -81,20 +76,15 @@ class TransactionsViewModel @Inject constructor( _events.emit(TransactionEvent.DateSelected) } - fun onAddTransactionClick(account: AccountUi) = launchScoped { _events.emit(TransactionEvent.OpenTheAddTransactionSheet(account)) } - fun onDeleteButtonClick(transaction: TransactionView) = launchScoped { _events.emit(TransactionEvent.ShowTheDeleteTransactionDialog(transaction)) } - fun onDeleteTransactionConfirm(transaction: TransactionView) = launchScoped { _events.emit(TransactionEvent.DeleteTransaction(transaction)) } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionBottomSheet.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionBottomSheet.kt index 042e1d6..deb4ea2 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionBottomSheet.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionBottomSheet.kt @@ -55,7 +55,6 @@ class AddTransactionBottomSheet : BottomSheetDialogFragment() { when (state) { is AddTransactionState.ValidTransaction -> navigateBackToTransactionFragment() is AddTransactionState.InvalidTransaction -> showInvalidTransactionSnackbar() - } } } @@ -104,7 +103,8 @@ class AddTransactionBottomSheet : BottomSheetDialogFragment() { private fun navigateBackToTransactionFragment() { val direction = - AddTransactionBottomSheetDirections.actionAddTransactionBottomSheetToTransactionsFragment() + AddTransactionBottomSheetDirections + .actionAddTransactionBottomSheetToTransactionsFragment() findNavController().navigate(direction) } @@ -119,12 +119,12 @@ class AddTransactionBottomSheet : BottomSheetDialogFragment() { ) accountBackground.setBackgroundColor(Color.parseColor(args.selectedAccount.color)) - categoryBackground.setBackgroundColor(Color.parseColor(args.selectedCategory.category.iconColor)) + categoryBackground + .setBackgroundColor(Color.parseColor(args.selectedCategory.category.iconColor)) } override fun onDestroyView() { super.onDestroyView() _binding = null } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionViewModel.kt index fbe4bc2..5c863c1 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionViewModel.kt @@ -1,16 +1,16 @@ package com.jxareas.xpensor.features.transactions.presentation.ui.actions.add import androidx.lifecycle.ViewModel +import com.jxareas.xpensor.common.extensions.launchScoped import com.jxareas.xpensor.features.transactions.domain.model.Transaction import com.jxareas.xpensor.features.transactions.domain.usecase.AddTransactionUseCase import com.jxareas.xpensor.features.transactions.domain.usecase.ValidateTransactionUseCase import com.jxareas.xpensor.features.transactions.presentation.ui.actions.add.event.AddTransactionEvent import com.jxareas.xpensor.features.transactions.presentation.ui.actions.add.state.AddTransactionState -import com.jxareas.xpensor.common.extensions.launchScoped import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -import javax.inject.Inject @HiltViewModel class AddTransactionViewModel @Inject constructor( @@ -36,5 +36,4 @@ class AddTransactionViewModel @Inject constructor( fun onApplyChanges() = launchScoped { _events.emit(AddTransactionEvent.CreateNewTransaction) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/event/AddTransactionEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/event/AddTransactionEvent.kt index 03de19d..09f9ef5 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/event/AddTransactionEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/event/AddTransactionEvent.kt @@ -2,4 +2,4 @@ package com.jxareas.xpensor.features.transactions.presentation.ui.actions.add.ev sealed class AddTransactionEvent { object CreateNewTransaction : AddTransactionEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryBottomSheet.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryBottomSheet.kt index d506258..05f6aff 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryBottomSheet.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryBottomSheet.kt @@ -17,8 +17,8 @@ import com.jxareas.xpensor.databinding.BottomSheetSelectCategoryBinding import com.jxareas.xpensor.features.transactions.presentation.ui.actions.category.adapter.CategoryAdapter import com.jxareas.xpensor.features.transactions.presentation.ui.actions.category.event.SelectCategoryEvent import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.flow.collectLatest import javax.inject.Inject +import kotlinx.coroutines.flow.collectLatest @AndroidEntryPoint class SelectCategoryBottomSheet : BottomSheetDialogFragment() { @@ -58,10 +58,12 @@ class SelectCategoryBottomSheet : BottomSheetDialogFragment() { when (event) { is SelectCategoryEvent.SelectCategory -> { val direction = - SelectCategoryBottomSheetDirections.actionSelectCategoryBottomSheetToAddTransactionBottomSheet( - event.account, - event.category, - args.amount) + SelectCategoryBottomSheetDirections + .actionSelectCategoryBottomSheetToAddTransactionBottomSheet( + event.account, + event.category, + args.amount + ) findNavController().navigate(direction) } } @@ -71,9 +73,11 @@ class SelectCategoryBottomSheet : BottomSheetDialogFragment() { private fun setupRecyclerView() = binding.recyclerViewCategories.run { adapter = categoryAdapter - categoryAdapter.setOnClickListener(CategoryAdapter.OnClickListener { category -> - viewModel.selectCategoryClick(args.selectedAccount, category) - }) + categoryAdapter.setOnClickListener( + CategoryAdapter.OnClickListener { category -> + viewModel.selectCategoryClick(args.selectedAccount, category) + } + ) } private fun setupCollectors() { @@ -98,5 +102,4 @@ class SelectCategoryBottomSheet : BottomSheetDialogFragment() { super.onDestroyView() _binding = null } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryViewModel.kt index 9623e68..9315e8b 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryViewModel.kt @@ -1,6 +1,5 @@ package com.jxareas.xpensor.features.transactions.presentation.ui.actions.category - import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.jxareas.xpensor.common.extensions.launchScoped @@ -11,6 +10,8 @@ import com.jxareas.xpensor.features.transactions.presentation.mapper.CategoryWit import com.jxareas.xpensor.features.transactions.presentation.model.CategoryWithAmountUi import com.jxareas.xpensor.features.transactions.presentation.ui.actions.category.event.SelectCategoryEvent import dagger.hilt.android.lifecycle.HiltViewModel +import java.time.LocalDate +import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -18,8 +19,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import java.time.LocalDate -import javax.inject.Inject @HiltViewModel class SelectCategoryViewModel @Inject constructor( @@ -31,7 +30,6 @@ class SelectCategoryViewModel @Inject constructor( private val _categories = MutableStateFlow(emptyList()) val categories = _categories.asStateFlow() - private val _events = MutableSharedFlow() val events = _events.asSharedFlow() @@ -71,5 +69,4 @@ class SelectCategoryViewModel @Inject constructor( ) = launchScoped { _events.emit(SelectCategoryEvent.SelectCategory(accountUi, categoryWithAmountUi)) } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryAdapter.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryAdapter.kt index 79aa0f4..c4b053d 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryAdapter.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryAdapter.kt @@ -28,8 +28,10 @@ class CategoryAdapter @Inject constructor( } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CategoryViewHolder = - CategoryViewHolder(parent invoke ListItemCategoryBinding::inflate, - sharedPreferences).apply { + CategoryViewHolder( + parent invoke ListItemCategoryBinding::inflate, + sharedPreferences + ).apply { val category by lazy { currentList[bindingAdapterPosition] } @@ -38,6 +40,4 @@ class CategoryAdapter @Inject constructor( override fun onBindViewHolder(holder: CategoryViewHolder, position: Int) = holder.bind(currentList[position]) - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryDiffCallback.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryDiffCallback.kt index 66b452b..02f2ff8 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryDiffCallback.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryDiffCallback.kt @@ -14,5 +14,4 @@ object CategoryDiffCallback : DiffUtil.ItemCallback() { oldItem: CategoryWithAmountUi, newItem: CategoryWithAmountUi, ): Boolean = oldItem.hashCode() == newItem.hashCode() - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryViewHolder.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryViewHolder.kt index 965c893..e0488b5 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryViewHolder.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/adapter/CategoryViewHolder.kt @@ -25,6 +25,4 @@ class CategoryViewHolder( name.isSelected = true } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/event/SelectCategoryEvent.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/event/SelectCategoryEvent.kt index 1aa4c86..087ebed 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/event/SelectCategoryEvent.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/event/SelectCategoryEvent.kt @@ -6,4 +6,4 @@ import com.jxareas.xpensor.features.transactions.presentation.model.CategoryWith sealed class SelectCategoryEvent { data class SelectCategory(val account: AccountUi, val category: CategoryWithAmountUi) : SelectCategoryEvent() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionAdapter.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionAdapter.kt index 2175c61..e88486d 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionAdapter.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionAdapter.kt @@ -1,17 +1,16 @@ package com.jxareas.xpensor.features.transactions.presentation.ui.adapter - import android.content.SharedPreferences import android.view.ViewGroup import androidx.recyclerview.widget.AsyncDifferConfig import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import androidx.viewbinding.ViewBinding +import com.jxareas.xpensor.common.extensions.invoke +import com.jxareas.xpensor.common.utils.OnBindViewHolder import com.jxareas.xpensor.databinding.CardItemTransactionBinding import com.jxareas.xpensor.databinding.ListItemDayInformationBinding import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails -import com.jxareas.xpensor.common.utils.OnBindViewHolder -import com.jxareas.xpensor.common.extensions.invoke import javax.inject.Inject class TransactionAdapter @Inject constructor( @@ -19,7 +18,8 @@ class TransactionAdapter @Inject constructor( ) : ListAdapter( AsyncDifferConfig.Builder(TransactionDiffCallback).build() ) { - abstract class ViewHolder(binding: ViewBinding) : RecyclerView.ViewHolder(binding.root), + abstract class ViewHolder(binding: ViewBinding) : + RecyclerView.ViewHolder(binding.root), OnBindViewHolder companion object { @@ -30,14 +30,17 @@ class TransactionAdapter @Inject constructor( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = when (viewType) { TRANSACTION_VIEW_TYPE -> - TransactionViewHolder(parent invoke CardItemTransactionBinding::inflate, - preferences) + TransactionViewHolder( + parent invoke CardItemTransactionBinding::inflate, + preferences + ) else -> - TransactionsByDayViewHolder(parent invoke ListItemDayInformationBinding::inflate, - preferences) + TransactionsByDayViewHolder( + parent invoke ListItemDayInformationBinding::inflate, + preferences + ) } - override fun onBindViewHolder(holder: ViewHolder, position: Int) = when (holder.itemViewType) { TRANSACTION_VIEW_TYPE -> { @@ -54,6 +57,4 @@ class TransactionAdapter @Inject constructor( if (currentList[position] is TransactionWithDetails) TRANSACTION_VIEW_TYPE else DAY_INFO_VIEW_TYPE - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionDiffCallback.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionDiffCallback.kt index bc15d41..fe19642 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionDiffCallback.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionDiffCallback.kt @@ -1,8 +1,8 @@ package com.jxareas.xpensor.features.transactions.presentation.ui.adapter import androidx.recyclerview.widget.DiffUtil -import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails import com.jxareas.xpensor.features.transactions.domain.model.TransactionAmountPerDay +import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails object TransactionDiffCallback : DiffUtil.ItemCallback() { @@ -19,5 +19,4 @@ object TransactionDiffCallback : DiffUtil.ItemCallback() { else if (oldItem is TransactionWithDetails && newItem is TransactionWithDetails) oldItem.hashCode() == newItem.hashCode() else false - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionViewHolder.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionViewHolder.kt index 53127b1..a927acf 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionViewHolder.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionViewHolder.kt @@ -1,13 +1,13 @@ package com.jxareas.xpensor.features.transactions.presentation.ui.adapter import android.content.SharedPreferences -import com.jxareas.xpensor.databinding.CardItemTransactionBinding -import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails +import com.jxareas.xpensor.common.extensions.setIcon +import com.jxareas.xpensor.common.extensions.setTint import com.jxareas.xpensor.common.utils.DateUtils.toAmountFormat import com.jxareas.xpensor.common.utils.PreferenceUtils.CURRENCY_PREFERENCE_KEY import com.jxareas.xpensor.common.utils.PreferenceUtils.MAIN_CURRENCY -import com.jxareas.xpensor.common.extensions.setIcon -import com.jxareas.xpensor.common.extensions.setTint +import com.jxareas.xpensor.databinding.CardItemTransactionBinding +import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails class TransactionViewHolder( private val binding: CardItemTransactionBinding, @@ -33,6 +33,4 @@ class TransactionViewHolder( cardName.isSelected = true } } - - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionsByDayViewHolder.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionsByDayViewHolder.kt index 2d40286..571a7b5 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionsByDayViewHolder.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/adapter/TransactionsByDayViewHolder.kt @@ -1,18 +1,17 @@ package com.jxareas.xpensor.features.transactions.presentation.ui.adapter import android.content.SharedPreferences -import com.jxareas.xpensor.databinding.ListItemDayInformationBinding -import com.jxareas.xpensor.features.transactions.domain.model.TransactionAmountPerDay import com.jxareas.xpensor.common.utils.DateUtils.toAmountFormat import com.jxareas.xpensor.common.utils.PreferenceUtils.CURRENCY_PREFERENCE_KEY import com.jxareas.xpensor.common.utils.PreferenceUtils.MAIN_CURRENCY +import com.jxareas.xpensor.databinding.ListItemDayInformationBinding +import com.jxareas.xpensor.features.transactions.domain.model.TransactionAmountPerDay class TransactionsByDayViewHolder( private val binding: ListItemDayInformationBinding, private val preferences: SharedPreferences, ) : TransactionAdapter.ViewHolder(binding) { - override fun bind(item: Any) { val dayInfo = item as TransactionAmountPerDay @@ -29,5 +28,4 @@ class TransactionsByDayViewHolder( dayOfWeek.text = dateValue.dayOfWeek.name } } - -} \ No newline at end of file +} diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 56b5c09..f325168 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -97,7 +97,7 @@ android:name="numberOfAccounts" app:argType="integer" /> Converter Check your internet connection Add transaction button + From: %1$s \nTo: %2$s\nAmount: %3$s Convert The amount entered is incorrect or not entered at all. From: diff --git a/build.gradle.kts b/build.gradle.kts index 3b1f577..0a79a6e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,6 +18,9 @@ plugins { id(BuildPlugins.JETBRAINS_KOTLIN_ANDROID) .version(ProjectProperties.KOTLIN_VERSION) .apply(false) + id(BuildPlugins.KTLINT) + .version(Versions.KTLINT) + .apply(false) } tasks.register("clean", Delete::class) { diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index f3e2f4b..4e04180 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -13,10 +13,6 @@ object Dependencies { const val LEGACY_SUPPORT = "androidx.legacy:legacy-support-v4:${Versions.LEGACY_SUPPORT_VERSION}" - const val ROOM_RUNTIME = "androidx.room:room-runtime:${Versions.ROOM}" - const val ROOM_KTX = "androidx.room:room-ktx:${Versions.ROOM}" - const val ROOM_COMPILER = "androidx.room:room-compiler:${Versions.ROOM}" - const val SPLASH_SCREEN = "androidx.core:core-splashscreen:${Versions.SPLASH_SCREEN}" const val FRAGMENT_KTX = "androidx.fragment:fragment-ktx:${Versions.FRAGMENT_KTX}" const val MATERIAL = @@ -32,6 +28,9 @@ object Dependencies { "androidx.recyclerview:recyclerview:${Versions.RECYCLERVIEW}" const val VIEWPAGER2 = "androidx.viewpager2:viewpager2:${Versions.VIEWPAGER2}" + const val DESUGARING_CORE_LIB = + "com.android.tools:desugar_jdk_libs:${Versions.DESUGAR_JDK_LIB}" + const val LIFECYCLE_LIVE_DATA_KTX = "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.LIFECYCLE_KTX_VERSION}" const val LIFECYCLE_VIEWMODEL_KTX = diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index 84be84f..9e000f9 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -29,4 +29,6 @@ object Versions { const val JUNIT = "4.13.2" const val JUNIT_ANDROID_EXT = "1.1.3" const val ESPRESSO_ANDROID_CORE = "3.4.0" + const val KTLINT = "11.0.0" + const val DESUGAR_JDK_LIB = "1.0.6" } \ No newline at end of file From 997cf34d11f2753734cac5d02561300cc6077e43 Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 14:36:46 -0600 Subject: [PATCH 05/10] Fix Core Desugaring Library Version --- build.gradle.kts | 4 ++-- buildSrc/src/main/java/Versions.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0a79a6e..0464789 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,6 +23,6 @@ plugins { .apply(false) } -tasks.register("clean", Delete::class) { - delete(rootProject.buildDir) +task("clean") { + delete = setOf(rootProject.buildDir) } \ No newline at end of file diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index 9e000f9..e83963e 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -30,5 +30,5 @@ object Versions { const val JUNIT_ANDROID_EXT = "1.1.3" const val ESPRESSO_ANDROID_CORE = "3.4.0" const val KTLINT = "11.0.0" - const val DESUGAR_JDK_LIB = "1.0.6" + const val DESUGAR_JDK_LIB = "1.1.5" } \ No newline at end of file From 5acf5720d7fa5119700bef09f57608204152ecc8 Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 14:59:20 -0600 Subject: [PATCH 06/10] Add Versions Plugin --- app/build.gradle.kts | 5 +++-- build.gradle.kts | 3 ++- buildSrc/src/main/java/BuildPlugins.kt | 3 +++ buildSrc/src/main/java/Dependencies.kt | 6 +++--- buildSrc/src/main/java/Versions.kt | 1 + 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a9ee6ea..0c29545 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -9,6 +9,7 @@ plugins { id(BuildPlugins.KOTLIN_PARCELIZE) id(BuildPlugins.DAGGER_HILT) id(BuildPlugins.KTLINT) + id(BuildPlugins.VERSIONS) } android { @@ -107,8 +108,8 @@ dependencies { implementation(Dependencies.DataStore.DATA_STORE) // Navigation - implementation(Dependencies.Navigation.NAVIGATION_FRAGMENT_KTX) - implementation(Dependencies.Navigation.NAVIGATION_UI_KTX) + implementation(Dependencies.Navigation.FRAGMENT_KTX) + implementation(Dependencies.Navigation.UI_KTX) // Lifecycle implementation(Dependencies.Android.LIFECYCLE_VIEWMODEL_KTX) diff --git a/build.gradle.kts b/build.gradle.kts index 0464789..38404a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,8 +3,9 @@ buildscript { dependencies { classpath(BuildPlugins.TOOLS_BUILD_GRADLE) classpath(BuildPlugins.KOTLIN_GRADLE_PLUGIN) - classpath(Dependencies.Navigation.NAVIGATION_SAFE_ARGS) + classpath(Dependencies.Navigation.SAFE_ARGS_PLUGIN) classpath(Dependencies.Dagger.HILT_PLUGIN) + classpath(BuildPlugins.VERSIONS_PLUGIN) } } diff --git a/buildSrc/src/main/java/BuildPlugins.kt b/buildSrc/src/main/java/BuildPlugins.kt index 5be3f90..1c59386 100644 --- a/buildSrc/src/main/java/BuildPlugins.kt +++ b/buildSrc/src/main/java/BuildPlugins.kt @@ -4,6 +4,9 @@ object BuildPlugins { const val JETBRAINS_KOTLIN_ANDROID = "org.jetbrains.kotlin.android" const val KOTLIN_KAPT = "kotlin-kapt" const val KTLINT = "org.jlleitschuh.gradle.ktlint" + const val VERSIONS = "com.github.ben-manes.versions" + const val VERSIONS_PLUGIN = + "com.github.ben-manes:gradle-versions-plugin:${Versions.VERSIONS_PLUGIN}" const val KOTLIN_PARCELIZE = "kotlin-parcelize" const val SAFE_ARGS = "androidx.navigation.safeargs" const val DAGGER_HILT = "dagger.hilt.android.plugin" diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 4e04180..6cfe137 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -46,11 +46,11 @@ object Dependencies { } object Navigation { - const val NAVIGATION_SAFE_ARGS = + const val SAFE_ARGS_PLUGIN = "androidx.navigation:navigation-safe-args-gradle-plugin:${Versions.NAVIGATION}" - const val NAVIGATION_FRAGMENT_KTX = + const val FRAGMENT_KTX = "androidx.navigation:navigation-fragment-ktx:${Versions.NAVIGATION}" - const val NAVIGATION_UI_KTX = "androidx.navigation:navigation-ui-ktx:${Versions.NAVIGATION}" + const val UI_KTX = "androidx.navigation:navigation-ui-ktx:${Versions.NAVIGATION}" } object DataStore { diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index e83963e..0642e1c 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -31,4 +31,5 @@ object Versions { const val ESPRESSO_ANDROID_CORE = "3.4.0" const val KTLINT = "11.0.0" const val DESUGAR_JDK_LIB = "1.1.5" + const val VERSIONS_PLUGIN = "0.44.0" } \ No newline at end of file From b08c6f3f65c9763239a3eb0d3f907dccf5ef5297 Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 15:35:12 -0600 Subject: [PATCH 07/10] Add BuildScripts --- app/build.gradle.kts | 17 ----------------- .../xpensor/core/presentation/MainActivity.kt | 2 +- .../presentation/MainActivityViewModel.kt | 4 ++-- .../xpensor/di/modules/ConverterModule.kt | 2 +- .../xpensor/di/modules/NetworkModule.kt | 2 +- .../data/repository/AccountRepositoryImpl.kt | 2 +- .../domain/usecase/GetAccountsUseCase.kt | 2 +- .../presentation/ui/AccountsFragment.kt | 2 +- .../presentation/ui/AccountsViewModel.kt | 2 +- .../ui/actions/AccountActionsViewModel.kt | 2 +- .../ui/actions/add/AddAccountViewModel.kt | 2 +- .../ui/actions/edit/EditAccountViewModel.kt | 2 +- .../filter/AccountFilterDialogFragment.kt | 2 +- .../actions/filter/AccountFilterViewModel.kt | 2 +- .../ui/AuthenticationViewModel.kt | 2 +- .../chart/presentation/ui/ChartViewModel.kt | 4 ++-- .../interceptor/AuthenticationInterceptor.kt | 2 +- .../presentation/ui/ConverterViewModel.kt | 2 +- .../presentation/ui/DateSelectorViewModel.kt | 4 ++-- .../features/settings/ui/SettingsFragment.kt | 2 +- .../data/local/dao/CategoryDao.kt | 2 +- .../data/local/dao/TransactionDao.kt | 2 +- .../data/repository/CategoryRepositoryImpl.kt | 4 ++-- .../repository/TransactionRepositoryImpl.kt | 4 ++-- .../domain/repository/CategoryRepository.kt | 2 +- .../repository/TransactionRepository.kt | 2 +- .../domain/usecase/GetCategoriesUseCase.kt | 2 +- .../domain/usecase/GetTransactionsUseCase.kt | 2 +- .../usecase/GetTransactionsWithDayUseCase.kt | 2 +- .../presentation/ui/TransactionsFragment.kt | 2 +- .../presentation/ui/TransactionsViewModel.kt | 4 ++-- .../ui/actions/add/AddTransactionViewModel.kt | 2 +- .../category/SelectCategoryBottomSheet.kt | 2 +- .../category/SelectCategoryViewModel.kt | 4 ++-- build.gradle.kts | 7 ++++++- buildSrc/src/main/java/BuildScripts.kt | 4 ++++ buildSrc/src/main/java/Versions.kt | 3 ++- buildscripts/ktlint.gradle | 19 +++++++++++++++++++ buildscripts/versions.gradle | 15 +++++++++++++++ 39 files changed, 86 insertions(+), 59 deletions(-) create mode 100644 buildSrc/src/main/java/BuildScripts.kt create mode 100644 buildscripts/ktlint.gradle create mode 100644 buildscripts/versions.gradle diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0c29545..4233758 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,5 +1,4 @@ import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties -import org.jlleitschuh.gradle.ktlint.reporter.ReporterType plugins { id(BuildPlugins.ANDROID_APPLICATION) @@ -8,8 +7,6 @@ plugins { id(BuildPlugins.SAFE_ARGS) id(BuildPlugins.KOTLIN_PARCELIZE) id(BuildPlugins.DAGGER_HILT) - id(BuildPlugins.KTLINT) - id(BuildPlugins.VERSIONS) } android { @@ -58,20 +55,6 @@ android { } } -tasks.getByPath("preBuild").dependsOn("ktlintFormat") - -ktlint { - android.set(true) - ignoreFailures.set(false) - disabledRules.add("no-wildcard-imports") - reporters { - reporter(ReporterType.PLAIN) - reporter(ReporterType.HTML) - reporter(ReporterType.JSON) - reporter(ReporterType.CHECKSTYLE) - } -} - dependencies { // Support Libraries diff --git a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivity.kt b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivity.kt index 6a07ba4..cfae080 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivity.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivity.kt @@ -15,9 +15,9 @@ import com.jxareas.xpensor.R import com.jxareas.xpensor.common.utils.DateUtils.getCurrentLocalDate import com.jxareas.xpensor.databinding.ActivityMainBinding import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.collectLatest import java.time.format.DateTimeFormatter import java.time.format.FormatStyle -import kotlinx.coroutines.flow.collectLatest @AndroidEntryPoint class MainActivity : AppCompatActivity() { diff --git a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityViewModel.kt b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityViewModel.kt index 2e6fc59..fa171a2 100644 --- a/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/core/presentation/MainActivityViewModel.kt @@ -11,8 +11,6 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.GetAccountsUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel -import java.time.LocalDate -import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -20,6 +18,8 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import java.time.LocalDate +import javax.inject.Inject @HiltViewModel class MainActivityViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/di/modules/ConverterModule.kt b/app/src/main/java/com/jxareas/xpensor/di/modules/ConverterModule.kt index 3a5e396..8af31b4 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/modules/ConverterModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/modules/ConverterModule.kt @@ -8,9 +8,9 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import javax.inject.Singleton import retrofit2.Retrofit import retrofit2.create +import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) diff --git a/app/src/main/java/com/jxareas/xpensor/di/modules/NetworkModule.kt b/app/src/main/java/com/jxareas/xpensor/di/modules/NetworkModule.kt index 793c999..acd549d 100644 --- a/app/src/main/java/com/jxareas/xpensor/di/modules/NetworkModule.kt +++ b/app/src/main/java/com/jxareas/xpensor/di/modules/NetworkModule.kt @@ -8,11 +8,11 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import javax.inject.Singleton import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit import retrofit2.converter.moshi.MoshiConverterFactory +import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/data/repository/AccountRepositoryImpl.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/data/repository/AccountRepositoryImpl.kt index ffb15c9..e3c2c9e 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/data/repository/AccountRepositoryImpl.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/data/repository/AccountRepositoryImpl.kt @@ -4,9 +4,9 @@ import com.jxareas.xpensor.features.accounts.data.local.dao.AccountDao import com.jxareas.xpensor.features.accounts.data.mapper.AccountEntityMapper import com.jxareas.xpensor.features.accounts.domain.model.AccountWithDetails import com.jxareas.xpensor.features.accounts.domain.repository.AccountRepository -import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map +import javax.inject.Inject class AccountRepositoryImpl @Inject constructor( private val dao: AccountDao, diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/domain/usecase/GetAccountsUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/domain/usecase/GetAccountsUseCase.kt index e89e91e..30dfc6e 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/domain/usecase/GetAccountsUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/domain/usecase/GetAccountsUseCase.kt @@ -3,8 +3,8 @@ package com.jxareas.xpensor.features.accounts.domain.usecase import com.jxareas.xpensor.features.accounts.domain.model.AccountWithDetails import com.jxareas.xpensor.features.accounts.domain.repository.AccountRepository import dagger.hilt.android.scopes.ViewModelScoped -import javax.inject.Inject import kotlinx.coroutines.flow.Flow +import javax.inject.Inject @ViewModelScoped class GetAccountsUseCase @Inject constructor(private val repository: AccountRepository) { diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsFragment.kt index ec4aca7..0d069a9 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsFragment.kt @@ -22,8 +22,8 @@ import com.jxareas.xpensor.databinding.FragmentAccountsBinding import com.jxareas.xpensor.features.accounts.presentation.ui.actions.menu.AddAccountMenu import com.jxareas.xpensor.features.accounts.presentation.ui.adapter.AccountsListAdapter import dagger.hilt.android.AndroidEntryPoint -import javax.inject.Inject import kotlinx.coroutines.flow.collectLatest +import javax.inject.Inject @AndroidEntryPoint class AccountsFragment : Fragment() { diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsViewModel.kt index f2965c8..520f24e 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/AccountsViewModel.kt @@ -7,7 +7,6 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.GetAccountsUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -15,6 +14,7 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import javax.inject.Inject @HiltViewModel class AccountsViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsViewModel.kt index cdf7de4..dc30e0a 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/AccountActionsViewModel.kt @@ -6,9 +6,9 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.DeleteAccountUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow +import javax.inject.Inject @HiltViewModel class AccountActionsViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountViewModel.kt index d67d433..9b730eb 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/add/AddAccountViewModel.kt @@ -8,9 +8,9 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.AddAccountUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow +import javax.inject.Inject @HiltViewModel class AddAccountViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountViewModel.kt index a3112c0..00fe5b4 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/edit/EditAccountViewModel.kt @@ -8,9 +8,9 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.UpdateAccountUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow +import javax.inject.Inject @HiltViewModel class EditAccountViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterDialogFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterDialogFragment.kt index f2be961..2e6241d 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterDialogFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterDialogFragment.kt @@ -16,8 +16,8 @@ import com.jxareas.xpensor.core.presentation.MainActivityViewModel import com.jxareas.xpensor.databinding.DialogFragmentAccountFilterBinding import com.jxareas.xpensor.features.accounts.presentation.ui.adapter.AccountsListAdapter import dagger.hilt.android.AndroidEntryPoint -import javax.inject.Inject import kotlinx.coroutines.flow.collectLatest +import javax.inject.Inject @AndroidEntryPoint class AccountFilterDialogFragment : DialogFragment() { diff --git a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterViewModel.kt index 25fe2d8..bb90186 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/accounts/presentation/ui/actions/filter/AccountFilterViewModel.kt @@ -7,7 +7,6 @@ import com.jxareas.xpensor.features.accounts.domain.usecase.GetAccountsUseCase import com.jxareas.xpensor.features.accounts.presentation.mapper.AccountUiMapper import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -15,6 +14,7 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import javax.inject.Inject @HiltViewModel class AccountFilterViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationViewModel.kt index add7eb5..4dae2b9 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/authentication/presentation/ui/AuthenticationViewModel.kt @@ -9,12 +9,12 @@ import com.jxareas.xpensor.features.authentication.domain.model.PinCode import com.jxareas.xpensor.features.authentication.domain.usecase.AddUserAuthenticationPin import com.jxareas.xpensor.features.authentication.domain.usecase.GetAuthenticationPinUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import javax.inject.Inject @HiltViewModel class AuthenticationViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartViewModel.kt index bfa040c..a3ad52b 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/chart/presentation/ui/ChartViewModel.kt @@ -9,8 +9,6 @@ import com.jxareas.xpensor.features.accounts.presentation.model.AccountUi import com.jxareas.xpensor.features.transactions.domain.model.CategoryWithDetails import com.jxareas.xpensor.features.transactions.domain.usecase.GetCategoriesUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import java.time.LocalDate -import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -18,6 +16,8 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import java.time.LocalDate +import javax.inject.Inject @HiltViewModel class ChartViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/interceptor/AuthenticationInterceptor.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/interceptor/AuthenticationInterceptor.kt index 2688bc1..5a86dc1 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/interceptor/AuthenticationInterceptor.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/data/api/interceptor/AuthenticationInterceptor.kt @@ -1,9 +1,9 @@ package com.jxareas.xpensor.features.converter.data.api.interceptor import com.jxareas.xpensor.features.converter.data.api.constants.ApiConstants -import javax.inject.Singleton import okhttp3.Interceptor import okhttp3.Response +import javax.inject.Singleton @Singleton object AuthenticationInterceptor : Interceptor { diff --git a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterViewModel.kt index 1d4fdf6..717bcb8 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/converter/presentation/ui/ConverterViewModel.kt @@ -5,11 +5,11 @@ import com.jxareas.xpensor.common.extensions.launchScoped import com.jxareas.xpensor.common.utils.DateUtils.toAmountFormat import com.jxareas.xpensor.features.converter.domain.usecase.ConvertCurrencyUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow +import javax.inject.Inject @HiltViewModel class ConverterViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorViewModel.kt index 6b01f23..4516af6 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/date/presentation/ui/DateSelectorViewModel.kt @@ -7,10 +7,10 @@ import com.jxareas.xpensor.common.utils.DateUtils.getCurrentLocalDate import com.jxareas.xpensor.common.utils.DateUtils.toLocalDate import com.jxareas.xpensor.common.utils.DateUtils.toMilliseconds import dagger.hilt.android.lifecycle.HiltViewModel -import java.time.LocalDate -import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow +import java.time.LocalDate +import javax.inject.Inject @HiltViewModel class DateSelectorViewModel @Inject constructor() : ViewModel() { diff --git a/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsFragment.kt index 16ae051..179860b 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/settings/ui/SettingsFragment.kt @@ -14,7 +14,7 @@ class SettingsFragment : PreferenceFragmentCompat() { setPreferencesFromResource(R.xml.root_preferences, rootKey) findPreference(THEME_PREFERENCE_KEY)?.setOnPreferenceChangeListener { - _, newValue -> + _, newValue -> AppCompatDelegate.setDefaultNightMode( when (newValue) { THEME_LIGHT -> AppCompatDelegate.MODE_NIGHT_NO diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/CategoryDao.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/CategoryDao.kt index 9cd5049..64fdf00 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/CategoryDao.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/CategoryDao.kt @@ -3,8 +3,8 @@ package com.jxareas.xpensor.features.transactions.data.local.dao import androidx.room.Dao import androidx.room.Query import com.jxareas.xpensor.features.transactions.data.local.views.CategoryView -import java.time.LocalDate import kotlinx.coroutines.flow.Flow +import java.time.LocalDate @Dao interface CategoryDao { diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/TransactionDao.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/TransactionDao.kt index ef2704e..f9931d2 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/TransactionDao.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/local/dao/TransactionDao.kt @@ -7,8 +7,8 @@ import androidx.room.Query import com.jxareas.xpensor.features.transactions.data.local.entity.TransactionEntity import com.jxareas.xpensor.features.transactions.data.local.views.TransactionView import com.jxareas.xpensor.features.transactions.data.local.views.TransactionsByDateView -import java.time.LocalDate import kotlinx.coroutines.flow.Flow +import java.time.LocalDate @Dao interface TransactionDao { diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/CategoryRepositoryImpl.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/CategoryRepositoryImpl.kt index aedc2ed..742b367 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/CategoryRepositoryImpl.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/CategoryRepositoryImpl.kt @@ -4,10 +4,10 @@ import com.jxareas.xpensor.features.transactions.data.local.dao.CategoryDao import com.jxareas.xpensor.features.transactions.data.mapper.CategoryViewMapper import com.jxareas.xpensor.features.transactions.domain.model.CategoryWithDetails import com.jxareas.xpensor.features.transactions.domain.repository.CategoryRepository -import java.time.LocalDate -import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map +import java.time.LocalDate +import javax.inject.Inject class CategoryRepositoryImpl @Inject constructor( private val dao: CategoryDao, diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/TransactionRepositoryImpl.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/TransactionRepositoryImpl.kt index b3aa42a..50271b8 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/TransactionRepositoryImpl.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/data/repository/TransactionRepositoryImpl.kt @@ -8,10 +8,10 @@ import com.jxareas.xpensor.features.transactions.domain.model.Transaction import com.jxareas.xpensor.features.transactions.domain.model.TransactionAmountPerDay import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails import com.jxareas.xpensor.features.transactions.domain.repository.TransactionRepository -import java.time.LocalDate -import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map +import java.time.LocalDate +import javax.inject.Inject class TransactionRepositoryImpl @Inject constructor( private val dao: TransactionDao, diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/CategoryRepository.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/CategoryRepository.kt index 4b878a0..b57667f 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/CategoryRepository.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/CategoryRepository.kt @@ -1,8 +1,8 @@ package com.jxareas.xpensor.features.transactions.domain.repository import com.jxareas.xpensor.features.transactions.domain.model.CategoryWithDetails -import java.time.LocalDate import kotlinx.coroutines.flow.Flow +import java.time.LocalDate interface CategoryRepository { diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/TransactionRepository.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/TransactionRepository.kt index 15530ca..c1ef844 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/TransactionRepository.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/repository/TransactionRepository.kt @@ -3,8 +3,8 @@ package com.jxareas.xpensor.features.transactions.domain.repository import com.jxareas.xpensor.features.transactions.domain.model.Transaction import com.jxareas.xpensor.features.transactions.domain.model.TransactionAmountPerDay import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails -import java.time.LocalDate import kotlinx.coroutines.flow.Flow +import java.time.LocalDate interface TransactionRepository { diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetCategoriesUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetCategoriesUseCase.kt index d5bc4b0..3294835 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetCategoriesUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetCategoriesUseCase.kt @@ -6,8 +6,8 @@ import com.jxareas.xpensor.features.accounts.domain.model.AccountWithDetails import com.jxareas.xpensor.features.transactions.domain.model.CategoryWithDetails import com.jxareas.xpensor.features.transactions.domain.repository.CategoryRepository import dagger.hilt.android.scopes.ViewModelScoped -import javax.inject.Inject import kotlinx.coroutines.flow.Flow +import javax.inject.Inject @ViewModelScoped class GetCategoriesUseCase @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsUseCase.kt index 0a6e8d6..bc0a942 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsUseCase.kt @@ -6,8 +6,8 @@ import com.jxareas.xpensor.features.accounts.domain.model.AccountWithDetails import com.jxareas.xpensor.features.transactions.domain.model.TransactionWithDetails import com.jxareas.xpensor.features.transactions.domain.repository.TransactionRepository import dagger.hilt.android.scopes.ViewModelScoped -import javax.inject.Inject import kotlinx.coroutines.flow.Flow +import javax.inject.Inject @ViewModelScoped class GetTransactionsUseCase @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsWithDayUseCase.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsWithDayUseCase.kt index 1250c9a..6ca3365 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsWithDayUseCase.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/domain/usecase/GetTransactionsWithDayUseCase.kt @@ -8,8 +8,8 @@ import com.jxareas.xpensor.features.transactions.domain.repository.TransactionRe import dagger.Module import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import javax.inject.Inject import kotlinx.coroutines.flow.first +import javax.inject.Inject @Module @InstallIn(SingletonComponent::class) diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsFragment.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsFragment.kt index af9e1b0..514ab2b 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsFragment.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsFragment.kt @@ -28,8 +28,8 @@ import com.jxareas.xpensor.features.date.presentation.ui.menu.SelectDateMenu import com.jxareas.xpensor.features.transactions.data.local.views.TransactionView import com.jxareas.xpensor.features.transactions.presentation.ui.adapter.TransactionAdapter import dagger.hilt.android.AndroidEntryPoint -import javax.inject.Inject import kotlinx.coroutines.flow.collectLatest +import javax.inject.Inject @AndroidEntryPoint class TransactionsFragment : Fragment() { diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsViewModel.kt index 7d28853..838554f 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/TransactionsViewModel.kt @@ -11,10 +11,10 @@ import com.jxareas.xpensor.features.transactions.domain.usecase.DeleteTransactio import com.jxareas.xpensor.features.transactions.domain.usecase.GetTransactionsUseCase import com.jxareas.xpensor.features.transactions.domain.usecase.GetTransactionsWithDayUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import java.time.LocalDate -import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.* +import java.time.LocalDate +import javax.inject.Inject @HiltViewModel class TransactionsViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionViewModel.kt index 5c863c1..ea34eaa 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/add/AddTransactionViewModel.kt @@ -8,9 +8,9 @@ import com.jxareas.xpensor.features.transactions.domain.usecase.ValidateTransact import com.jxareas.xpensor.features.transactions.presentation.ui.actions.add.event.AddTransactionEvent import com.jxareas.xpensor.features.transactions.presentation.ui.actions.add.state.AddTransactionState import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow +import javax.inject.Inject @HiltViewModel class AddTransactionViewModel @Inject constructor( diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryBottomSheet.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryBottomSheet.kt index 05f6aff..32e8882 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryBottomSheet.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryBottomSheet.kt @@ -17,8 +17,8 @@ import com.jxareas.xpensor.databinding.BottomSheetSelectCategoryBinding import com.jxareas.xpensor.features.transactions.presentation.ui.actions.category.adapter.CategoryAdapter import com.jxareas.xpensor.features.transactions.presentation.ui.actions.category.event.SelectCategoryEvent import dagger.hilt.android.AndroidEntryPoint -import javax.inject.Inject import kotlinx.coroutines.flow.collectLatest +import javax.inject.Inject @AndroidEntryPoint class SelectCategoryBottomSheet : BottomSheetDialogFragment() { diff --git a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryViewModel.kt b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryViewModel.kt index 9315e8b..695c2e4 100644 --- a/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryViewModel.kt +++ b/app/src/main/java/com/jxareas/xpensor/features/transactions/presentation/ui/actions/category/SelectCategoryViewModel.kt @@ -10,8 +10,6 @@ import com.jxareas.xpensor.features.transactions.presentation.mapper.CategoryWit import com.jxareas.xpensor.features.transactions.presentation.model.CategoryWithAmountUi import com.jxareas.xpensor.features.transactions.presentation.ui.actions.category.event.SelectCategoryEvent import dagger.hilt.android.lifecycle.HiltViewModel -import java.time.LocalDate -import javax.inject.Inject import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -19,6 +17,8 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import java.time.LocalDate +import javax.inject.Inject @HiltViewModel class SelectCategoryViewModel @Inject constructor( diff --git a/build.gradle.kts b/build.gradle.kts index 38404a9..c66ea45 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,10 +20,15 @@ plugins { .version(ProjectProperties.KOTLIN_VERSION) .apply(false) id(BuildPlugins.KTLINT) - .version(Versions.KTLINT) + .version(Versions.KTLINT_PLUGIN) .apply(false) } +subprojects { + apply(from = "${rootProject.projectDir}/${BuildScripts.KTLINT}") + apply(from = "${rootProject.projectDir}/${BuildScripts.VERSIONS}") +} + task("clean") { delete = setOf(rootProject.buildDir) } \ No newline at end of file diff --git a/buildSrc/src/main/java/BuildScripts.kt b/buildSrc/src/main/java/BuildScripts.kt new file mode 100644 index 0000000..5408e3b --- /dev/null +++ b/buildSrc/src/main/java/BuildScripts.kt @@ -0,0 +1,4 @@ +object BuildScripts { + const val KTLINT = "buildscripts/ktlint.gradle" + const val VERSIONS = "buildscripts/versions.gradle" +} \ No newline at end of file diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index 0642e1c..c43aebb 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -29,7 +29,8 @@ object Versions { const val JUNIT = "4.13.2" const val JUNIT_ANDROID_EXT = "1.1.3" const val ESPRESSO_ANDROID_CORE = "3.4.0" - const val KTLINT = "11.0.0" + const val KTLINT_PLUGIN = "11.0.0" + const val KTLINT = "0.45.2" const val DESUGAR_JDK_LIB = "1.1.5" const val VERSIONS_PLUGIN = "0.44.0" } \ No newline at end of file diff --git a/buildscripts/ktlint.gradle b/buildscripts/ktlint.gradle new file mode 100644 index 0000000..fd6288e --- /dev/null +++ b/buildscripts/ktlint.gradle @@ -0,0 +1,19 @@ +apply plugin: BuildPlugins.KTLINT + +ktlint { + // https://github.com/pinterest/ktlint/releases + version = Versions.KTLINT + + reporters { + reporter "plain" + reporter "checkstyle" + reporter "html" + } + + disabledRules.set(["no-wildcard-imports"]) + outputColorName = "RED" + + filter { + exclude { element -> element.file.path.contains("build/") } + } +} \ No newline at end of file diff --git a/buildscripts/versions.gradle b/buildscripts/versions.gradle new file mode 100644 index 0000000..1d8ea27 --- /dev/null +++ b/buildscripts/versions.gradle @@ -0,0 +1,15 @@ +apply plugin: BuildPlugins.VERSIONS + +def isNonStable = { String version -> + def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) } + def regex = /^[0-9,.v-]+(-r)?$/ + return !stableKeyword && !(version ==~ regex) +} + +tasks.named("dependencyUpdates").configure { + rejectVersionIf { + isNonStable(it.candidate.version) + } + + gradleReleaseChannel = "current" +} \ No newline at end of file From 77b3f35f30411d45fbc8928c23d6d0a43aa7c03d Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 16:07:45 -0600 Subject: [PATCH 08/10] Init Detekt --- build.gradle.kts | 16 + buildSrc/src/main/java/BuildPlugins.kt | 2 + buildSrc/src/main/java/Versions.kt | 1 + config/detekt/detekt.yml | 617 +++++++++++++++++++++++++ 4 files changed, 636 insertions(+) create mode 100644 config/detekt/detekt.yml diff --git a/build.gradle.kts b/build.gradle.kts index c66ea45..81744a3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,7 @@ buildscript { classpath(Dependencies.Navigation.SAFE_ARGS_PLUGIN) classpath(Dependencies.Dagger.HILT_PLUGIN) classpath(BuildPlugins.VERSIONS_PLUGIN) + classpath(BuildPlugins.DETEKT_PLUGIN) } } @@ -22,6 +23,8 @@ plugins { id(BuildPlugins.KTLINT) .version(Versions.KTLINT_PLUGIN) .apply(false) + id(BuildPlugins.DETEKT) + .version(Versions.DETEKT) } subprojects { @@ -29,6 +32,19 @@ subprojects { apply(from = "${rootProject.projectDir}/${BuildScripts.VERSIONS}") } +tasks { + val detektAll by registering(io.gitlab.arturbosch.detekt.Detekt::class) { + parallel = true + setSource(files(projectDir)) + include("**/*.kt") + include("**/*.kts") + exclude("**/resources/**") + exclude("**/build/**") + config.setFrom(files("$rootDir/config/detekt/detekt.yml")) + buildUponDefaultConfig = false + } +} + task("clean") { delete = setOf(rootProject.buildDir) } \ No newline at end of file diff --git a/buildSrc/src/main/java/BuildPlugins.kt b/buildSrc/src/main/java/BuildPlugins.kt index 1c59386..5f7a2fc 100644 --- a/buildSrc/src/main/java/BuildPlugins.kt +++ b/buildSrc/src/main/java/BuildPlugins.kt @@ -10,6 +10,8 @@ object BuildPlugins { const val KOTLIN_PARCELIZE = "kotlin-parcelize" const val SAFE_ARGS = "androidx.navigation.safeargs" const val DAGGER_HILT = "dagger.hilt.android.plugin" + const val DETEKT = "io.gitlab.arturbosch.detekt" + const val DETEKT_PLUGIN = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${Versions.DETEKT}" private const val TOOLS_BUILD_VERSION = "7.1.3" const val TOOLS_BUILD_GRADLE = diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index c43aebb..62910fa 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -33,4 +33,5 @@ object Versions { const val KTLINT = "0.45.2" const val DESUGAR_JDK_LIB = "1.1.5" const val VERSIONS_PLUGIN = "0.44.0" + const val DETEKT = "1.21.0" } \ No newline at end of file diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml new file mode 100644 index 0000000..e289741 --- /dev/null +++ b/config/detekt/detekt.yml @@ -0,0 +1,617 @@ +build: + maxIssues: 0 + excludeCorrectable: false + weights: + # complexity: 2 + # LongParameterList: 1 + # style: 1 + # comments: 1 + +config: + validation: true + warningsAsErrors: false + # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' + excludes: '' + +processors: + active: true + exclude: + - 'DetektProgressListener' + # - 'KtFileCountProcessor' + # - 'PackageCountProcessor' + # - 'ClassCountProcessor' + # - 'FunctionCountProcessor' + # - 'PropertyCountProcessor' + # - 'ProjectComplexityProcessor' + # - 'ProjectCognitiveComplexityProcessor' + # - 'ProjectLLOCProcessor' + # - 'ProjectCLOCProcessor' + # - 'ProjectLOCProcessor' + # - 'ProjectSLOCProcessor' + # - 'LicenseHeaderLoaderExtension' + +console-reports: + active: true + exclude: + - 'ProjectStatisticsReport' + - 'ComplexityReport' + - 'NotificationReport' + # - 'FindingsReport' + - 'FileBasedFindingsReport' + +output-reports: + active: true + exclude: + # - 'TxtOutputReport' + # - 'XmlOutputReport' + # - 'HtmlOutputReport' + +comments: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + AbsentOrWrongFileLicense: + active: false + licenseTemplateFile: 'license.template' + licenseTemplateIsRegex: false + CommentOverPrivateFunction: + active: false + CommentOverPrivateProperty: + active: false + DeprecatedBlockTag: + active: false + EndOfSentenceFormat: + active: false + endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + UndocumentedPublicClass: + active: true + searchInNestedClass: true + searchInInnerClass: true + searchInInnerObject: true + searchInInnerInterface: true + UndocumentedPublicFunction: + active: true + excludes: ['**/com/adammcneilly/pocketleague/data/local/sqldelight/mappers/**',] + UndocumentedPublicProperty: + active: false + OutdatedDocumentation: + active: true + matchTypeParameters: true + matchDeclarationsOrder: true + +complexity: + active: true + ComplexCondition: + active: true + threshold: 4 + ComplexInterface: + active: false + threshold: 10 + includeStaticDeclarations: false + includePrivateDeclarations: false + ComplexMethod: + active: true + threshold: 15 + ignoreSingleWhenExpression: false + ignoreSimpleWhenEntries: false + ignoreNestingFunctions: false + nestingFunctions: ['run', 'let', 'apply', 'with', 'also', 'use', 'forEach', 'isNotNull', 'ifNull'] + LabeledExpression: + active: false + ignoredLabels: [] + LargeClass: + active: true + threshold: 600 + LongMethod: + active: true + threshold: 60 + LongParameterList: + active: true + functionThreshold: 6 + constructorThreshold: 7 + ignoreDefaultParameters: false + ignoreDataClasses: true + ignoreAnnotated: ['Composable'] + MethodOverloading: + active: false + threshold: 6 + NamedArguments: + active: false + threshold: 3 + NestedBlockDepth: + active: true + threshold: 4 + ReplaceSafeCallChainWithRun: + active: false + StringLiteralDuplication: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + threshold: 3 + ignoreAnnotation: true + excludeStringsWithLessThan5Characters: true + ignoreStringsRegex: '$^' + TooManyFunctions: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + thresholdInFiles: 11 + thresholdInClasses: 11 + thresholdInInterfaces: 11 + thresholdInObjects: 11 + thresholdInEnums: 11 + ignoreDeprecated: false + ignorePrivate: false + ignoreOverridden: false + +coroutines: + active: true + GlobalCoroutineUsage: + active: false + RedundantSuspendModifier: + active: false + SleepInsteadOfDelay: + active: false + SuspendFunWithFlowReturnType: + active: false + +empty-blocks: + active: true + EmptyCatchBlock: + active: true + allowedExceptionNameRegex: '_|(ignore|expected).*' + EmptyClassBlock: + active: true + EmptyDefaultConstructor: + active: true + EmptyDoWhileBlock: + active: true + EmptyElseBlock: + active: true + EmptyFinallyBlock: + active: true + EmptyForBlock: + active: true + EmptyFunctionBlock: + active: true + ignoreOverridden: false + EmptyIfBlock: + active: true + EmptyInitBlock: + active: true + EmptyKtFile: + active: true + EmptySecondaryConstructor: + active: true + EmptyTryBlock: + active: true + EmptyWhenBlock: + active: true + EmptyWhileBlock: + active: true + +exceptions: + active: true + ExceptionRaisedInUnexpectedLocation: + active: true + methodNames: [toString, hashCode, equals, finalize] + InstanceOfCheckForException: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + NotImplementedDeclaration: + active: false + ObjectExtendsThrowable: + active: false + PrintStackTrace: + active: true + RethrowCaughtException: + active: true + ReturnFromFinally: + active: true + ignoreLabeled: false + SwallowedException: + active: false + ignoredExceptionTypes: + - InterruptedException + - NumberFormatException + - ParseException + - MalformedURLException + allowedExceptionNameRegex: '_|(ignore|expected).*' + ThrowingExceptionFromFinally: + active: true + ThrowingExceptionInMain: + active: false + ThrowingExceptionsWithoutMessageOrCause: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + exceptions: + - IllegalArgumentException + - IllegalStateException + - IOException + ThrowingNewInstanceOfSameException: + active: true + TooGenericExceptionCaught: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + exceptionNames: + - ArrayIndexOutOfBoundsException + - Error + - Exception + - IllegalMonitorStateException + - NullPointerException + - IndexOutOfBoundsException + - RuntimeException + - Throwable + allowedExceptionNameRegex: '_|(ignore|expected).*' + TooGenericExceptionThrown: + active: true + exceptionNames: + - Error + - Exception + - Throwable + - RuntimeException + +naming: + active: true + ClassNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + classPattern: '[A-Z][a-zA-Z0-9]*' + ConstructorParameterNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + parameterPattern: '[a-z][A-Za-z0-9]*' + privateParameterPattern: '[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + ignoreOverridden: true + EnumNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' + ForbiddenClassName: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + forbiddenName: [] + FunctionMaxLength: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + maximumFunctionNameLength: 30 + FunctionMinLength: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + minimumFunctionNameLength: 3 + FunctionNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' + excludeClassPattern: '$^' + ignoreOverridden: true + ignoreAnnotated: ['Composable'] + FunctionParameterNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + parameterPattern: '[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + ignoreOverridden: true + InvalidPackageDeclaration: + active: false + excludes: ['*.kts'] + rootPackage: '' + MatchingDeclarationName: + active: true + mustBeFirst: true + MemberNameEqualsClassName: + active: true + ignoreOverridden: true + NoNameShadowing: + active: false + NonBooleanPropertyPrefixedWithIs: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + ObjectPropertyNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + constantPattern: '[A-Za-z][_A-Za-z0-9]*' + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' + PackageNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' + TopLevelPropertyNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + constantPattern: '[A-Z][_A-Z0-9]*' + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' + VariableMaxLength: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + maximumVariableNameLength: 64 + VariableMinLength: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + minimumVariableNameLength: 1 + VariableNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + variablePattern: '[a-z][A-Za-z0-9]*' + privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + ignoreOverridden: true + +performance: + active: true + ArrayPrimitive: + active: true + ForEachOnRange: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + SpreadOperator: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + UnnecessaryTemporaryInstantiation: + active: true + +potential-bugs: + active: true + CastToNullableType: + active: false + Deprecation: + active: false + DontDowncastCollectionTypes: + active: false + DoubleMutabilityForCollection: + active: false + DuplicateCaseInWhenExpression: + active: true + EqualsAlwaysReturnsTrueOrFalse: + active: true + EqualsWithHashCodeExist: + active: true + ExitOutsideMain: + active: false + ExplicitGarbageCollectionCall: + active: true + HasPlatformType: + active: false + IgnoredReturnValue: + active: false + restrictToAnnotatedMethods: true + returnValueAnnotations: ['*.CheckReturnValue', '*.CheckResult'] + ImplicitDefaultLocale: + active: true + ImplicitUnitReturnType: + active: false + allowExplicitReturnType: true + InvalidRange: + active: true + IteratorHasNextCallsNextMethod: + active: true + IteratorNotThrowingNoSuchElementException: + active: true + LateinitUsage: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + ignoreAnnotated: [] + ignoreOnClassesPattern: '' + MapGetWithNotNullAssertionOperator: + active: false + MissingWhenCase: + active: true + allowElseExpression: true + NullableToStringCall: + active: false + RedundantElseInWhen: + active: true + UnconditionalJumpStatementInLoop: + active: false + UnnecessaryNotNullOperator: + active: true + UnnecessarySafeCall: + active: true + UnreachableCatchBlock: + active: false + UnreachableCode: + active: true + UnsafeCallOnNullableType: + active: true + UnsafeCast: + active: true + UnusedUnaryOperator: + active: false + UselessPostfixExpression: + active: false + WrongEqualsTypeParameter: + active: true + +style: + active: true + ClassOrdering: + active: false + CollapsibleIfStatements: + active: false + DataClassContainsFunctions: + active: false + conversionFunctionPrefix: 'to' + DataClassShouldBeImmutable: + active: false + DestructuringDeclarationWithTooManyEntries: + active: false + maxDestructuringEntries: 3 + EqualsNullCall: + active: true + EqualsOnSignatureLine: + active: false + ExplicitCollectionElementAccessMethod: + active: false + ExplicitItLambdaParameter: + active: false + ExpressionBodySyntax: + active: false + includeLineWrapping: false + ForbiddenComment: + active: true + values: ['TODO:', 'FIXME:', 'STOPSHIP:'] + allowedPatterns: '' + ForbiddenImport: + active: false + imports: [] + forbiddenPatterns: '' + ForbiddenMethodCall: + active: false + methods: ['kotlin.io.println', 'kotlin.io.print'] + ForbiddenPublicDataClass: + active: true + excludes: ['**'] + ignorePackages: ['*.internal', '*.internal.*'] + ForbiddenVoid: + active: false + ignoreOverridden: false + ignoreUsageInGenerics: false + FunctionOnlyReturningConstant: + active: true + ignoreOverridableFunction: true + ignoreActualFunction: true + excludedFunctions: 'describeContents' + ignoreAnnotated: ['dagger.Provides'] + LibraryCodeMustSpecifyReturnType: + active: true + excludes: ['**'] + LibraryEntitiesShouldNotBePublic: + active: true + excludes: ['**'] + LoopWithTooManyJumpStatements: + active: true + maxJumpCount: 1 + MagicNumber: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/build.gradle.kts'] + ignoreNumbers: ['-1', '0', '1', '2', '3', '10'] + ignoreHashCodeFunction: true + ignorePropertyDeclaration: false + ignoreLocalVariableDeclaration: false + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true + ignoreAnnotation: false + ignoreNamedArgument: true + ignoreEnums: false + ignoreRanges: false + ignoreExtensionFunctions: true + MandatoryBracesIfStatements: + active: false + MandatoryBracesLoops: + active: false + MaxLineLength: + active: true + maxLineLength: 120 + excludePackageStatements: true + excludeImportStatements: true + excludeCommentStatements: true + excludes: ['**/commonTest/**Json**',] + MayBeConst: + active: true + ModifierOrder: + active: true + MultilineLambdaItParameter: + active: false + NestedClassesVisibility: + active: true + NewLineAtEndOfFile: + active: true + NoTabs: + active: false + ObjectLiteralToLambda: + active: false + OptionalAbstractKeyword: + active: true + OptionalUnit: + active: false + OptionalWhenBraces: + active: false + PreferToOverPairSyntax: + active: false + ProtectedMemberInFinalClass: + active: true + RedundantExplicitType: + active: false + RedundantHigherOrderMapUsage: + active: false + RedundantVisibilityModifierRule: + active: false + ReturnCount: + active: true + max: 2 + excludedFunctions: 'equals' + excludeLabeled: false + excludeReturnFromLambda: true + excludeGuardClauses: false + SafeCast: + active: true + SerialVersionUIDInSerializableClass: + active: true + SpacingBetweenPackageAndImports: + active: false + ThrowsCount: + active: true + max: 2 + TrailingWhitespace: + active: false + UnderscoresInNumericLiterals: + active: false + acceptableLength: 5 + UnnecessaryAbstractClass: + active: true + ignoreAnnotated: ['Module'] + UnnecessaryAnnotationUseSiteTarget: + active: false + UnnecessaryApply: + active: true + UnnecessaryFilter: + active: false + UnnecessaryInheritance: + active: true + UnnecessaryLet: + active: false + UnnecessaryParentheses: + active: false + UntilInsteadOfRangeTo: + active: false + UnusedImports: + active: false + UnusedPrivateClass: + active: true + UnusedPrivateMember: + active: false + allowedNames: '(_|ignored|expected|serialVersionUID)' + UseArrayLiteralsInAnnotations: + active: false + UseCheckNotNull: + active: false + UseCheckOrError: + active: false + UseDataClass: + active: false + ignoreAnnotated: [] + allowVars: false + UseEmptyCounterpart: + active: false + UseIfEmptyOrIfBlank: + active: false + UseIfInsteadOfWhen: + active: false + UseIsNullOrEmpty: + active: false + UseOrEmpty: + active: false + UseRequire: + active: false + UseRequireNotNull: + active: false + UselessCallOnNotNull: + active: true + UtilityClassWithPublicConstructor: + active: true + VarCouldBeVal: + active: true + WildcardImport: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + excludeImports: ['java.util.*', 'kotlinx.android.synthetic.*'] \ No newline at end of file From e6c7658e97fc16465806c6030ac8e3adb08f4f75 Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 16:14:52 -0600 Subject: [PATCH 09/10] Add Docs --- docs/StaticCodeAnalysis.md | 39 ++++++++++++++++++++++++++++++++++++++ docs/VersionsPlugin.md | 14 ++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 docs/StaticCodeAnalysis.md create mode 100644 docs/VersionsPlugin.md diff --git a/docs/StaticCodeAnalysis.md b/docs/StaticCodeAnalysis.md new file mode 100644 index 0000000..2aec43d --- /dev/null +++ b/docs/StaticCodeAnalysis.md @@ -0,0 +1,39 @@ +# Static Code Analysis + +This project uses static code analysis in order to ensure that the codebase meets certain standards +that can be verified through automation. Two of these libraries used throughout this project are +Detekt and Ktlint. + +## Detekt + +[Detekt](https://github.com/detekt/detekt) is a static analysis tool that checks for code smells. +Examples include magic numbers, complicated conditionals, long methods, long parameter lists, and so +much more. It is highly configurable, and if you choose to turn off any checks or customize +thresholds you can do so in the [config file](/config/detekt/detekt.yml). + +To run a detekt validation, use the following Gradle command: + +``` +./gradlew detekt +``` + +## Ktlint + +[Ktlint](https://github.com/pinterest/ktlint) is a static analysis tool from Pinterest that prevents +bike shedding when it comes to code formatting. It also comes with a Gradle task to automatically +format your entire codebase, if it can. The benefit of a tool like this is to ensure everyone on the +team will have code formatted the same way, and there's no debating around white spaces, +indentation, imports, etc. + +We use the [JLLeitschuh](https://github.com/jlleitschuh/ktlint-gradle) Ktlint Gradle plugin in this +project. You can find the setup in [this Gradle file](/buildscripts/ktlint.gradle). + +The following Gradle commands can be helpful: + +``` +// Format the Codebase +./gradlew ktlintFormat + +// Check if everything is formatted correctly +./gradlew ktlintCheck +``` \ No newline at end of file diff --git a/docs/VersionsPlugin.md b/docs/VersionsPlugin.md new file mode 100644 index 0000000..25cc06f --- /dev/null +++ b/docs/VersionsPlugin.md @@ -0,0 +1,14 @@ +# Versions Plugin + +This project uses the [Gradle Versions Plugin](https://github.com/ben-manes/gradle-versions-plugin) +from Ben Manes. Ths is an extremely helpful plugin that will check all of the dependencies in the +project, and see if they have any new versions. Currently, it is configured to only check for stable +versions, but you can customize that inside [this Gradle file](/buildscripts/versions.gradle). + +To run this check of dependency updates, use the following Gradle command: + +``` +./gradlew dependencyUpdates +``` + +This will print the updates to the console, as well as in a text file. \ No newline at end of file From a65e619d2aa1e3dd03d3a3626a0c9db7be5eadcd Mon Sep 17 00:00:00 2001 From: Jon Areas Date: Thu, 22 Dec 2022 16:28:21 -0600 Subject: [PATCH 10/10] Add Requirements to README --- LEARN.md | 12 +++---- README.md | 31 ++++++++++++++---- app/build.gradle.kts | 1 + {readme => assets}/gifs/bottom_sheet.gif | Bin .../gifs/date_selector_dialog.gif | Bin .../gifs/top_destination_transition.gif | Bin {readme => assets}/gifs/transition.gif | Bin {readme => assets}/images/account_filter.png | Bin .../images/account_filter_dark.png | Bin {readme => assets}/images/accounts.png | Bin {readme => assets}/images/accounts_dark.png | Bin {readme => assets}/images/chart.png | Bin {readme => assets}/images/chart_dark.png | Bin .../images/clean_architecture.png | Bin {readme => assets}/images/converter.png | Bin {readme => assets}/images/converter_dark.png | Bin {readme => assets}/images/date_filter.png | Bin .../images/date_filter_dark.png | Bin {readme => assets}/images/settings.png | Bin {readme => assets}/images/settings_dark.png | Bin {readme => assets}/images/transactions.png | Bin .../images/transactions_dark.png | Bin {readme => assets}/logo/black.svg | 0 {readme => assets}/logo/blue.svg | 0 {readme => assets}/logo/green.svg | 0 {readme => assets}/logo/white.svg | 0 26 files changed, 31 insertions(+), 13 deletions(-) rename {readme => assets}/gifs/bottom_sheet.gif (100%) rename {readme => assets}/gifs/date_selector_dialog.gif (100%) rename {readme => assets}/gifs/top_destination_transition.gif (100%) rename {readme => assets}/gifs/transition.gif (100%) rename {readme => assets}/images/account_filter.png (100%) rename {readme => assets}/images/account_filter_dark.png (100%) rename {readme => assets}/images/accounts.png (100%) rename {readme => assets}/images/accounts_dark.png (100%) rename {readme => assets}/images/chart.png (100%) rename {readme => assets}/images/chart_dark.png (100%) rename {readme => assets}/images/clean_architecture.png (100%) rename {readme => assets}/images/converter.png (100%) rename {readme => assets}/images/converter_dark.png (100%) rename {readme => assets}/images/date_filter.png (100%) rename {readme => assets}/images/date_filter_dark.png (100%) rename {readme => assets}/images/settings.png (100%) rename {readme => assets}/images/settings_dark.png (100%) rename {readme => assets}/images/transactions.png (100%) rename {readme => assets}/images/transactions_dark.png (100%) rename {readme => assets}/logo/black.svg (100%) rename {readme => assets}/logo/blue.svg (100%) rename {readme => assets}/logo/green.svg (100%) rename {readme => assets}/logo/white.svg (100%) diff --git a/LEARN.md b/LEARN.md index 120aca4..480bbbd 100644 --- a/LEARN.md +++ b/LEARN.md @@ -34,7 +34,7 @@ Some of the APIs and Motion Patterns used all around this app are [*ObjectAnimat Bottom Items | Settings Menu | Date Selector Dialog | Expense Bottom Sheet | :------:|:---------------------:|:-----------------------------:|:-------------:| -![](./readme/gifs/top_destination_transition.gif) | ![](./readme/gifs/transition.gif) | ![](./readme/gifs/date_selector_dialog.gif) | ![](./readme/gifs/bottom_sheet.gif) +![](assets/gifs/top_destination_transition.gif) | ![](assets/gifs/transition.gif) | ![](assets/gifs/date_selector_dialog.gif) | ![](assets/gifs/bottom_sheet.gif) ## ๐Ÿ“ท Screenshots ๐Ÿ“ท @@ -42,13 +42,13 @@ This Project uses [**Material 3**](https://m3.material.io/), the latest version | Accounts List | Expenses | Expenses Chart | | ------------- | ------------- | ------------- | -| ![](./readme/images/accounts.png) | ![](./readme/images/transactions.png) | ![](./readme/images/chart.png) | -| ![](./readme/images/accounts_dark.png) | ![](./readme/images/transactions_dark.png) | ![](./readme/images/chart_dark.png) | +| ![](assets/images/accounts.png) | ![](assets/images/transactions.png) | ![](assets/images/chart.png) | +| ![](assets/images/accounts_dark.png) | ![](assets/images/transactions_dark.png) | ![](assets/images/chart_dark.png) | | Account Filter | Date Selector | Settings | | ------------- | ------------- | ------------- | -| ![](./readme/images/account_filter.png) | ![](./readme/images/date_filter.png) | ![](./readme/images/settings.png) | -| ![](./readme/images/account_filter_dark.png) | ![](./readme/images/date_filter_dark.png) | ![](./readme/images/settings_dark.png) | +| ![](assets/images/account_filter.png) | ![](assets/images/date_filter.png) | ![](assets/images/settings.png) | +| ![](assets/images/account_filter_dark.png) | ![](assets/images/date_filter_dark.png) | ![](assets/images/settings_dark.png) | ## ๐Ÿ›  Architecture ๐Ÿ›  @@ -61,7 +61,7 @@ The architecture used in this project is that of Clean Architecture, sticking to **3. Data:** Dispenses data to the app, which can be local (SQLLite Database) or remote (API). -![clean_architecture](./readme/images/clean_architecture.png) +![clean_architecture](assets/images/clean_architecture.png) ## โš™๏ธ Technologies โš™๏ธ diff --git a/README.md b/README.md index 074f874..fc7392c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@
- Logo + Logo

@@ -13,6 +13,8 @@
Screenshots ยท + Requirements + ยท Architecture ยท Technologies @@ -34,7 +36,7 @@ Some of the APIs and Motion Patterns used all around this app are [*ObjectAnimat Bottom Items | Settings Menu | Date Selector Dialog | Expense Bottom Sheet | :------:|:---------------------:|:-----------------------------:|:-------------:| -![](./readme/gifs/top_destination_transition.gif) | ![](./readme/gifs/transition.gif) | ![](./readme/gifs/date_selector_dialog.gif) | ![](./readme/gifs/bottom_sheet.gif) +![](assets/gifs/top_destination_transition.gif) | ![](assets/gifs/transition.gif) | ![](assets/gifs/date_selector_dialog.gif) | ![](assets/gifs/bottom_sheet.gif) ## ๐Ÿ“ท Screenshots ๐Ÿ“ท @@ -42,14 +44,29 @@ This Project uses [**Material 3**](https://m3.material.io/), the latest version | Accounts List | Expenses | Expenses Chart | | ------------- | ------------- | ------------- | -| ![](./readme/images/accounts.png) | ![](./readme/images/transactions.png) | ![](./readme/images/chart.png) | -| ![](./readme/images/accounts_dark.png) | ![](./readme/images/transactions_dark.png) | ![](./readme/images/chart_dark.png) | +| ![](assets/images/accounts.png) | ![](assets/images/transactions.png) | ![](assets/images/chart.png) | +| ![](assets/images/accounts_dark.png) | ![](assets/images/transactions_dark.png) | ![](assets/images/chart_dark.png) | | Account Filter | Date Selector | Settings | | ------------- | ------------- | ------------- | -| ![](./readme/images/account_filter.png) | ![](./readme/images/date_filter.png) | ![](./readme/images/settings.png) | -| ![](./readme/images/account_filter_dark.png) | ![](./readme/images/date_filter_dark.png) | ![](./readme/images/settings_dark.png) | +| ![](assets/images/account_filter.png) | ![](assets/images/date_filter.png) | ![](assets/images/settings.png) | +| ![](assets/images/account_filter_dark.png) | ![](assets/images/date_filter_dark.png) | ![](assets/images/settings_dark.png) | + +## ๐Ÿ“ Requirements ๐Ÿ“ + +This project uses the [Currency API](https://currencyapi.com/) in order to convert currencies. +Hence, in order to run this project it is necessary to specify the API keys in the `local.properties` file, in the following way: +```groovy +CURRENCY_API_KEY = "ReplaceThisForYourApiKey" +``` +These fields are later on read in order to generate `BuildConfig` fields in the code, in the `build.gradle.kts` file from the App Module, in the following way: +```kotlin +// Read CURRENCY_API_TOKEN key from local.properties +val currencyApiToken: String = gradleLocalProperties(rootDir).getProperty(currencyApiKey) +buildConfigField("String", currencyApiKey, currencyApiToken) +``` +For more information, feel free to [visit the website](https://currencyapi.com/). ## ๐Ÿ›  Architecture ๐Ÿ›  @@ -61,7 +78,7 @@ The architecture used in this project is that of Clean Architecture, sticking to **3. Data:** Dispenses data to the app, which can be local (SQLLite Database) or remote (API). -![clean_architecture](./readme/images/clean_architecture.png) +![clean_architecture](assets/images/clean_architecture.png) ## โš™๏ธ Technologies โš™๏ธ diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4233758..d0ce946 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -23,6 +23,7 @@ android { testInstrumentationRunner = ProjectProperties.TEST_RUNNER val currencyApiKey = ProjectProperties.CURRENCY_API_KEY + // Read CURRENCY_API_TOKEN key from local.properties val currencyApiToken: String = gradleLocalProperties(rootDir).getProperty(currencyApiKey) buildConfigField("String", currencyApiKey, currencyApiToken) } diff --git a/readme/gifs/bottom_sheet.gif b/assets/gifs/bottom_sheet.gif similarity index 100% rename from readme/gifs/bottom_sheet.gif rename to assets/gifs/bottom_sheet.gif diff --git a/readme/gifs/date_selector_dialog.gif b/assets/gifs/date_selector_dialog.gif similarity index 100% rename from readme/gifs/date_selector_dialog.gif rename to assets/gifs/date_selector_dialog.gif diff --git a/readme/gifs/top_destination_transition.gif b/assets/gifs/top_destination_transition.gif similarity index 100% rename from readme/gifs/top_destination_transition.gif rename to assets/gifs/top_destination_transition.gif diff --git a/readme/gifs/transition.gif b/assets/gifs/transition.gif similarity index 100% rename from readme/gifs/transition.gif rename to assets/gifs/transition.gif diff --git a/readme/images/account_filter.png b/assets/images/account_filter.png similarity index 100% rename from readme/images/account_filter.png rename to assets/images/account_filter.png diff --git a/readme/images/account_filter_dark.png b/assets/images/account_filter_dark.png similarity index 100% rename from readme/images/account_filter_dark.png rename to assets/images/account_filter_dark.png diff --git a/readme/images/accounts.png b/assets/images/accounts.png similarity index 100% rename from readme/images/accounts.png rename to assets/images/accounts.png diff --git a/readme/images/accounts_dark.png b/assets/images/accounts_dark.png similarity index 100% rename from readme/images/accounts_dark.png rename to assets/images/accounts_dark.png diff --git a/readme/images/chart.png b/assets/images/chart.png similarity index 100% rename from readme/images/chart.png rename to assets/images/chart.png diff --git a/readme/images/chart_dark.png b/assets/images/chart_dark.png similarity index 100% rename from readme/images/chart_dark.png rename to assets/images/chart_dark.png diff --git a/readme/images/clean_architecture.png b/assets/images/clean_architecture.png similarity index 100% rename from readme/images/clean_architecture.png rename to assets/images/clean_architecture.png diff --git a/readme/images/converter.png b/assets/images/converter.png similarity index 100% rename from readme/images/converter.png rename to assets/images/converter.png diff --git a/readme/images/converter_dark.png b/assets/images/converter_dark.png similarity index 100% rename from readme/images/converter_dark.png rename to assets/images/converter_dark.png diff --git a/readme/images/date_filter.png b/assets/images/date_filter.png similarity index 100% rename from readme/images/date_filter.png rename to assets/images/date_filter.png diff --git a/readme/images/date_filter_dark.png b/assets/images/date_filter_dark.png similarity index 100% rename from readme/images/date_filter_dark.png rename to assets/images/date_filter_dark.png diff --git a/readme/images/settings.png b/assets/images/settings.png similarity index 100% rename from readme/images/settings.png rename to assets/images/settings.png diff --git a/readme/images/settings_dark.png b/assets/images/settings_dark.png similarity index 100% rename from readme/images/settings_dark.png rename to assets/images/settings_dark.png diff --git a/readme/images/transactions.png b/assets/images/transactions.png similarity index 100% rename from readme/images/transactions.png rename to assets/images/transactions.png diff --git a/readme/images/transactions_dark.png b/assets/images/transactions_dark.png similarity index 100% rename from readme/images/transactions_dark.png rename to assets/images/transactions_dark.png diff --git a/readme/logo/black.svg b/assets/logo/black.svg similarity index 100% rename from readme/logo/black.svg rename to assets/logo/black.svg diff --git a/readme/logo/blue.svg b/assets/logo/blue.svg similarity index 100% rename from readme/logo/blue.svg rename to assets/logo/blue.svg diff --git a/readme/logo/green.svg b/assets/logo/green.svg similarity index 100% rename from readme/logo/green.svg rename to assets/logo/green.svg diff --git a/readme/logo/white.svg b/assets/logo/white.svg similarity index 100% rename from readme/logo/white.svg rename to assets/logo/white.svg