PrefListProvider interface

This commit is contained in:
Milos Kozak 2022-11-22 00:15:16 +01:00
parent 4513ae6947
commit 325311e865
37 changed files with 89 additions and 51 deletions

View file

@ -3,8 +3,8 @@ package info.nightscout.androidaps.implementations
import android.os.Build import android.os.Build
import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import java.io.File import java.io.File
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton

View file

@ -39,6 +39,7 @@ import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.AndroidPermission import info.nightscout.interfaces.AndroidPermission
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.maintenance.ImportExportPrefs import info.nightscout.interfaces.maintenance.ImportExportPrefs
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.maintenance.PrefFileNotFoundError import info.nightscout.interfaces.maintenance.PrefFileNotFoundError
import info.nightscout.interfaces.maintenance.PrefIOError import info.nightscout.interfaces.maintenance.PrefIOError
import info.nightscout.interfaces.maintenance.PrefMetadata import info.nightscout.interfaces.maintenance.PrefMetadata

View file

@ -9,6 +9,7 @@ import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.logging.LoggerUtils import info.nightscout.interfaces.logging.LoggerUtils
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType

View file

@ -20,8 +20,8 @@ import info.nightscout.androidaps.databinding.OverviewQuickwizardlistActivityBin
import info.nightscout.androidaps.databinding.OverviewQuickwizardlistItemBinding import info.nightscout.androidaps.databinding.OverviewQuickwizardlistItemBinding
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWizardChange import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWizardChange
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.wizard.QuickWizard import info.nightscout.core.wizard.QuickWizard
import info.nightscout.core.wizard.QuickWizardEntry import info.nightscout.core.wizard.QuickWizardEntry

View file

@ -8,21 +8,21 @@ import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.dana.DanaPump import info.nightscout.androidaps.dana.DanaPump
import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.androidaps.danar.DanaRPlugin
import info.nightscout.androidaps.danars.DanaRSPlugin import info.nightscout.androidaps.danars.DanaRSPlugin
import info.nightscout.androidaps.implementations.ConfigImpl
import info.nightscout.androidaps.insight.database.InsightDatabaseDao import info.nightscout.androidaps.insight.database.InsightDatabaseDao
import info.nightscout.androidaps.insight.database.InsightDbHelper import info.nightscout.androidaps.insight.database.InsightDbHelper
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.RuffyScripter import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.RuffyScripter
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.implementations.ConfigImpl
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.constraints.ConstraintsImpl import info.nightscout.implementation.constraints.ConstraintsImpl
import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.constraints.Objectives import info.nightscout.interfaces.constraints.Objectives
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.plugin.PluginType

View file

@ -5,6 +5,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.logging.LoggerUtils import info.nightscout.interfaces.logging.LoggerUtils
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.plugins.sync.nsclient.data.NSSettingsStatus import info.nightscout.plugins.sync.nsclient.data.NSSettingsStatus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP

View file

@ -34,10 +34,6 @@ dependencies {
api "com.google.dagger:dagger-android:$dagger_version" api "com.google.dagger:dagger-android:$dagger_version"
api "com.google.dagger:dagger-android-support:$dagger_version" api "com.google.dagger:dagger-android-support:$dagger_version"
//CryptoUtil
api 'com.madgag.spongycastle:core:1.58.0.0'
api "com.google.crypto.tink:tink-android:$tink_version"
//WorkManager //WorkManager
api "androidx.work:work-runtime:$work_version" // DataWorkerStorage api "androidx.work:work-runtime:$work_version" // DataWorkerStorage
} }

View file

@ -11,12 +11,12 @@ import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerAppCompatActivity import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.main.databinding.MaintenanceImportListActivityBinding import info.nightscout.core.main.databinding.MaintenanceImportListActivityBinding
import info.nightscout.core.main.databinding.MaintenanceImportListItemBinding import info.nightscout.core.main.databinding.MaintenanceImportListItemBinding
import info.nightscout.interfaces.locale.LocaleHelper import info.nightscout.interfaces.locale.LocaleHelper
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.maintenance.PrefsFile import info.nightscout.interfaces.maintenance.PrefsFile
import info.nightscout.interfaces.maintenance.PrefsMetadataKey import info.nightscout.interfaces.maintenance.PrefsMetadataKey
import info.nightscout.interfaces.maintenance.PrefsStatus import info.nightscout.interfaces.maintenance.PrefsStatus

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.maintenance.formats package info.nightscout.androidaps.plugins.general.maintenance.formats
import info.nightscout.androidaps.utils.CryptoUtil
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.utils.CryptoUtil
import info.nightscout.core.utils.hexStringToByteArray import info.nightscout.core.utils.hexStringToByteArray
import info.nightscout.core.utils.toHex import info.nightscout.core.utils.toHex
import info.nightscout.interfaces.maintenance.PrefFileNotFoundError import info.nightscout.interfaces.maintenance.PrefFileNotFoundError

