diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsUserEntryFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsUserEntryFragment.kt index a0b5d1b169..af2ff771cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsUserEntryFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsUserEntryFragment.kt @@ -68,7 +68,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") { uel.log(Action.EXPORT_CSV, Sources.Treatments) - importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries()) + importExportPrefs.exportUserEntriesCsv(activity) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt index 908d801137..44c26e0c57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefsImpl.kt @@ -15,7 +15,7 @@ import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.DaggerAppCompatActivityWithResult import info.nightscout.androidaps.activities.PreferencesActivity -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.events.EventAppExit @@ -28,6 +28,8 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.maintenance.formats.* import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.MidnightTime +import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.PrefImportSummaryDialog @@ -37,7 +39,6 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.protection.PasswordCheck import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP -import io.reactivex.Single import java.io.File import java.io.FileNotFoundException import java.io.IOException @@ -63,6 +64,7 @@ class ImportExportPrefsImpl @Inject constructor( private val encryptedPrefsFormat: EncryptedPrefsFormat, private val prefFileList: PrefFileListProvider, private val uel: UserEntryLogger, + private val repository: AppRepository, private val dateUtil: DateUtil ) : ImportExportPrefs { @@ -360,8 +362,8 @@ class ImportExportPrefsImpl @Inject constructor( } } - override fun exportUserEntriesCsv(activity: FragmentActivity, singleEntries: Single>) { - val entries = singleEntries.blockingGet() + override fun exportUserEntriesCsv(activity: FragmentActivity) { + val entries = repository.getUserEntryFilteredDataFromTime(MidnightTime.calc() - T.days(90).msecs()).blockingGet() prefFileList.ensureExportDirExists() val newFile = prefFileList.newExportCsvFile() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt index a78575151c..750df25015 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt @@ -118,7 +118,7 @@ class MaintenanceFragment : DaggerFragment() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") { uel.log(Action.EXPORT_CSV, Sources.Maintenance) - importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries()) + importExportPrefs.exportUserEntriesCsv(activity) } } } diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ImportExportPrefs.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ImportExportPrefs.kt index 81782fbb88..95dbb3467f 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/ImportExportPrefs.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ImportExportPrefs.kt @@ -14,5 +14,5 @@ interface ImportExportPrefs { fun prefsFileExists(): Boolean fun verifyStoragePermissions(fragment: Fragment, onGranted: Runnable) fun exportSharedPreferences(f: Fragment) - fun exportUserEntriesCsv(activity: FragmentActivity, singleEntries: Single>) + fun exportUserEntriesCsv(activity: FragmentActivity) } \ No newline at end of file