FoodPlugin -> plugins module

This commit is contained in:
Milos Kozak 2022-11-04 16:55:32 +01:00
parent cb2adc9fab
commit 139e788e6e
21 changed files with 115 additions and 63 deletions

View file

@ -23,9 +23,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.di.MedtronicModule
import info.nightscout.androidaps.plugins.pump.omnipod.dash.di.OmnipodDashModule import info.nightscout.androidaps.plugins.pump.omnipod.dash.di.OmnipodDashModule
import info.nightscout.androidaps.plugins.pump.omnipod.eros.di.OmnipodErosModule import info.nightscout.androidaps.plugins.pump.omnipod.eros.di.OmnipodErosModule
import info.nightscout.automation.di.AutomationModule import info.nightscout.automation.di.AutomationModule
import info.nightscout.implementation.di.CommandQueueModule import info.nightscout.implementation.di.ImplementationModule
import info.nightscout.plugins.di.InsulinModule import info.nightscout.plugins.di.PluginsModule
import info.nightscout.plugins.di.SMSCommunicatorModule
import info.nightscout.shared.di.SharedModule import info.nightscout.shared.di.SharedModule
import info.nightscout.ui.di.UiModule import info.nightscout.ui.di.UiModule
import javax.inject.Singleton import javax.inject.Singleton
@ -34,46 +33,50 @@ import javax.inject.Singleton
@Component( @Component(
modules = [ modules = [
AndroidInjectionModule::class, AndroidInjectionModule::class,
DatabaseModule::class, AppModule::class,
PluginsModule::class, PluginsListModule::class,
SkinsModule::class, SkinsModule::class,
ActivitiesModule::class, ActivitiesModule::class,
FragmentsModule::class, FragmentsModule::class,
AppModule::class,
ReceiversModule::class, ReceiversModule::class,
ServicesModule::class, ServicesModule::class,
AutomationModule::class,
AutotuneModule::class, AutotuneModule::class,
CommandQueueModule::class,
ObjectivesModule::class, ObjectivesModule::class,
WizardModule::class, WizardModule::class,
PumpCommonModule::class,
RileyLinkModule::class,
MedtronicModule::class,
OmnipodDashModule::class,
OmnipodErosModule::class,
APSModule::class, APSModule::class,
WorkflowModule::class, WorkflowModule::class,
PreferencesModule::class, PreferencesModule::class,
OverviewModule::class, OverviewModule::class,
DataClassesModule::class, DataClassesModule::class,
SMSCommunicatorModule::class, WorkersModule::class,
UIModule::class, UiModule::class,
// Gradle modules
AutomationModule::class,
CoreModule::class, CoreModule::class,
DanaModule::class, DatabaseModule::class,
ImplementationModule::class,
PluginsModule::class,
SharedModule::class,
OpenHumansModule::class,
UIModule::class,
// pumps
ComboModule::class,
DanaHistoryModule::class, DanaHistoryModule::class,
DanaModule::class,
DanaRModule::class, DanaRModule::class,
DanaRSModule::class, DanaRSModule::class,
ComboModule::class, DiaconnG8Module::class,
EopatchModule::class,
InsightModule::class, InsightModule::class,
InsightDatabaseModule::class, InsightDatabaseModule::class,
WorkersModule::class, MedtronicModule::class,
DiaconnG8Module::class, OmnipodDashModule::class,
OpenHumansModule::class, OmnipodErosModule::class,
EopatchModule::class, PumpCommonModule::class,
SharedModule::class, RileyLinkModule::class,
UiModule::class,
InsulinModule::class
] ]
) )
interface AppComponent : AndroidInjector<MainApp> { interface AppComponent : AndroidInjector<MainApp> {

View file

@ -87,11 +87,11 @@ open class AppModule {
@Provides @Provides
fun providesPlugins( fun providesPlugins(
config: Config, buildHelper: BuildHelper, config: Config, buildHelper: BuildHelper,
@PluginsModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>, @PluginsListModule.AllConfigs allConfigs: Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>,
@PluginsModule.PumpDriver pumpDrivers: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>, @PluginsListModule.PumpDriver pumpDrivers: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
@PluginsModule.NotNSClient notNsClient: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>, @PluginsListModule.NotNSClient notNsClient: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
@PluginsModule.APS aps: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>, @PluginsListModule.APS aps: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>,
@PluginsModule.Unfinished unfinished: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>> @PluginsListModule.Unfinished unfinished: Lazy<Map<@JvmSuppressWildcards Int, @JvmSuppressWildcards PluginBase>>
) )
: List<@JvmSuppressWildcards PluginBase> { : List<@JvmSuppressWildcards PluginBase> {
val plugins = allConfigs.toMutableMap() val plugins = allConfigs.toMutableMap()

View file

@ -28,7 +28,6 @@ import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragm
import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog
import info.nightscout.androidaps.plugins.general.actions.ActionsFragment import info.nightscout.androidaps.plugins.general.actions.ActionsFragment
import info.nightscout.androidaps.plugins.general.autotune.AutotuneFragment import info.nightscout.androidaps.plugins.general.autotune.AutotuneFragment
import info.nightscout.androidaps.plugins.general.food.FoodFragment
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
import info.nightscout.androidaps.plugins.general.nsclient.NSClientFragment import info.nightscout.androidaps.plugins.general.nsclient.NSClientFragment
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment import info.nightscout.androidaps.plugins.general.overview.OverviewFragment
@ -52,7 +51,6 @@ abstract class FragmentsModule {
@ContributesAndroidInjector abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment @ContributesAndroidInjector abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment
@ContributesAndroidInjector abstract fun contributesFoodFragment(): FoodFragment
@ContributesAndroidInjector abstract fun contributesLocalProfileFragment(): LocalProfileFragment @ContributesAndroidInjector abstract fun contributesLocalProfileFragment(): LocalProfileFragment
@ContributesAndroidInjector abstract fun contributesObjectivesFragment(): ObjectivesFragment @ContributesAndroidInjector abstract fun contributesObjectivesFragment(): ObjectivesFragment
@ContributesAndroidInjector abstract fun contributesOpenAPSFragment(): OpenAPSFragment @ContributesAndroidInjector abstract fun contributesOpenAPSFragment(): OpenAPSFragment

View file

@ -26,7 +26,7 @@ import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionChec
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin
import info.nightscout.androidaps.plugins.general.autotune.AutotunePlugin import info.nightscout.androidaps.plugins.general.autotune.AutotunePlugin
import info.nightscout.androidaps.plugins.general.dataBroadcaster.DataBroadcastPlugin import info.nightscout.androidaps.plugins.general.dataBroadcaster.DataBroadcastPlugin
import info.nightscout.androidaps.plugins.general.food.FoodPlugin import info.nightscout.plugins.general.food.FoodPlugin
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin
@ -68,7 +68,7 @@ import javax.inject.Qualifier
@Suppress("unused") @Suppress("unused")
@Module @Module
abstract class PluginsModule { abstract class PluginsListModule {
@Binds @Binds
@AllConfigs @AllConfigs

View file

@ -11,7 +11,7 @@ import info.nightscout.ui.widget.Widget
abstract class UIModule { abstract class UIModule {
@ContributesAndroidInjector abstract fun skinListPreferenceInjector(): SkinListPreference @ContributesAndroidInjector abstract fun skinListPreferenceInjector(): SkinListPreference
@ContributesAndroidInjector abstract fun aapsWidgetInjector(): Widget @ContributesAndroidInjector abstract fun contributesWidget(): Widget
@ContributesAndroidInjector abstract fun contributesWidgetConfigureActivity(): WidgetConfigureActivity @ContributesAndroidInjector abstract fun contributesWidgetConfigureActivity(): WidgetConfigureActivity
} }

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.di
import dagger.Module import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.general.food.FoodPlugin
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsImpl import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsImpl
import info.nightscout.androidaps.plugins.general.nsclient.NSClientAddAckWorker import info.nightscout.androidaps.plugins.general.nsclient.NSClientAddAckWorker
import info.nightscout.androidaps.plugins.general.nsclient.NSClientAddUpdateWorker import info.nightscout.androidaps.plugins.general.nsclient.NSClientAddUpdateWorker
@ -36,7 +35,6 @@ abstract class WorkersModule {
@ContributesAndroidInjector abstract fun contributesNSClientAddAckWorker(): NSClientAddAckWorker @ContributesAndroidInjector abstract fun contributesNSClientAddAckWorker(): NSClientAddAckWorker
@ContributesAndroidInjector abstract fun contributesNSClientUpdateRemoveAckWorker(): NSClientUpdateRemoveAckWorker @ContributesAndroidInjector abstract fun contributesNSClientUpdateRemoveAckWorker(): NSClientUpdateRemoveAckWorker
@ContributesAndroidInjector abstract fun contributesNSClientMbgWorker(): NSClientMbgWorker @ContributesAndroidInjector abstract fun contributesNSClientMbgWorker(): NSClientMbgWorker
@ContributesAndroidInjector abstract fun contributesFoodWorker(): FoodPlugin.FoodWorker
@ContributesAndroidInjector abstract fun contributesCsvExportWorker(): ImportExportPrefsImpl.CsvExportWorker @ContributesAndroidInjector abstract fun contributesCsvExportWorker(): ImportExportPrefsImpl.CsvExportWorker
@ContributesAndroidInjector abstract fun contributesAidexWorker(): AidexPlugin.AidexWorker @ContributesAndroidInjector abstract fun contributesAidexWorker(): AidexPlugin.AidexWorker
} }

View file

@ -2,8 +2,11 @@ package info.nightscout.androidaps.implementations
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle
import androidx.annotation.RawRes import androidx.annotation.RawRes
import androidx.fragment.app.FragmentManager
import info.nightscout.androidaps.MainActivity import info.nightscout.androidaps.MainActivity
import info.nightscout.androidaps.dialogs.WizardDialog
import info.nightscout.androidaps.interfaces.ActivityNames import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.services.AlarmSoundService import info.nightscout.androidaps.services.AlarmSoundService
import info.nightscout.ui.activities.BolusProgressHelperActivity import info.nightscout.ui.activities.BolusProgressHelperActivity
@ -33,4 +36,14 @@ class ActivityNamesImpl @Inject constructor() : ActivityNames {
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i) ctx.startActivity(i)
} }
override fun runWizard(fragmentManager: FragmentManager, carbs: Int, name: String) {
WizardDialog().also { dialog ->
dialog.arguments = Bundle().also { bundle ->
bundle.putDouble("carbs_input", carbs.toDouble())
bundle.putString("notes_input", " $name - ${carbs}g")
}
}.show(fragmentManager, "Food Item")
}
} }

View file

@ -19,7 +19,7 @@ import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.DataSyncSelector import info.nightscout.androidaps.interfaces.DataSyncSelector
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.food.FoodPlugin.FoodWorker import info.nightscout.plugins.general.food.FoodPlugin.FoodWorker
import info.nightscout.androidaps.plugins.general.nsclient.NSClientAddAckWorker import info.nightscout.androidaps.plugins.general.nsclient.NSClientAddAckWorker
import info.nightscout.androidaps.plugins.general.nsclient.NSClientAddUpdateWorker import info.nightscout.androidaps.plugins.general.nsclient.NSClientAddUpdateWorker
import info.nightscout.androidaps.plugins.general.nsclient.NSClientMbgWorker import info.nightscout.androidaps.plugins.general.nsclient.NSClientMbgWorker

View file

@ -68,7 +68,6 @@
<string name="description_actions">Some buttons to quickly access common features</string> <string name="description_actions">Some buttons to quickly access common features</string>
<string name="description_config_builder">Used for configuring the active plugins</string> <string name="description_config_builder">Used for configuring the active plugins</string>
<string name="description_objectives">Learning program</string> <string name="description_objectives">Learning program</string>
<string name="description_food">Displays the food presets defined in Nightscout</string>
<string name="description_loop">Activate or deactivate the implementation triggering the loop.</string> <string name="description_loop">Activate or deactivate the implementation triggering the loop.</string>
<string name="description_ns_client">Synchronizes your data with Nightscout</string> <string name="description_ns_client">Synchronizes your data with Nightscout</string>
<string name="description_ama">State of the algorithm in 2017</string> <string name="description_ama">State of the algorithm in 2017</string>
@ -430,11 +429,6 @@
<string name="reuse_profile_pct_hours">Reuse %1$d%% %2$dh</string> <string name="reuse_profile_pct_hours">Reuse %1$d%% %2$dh</string>
<string name="wearcontrol_title">Controls from Watch</string> <string name="wearcontrol_title">Controls from Watch</string>
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string> <string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
<string name="food">Food</string>
<string name="shortkilojoul">kJ</string>
<string name="shortenergy">En</string>
<string name="shortprotein">Pr</string>
<string name="shortfat">Fat</string>
<string name="key_raise_notifications_as_android_notifications" translatable="false">raise_urgent_alarms_as_android_notification</string> <string name="key_raise_notifications_as_android_notifications" translatable="false">raise_urgent_alarms_as_android_notification</string>
<string name="raise_notifications_as_android_notifications">Use system notifications for alerts and notifications</string> <string name="raise_notifications_as_android_notifications">Use system notifications for alerts and notifications</string>
<string name="gradually_increase_notification_volume">Gradually increase the volume for alerts and notifications</string> <string name="gradually_increase_notification_volume">Gradually increase the volume for alerts and notifications</string>
@ -572,7 +566,6 @@
<string name="record_insulin_cartridge_change">Record insulin cartridge change</string> <string name="record_insulin_cartridge_change">Record insulin cartridge change</string>
<string name="smbalwaysdisabled">SMB always and after carbs disabled because active BG source doesn\'t support advanced filtering</string> <string name="smbalwaysdisabled">SMB always and after carbs disabled because active BG source doesn\'t support advanced filtering</string>
<string name="smbnotallowedinopenloopmode">SMB not allowed in open loop mode</string> <string name="smbnotallowedinopenloopmode">SMB not allowed in open loop mode</string>
<string name="food_short">Food</string>
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string> <string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
<string name="key_openapssmb_max_iob" translatable="false">openapsmb_max_iob</string> <string name="key_openapssmb_max_iob" translatable="false">openapsmb_max_iob</string>
<string name="openapssmb_maxiob_title">Maximum total IOB OpenAPS can\'t go over [U]</string> <string name="openapssmb_maxiob_title">Maximum total IOB OpenAPS can\'t go over [U]</string>
@ -838,7 +831,6 @@
<string name="basalpctfromtdd_label">% of basal</string> <string name="basalpctfromtdd_label">% of basal</string>
<string name="dpvdefaultprofile">DPV Default profile</string> <string name="dpvdefaultprofile">DPV Default profile</string>
<string name="setupwizard_pump_riley_link_status">RileyLink status:</string> <string name="setupwizard_pump_riley_link_status">RileyLink status:</string>
<string name="filter">Filter</string>
<string name="copytolocalprofile_invalid">Unable to create profile. Profile is invalid.</string> <string name="copytolocalprofile_invalid">Unable to create profile. Profile is invalid.</string>
<string name="cta_dont_kill_my_app_info">Don\'t kill my app?</string> <string name="cta_dont_kill_my_app_info">Don\'t kill my app?</string>
<string name="advisoralarm">Run alarm when is time to eat</string> <string name="advisoralarm">Run alarm when is time to eat</string>

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.interfaces
import android.content.Context import android.content.Context
import androidx.annotation.RawRes import androidx.annotation.RawRes
import androidx.fragment.app.FragmentManager
/** /**
* Interface to use activities located in different modules * Interface to use activities located in different modules
@ -22,4 +23,5 @@ interface ActivityNames {
* @param soundId sound resource. if == 0 alarm is not started * @param soundId sound resource. if == 0 alarm is not started
*/ */
fun runAlarm(ctx: Context, status: String, title: String, @RawRes soundId: Int = 0) fun runAlarm(ctx: Context, status: String, title: String, @RawRes soundId: Int = 0)
fun runWizard(fragmentManager: FragmentManager, carbs: Int, name: String)
} }

View file

@ -227,6 +227,7 @@
<string name="average">Average</string> <string name="average">Average</string>
<string name="tir">TIR</string> <string name="tir">TIR</string>
<string name="tdd_total">TDD Total</string> <string name="tdd_total">TDD Total</string>
<string name="none"><![CDATA[<none>]]></string>
<!-- Constraints--> <!-- Constraints-->
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string> <string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>

View file

@ -0,0 +1,12 @@
package info.nightscout.implementation.di
import dagger.Module
@Module(
includes = [
CommandQueueModule::class
]
)
@Suppress("unused")
abstract class ImplementationModule

View file

@ -0,0 +1,14 @@
package info.nightscout.plugins.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.plugins.general.food.FoodFragment
import info.nightscout.plugins.general.food.FoodPlugin
@Module
@Suppress("unused")
abstract class FoodModule {
@ContributesAndroidInjector abstract fun contributesFoodFragment(): FoodFragment
@ContributesAndroidInjector abstract fun contributesFoodWorker(): FoodPlugin.FoodWorker
}

View file

@ -0,0 +1,14 @@
package info.nightscout.plugins.di
import dagger.Module
@Module(
includes = [
InsulinModule::class,
FoodModule::class,
SMSCommunicatorModule::class
]
)
@Suppress("unused")
abstract class PluginsModule

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.general.food package info.nightscout.plugins.general.food
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
@ -12,30 +12,30 @@ import android.widget.ArrayAdapter
import androidx.recyclerview.widget.LinearLayoutManager 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.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.Food import info.nightscout.androidaps.database.entities.Food
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction
import info.nightscout.androidaps.databinding.FoodFragmentBinding
import info.nightscout.androidaps.databinding.FoodItemBinding
import info.nightscout.androidaps.dialogs.WizardDialog
import info.nightscout.androidaps.events.EventFoodDatabaseChanged import info.nightscout.androidaps.events.EventFoodDatabaseChanged
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivityNames
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.ui.UIRunnable import info.nightscout.androidaps.utils.ui.UIRunnable
import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.FoodFragmentBinding
import info.nightscout.plugins.databinding.FoodItemBinding
import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag import info.nightscout.shared.logging.LTag
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
import java.util.* import java.util.Locale
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
@ -49,6 +49,7 @@ class FoodFragment : DaggerFragment() {
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@Inject lateinit var protectionCheck: ProtectionCheck @Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var activityNames: ActivityNames
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
private var unfiltered: List<Food> = arrayListOf() private var unfiltered: List<Food> = arrayListOf()
@ -223,13 +224,7 @@ class FoodFragment : DaggerFragment() {
val food = v.tag as Food val food = v.tag as Food
activity?.let { activity -> activity?.let { activity ->
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
if (isAdded) if (isAdded) activityNames.runWizard(childFragmentManager, food.carbs, food.name)
WizardDialog().also { dialog ->
dialog.arguments = Bundle().also { bundle ->
bundle.putDouble("carbs_input", food.carbs.toDouble())
bundle.putString("notes_input", " ${food.name} - ${food.carbs}g")
}
}.show(childFragmentManager, "Food Item")
}) })
} }
} }