View file

@ -12,10 +12,10 @@ import android.widget.EditText
import android.widget.TextView import android.widget.TextView
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.androidaps.utils.CryptoUtil
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.CryptoUtil
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import java.io.File import java.io.File

View file

@ -2,9 +2,9 @@ package info.nightscout.core.di
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
import info.nightscout.androidaps.utils.CryptoUtil import info.nightscout.core.utils.CryptoUtil
import info.nightscout.interfaces.maintenance.PrefFileListProvider
@Module @Module
@Suppress("unused") @Suppress("unused")

View file

@ -479,11 +479,6 @@
<string name="formatPercent">%1$.0f%%</string> <string name="formatPercent">%1$.0f%%</string>
<string name="basal">Basal</string> <string name="basal">Basal</string>
<string name="basalpct">Basal %</string> <string name="basalpct">Basal %</string>
<string name="count_selected">%1$d selected</string>
<string name="sort_label">Sort</string>
<string name="remove_items">Remove Items</string>
<string name="sort_items">Sort Items</string>
<string name="remove_selected_items">Remove Selected Items</string>
<string name="a11y_file">file</string> <string name="a11y_file">file</string>
<string name="a11y_user">user</string> <string name="a11y_user">user</string>

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.general.maintenance.formats package info.nightscout.androidaps.plugins.general.maintenance.formats
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.utils.CryptoUtil import info.nightscout.core.utils.CryptoUtil
import info.nightscout.interfaces.maintenance.PrefFormatError import info.nightscout.interfaces.maintenance.PrefFormatError
import info.nightscout.interfaces.maintenance.PrefMetadata import info.nightscout.interfaces.maintenance.PrefMetadata
import info.nightscout.interfaces.maintenance.Prefs import info.nightscout.interfaces.maintenance.Prefs

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.utils package info.nightscout.androidaps.utils
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.core.utils.CryptoUtil
import org.hamcrest.CoreMatchers.containsString import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.CoreMatchers.not import org.hamcrest.CoreMatchers.not
import org.junit.Assert import org.junit.Assert

View file

