mirror of
https://github.com/dzeiocom/OpenHealth.git
synced 2025-04-23 03:12:14 +00:00
feat: Project cleanup (#146)
This commit is contained in:
parent
1f780ae2c4
commit
bcf8004497
@ -145,14 +145,14 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile using JAVA 8
|
// Compile using JAVA 11
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = JavaVersion.VERSION_11.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable View Binding and Data Binding
|
// Enable View Binding and Data Binding
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
<vector android:autoMirrored="true" android:height="24dp"
|
|
||||||
android:tint="#000000" android:viewportHeight="24"
|
|
||||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/>
|
|
||||||
</vector>
|
|
@ -1,5 +0,0 @@
|
|||||||
<vector android:autoMirrored="true" android:height="24dp"
|
|
||||||
android:tint="#000000" android:viewportHeight="24"
|
|
||||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"/>
|
|
||||||
</vector>
|
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@drawable/vector_logo_background" />
|
<background android:drawable="@drawable/logo_background" />
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
|
@ -34,4 +34,7 @@ object Settings {
|
|||||||
* Goal number of steps each days
|
* Goal number of steps each days
|
||||||
*/
|
*/
|
||||||
const val STEPS_GOAL = "com.dzeio.open-health.steps.goal-daily"
|
const val STEPS_GOAL = "com.dzeio.open-health.steps.goal-daily"
|
||||||
|
|
||||||
|
const val WATER_INTAKE_SIZE = "com.dzeio.open-health.water.size"
|
||||||
|
const val WATER_INTAKE_SIZE_DEFAULT = 250
|
||||||
}
|
}
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
package com.dzeio.openhealth.adapters
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import com.dzeio.openhealth.R
|
|
||||||
import com.dzeio.openhealth.core.BaseAdapter
|
|
||||||
import com.dzeio.openhealth.core.BaseViewHolder
|
|
||||||
import com.dzeio.openhealth.data.food.Food
|
|
||||||
import com.dzeio.openhealth.databinding.ItemFoodBinding
|
|
||||||
import com.dzeio.openhealth.utils.NetworkUtils
|
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
class FoodAdapter : BaseAdapter<Food, ItemFoodBinding>() {
|
|
||||||
|
|
||||||
override val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> ItemFoodBinding
|
|
||||||
get() = ItemFoodBinding::inflate
|
|
||||||
|
|
||||||
var onItemClick: ((weight: Food) -> Unit)? = null
|
|
||||||
|
|
||||||
override fun onBindData(
|
|
||||||
holder: BaseViewHolder<ItemFoodBinding>,
|
|
||||||
item: Food,
|
|
||||||
position: Int
|
|
||||||
) {
|
|
||||||
// Download remote picture
|
|
||||||
if (item.image != null) {
|
|
||||||
NetworkUtils.getImageInBackground(holder.binding.productImage, item.image!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the food name
|
|
||||||
holder.binding.foodName.text = item.name + " ${item.id}"
|
|
||||||
|
|
||||||
// set the food description
|
|
||||||
holder.binding.foodDescription.text = holder.itemView.context.getString(
|
|
||||||
R.string.food_description,
|
|
||||||
item.quantity.roundToInt().toString() + item.serving.replace(Regex("\\d+"), ""),
|
|
||||||
(item.energy / 100 * item.quantity)
|
|
||||||
)
|
|
||||||
|
|
||||||
// set the callback
|
|
||||||
holder.binding.edit.setOnClickListener {
|
|
||||||
onItemClick?.invoke(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.dzeio.openhealth.adapters
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import com.dzeio.openhealth.R
|
|
||||||
import com.dzeio.openhealth.core.BaseAdapter
|
|
||||||
import com.dzeio.openhealth.core.BaseViewHolder
|
|
||||||
import com.dzeio.openhealth.data.step.Step
|
|
||||||
import com.dzeio.openhealth.databinding.LayoutItemListBinding
|
|
||||||
|
|
||||||
class StepsAdapter() : BaseAdapter<Step, LayoutItemListBinding>() {
|
|
||||||
|
|
||||||
override val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> LayoutItemListBinding
|
|
||||||
get() = LayoutItemListBinding::inflate
|
|
||||||
|
|
||||||
var onItemClick: ((weight: Step) -> Unit)? = null
|
|
||||||
|
|
||||||
var isDay = false
|
|
||||||
|
|
||||||
override fun onBindData(
|
|
||||||
holder: BaseViewHolder<LayoutItemListBinding>,
|
|
||||||
item: Step,
|
|
||||||
position: Int
|
|
||||||
) {
|
|
||||||
// set the number of steps taken
|
|
||||||
holder.binding.value.text = holder.itemView.context.getString(
|
|
||||||
R.string.steps_count,
|
|
||||||
item.value
|
|
||||||
)
|
|
||||||
|
|
||||||
// set the datetime
|
|
||||||
holder.binding.datetime.text = item.formatTimestamp(!isDay)
|
|
||||||
|
|
||||||
if (isDay) {
|
|
||||||
holder.binding.iconRight.visibility = View.GONE
|
|
||||||
} else {
|
|
||||||
holder.binding.iconRight.setImageResource(R.drawable.ic_zoom_out_map)
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the callback
|
|
||||||
holder.binding.edit.setOnClickListener {
|
|
||||||
onItemClick?.invoke(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package com.dzeio.openhealth.adapters
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import com.dzeio.openhealth.core.BaseAdapter
|
|
||||||
import com.dzeio.openhealth.core.BaseViewHolder
|
|
||||||
import com.dzeio.openhealth.data.water.Water
|
|
||||||
import com.dzeio.openhealth.databinding.LayoutItemListBinding
|
|
||||||
import com.dzeio.openhealth.units.Units
|
|
||||||
|
|
||||||
class WaterAdapter : BaseAdapter<Water, LayoutItemListBinding>() {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The unit the adapter will be using
|
|
||||||
*/
|
|
||||||
var unit: Units.Volume = Units.Volume.MILLILITER
|
|
||||||
|
|
||||||
override val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> LayoutItemListBinding
|
|
||||||
get() = LayoutItemListBinding::inflate
|
|
||||||
|
|
||||||
var onItemClick: ((weight: Water) -> Unit)? = null
|
|
||||||
|
|
||||||
override fun onBindData(
|
|
||||||
holder: BaseViewHolder<LayoutItemListBinding>,
|
|
||||||
item: Water,
|
|
||||||
position: Int
|
|
||||||
) {
|
|
||||||
// set the wate intake text
|
|
||||||
holder.binding.value.text =
|
|
||||||
holder.itemView.context.getString(unit.unit, unit.formatToString(item.value))
|
|
||||||
|
|
||||||
// set the datetime
|
|
||||||
holder.binding.datetime.text = item.formatTimestamp()
|
|
||||||
|
|
||||||
// set the callback
|
|
||||||
holder.binding.edit.setOnClickListener {
|
|
||||||
onItemClick?.invoke(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package com.dzeio.openhealth.adapters
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import com.dzeio.openhealth.core.BaseAdapter
|
|
||||||
import com.dzeio.openhealth.core.BaseViewHolder
|
|
||||||
import com.dzeio.openhealth.data.weight.Weight
|
|
||||||
import com.dzeio.openhealth.databinding.LayoutItemListBinding
|
|
||||||
import com.dzeio.openhealth.units.Units
|
|
||||||
|
|
||||||
class WeightAdapter : BaseAdapter<Weight, LayoutItemListBinding>() {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The unit the adapter will be using
|
|
||||||
*/
|
|
||||||
var unit: Units.Mass = Units.Mass.KILOGRAM
|
|
||||||
|
|
||||||
override val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> LayoutItemListBinding
|
|
||||||
get() = LayoutItemListBinding::inflate
|
|
||||||
|
|
||||||
var onItemClick: ((weight: Weight) -> Unit)? = null
|
|
||||||
|
|
||||||
override fun onBindData(
|
|
||||||
holder: BaseViewHolder<LayoutItemListBinding>,
|
|
||||||
item: Weight,
|
|
||||||
position: Int
|
|
||||||
) {
|
|
||||||
// set the weight text
|
|
||||||
holder.binding.value.text =
|
|
||||||
holder.itemView.context.getString(unit.unit, unit.formatToString(item.weight))
|
|
||||||
|
|
||||||
// set the datetime
|
|
||||||
holder.binding.datetime.text = item.formatTimestamp()
|
|
||||||
|
|
||||||
// set the callback
|
|
||||||
holder.binding.edit.setOnClickListener {
|
|
||||||
onItemClick?.invoke(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -75,17 +75,21 @@ data class Food(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try to know how much was eaten by the user if not said
|
// try to know how much was eaten by the user if not said
|
||||||
var eaten = quantity ?: food.servingQuantity ?: food.productQuantity ?: 0f
|
var eaten = quantity ?: food.productQuantity ?: food.servingQuantity ?: 0f
|
||||||
if (eaten == 0f) {
|
if (eaten == 0f) {
|
||||||
if (food.servingQuantity != null && food.servingQuantity != 0f) {
|
if (food.productQuantity != null && food.productQuantity != 0f) {
|
||||||
eaten = food.servingQuantity!!
|
|
||||||
} else if (food.productQuantity != null && food.productQuantity != 0f) {
|
|
||||||
eaten = food.productQuantity!!
|
eaten = food.productQuantity!!
|
||||||
|
} else if (food.servingQuantity != null && food.servingQuantity != 0f) {
|
||||||
|
eaten = food.servingQuantity!!
|
||||||
} else if (food.servingSize != null || food.quantity != null) {
|
} else if (food.servingSize != null || food.quantity != null) {
|
||||||
eaten = (food.servingSize ?: food.quantity)!!.trim().replace(
|
eaten = try {
|
||||||
Regex(" +\\w+$"),
|
(food.quantity ?: food.servingSize)!!.trim().replace(
|
||||||
|
Regex(" +\\w+"),
|
||||||
""
|
""
|
||||||
).toInt().toFloat()
|
).toInt().toFloat()
|
||||||
|
} catch (e: NumberFormatException) {
|
||||||
|
0f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d("Food", "$food")
|
Log.d("Food", "$food")
|
||||||
|
@ -10,6 +10,7 @@ import com.dzeio.openhealth.databinding.DialogFoodProductBinding
|
|||||||
import com.dzeio.openhealth.utils.NetworkUtils
|
import com.dzeio.openhealth.utils.NetworkUtils
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog that display to the user a spcific product and it's consumption
|
* Dialog that display to the user a spcific product and it's consumption
|
||||||
@ -66,6 +67,7 @@ class FoodDialog :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
binding.quantity.setText(it.quantity.toString())
|
binding.quantity.setText(it.quantity.toString())
|
||||||
|
dialog?.setTitle(it.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.quantity.addTextChangedListener {
|
binding.quantity.addTextChangedListener {
|
||||||
@ -77,17 +79,17 @@ class FoodDialog :
|
|||||||
quantity = newQuantity
|
quantity = newQuantity
|
||||||
viewModel.items.value?.let {
|
viewModel.items.value?.let {
|
||||||
val transformer = newQuantity ?: it.quantity
|
val transformer = newQuantity ?: it.quantity
|
||||||
val energy = it.energy / 100 * transformer
|
val energy = it.energy * transformer / 100
|
||||||
binding.energyTxt.text = "${energy.toInt()} / 2594kcal"
|
binding.energyTxt.text = "${energy.roundToInt()} / 2594kcal"
|
||||||
binding.energyBar.progress = (100 * energy / 2594).toInt()
|
binding.energyBar.progress = (100 * energy / 2594).toInt()
|
||||||
val proteins = it.proteins / 100 * transformer
|
val proteins = it.proteins * transformer / 100
|
||||||
binding.proteinsTxt.text = "${proteins.toInt()} / 130g"
|
binding.proteinsTxt.text = "${proteins.roundToInt()} / 130g"
|
||||||
binding.proteinsBar.progress = (100 * proteins / 130).toInt()
|
binding.proteinsBar.progress = (100 * proteins / 130).toInt()
|
||||||
val carbohydrates = it.carbohydrates / 100 * transformer
|
val carbohydrates = it.carbohydrates * transformer / 100
|
||||||
binding.carbsTxt.text = "${carbohydrates.toInt()} / 324g"
|
binding.carbsTxt.text = "${carbohydrates.roundToInt()} / 324g"
|
||||||
binding.carbsBar.progress = (100 * carbohydrates / 324).toInt()
|
binding.carbsBar.progress = (100 * carbohydrates / 324).toInt()
|
||||||
val fat = it.fat / 100 * transformer
|
val fat = it.fat * transformer / 100
|
||||||
binding.fatTxt.text = "${fat.toInt()} / 87g"
|
binding.fatTxt.text = "${fat.roundToInt()} / 87g"
|
||||||
binding.fatBar.progress = (100 * fat / 87).toInt()
|
binding.fatBar.progress = (100 * fat / 87).toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,6 @@ class FoodDialogViewModel @Inject internal constructor(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val transformer = quantity / it.quantity
|
|
||||||
it.energy = it.energy * transformer
|
|
||||||
it.proteins = it.proteins * transformer
|
|
||||||
it.carbohydrates = it.carbohydrates * transformer
|
|
||||||
it.fat = it.fat * transformer
|
|
||||||
it.quantity = quantity
|
it.quantity = quantity
|
||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.dzeio.openhealth.ui.food
|
package com.dzeio.openhealth.ui.food
|
||||||
|
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
@ -10,12 +11,15 @@ import androidx.navigation.fragment.findNavController
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.dzeio.openhealth.Application
|
import com.dzeio.openhealth.Application
|
||||||
import com.dzeio.openhealth.R
|
import com.dzeio.openhealth.R
|
||||||
import com.dzeio.openhealth.adapters.FoodAdapter
|
import com.dzeio.openhealth.adapters.ItemAdapter
|
||||||
import com.dzeio.openhealth.core.BaseFragment
|
import com.dzeio.openhealth.core.BaseFragment
|
||||||
|
import com.dzeio.openhealth.data.food.Food
|
||||||
import com.dzeio.openhealth.databinding.FragmentFoodHomeBinding
|
import com.dzeio.openhealth.databinding.FragmentFoodHomeBinding
|
||||||
import com.dzeio.openhealth.ui.steps.FoodHomeViewModel
|
import com.dzeio.openhealth.ui.steps.FoodHomeViewModel
|
||||||
|
import com.google.android.material.color.MaterialColors
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class FoodHomeFragment :
|
class FoodHomeFragment :
|
||||||
@ -41,11 +45,11 @@ class FoodHomeFragment :
|
|||||||
val manager = LinearLayoutManager(requireContext())
|
val manager = LinearLayoutManager(requireContext())
|
||||||
recycler.layoutManager = manager
|
recycler.layoutManager = manager
|
||||||
|
|
||||||
val adapter = FoodAdapter()
|
val adapter = ItemAdapter<Food>()
|
||||||
adapter.onItemClick = {
|
adapter.onItemClick = {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
FoodHomeFragmentDirections.actionFoodHomeFragmentToNavDialogFoodProduct(
|
FoodHomeFragmentDirections.actionFoodHomeFragmentToNavDialogFoodProduct(
|
||||||
it.id,
|
it.value.id,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -53,7 +57,24 @@ class FoodHomeFragment :
|
|||||||
recycler.adapter = adapter
|
recycler.adapter = adapter
|
||||||
|
|
||||||
viewModel.items.observe(viewLifecycleOwner) {
|
viewModel.items.observe(viewLifecycleOwner) {
|
||||||
adapter.set(it)
|
adapter.set(
|
||||||
|
it!!.map { food ->
|
||||||
|
ItemAdapter.Item(
|
||||||
|
food,
|
||||||
|
food.name,
|
||||||
|
getString(
|
||||||
|
R.string.food_description,
|
||||||
|
food.quantity.roundToInt().toString() + food.serving.replace(
|
||||||
|
Regex("\\d+"),
|
||||||
|
""
|
||||||
|
),
|
||||||
|
(food.energy / 100 * food.quantity)
|
||||||
|
),
|
||||||
|
food.image,
|
||||||
|
R.drawable.ic_outline_edit_24
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
var energy = 0f
|
var energy = 0f
|
||||||
var proteins = 0f
|
var proteins = 0f
|
||||||
@ -65,14 +86,47 @@ class FoodHomeFragment :
|
|||||||
carbohydrates += food.carbohydrates / 100 * food.quantity
|
carbohydrates += food.carbohydrates / 100 * food.quantity
|
||||||
fat += food.fat / 100 * food.quantity
|
fat += food.fat / 100 * food.quantity
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.energyTxt.text = "${energy.toInt()} / 2594kcal"
|
binding.energyTxt.text = "${energy.toInt()} / 2594kcal"
|
||||||
binding.energyBar.progress = (100 * energy / 2594).toInt()
|
binding.energyBar.progress = (100 * energy / 2594).toInt()
|
||||||
|
if (binding.energyBar.progress >= 100) {
|
||||||
|
binding.energyBar.progressTintList = ColorStateList.valueOf(
|
||||||
|
MaterialColors.getColor(
|
||||||
|
view,
|
||||||
|
com.google.android.material.R.attr.colorError
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
binding.proteinsTxt.text = "${proteins.toInt()} / 130g"
|
binding.proteinsTxt.text = "${proteins.toInt()} / 130g"
|
||||||
binding.proteinsBar.progress = (100 * proteins / 130).toInt()
|
binding.proteinsBar.progress = (100 * proteins / 130).toInt()
|
||||||
|
if (binding.proteinsBar.progress >= 100) {
|
||||||
|
binding.proteinsBar.progressTintList = ColorStateList.valueOf(
|
||||||
|
MaterialColors.getColor(
|
||||||
|
view,
|
||||||
|
com.google.android.material.R.attr.colorError
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
binding.carbsTxt.text = "${carbohydrates.toInt()} / 324g"
|
binding.carbsTxt.text = "${carbohydrates.toInt()} / 324g"
|
||||||
binding.carbsBar.progress = (100 * carbohydrates / 324).toInt()
|
binding.carbsBar.progress = (100 * carbohydrates / 324).toInt()
|
||||||
|
if (binding.carbsBar.progress >= 100) {
|
||||||
|
binding.carbsBar.progressTintList = ColorStateList.valueOf(
|
||||||
|
MaterialColors.getColor(
|
||||||
|
view,
|
||||||
|
com.google.android.material.R.attr.colorError
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
binding.fatTxt.text = "${fat.toInt()} / 87g"
|
binding.fatTxt.text = "${fat.toInt()} / 87g"
|
||||||
binding.fatBar.progress = (100 * fat / 87).toInt()
|
binding.fatBar.progress = (100 * fat / 87).toInt()
|
||||||
|
if (binding.fatBar.progress >= 100) {
|
||||||
|
binding.fatBar.progressTintList = ColorStateList.valueOf(
|
||||||
|
MaterialColors.getColor(
|
||||||
|
view,
|
||||||
|
com.google.android.material.R.attr.colorError
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.next.setOnClickListener {
|
binding.next.setOnClickListener {
|
||||||
|
@ -7,22 +7,24 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.dzeio.openhealth.R
|
import com.dzeio.openhealth.R
|
||||||
import com.dzeio.openhealth.adapters.FoodAdapter
|
import com.dzeio.openhealth.adapters.ItemAdapter
|
||||||
import com.dzeio.openhealth.core.BaseDialog
|
import com.dzeio.openhealth.core.BaseDialog
|
||||||
import com.dzeio.openhealth.databinding.DialogFoodSearchProductBinding
|
import com.dzeio.openhealth.data.food.Food
|
||||||
|
import com.dzeio.openhealth.databinding.DialogSearchBinding
|
||||||
import com.dzeio.openhealth.utils.NetworkResult
|
import com.dzeio.openhealth.utils.NetworkResult
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class SearchFoodDialog :
|
class SearchFoodDialog :
|
||||||
BaseDialog<SearchFoodDialogViewModel, DialogFoodSearchProductBinding>(
|
BaseDialog<SearchFoodDialogViewModel, DialogSearchBinding>(
|
||||||
SearchFoodDialogViewModel::class.java
|
SearchFoodDialogViewModel::class.java
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override val bindingInflater: (LayoutInflater) -> DialogFoodSearchProductBinding =
|
override val bindingInflater: (LayoutInflater) -> DialogSearchBinding =
|
||||||
DialogFoodSearchProductBinding::inflate
|
DialogSearchBinding::inflate
|
||||||
|
|
||||||
override fun onBuilderInit(builder: MaterialAlertDialogBuilder) {
|
override fun onBuilderInit(builder: MaterialAlertDialogBuilder) {
|
||||||
super.onBuilderInit(builder)
|
super.onBuilderInit(builder)
|
||||||
@ -43,7 +45,7 @@ class SearchFoodDialog :
|
|||||||
dialog.setOnShowListener {
|
dialog.setOnShowListener {
|
||||||
val btn = dialog.getButton(AlertDialog.BUTTON_NEUTRAL)
|
val btn = dialog.getButton(AlertDialog.BUTTON_NEUTRAL)
|
||||||
btn.setOnClickListener {
|
btn.setOnClickListener {
|
||||||
viewModel.search(binding.input.text.toString())
|
viewModel.search(binding.search.text.toString())
|
||||||
binding.loading.visibility = View.VISIBLE
|
binding.loading.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,10 +59,10 @@ class SearchFoodDialog :
|
|||||||
val manager = LinearLayoutManager(requireContext())
|
val manager = LinearLayoutManager(requireContext())
|
||||||
recycler.layoutManager = manager
|
recycler.layoutManager = manager
|
||||||
|
|
||||||
val adapter = FoodAdapter()
|
val adapter = ItemAdapter<Food>()
|
||||||
adapter.onItemClick = {
|
adapter.onItemClick = {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val id = viewModel.addProduct(it)
|
val id = viewModel.addProduct(it.value)
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
SearchFoodDialogDirections.actionNavDialogFoodSearchToNavDialogFoodProduct(
|
SearchFoodDialogDirections.actionNavDialogFoodSearchToNavDialogFoodProduct(
|
||||||
id,
|
id,
|
||||||
@ -72,7 +74,25 @@ class SearchFoodDialog :
|
|||||||
recycler.adapter = adapter
|
recycler.adapter = adapter
|
||||||
|
|
||||||
viewModel.items.observe(this) {
|
viewModel.items.observe(this) {
|
||||||
adapter.set(it.data ?: arrayListOf())
|
if (it.data != null) {
|
||||||
|
adapter.set(
|
||||||
|
it.data!!.map { food ->
|
||||||
|
ItemAdapter.Item(
|
||||||
|
food,
|
||||||
|
food.name,
|
||||||
|
getString(
|
||||||
|
R.string.food_description,
|
||||||
|
food.quantity.roundToInt().toString() + food.serving.replace(
|
||||||
|
Regex("\\d+"),
|
||||||
|
""
|
||||||
|
),
|
||||||
|
(food.energy / 100 * food.quantity)
|
||||||
|
),
|
||||||
|
food.image
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
if (it.status == NetworkResult.NetworkStatus.FINISHED) {
|
if (it.status == NetworkResult.NetworkStatus.FINISHED) {
|
||||||
binding.loading.visibility = View.GONE
|
binding.loading.visibility = View.GONE
|
||||||
} else if (it.status == NetworkResult.NetworkStatus.ERRORED) {
|
} else if (it.status == NetworkResult.NetworkStatus.ERRORED) {
|
||||||
|
@ -12,7 +12,8 @@ import com.dzeio.charts.Entry
|
|||||||
import com.dzeio.charts.axis.Line
|
import com.dzeio.charts.axis.Line
|
||||||
import com.dzeio.charts.series.BarSerie
|
import com.dzeio.charts.series.BarSerie
|
||||||
import com.dzeio.openhealth.Application
|
import com.dzeio.openhealth.Application
|
||||||
import com.dzeio.openhealth.adapters.StepsAdapter
|
import com.dzeio.openhealth.R
|
||||||
|
import com.dzeio.openhealth.adapters.ItemAdapter
|
||||||
import com.dzeio.openhealth.core.BaseFragment
|
import com.dzeio.openhealth.core.BaseFragment
|
||||||
import com.dzeio.openhealth.data.step.Step
|
import com.dzeio.openhealth.data.step.Step
|
||||||
import com.dzeio.openhealth.databinding.FragmentStepsHomeBinding
|
import com.dzeio.openhealth.databinding.FragmentStepsHomeBinding
|
||||||
@ -50,16 +51,14 @@ class StepsHomeFragment :
|
|||||||
val manager = LinearLayoutManager(requireContext())
|
val manager = LinearLayoutManager(requireContext())
|
||||||
recycler.layoutManager = manager
|
recycler.layoutManager = manager
|
||||||
|
|
||||||
val adapter = StepsAdapter().apply {
|
val adapter = ItemAdapter<Step>()
|
||||||
this.isDay = isDay
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isDay) {
|
if (!isDay) {
|
||||||
adapter.onItemClick = {
|
adapter.onItemClick = {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
StepsHomeFragmentDirections.actionNavStepsHomeSelf().apply {
|
StepsHomeFragmentDirections.actionNavStepsHomeSelf().apply {
|
||||||
day = it.timestamp
|
day = it.value.timestamp
|
||||||
title = "Steps from " + it.formatTimestamp(true)
|
title = "Steps from " + it.value.formatTimestamp(true)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -137,7 +136,18 @@ class StepsHomeFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDay) {
|
if (isDay) {
|
||||||
adapter.set(filtered)
|
adapter.set(
|
||||||
|
filtered.map {
|
||||||
|
ItemAdapter.Item(
|
||||||
|
it,
|
||||||
|
getString(
|
||||||
|
R.string.steps_count,
|
||||||
|
it.value
|
||||||
|
),
|
||||||
|
it.formatTimestamp(false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
serie.entries = filtered.map {
|
serie.entries = filtered.map {
|
||||||
Entry(
|
Entry(
|
||||||
it.timestamp.toDouble(),
|
it.timestamp.toDouble(),
|
||||||
@ -172,6 +182,17 @@ class StepsHomeFragment :
|
|||||||
adapter.set(
|
adapter.set(
|
||||||
entries.map { Step(value = it.value.y.toInt(), timestamp = it.key) }
|
entries.map { Step(value = it.value.y.toInt(), timestamp = it.key) }
|
||||||
.sortedByDescending { it.timestamp }
|
.sortedByDescending { it.timestamp }
|
||||||
|
.map {
|
||||||
|
ItemAdapter.Item(
|
||||||
|
it,
|
||||||
|
getString(
|
||||||
|
R.string.steps_count,
|
||||||
|
it.value
|
||||||
|
),
|
||||||
|
it.formatTimestamp(true),
|
||||||
|
icon = R.drawable.ic_zoom_out_map
|
||||||
|
)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
serie.entries = ArrayList(entries.values)
|
serie.entries = ArrayList(entries.values)
|
||||||
|
@ -8,9 +8,12 @@ import androidx.navigation.fragment.findNavController
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.dzeio.charts.Entry
|
import com.dzeio.charts.Entry
|
||||||
import com.dzeio.charts.series.BarSerie
|
import com.dzeio.charts.series.BarSerie
|
||||||
import com.dzeio.openhealth.adapters.WaterAdapter
|
import com.dzeio.openhealth.R
|
||||||
|
import com.dzeio.openhealth.adapters.ItemAdapter
|
||||||
import com.dzeio.openhealth.core.BaseFragment
|
import com.dzeio.openhealth.core.BaseFragment
|
||||||
|
import com.dzeio.openhealth.data.water.Water
|
||||||
import com.dzeio.openhealth.databinding.FragmentMainWaterHomeBinding
|
import com.dzeio.openhealth.databinding.FragmentMainWaterHomeBinding
|
||||||
|
import com.dzeio.openhealth.units.Units
|
||||||
import com.dzeio.openhealth.utils.ChartUtils
|
import com.dzeio.openhealth.utils.ChartUtils
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
@ -34,15 +37,16 @@ class WaterHomeFragment :
|
|||||||
val manager = LinearLayoutManager(requireContext())
|
val manager = LinearLayoutManager(requireContext())
|
||||||
recycler.layoutManager = manager
|
recycler.layoutManager = manager
|
||||||
|
|
||||||
val adapter = WaterAdapter()
|
val adapter = ItemAdapter<Water>().apply {
|
||||||
adapter.onItemClick = {
|
onItemClick = {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
WaterHomeFragmentDirections.actionNavWaterHomeToNavWaterEdit(
|
WaterHomeFragmentDirections.actionNavWaterHomeToNavWaterEdit(
|
||||||
it.id
|
it.value.id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
recycler.adapter = adapter
|
recycler.adapter = this
|
||||||
|
}
|
||||||
|
|
||||||
val chart = binding.chart
|
val chart = binding.chart
|
||||||
|
|
||||||
@ -58,6 +62,7 @@ class WaterHomeFragment :
|
|||||||
xAxis.apply {
|
xAxis.apply {
|
||||||
dataWidth = 604800000.0
|
dataWidth = 604800000.0
|
||||||
textPaint.textSize = 32f
|
textPaint.textSize = 32f
|
||||||
|
scrollEnabled = true
|
||||||
onValueFormat = onValueFormat@{
|
onValueFormat = onValueFormat@{
|
||||||
return@onValueFormat SimpleDateFormat(
|
return@onValueFormat SimpleDateFormat(
|
||||||
"yyyy-MM-dd",
|
"yyyy-MM-dd",
|
||||||
@ -74,7 +79,20 @@ class WaterHomeFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewModel.items.observe(viewLifecycleOwner) { list ->
|
viewModel.items.observe(viewLifecycleOwner) { list ->
|
||||||
adapter.set(list)
|
val unit = Units.Volume.MILLILITER
|
||||||
|
adapter.set(
|
||||||
|
list.map {
|
||||||
|
ItemAdapter.Item(
|
||||||
|
it,
|
||||||
|
getString(
|
||||||
|
unit.unit,
|
||||||
|
unit.formatToString(it.value)
|
||||||
|
),
|
||||||
|
it.formatTimestamp(),
|
||||||
|
icon = R.drawable.ic_outline_edit_24
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return@observe
|
return@observe
|
||||||
@ -88,7 +106,9 @@ class WaterHomeFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
serie.entries = dataset as ArrayList<Entry>
|
serie.entries = dataset as ArrayList<Entry>
|
||||||
chart.xAxis.x = dataset[0].x
|
chart.xAxis.x = chart.xAxis.getXMin()
|
||||||
|
chart.xAxis.x =
|
||||||
|
chart.xAxis.getXMax() - chart.xAxis.dataWidth!! + chart.xAxis.dataWidth!! / 7
|
||||||
chart.refresh()
|
chart.refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.dzeio.openhealth.ui.water
|
package com.dzeio.openhealth.ui.water
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.widget.doOnTextChanged
|
||||||
import com.dzeio.openhealth.R
|
import com.dzeio.openhealth.R
|
||||||
|
import com.dzeio.openhealth.Settings
|
||||||
import com.dzeio.openhealth.core.BaseDialog
|
import com.dzeio.openhealth.core.BaseDialog
|
||||||
import com.dzeio.openhealth.databinding.DialogWaterSizeSelectorBinding
|
import com.dzeio.openhealth.databinding.DialogWaterSizeSelectorBinding
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -30,50 +30,47 @@ class WaterSizeSelectorDialog :
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewModel.cupSize.observe(this) {
|
viewModel.cupSize.observe(this) {
|
||||||
|
var real = it ?: Settings.WATER_INTAKE_SIZE_DEFAULT
|
||||||
binding.customSize.text = String.format(
|
binding.customSize.text = String.format(
|
||||||
getString(R.string.custom_amount),
|
getString(R.string.custom_amount),
|
||||||
"${it}ml"
|
"${real}ml"
|
||||||
)
|
)
|
||||||
|
if (binding.inputParent.visibility == View.GONE) {
|
||||||
|
binding.input.setText(real.toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.size100ml.setOnClickListener {
|
binding.size100ml.setOnClickListener {
|
||||||
|
setTextFieldStatus()
|
||||||
viewModel.setCupSize(100)
|
viewModel.setCupSize(100)
|
||||||
}
|
}
|
||||||
binding.size250ml.setOnClickListener {
|
binding.size250ml.setOnClickListener {
|
||||||
|
setTextFieldStatus()
|
||||||
viewModel.setCupSize(250)
|
viewModel.setCupSize(250)
|
||||||
}
|
}
|
||||||
binding.size500ml.setOnClickListener {
|
binding.size500ml.setOnClickListener {
|
||||||
|
setTextFieldStatus()
|
||||||
viewModel.setCupSize(500)
|
viewModel.setCupSize(500)
|
||||||
}
|
}
|
||||||
binding.size1000ml.setOnClickListener {
|
binding.size1000ml.setOnClickListener {
|
||||||
|
setTextFieldStatus()
|
||||||
viewModel.setCupSize(1000)
|
viewModel.setCupSize(1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.customSize.setOnClickListener {
|
binding.customSize.setOnClickListener {
|
||||||
val editTextLayout = TextInputLayout(requireContext())
|
setTextFieldStatus(true)
|
||||||
|
}
|
||||||
|
|
||||||
val editText = TextInputEditText(requireContext())
|
binding.input.doOnTextChanged { text, start, before, count ->
|
||||||
editText.setText(viewModel.cupSize.value.toString())
|
val newSize = text.toString().toIntOrNull()
|
||||||
|
if (newSize != null) {
|
||||||
|
viewModel.setCupSize(newSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editTextLayout.addView(editText)
|
private fun setTextFieldStatus(displayed: Boolean = false) {
|
||||||
|
binding.inputParent.visibility = if (displayed) View.VISIBLE else View.GONE
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
binding.customSize.visibility = if (displayed) View.GONE else View.VISIBLE
|
||||||
.setView(editTextLayout)
|
|
||||||
.setTitle("Custom Cup Size")
|
|
||||||
.setOnCancelListener {
|
|
||||||
it.dismiss()
|
|
||||||
}
|
|
||||||
.setNegativeButton(R.string.cancel) { dialog, _ ->
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
.setPositiveButton(
|
|
||||||
R.string.validate
|
|
||||||
) { dialog, _ ->
|
|
||||||
viewModel.setCupSize(editText.text.toString().toInt())
|
|
||||||
dismiss()
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,19 @@
|
|||||||
package com.dzeio.openhealth.ui.water
|
package com.dzeio.openhealth.ui.water
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
import com.dzeio.openhealth.Settings
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import com.dzeio.openhealth.core.BaseViewModel
|
import com.dzeio.openhealth.core.BaseViewModel
|
||||||
|
import com.dzeio.openhealth.utils.Configuration
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class WaterSizeSelectorViewModel @Inject constructor(
|
class WaterSizeSelectorViewModel @Inject constructor(
|
||||||
private val settings: SharedPreferences
|
private val settings: Configuration
|
||||||
) : BaseViewModel() {
|
) : BaseViewModel() {
|
||||||
|
|
||||||
private val _cupSize = MutableLiveData(0)
|
val cupSize = settings.getInt(Settings.WATER_INTAKE_SIZE).toLiveData()
|
||||||
|
|
||||||
val cupSize = _cupSize
|
|
||||||
|
|
||||||
init {
|
|
||||||
val cup = settings.getInt("water_cup_size", -1)
|
|
||||||
if (cup != -1) {
|
|
||||||
_cupSize.value = cup
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setCupSize(value: Int) {
|
fun setCupSize(value: Int) {
|
||||||
settings.edit()
|
settings.getInt(Settings.WATER_INTAKE_SIZE).value = value
|
||||||
.putInt("water_cup_size", value)
|
|
||||||
.apply()
|
|
||||||
|
|
||||||
_cupSize.value = value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,11 @@ import com.dzeio.charts.axis.Line
|
|||||||
import com.dzeio.charts.series.LineSerie
|
import com.dzeio.charts.series.LineSerie
|
||||||
import com.dzeio.openhealth.BuildConfig
|
import com.dzeio.openhealth.BuildConfig
|
||||||
import com.dzeio.openhealth.R
|
import com.dzeio.openhealth.R
|
||||||
import com.dzeio.openhealth.adapters.WeightAdapter
|
import com.dzeio.openhealth.adapters.ItemAdapter
|
||||||
import com.dzeio.openhealth.core.BaseFragment
|
import com.dzeio.openhealth.core.BaseFragment
|
||||||
import com.dzeio.openhealth.data.weight.Weight
|
import com.dzeio.openhealth.data.weight.Weight
|
||||||
import com.dzeio.openhealth.databinding.FragmentListWeightBinding
|
import com.dzeio.openhealth.databinding.FragmentListWeightBinding
|
||||||
|
import com.dzeio.openhealth.units.Units
|
||||||
import com.dzeio.openhealth.utils.PermissionsManager
|
import com.dzeio.openhealth.utils.PermissionsManager
|
||||||
import com.google.android.material.color.MaterialColors
|
import com.google.android.material.color.MaterialColors
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
@ -113,11 +114,11 @@ class ListWeightFragment :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapter = WeightAdapter().apply {
|
val adapter = ItemAdapter<Weight>().apply {
|
||||||
onItemClick = {
|
onItemClick = {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
ListWeightFragmentDirections.actionNavListWeightToNavEditWeight(
|
ListWeightFragmentDirections.actionNavListWeightToNavEditWeight(
|
||||||
it.id
|
it.value.id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -129,16 +130,23 @@ class ListWeightFragment :
|
|||||||
this.adapter = adapter
|
this.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.massUnit.observe(viewLifecycleOwner) {
|
viewModel.weights.observe(viewLifecycleOwner) { list ->
|
||||||
adapter.unit = it
|
if (list != null) {
|
||||||
}
|
val unit = viewModel.massUnit.value ?: Units.Mass.KILOGRAM
|
||||||
|
adapter.set(
|
||||||
viewModel.weights.observe(viewLifecycleOwner) {
|
list.map {
|
||||||
if (it != null) {
|
ItemAdapter.Item(
|
||||||
val itt = it.toMutableList()
|
it,
|
||||||
itt.sortWith { o1, o2 -> if (o1.timestamp > o2.timestamp) -1 else 1 }
|
getString(
|
||||||
adapter.set(itt)
|
unit.unit,
|
||||||
updateGraph(it)
|
unit.formatToString(it.weight)
|
||||||
|
),
|
||||||
|
it.formatTimestamp(),
|
||||||
|
icon = R.drawable.ic_outline_edit_24
|
||||||
|
)
|
||||||
|
}.reversed()
|
||||||
|
)
|
||||||
|
updateGraph(list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ class Configuration(
|
|||||||
return cache[key] as BooleanField
|
return cache[key] as BooleanField
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getInt(key: String): IntField {
|
fun getInt(key: String, defaultValue: Int? = null): IntField {
|
||||||
if (cache[key] == null) {
|
if (cache[key] == null) {
|
||||||
// Log.d(TAG, "$key is not cache, creating new instance")
|
// Log.d(TAG, "$key is not cache, creating new instance")
|
||||||
cache[key] = IntField(key)
|
cache[key] = IntField(key, defaultValue)
|
||||||
} else {
|
} else {
|
||||||
// Log.d(TAG, "$key in cache")
|
// Log.d(TAG, "$key in cache")
|
||||||
}
|
}
|
||||||
@ -141,10 +141,15 @@ class Configuration(
|
|||||||
|
|
||||||
inner class IntField(
|
inner class IntField(
|
||||||
private val key: String,
|
private val key: String,
|
||||||
private val defaultValue: Int = -1
|
private val defaultValue: Int? = null
|
||||||
) : Field<Int?>(defaultValue) {
|
) : Field<Int?>(defaultValue) {
|
||||||
override fun exists(): Boolean = prefs.contains(key)
|
override fun exists(): Boolean = prefs.contains(key)
|
||||||
override fun internalGet(): Int = prefs.getInt(key, defaultValue)
|
override fun internalGet(): Int? {
|
||||||
|
if (exists()) {
|
||||||
|
return prefs.getInt(key, 0)
|
||||||
|
}
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
override fun internalSet(value: Int?) =
|
override fun internalSet(value: Int?) =
|
||||||
prefs.edit { if (value == null) remove(key) else putInt(key, value) }
|
prefs.edit { if (value == null) remove(key) else putInt(key, value) }
|
||||||
}
|
}
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24"
|
|
||||||
android:tint="?attr/colorControlNormal">
|
|
||||||
<path
|
|
||||||
android:fillColor="@android:color/white"
|
|
||||||
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
|
|
||||||
</vector>
|
|
Binary file not shown.
Before Width: | Height: | Size: 19 KiB |
@ -18,7 +18,7 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<android.widget.NumberPicker
|
<NumberPicker
|
||||||
android:id="@+id/layout_dialog_edit_weight_kg"
|
android:id="@+id/layout_dialog_edit_weight_kg"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -26,7 +26,7 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
tools:layout_editor_absoluteY="0dp" />
|
tools:layout_editor_absoluteY="0dp" />
|
||||||
|
|
||||||
<android.widget.NumberPicker
|
<NumberPicker
|
||||||
android:id="@+id/layout_dialog_edit_weight_gram"
|
android:id="@+id/layout_dialog_edit_weight_gram"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:srcCompat="@tools:sample/avatars" />
|
tools:srcCompat="@tools:sample/avatars" />
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center"
|
|
||||||
android:paddingHorizontal="16dp"
|
|
||||||
android:nestedScrollingEnabled="true"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
|
||||||
android:id="@+id/input"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/loading"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/error_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/connectivity_error" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:itemCount="5"
|
|
||||||
tools:listitem="@layout/item_food">
|
|
||||||
|
|
||||||
</androidx.recyclerview.widget.RecyclerView>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -87,11 +87,24 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:visibility="visible"
|
||||||
android:text="@string/custom_amount"
|
android:text="@string/custom_amount"
|
||||||
style="@style/Widget.Material3.Button.TextButton"
|
style="@style/Widget.Material3.Button.TextButton"
|
||||||
tools:text="Custom amount: 1234ml"
|
tools:text="Custom amount: 1234ml"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/input_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/input"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -172,7 +172,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
tools:listitem="@layout/layout_item_list"
|
tools:listitem="@layout/item_list"
|
||||||
tools:context=".ui.weight.ListWeightFragment" />
|
tools:context=".ui.weight.ListWeightFragment" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -5,6 +5,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"
|
||||||
|
android:padding="16dp"
|
||||||
tools:context=".ui.home.HomeFragment">
|
tools:context=".ui.home.HomeFragment">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@ -12,6 +13,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
android:text="Goto Tests" />
|
android:text="Goto Tests" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -23,9 +25,9 @@
|
|||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="?attr/materialCardViewFilledStyle"
|
style="?attr/materialCardViewFilledStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginRight="8dp"
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -143,10 +145,8 @@
|
|||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="?attr/materialCardViewFilledStyle"
|
style="?attr/materialCardViewFilledStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -264,7 +264,6 @@
|
|||||||
style="?attr/materialCardViewFilledStyle"
|
style="?attr/materialCardViewFilledStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginTop="16dp">
|
android:layout_marginTop="16dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -314,8 +313,7 @@
|
|||||||
android:id="@+id/weight_graph"
|
android:id="@+id/weight_graph"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="150dp"
|
android:layout_height="150dp"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp" />
|
||||||
android:minHeight="200dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -19,43 +19,32 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:padding="16dp"
|
||||||
android:paddingHorizontal="12dp"
|
>
|
||||||
android:paddingVertical="16dp">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:paddingVertical="8dp"
|
android:paddingVertical="8dp"
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:src="@drawable/ic_bluetooth"
|
android:src="@drawable/ic_bluetooth"
|
||||||
android:background="@drawable/shape_circle"
|
android:background="@drawable/shape_circle"
|
||||||
app:tint="?colorOnPrimary" />
|
app:tint="?colorOnPrimary" />
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:orientation="vertical">
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:text="@string/bluetooth_scale" />
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingBottom="4dp"
|
|
||||||
android:text="Bluetooth Scale Status" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bluetooth_button"
|
android:id="@+id/bluetooth_button"
|
||||||
android:text="@string/add_goal"
|
android:text="@string/sync"
|
||||||
style="?materialButtonOutlinedStyle"
|
style="?materialButtonOutlinedStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginVertical="16dp"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@ -139,14 +128,14 @@
|
|||||||
android:text="Generate random values" />
|
android:text="Generate random values" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:clipToPadding="false"
|
|
||||||
android:id="@+id/list"
|
android:id="@+id/list"
|
||||||
android:padding="16dp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:padding="16dp"
|
||||||
|
|
||||||
tools:listitem="@layout/layout_item_list"
|
tools:context=".ui.weight.ListWeightFragment"
|
||||||
tools:context=".ui.weight.ListWeightFragment" />
|
tools:listitem="@layout/item_list" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@ -56,6 +55,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
tools:listitem="@layout/layout_item_list" />
|
tools:listitem="@layout/item_list" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
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"
|
||||||
@ -56,6 +55,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
tools:listitem="@layout/layout_item_list" />
|
tools:listitem="@layout/item_list" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
style="?attr/materialCardViewFilledStyle"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:id="@+id/edit"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:weightSum="1">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/product_image"
|
|
||||||
android:layout_width="43dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
|
|
||||||
tools:srcCompat="@tools:sample/avatars" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/food_name"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Name of food" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/food_description"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:text="250g (800kcal)" />
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:src="@drawable/ic_baseline_edit_24" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -55,7 +55,7 @@
|
|||||||
android:id="@+id/icon_right"
|
android:id="@+id/icon_right"
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:src="@drawable/ic_baseline_edit_24" />
|
android:src="@drawable/ic_outline_edit_24" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
style="?attr/materialCardViewFilledStyle"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:id="@+id/card"
|
|
||||||
android:layout_marginEnd="16dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:id="@+id/logo"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginVertical="16dp"
|
|
||||||
android:src="@drawable/ic_logo_fit" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="54dp"
|
|
||||||
android:layout_marginVertical="16dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
style="@style/TextAppearance.Material3.TitleMedium"
|
|
||||||
android:id="@+id/name"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Google Fit" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/status"
|
|
||||||
style="@style/TextAppearance.Material3.BodyMedium"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Last Sync: Yesterday" />
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/icon"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginVertical="16dp"
|
|
||||||
android:src="@drawable/ic_baseline_extension_24" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
style="?attr/materialCardViewFilledStyle"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:id="@+id/edit"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:weightSum="1">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/value"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="xkg" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/datetime"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:text="Taken: yyyy-mm-dd" />
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/icon_right"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:src="@drawable/ic_baseline_edit_24" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@drawable/vector_logo_background"/>
|
<background android:drawable="@drawable/logo_background"/>
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
|
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
|
@ -183,7 +183,7 @@
|
|||||||
<dialog
|
<dialog
|
||||||
android:id="@+id/nav_dialog_food_search"
|
android:id="@+id/nav_dialog_food_search"
|
||||||
android:name="com.dzeio.openhealth.ui.food.SearchFoodDialog"
|
android:name="com.dzeio.openhealth.ui.food.SearchFoodDialog"
|
||||||
tools:layout="@layout/dialog_food_search_product"
|
tools:layout="@layout/dialog_search"
|
||||||
>
|
>
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_nav_dialog_food_search_to_nav_dialog_food_product"
|
android:id="@+id/action_nav_dialog_food_search_to_nav_dialog_food_product"
|
||||||
|
@ -55,5 +55,7 @@
|
|||||||
<string name="error_reporter_crash">Erreur lors de la géneration d\'un rapport d\'erreur</string>
|
<string name="error_reporter_crash">Erreur lors de la géneration d\'un rapport d\'erreur</string>
|
||||||
<string name="steps_count">%1$d pas</string>
|
<string name="steps_count">%1$d pas</string>
|
||||||
<string name="connectivity_error">Il semplerais que nous ne pouvons pas communiquer avec OpenFoodFact, Merci de re-essayer plus tard</string>
|
<string name="connectivity_error">Il semplerais que nous ne pouvons pas communiquer avec OpenFoodFact, Merci de re-essayer plus tard</string>
|
||||||
|
<string name="bluetooth_scale">Balance bluetooth</string>
|
||||||
|
<string name="sync">Synchroniser</string>
|
||||||
|
<string name="searching_scales">Recherche de balances connecté...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -68,5 +68,7 @@
|
|||||||
<string name="food_description" translatable="false">%1$s (%2$.0f kcal)</string>
|
<string name="food_description" translatable="false">%1$s (%2$.0f kcal)</string>
|
||||||
<string name="steps_count">%1$d steps</string>
|
<string name="steps_count">%1$d steps</string>
|
||||||
<string name="connectivity_error">It seems that we can\'t communicate with OpenFoodFact, please retry later</string>
|
<string name="connectivity_error">It seems that we can\'t communicate with OpenFoodFact, please retry later</string>
|
||||||
<string name="searching_scales">Searchin Scales</string>
|
<string name="searching_scales">Searching Scales</string>
|
||||||
|
<string name="sync">Sync</string>
|
||||||
|
<string name="bluetooth_scale">Bluetooth Scale</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -15,9 +15,9 @@ buildscript {
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
// android app plugin ? (tbh idk what thoses "plugins" does)
|
// android app plugin ? (tbh idk what thoses "plugins" does)
|
||||||
id("com.android.application") version "7.4.0" apply false
|
id("com.android.application") version "7.4.1" apply false
|
||||||
// is it a lib? no, do I need it? IDK
|
// is it a lib? no, do I need it? IDK
|
||||||
id("com.android.library") version "7.4.0" apply false
|
id("com.android.library") version "7.4.1" apply false
|
||||||
|
|
||||||
// add kotlin compatibility :>
|
// add kotlin compatibility :>
|
||||||
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
|
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user