Skip to content

Commit

Permalink
Improve package structure, refactor Manage Symptoms Screen (#204)
Browse files Browse the repository at this point in the history
* Move files into packages

* cleanup

* Use ViewModel

* Don't close database. If parallel requests to the database are ongoing, closing the db results in crashes

* add todos

* Improve fab height consistency, cleanup

* Fix wrong insets

* Use shapes, extract constant

* Extract item

* Introduce UiAction class to enable previewing of composables

* Move some other files

* Only allow symptom creation when name is specified

* Remove db.close calls

* Cleanup

* Cleanup
  • Loading branch information
carstenhag authored Jan 30, 2025
1 parent bdd54a9 commit e096295
Show file tree
Hide file tree
Showing 35 changed files with 608 additions and 471 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/com/mensinator/app/App.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.mensinator.app

import android.app.Application
import com.mensinator.app.business.*
import com.mensinator.app.settings.SettingsViewModel
import com.mensinator.app.statistics.StatisticsViewModel
import com.mensinator.app.symptoms.ManageSymptomsViewModel
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
Expand All @@ -22,6 +24,7 @@ class App : Application() {
singleOf(::ExportImport) { bind<IExportImport>() }
singleOf(::NotificationScheduler) { bind<INotificationScheduler>() }

viewModel { ManageSymptomsViewModel(get()) }
viewModel { SettingsViewModel(get(), get(), get()) }
viewModel { StatisticsViewModel(get(), get(), get(), get(), get()) }
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/mensinator/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.WindowManager
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.mensinator.app.navigation.MensinatorApp
import com.mensinator.app.ui.navigation.MensinatorApp
import com.mensinator.app.ui.theme.MensinatorTheme

class MainActivity : AppCompatActivity() {
Expand Down
275 changes: 0 additions & 275 deletions app/src/main/java/com/mensinator/app/ManageSymptomScreen.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

import android.util.Log
import com.mensinator.app.extensions.roundToTwoDecimalPoints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

import android.database.sqlite.SQLiteDatabase

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

import android.content.ContentValues
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

import java.time.LocalDate

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

interface IExportImport {
fun getDocumentsExportFilePath(): String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

import java.time.LocalDate

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

import java.time.LocalDate

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.mensinator.app
package com.mensinator.app.business

import android.database.sqlite.SQLiteDatabase
import androidx.annotation.WorkerThread
import com.mensinator.app.data.Symptom
import com.mensinator.app.data.Setting
import java.time.LocalDate

interface IPeriodDatabaseHelper {
Expand Down Expand Up @@ -39,7 +41,7 @@ interface IPeriodDatabaseHelper {
fun updateSymptomDate(dates: List<LocalDate>, symptomId: List<Int>)

// This function is used to get symptoms for a given date
fun getSymptomsFromDate(date: LocalDate): List<Int>
fun getActiveSymptomIdsForDate(date: LocalDate): List<Int>

fun getSymptomColorForDate(date: LocalDate): List<String>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

import java.time.LocalDate

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business


import android.app.AlarmManager
Expand All @@ -7,6 +7,7 @@ import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.core.app.NotificationManagerCompat
import com.mensinator.app.NotificationReceiver
import java.time.LocalDate
import java.time.ZoneId

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mensinator.app
package com.mensinator.app.business

import android.util.Log
import java.time.LocalDate
Expand Down
Loading

0 comments on commit e096295

Please sign in to comment.