View file

@ -1,11 +1,10 @@
package info.nightscout.androidaps.plugins.general.food package info.nightscout.plugins.general.food
import android.content.Context import android.content.Context
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.Food import info.nightscout.androidaps.database.entities.Food
import info.nightscout.androidaps.database.transactions.SyncNsFoodTransaction import info.nightscout.androidaps.database.transactions.SyncNsFoodTransaction
@ -18,6 +17,7 @@ import info.nightscout.shared.logging.LTag
import info.nightscout.androidaps.receivers.DataWorkerStorage import info.nightscout.androidaps.receivers.DataWorkerStorage
import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.JsonHelper
import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.plugins.R
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import org.json.JSONObject import org.json.JSONObject
import javax.inject.Inject import javax.inject.Inject

View file

@ -4,7 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.plugins.general.food.FoodFragment"> tools:context=".general.food.FoodFragment">
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:id="@+id/filter_input_layout" android:id="@+id/filter_input_layout"

View file

@ -137,6 +137,7 @@
<string name="key_xdrip_status_show_bgi" translatable="false">xdripstatus_showbgi</string> <string name="key_xdrip_status_show_bgi" translatable="false">xdripstatus_showbgi</string>
<string name="key_xdrip_status_settings" translatable="false">xdripstatus_settings</string> <string name="key_xdrip_status_settings" translatable="false">xdripstatus_settings</string>
<!-- Statusline -->
<string name="xdrip_status">xDrip+ Statusline (watch)</string> <string name="xdrip_status">xDrip+ Statusline (watch)</string>
<string name="xdrip_status_shortname">xds</string> <string name="xdrip_status_shortname">xds</string>
<string name="description_xdrip_status_line">Show information about your loop on your xDrip+ watchface.</string> <string name="description_xdrip_status_line">Show information about your loop on your xDrip+ watchface.</string>
@ -147,4 +148,14 @@
<string name="xdrip_status_show_bgi_summary">Add BGI to status line</string> <string name="xdrip_status_show_bgi_summary">Add BGI to status line</string>
<string name="xdrip_status_settings">xDrip+ Status (watch)</string> <string name="xdrip_status_settings">xDrip+ Status (watch)</string>
<!-- Food-->
<string name="food_short">Food</string>
<string name="description_food">Displays the food presets defined in Nightscout</string>
<string name="filter">Filter</string>
<string name="food">Food</string>
<string name="shortkilojoul">kJ</string>
<string name="shortenergy">En</string>
<string name="shortprotein">Pr</string>
<string name="shortfat">Fat</string>
</resources> </resources>

View file

@ -40,6 +40,5 @@
<string name="bg_other">Other</string> <string name="bg_other">Other</string>
<string name="bg_meter">Meter</string> <string name="bg_meter">Meter</string>
<string name="bg_sensor">Sensor</string> <string name="bg_sensor">Sensor</string>
<string name="none"><![CDATA[<none>]]></string>
</resources> </resources>