From 2a3341b5be27ba39c0ddca190ea461c1ff41b35a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 25 Apr 2022 14:55:30 +0200 Subject: [PATCH] Food xml cleanup --- .../plugins/general/food/FoodFragment.kt | 27 +-- app/src/main/res/layout/food_fragment.xml | 44 ++-- app/src/main/res/layout/food_item.xml | 192 +++++++----------- 3 files changed, 97 insertions(+), 166 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt index 3cba103783..392adda03d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt @@ -17,7 +17,6 @@ import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.Food import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Sources -import info.nightscout.androidaps.database.entities.ValueWithUnit import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction import info.nightscout.androidaps.databinding.FoodFragmentBinding import info.nightscout.androidaps.databinding.FoodItemBinding @@ -26,7 +25,6 @@ import info.nightscout.androidaps.events.EventFoodDatabaseChanged import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBus -import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.protection.ProtectionCheck @@ -35,10 +33,8 @@ import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.ui.UIRunnable import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag -import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign -import io.reactivex.rxjava3.kotlin.subscribeBy import java.util.* import java.util.concurrent.TimeUnit import javax.inject.Inject @@ -73,27 +69,7 @@ class FoodFragment : DaggerFragment() { binding.recyclerview.setHasFixedSize(true) binding.recyclerview.layoutManager = LinearLayoutManager(view.context) - binding.refreshFromNightscout.setOnClickListener { - context?.let { context -> - OKDialog.showConfirmation(context, rh.gs(R.string.refresheventsfromnightscout) + " ?", { - uel.log( - Action.FOOD, Sources.Food, rh.gs(R.string.refresheventsfromnightscout), - ValueWithUnit.SimpleString(rh.gsNotLocalised(R.string.refresheventsfromnightscout)) - ) - disposable += Completable.fromAction { repository.deleteAllFoods() } - .subscribeOn(aapsSchedulers.io) - .observeOn(aapsSchedulers.main) - .subscribeBy( - onError = { aapsLogger.error("Error removing foods", it) }, - onComplete = { rxBus.send(EventFoodDatabaseChanged()) } - ) - - rxBus.send(EventNSClientRestart()) - }) - } - } - - binding.filterinputLayout.setEndIconOnClickListener { + binding.filterInputLayout.setEndIconOnClickListener { binding.filter.setText("") binding.categoryList.setText(rh.gs(R.string.none), false) binding.subcategoryList.setText(rh.gs(R.string.none), false) @@ -220,7 +196,6 @@ class FoodFragment : DaggerFragment() { holder.binding.energy.text = rh.gs(R.string.shortenergy) + ": " + food.energy + rh.gs(R.string.shortkilojoul) holder.binding.energy.visibility = food.energy.isNotZero().toVisibility() holder.binding.icRemove.tag = food - holder.binding.foodItem.tag = food holder.binding.icCalculator.tag = food } diff --git a/app/src/main/res/layout/food_fragment.xml b/app/src/main/res/layout/food_fragment.xml index a64274ad54..7eb642a540 100644 --- a/app/src/main/res/layout/food_fragment.xml +++ b/app/src/main/res/layout/food_fragment.xml @@ -6,39 +6,29 @@ android:orientation="vertical" tools:context="info.nightscout.androidaps.plugins.general.food.FoodFragment"> - + android:hint="@string/filter" + app:endIconMode="clear_text" + app:startIconDrawable="@android:drawable/ic_menu_search"> - + android:layout_gravity="center_vertical" + android:layout_marginStart="5dp" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:autofillHints="@string/notes_label" + android:gravity="start" + android:inputType="text|textCapSentences" + android:textStyle="bold" /> - - - + - + app:contentPadding="2dp" + app:strokeWidth="1dp"> + android:baselineAligned="false" + android:orientation="horizontal" + android:paddingStart="3dp" + android:paddingEnd="3dp"> + android:layout_weight="1" + android:gravity="start" + android:orientation="vertical"> + + + android:layout_marginStart="5dp" + android:gravity="start" + android:orientation="horizontal"> - + android:text="Carbs" + tools:ignore="HardcodedText" /> - - - - - + android:gravity="center" + android:text="Portion" + tools:ignore="HardcodedText" /> - + - + - - - - - - + - - - - - - + - +