@ -31,6 +31,10 @@ dependencies {
// api 'com.google.firebase:firebase-auth-ktx' // api 'com.google.firebase:firebase-auth-ktx'
// api 'com.google.firebase:firebase-database-ktx' // api 'com.google.firebase:firebase-database-ktx'
//CryptoUtil
api 'com.madgag.spongycastle:core:1.58.0.0'
api "com.google.crypto.tink:tink-android:$tink_version"
//WorkManager //WorkManager
api "androidx.work:work-runtime:$work_version" // DataWorkerStorage api "androidx.work:work-runtime:$work_version" // DataWorkerStorage
} }

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.utils package info.nightscout.core.utils
import android.util.SparseArray import android.util.SparseArray
import android.view.ActionMode import android.view.ActionMode
@ -7,8 +7,6 @@ import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import info.nightscout.core.main.R
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
class ActionModeHelper<T>(val rh: ResourceHelper, val activity: FragmentActivity?, val fragment: Fragment?) { class ActionModeHelper<T>(val rh: ResourceHelper, val activity: FragmentActivity?, val fragment: Fragment?) {

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.utils package info.nightscout.core.utils
import info.nightscout.core.utils.toHex
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import org.spongycastle.util.encoders.Base64 import org.spongycastle.util.encoders.Base64
import java.nio.ByteBuffer import java.nio.ByteBuffer

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="count_selected">%1$d selected</string>
<string name="remove_items">Remove Items</string>
<string name="sort_items">Sort Items</string>
<string name="remove_selected_items">Remove Selected Items</string>
<string name="sort_label">Sort</string>
</resources>

View file

@ -1,19 +1,25 @@
package info.nightscout.implementation.di package info.nightscout.implementation.di
import android.content.Context import android.content.Context
import dagger.Lazy
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.HardLimitsImpl import info.nightscout.implementation.HardLimitsImpl
import info.nightscout.implementation.logging.LoggerUtilsImpl import info.nightscout.implementation.logging.LoggerUtilsImpl
import info.nightscout.implementation.maintenance.PrefFileListProviderImpl
import info.nightscout.implementation.profiling.ProfilerImpl import info.nightscout.implementation.profiling.ProfilerImpl
import info.nightscout.implementation.pump.WarnColorsImpl import info.nightscout.implementation.pump.WarnColorsImpl
import info.nightscout.implementation.resources.ResourceHelperImpl import info.nightscout.implementation.resources.ResourceHelperImpl
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.logging.LoggerUtils import info.nightscout.interfaces.logging.LoggerUtils
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.profiling.Profiler import info.nightscout.interfaces.profiling.Profiler
import info.nightscout.interfaces.pump.WarnColors import info.nightscout.interfaces.pump.WarnColors
import info.nightscout.interfaces.storage.Storage
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
@ -51,4 +57,15 @@ open class ImplementationModule {
@Provides @Provides
@Singleton @Singleton
fun provideLoggerUtils(prefFileListProvider: PrefFileListProvider): LoggerUtils = LoggerUtilsImpl(prefFileListProvider) fun provideLoggerUtils(prefFileListProvider: PrefFileListProvider): LoggerUtils = LoggerUtilsImpl(prefFileListProvider)
@Provides
@Singleton
fun providePrefFileListProvider(
rh: ResourceHelper,
config: Lazy<Config>,
encryptedPrefsFormat: EncryptedPrefsFormat,
storage: Storage,
versionCheckerUtils: VersionCheckerUtils,
context: Context
): PrefFileListProvider = PrefFileListProviderImpl(rh, config, encryptedPrefsFormat, storage, versionCheckerUtils, context)
} }

View file

@ -2,8 +2,8 @@ package info.nightscout.implementation.logging
import dagger.Reusable import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import info.nightscout.interfaces.logging.LoggerUtils import info.nightscout.interfaces.logging.LoggerUtils
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import javax.inject.Inject import javax.inject.Inject
/** /**

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.maintenance package info.nightscout.implementation.maintenance
import android.content.Context import android.content.Context
import android.os.Environment import android.os.Environment
@ -8,6 +8,7 @@ import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionChec
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.maintenance.PrefMetadata import info.nightscout.interfaces.maintenance.PrefMetadata
import info.nightscout.interfaces.maintenance.PrefMetadataMap import info.nightscout.interfaces.maintenance.PrefMetadataMap
import info.nightscout.interfaces.maintenance.PrefsFile import info.nightscout.interfaces.maintenance.PrefsFile
@ -29,20 +30,20 @@ import kotlin.math.abs
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
@OpenForTesting @OpenForTesting
@Singleton @Singleton
class PrefFileListProvider @Inject constructor( class PrefFileListProviderImpl @Inject constructor(
private val rh: ResourceHelper, private val rh: ResourceHelper,
private val config: Lazy<Config>, private val config: Lazy<Config>,
private val encryptedPrefsFormat: EncryptedPrefsFormat, private val encryptedPrefsFormat: EncryptedPrefsFormat,
private val storage: Storage, private val storage: Storage,
private val versionCheckerUtils: VersionCheckerUtils, private val versionCheckerUtils: VersionCheckerUtils,
context: Context context: Context
) { ) : PrefFileListProvider {
private val path = File(Environment.getExternalStorageDirectory().toString()) private val path = File(Environment.getExternalStorageDirectory().toString())
private val aapsPath = File(path, "AAPS" + File.separator + "preferences") private val aapsPath = File(path, "AAPS" + File.separator + "preferences")
private val exportsPath = File(path, "AAPS" + File.separator + "exports") private val exportsPath = File(path, "AAPS" + File.separator + "exports")
private val tempPath = File(path, "AAPS" + File.separator + "temp") private val tempPath = File(path, "AAPS" + File.separator + "temp")
private val extraPath = File(path, "AAPS" + File.separator + "extra") private val extraPath = File(path, "AAPS" + File.separator + "extra")
val logsPath: String = File(path, "AAPS" + File.separator + "logs" + File.separator + context.packageName).absolutePath override val logsPath: String = File(path, "AAPS" + File.separator + "logs" + File.separator + context.packageName).absolutePath
companion object { companion object {
@ -56,7 +57,7 @@ class PrefFileListProvider @Inject constructor(
* - file name and extension * - file name and extension
* - predicted file contents * - predicted file contents
*/ */
fun listPreferenceFiles(loadMetadata: Boolean = false): MutableList<PrefsFile> { override fun listPreferenceFiles(loadMetadata: Boolean): MutableList<PrefsFile> {
val prefFiles = mutableListOf<PrefsFile>() val prefFiles = mutableListOf<PrefsFile>()
// searching rood dir for legacy files // searching rood dir for legacy files
@ -94,7 +95,7 @@ class PrefFileListProvider @Inject constructor(
return checkMetadata(encryptedPrefsFormat.loadMetadata(contents)) return checkMetadata(encryptedPrefsFormat.loadMetadata(contents))
} }
fun ensureExportDirExists(): File { override fun ensureExportDirExists(): File {
if (!aapsPath.exists()) { if (!aapsPath.exists()) {
aapsPath.mkdirs() aapsPath.mkdirs()
} }
@ -104,32 +105,32 @@ class PrefFileListProvider @Inject constructor(
return exportsPath return exportsPath
} }
fun ensureTempDirExists(): File { override fun ensureTempDirExists(): File {
if (!tempPath.exists()) { if (!tempPath.exists()) {
tempPath.mkdirs() tempPath.mkdirs()
} }
return tempPath return tempPath
} }
fun ensureExtraDirExists(): File { override fun ensureExtraDirExists(): File {
if (!extraPath.exists()) { if (!extraPath.exists()) {
extraPath.mkdirs() extraPath.mkdirs()
} }
return extraPath return extraPath
} }
fun newExportFile(): File { override fun newExportFile(): File {
val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss")) val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss"))
return File(aapsPath, timeLocal + "_" + config.get().FLAVOR + ".json") return File(aapsPath, timeLocal + "_" + config.get().FLAVOR + ".json")
} }
fun newExportCsvFile(): File { override fun newExportCsvFile(): File {
val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss")) val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss"))
return File(exportsPath, timeLocal + "_UserEntry.csv") return File(exportsPath, timeLocal + "_UserEntry.csv")
} }
// check metadata for known issues, change their status and add info with explanations // check metadata for known issues, change their status and add info with explanations
fun checkMetadata(metadata: Map<PrefsMetadataKey, PrefMetadata>): Map<PrefsMetadataKey, PrefMetadata> { override fun checkMetadata(metadata: Map<PrefsMetadataKey, PrefMetadata>): Map<PrefsMetadataKey, PrefMetadata> {
val meta = metadata.toMutableMap() val meta = metadata.toMutableMap()
meta[PrefsMetadataKey.AAPS_FLAVOUR]?.let { flavour -> meta[PrefsMetadataKey.AAPS_FLAVOUR]?.let { flavour ->
@ -182,7 +183,7 @@ class PrefFileListProvider @Inject constructor(
return meta return meta
} }
fun formatExportedAgo(utcTime: String): String { override fun formatExportedAgo(utcTime: String): String {
val refTime = DateTime.now() val refTime = DateTime.now()
val itTime = DateTime.parse(utcTime) val itTime = DateTime.parse(utcTime)
val days = Days.daysBetween(itTime, refTime).days val days = Days.daysBetween(itTime, refTime).days

View file

@ -0,0 +1,16 @@
package info.nightscout.interfaces.maintenance
import java.io.File
interface PrefFileListProvider {
val logsPath: String
fun ensureTempDirExists(): File
fun ensureExportDirExists(): File
fun ensureExtraDirExists(): File
fun newExportFile(): File
fun newExportCsvFile(): File
fun listPreferenceFiles(loadMetadata: Boolean = false): MutableList<PrefsFile>
fun checkMetadata(metadata: Map<PrefsMetadataKey, PrefMetadata>): Map<PrefsMetadataKey, PrefMetadata>
fun formatExportedAgo(utcTime: String): String
}

View file

@ -24,7 +24,6 @@ import androidx.recyclerview.widget.RecyclerView
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.automation.databinding.AutomationEventItemBinding import info.nightscout.automation.databinding.AutomationEventItemBinding
import info.nightscout.automation.databinding.AutomationFragmentBinding import info.nightscout.automation.databinding.AutomationFragmentBinding
import info.nightscout.automation.dialogs.EditEventDialog import info.nightscout.automation.dialogs.EditEventDialog
@ -32,6 +31,7 @@ import info.nightscout.automation.events.EventAutomationDataChanged
import info.nightscout.automation.events.EventAutomationUpdateGui import info.nightscout.automation.events.EventAutomationUpdateGui
import info.nightscout.automation.triggers.TriggerConnector import info.nightscout.automation.triggers.TriggerConnector
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.UserEntry.Sources

View file

@ -118,7 +118,6 @@
<string name="remove_selected_items">Remove selected items</string> <string name="remove_selected_items">Remove selected items</string>
<string name="count_selected">%1$d selected</string> <string name="count_selected">%1$d selected</string>
<string name="confirm_remove_multiple_items">Are you sure you want to remove %1$d items</string> <string name="confirm_remove_multiple_items">Are you sure you want to remove %1$d items</string>
<string name="sort_label">Sort</string>
<string name="system_automation">System automation</string> <string name="system_automation">System automation</string>
<string name="run_automations">Run automations</string> <string name="run_automations">Run automations</string>
<string name="add_automation">Add rule</string> <string name="add_automation">Add rule</string>

View file

@ -8,7 +8,6 @@ import android.provider.Settings
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.utils.CryptoUtil
import info.nightscout.configuration.R import info.nightscout.configuration.R
import info.nightscout.configuration.setupwizard.elements.SWBreak import info.nightscout.configuration.setupwizard.elements.SWBreak
import info.nightscout.configuration.setupwizard.elements.SWButton import info.nightscout.configuration.setupwizard.elements.SWButton
@ -23,6 +22,7 @@ import info.nightscout.configuration.setupwizard.elements.SWInfoText
import info.nightscout.configuration.setupwizard.elements.SWPlugin import info.nightscout.configuration.setupwizard.elements.SWPlugin
import info.nightscout.configuration.setupwizard.elements.SWPreference import info.nightscout.configuration.setupwizard.elements.SWPreference
import info.nightscout.configuration.setupwizard.elements.SWRadioButton import info.nightscout.configuration.setupwizard.elements.SWRadioButton
import info.nightscout.core.utils.CryptoUtil
import info.nightscout.core.utils.isRunningTest import info.nightscout.core.utils.isRunningTest
import info.nightscout.interfaces.AndroidPermission import info.nightscout.interfaces.AndroidPermission
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config

View file

@ -10,9 +10,9 @@ import android.widget.EditText
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.utils.CryptoUtil
import info.nightscout.configuration.R import info.nightscout.configuration.R
import info.nightscout.configuration.setupwizard.SWTextValidator import info.nightscout.configuration.setupwizard.SWTextValidator
import info.nightscout.core.utils.CryptoUtil
import info.nightscout.shared.extensions.toVisibility import info.nightscout.shared.extensions.toVisibility
class SWEditEncryptedPassword(injector: HasAndroidInjector, private val cryptoUtil: CryptoUtil) : SWItem(injector, Type.STRING) { class SWEditEncryptedPassword(injector: HasAndroidInjector, private val cryptoUtil: CryptoUtil) : SWItem(injector, Type.STRING) {

View file

@ -18,8 +18,8 @@ import info.nightscout.androidaps.events.EventNewBG
import info.nightscout.androidaps.extensions.directionToIcon import info.nightscout.androidaps.extensions.directionToIcon
import info.nightscout.androidaps.extensions.valueToUnitsString import info.nightscout.androidaps.extensions.valueToUnitsString
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action

View file

@ -19,9 +19,9 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.events.EventNewHistoryData import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.BolusCalculatorResult import info.nightscout.database.entities.BolusCalculatorResult

View file

@ -15,10 +15,10 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.androidaps.utils.Translator import info.nightscout.androidaps.utils.Translator
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action

View file

@ -18,9 +18,9 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.extensions.iobCalc import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.isInProgress import info.nightscout.androidaps.extensions.isInProgress
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action

View file

@ -21,9 +21,9 @@ import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
import info.nightscout.androidaps.events.EventNewHistoryData import info.nightscout.androidaps.events.EventNewHistoryData
import info.nightscout.androidaps.extensions.getCustomizedName import info.nightscout.androidaps.extensions.getCustomizedName
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.UserEntry.Sources

View file

@ -21,10 +21,10 @@ import info.nightscout.androidaps.extensions.friendlyDescription
import info.nightscout.androidaps.extensions.highValueToUnitsToString import info.nightscout.androidaps.extensions.highValueToUnitsToString
import info.nightscout.androidaps.extensions.lowValueToUnitsToString import info.nightscout.androidaps.extensions.lowValueToUnitsToString
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.androidaps.utils.Translator import info.nightscout.androidaps.utils.Translator
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.TemporaryTarget import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Action

View file

@ -19,9 +19,9 @@ import info.nightscout.androidaps.extensions.iobCalc
import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.extensions.toStringFull
import info.nightscout.androidaps.extensions.toTemporaryBasal import info.nightscout.androidaps.extensions.toTemporaryBasal
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.utils.ActionModeHelper
import info.nightscout.core.ui.dialogs.OKDialog import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.ActionModeHelper
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal