From 632cf8c873134f9874e0b9e24db63ebd1487addb Mon Sep 17 00:00:00 2001 From: Alejandro Ismael Silva Date: Wed, 2 Oct 2019 16:09:34 -0300 Subject: [PATCH] Show more in home, removed estimations, fixed compilation warnings --- app/build.gradle | 22 +- .../com.uncmorfi.models.AppDatabase/1.json | 231 ++++++++++++++++++ .../main/java/com/uncmorfi/MainActivity.kt | 4 + .../com/uncmorfi/balance/BalanceFragment.kt | 2 +- .../balance/dialogs/UserOptionsDialog.kt | 8 +- .../java/com/uncmorfi/home/HomeFragment.kt | 24 +- .../java/com/uncmorfi/menu/MenuAdapter.kt | 4 +- .../java/com/uncmorfi/models/Reservation.kt | 2 +- .../uncmorfi/reservations/CaptchaDialog.kt | 2 +- .../com/uncmorfi/servings/ServingsFragment.kt | 90 +------ .../uncmorfi/servings/TotalPieChartView.kt | 6 +- .../com/uncmorfi/viewmodel/MainViewModel.kt | 1 - app/src/main/res/drawable/ic_arrow.xml | 9 + app/src/main/res/layout/fragment_balance.xml | 5 - app/src/main/res/layout/fragment_home.xml | 98 ++++++-- app/src/main/res/layout/fragment_servings.xml | 77 +----- app/src/main/res/layout/item_menu.xml | 10 +- app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-v21/styles.xml | 4 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 17 +- 21 files changed, 388 insertions(+), 230 deletions(-) create mode 100644 app/schemas/com.uncmorfi.models.AppDatabase/1.json create mode 100644 app/src/main/res/drawable/ic_arrow.xml diff --git a/app/build.gradle b/app/build.gradle index c5d1a5c..503e436 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,6 +14,11 @@ android { versionCode 11 versionName "v6.0 Florentina" resValue "string", "app_name", "UNCmorfi" + kapt { + arguments { + arg("room.schemaLocation", "$projectDir/schemas".toString()) + } + } } buildTypes { release { @@ -32,23 +37,22 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'org.apache.commons:commons-math3:3.6.1' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31' - implementation 'androidx.appcompat:appcompat:1.1.0-alpha05' - implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha05' + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0-beta04' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1' - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha03' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha03' - implementation 'androidx.core:core-ktx:1.2.0-alpha01' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha05' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha05' + implementation 'androidx.core:core-ktx:1.2.0-alpha04' - def room_version = "2.2.0-alpha02" + def room_version = "2.2.0-rc01" implementation "androidx.room:room-runtime:$room_version" kapt "androidx.room:room-compiler:$room_version" implementation "androidx.room:room-ktx:$room_version" - implementation 'com.google.android.material:material:1.1.0-alpha07' + implementation 'com.google.android.material:material:1.1.0-alpha10' implementation 'com.google.android.gms:play-services-maps:17.0.0' implementation 'com.github.bumptech.glide:glide:4.9.0' diff --git a/app/schemas/com.uncmorfi.models.AppDatabase/1.json b/app/schemas/com.uncmorfi.models.AppDatabase/1.json new file mode 100644 index 0000000..aa51bf2 --- /dev/null +++ b/app/schemas/com.uncmorfi.models.AppDatabase/1.json @@ -0,0 +1,231 @@ +{ + "formatVersion": 1, + "database": { + "version": 1, + "identityHash": "3973efb2e7e8de8d8e6b7afa6dd74adf", + "entities": [ + { + "tableName": "users", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`card` TEXT NOT NULL, `name` TEXT, `type` TEXT, `image` TEXT, `balance` INTEGER NOT NULL, `expiration` TEXT NOT NULL, `lastUpdate` TEXT NOT NULL, PRIMARY KEY(`card`))", + "fields": [ + { + "fieldPath": "card", + "columnName": "card", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "image", + "columnName": "image", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "balance", + "columnName": "balance", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "expiration", + "columnName": "expiration", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "lastUpdate", + "columnName": "lastUpdate", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "card" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "menu", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`date` TEXT NOT NULL, `food` TEXT NOT NULL, PRIMARY KEY(`date`))", + "fields": [ + { + "fieldPath": "date", + "columnName": "date", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "food", + "columnName": "food", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "date" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "servings", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`date` TEXT NOT NULL, `serving` INTEGER NOT NULL, PRIMARY KEY(`date`))", + "fields": [ + { + "fieldPath": "date", + "columnName": "date", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "serving", + "columnName": "serving", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "date" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "reservations", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`code` TEXT NOT NULL, `token` TEXT NOT NULL, `path` TEXT NOT NULL, PRIMARY KEY(`code`), FOREIGN KEY(`code`) REFERENCES `users`(`card`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "code", + "columnName": "code", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "token", + "columnName": "token", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "path", + "columnName": "path", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "code" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [ + { + "table": "users", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "code" + ], + "referencedColumns": [ + "card" + ] + } + ] + }, + { + "tableName": "cookies", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cookieId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `code_id` TEXT NOT NULL, `domain` TEXT NOT NULL, `value` TEXT NOT NULL, `name` TEXT NOT NULL, FOREIGN KEY(`code_id`) REFERENCES `reservations`(`code`) ON UPDATE NO ACTION ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "cookieId", + "columnName": "cookieId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "code", + "columnName": "code_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "domain", + "columnName": "domain", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "value", + "columnName": "value", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "cookieId" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_cookies_code_id", + "unique": false, + "columnNames": [ + "code_id" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_cookies_code_id` ON `${TABLE_NAME}` (`code_id`)" + } + ], + "foreignKeys": [ + { + "table": "reservations", + "onDelete": "CASCADE", + "onUpdate": "NO ACTION", + "columns": [ + "code_id" + ], + "referencedColumns": [ + "code" + ] + } + ] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3973efb2e7e8de8d8e6b7afa6dd74adf')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/com/uncmorfi/MainActivity.kt b/app/src/main/java/com/uncmorfi/MainActivity.kt index 682ee58..1285f80 100644 --- a/app/src/main/java/com/uncmorfi/MainActivity.kt +++ b/app/src/main/java/com/uncmorfi/MainActivity.kt @@ -135,4 +135,8 @@ class MainActivity : return fragment } + fun change(id: Int) { + replaceFragment(id) + navView.setCheckedItem(id) + } } \ No newline at end of file diff --git a/app/src/main/java/com/uncmorfi/balance/BalanceFragment.kt b/app/src/main/java/com/uncmorfi/balance/BalanceFragment.kt index 191d982..f773635 100644 --- a/app/src/main/java/com/uncmorfi/balance/BalanceFragment.kt +++ b/app/src/main/java/com/uncmorfi/balance/BalanceFragment.kt @@ -105,7 +105,7 @@ class BalanceFragment : Fragment() { private fun showUserOptionsDialog(user: User) { UserOptionsDialog.newInstance(this, USER_OPTIONS_CODE, user) - .show(fragmentManager!!, "UserOptionsDialog") + .show(parentFragmentManager, "UserOptionsDialog") } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { diff --git a/app/src/main/java/com/uncmorfi/balance/dialogs/UserOptionsDialog.kt b/app/src/main/java/com/uncmorfi/balance/dialogs/UserOptionsDialog.kt index f6fe158..8118fab 100644 --- a/app/src/main/java/com/uncmorfi/balance/dialogs/UserOptionsDialog.kt +++ b/app/src/main/java/com/uncmorfi/balance/dialogs/UserOptionsDialog.kt @@ -39,7 +39,7 @@ class UserOptionsDialog: BaseDialogHelper() { 1 -> reservation() 2 -> DeleteUserDialog .newInstance(this, 0, user) - .show(fragmentManager!!, "DeleteUserDialog") + .show(parentFragmentManager, "DeleteUserDialog") 3 -> { context?.copyToClipboard("card", user.card) viewModel.status.value = StatusCode.COPIED @@ -47,7 +47,7 @@ class UserOptionsDialog: BaseDialogHelper() { 4 -> startActivity(BarcodeActivity.intent(context!!, user)) 5 -> SetNameDialog .newInstance(this, 0, user) - .show(fragmentManager!!, "SetNameDialog") + .show(parentFragmentManager, "SetNameDialog") } } return builder.create() @@ -64,11 +64,11 @@ class UserOptionsDialog: BaseDialogHelper() { if (reserveCached) { ReserveOptionsDialog .newInstance(this, 0, user) - .show(fragmentManager!!, "ReserveOptionsDialog") + .show(parentFragmentManager, "ReserveOptionsDialog") } else { CaptchaDialog .newInstance(this, 0, user) - .show(fragmentManager!!, "CaptchaDialog") + .show(parentFragmentManager, "CaptchaDialog") } } diff --git a/app/src/main/java/com/uncmorfi/home/HomeFragment.kt b/app/src/main/java/com/uncmorfi/home/HomeFragment.kt index 40e50be..d074f80 100644 --- a/app/src/main/java/com/uncmorfi/home/HomeFragment.kt +++ b/app/src/main/java/com/uncmorfi/home/HomeFragment.kt @@ -10,6 +10,7 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider +import com.uncmorfi.MainActivity import com.uncmorfi.R import com.uncmorfi.balance.dialogs.UserOptionsDialog import com.uncmorfi.models.DayMenu @@ -73,6 +74,9 @@ class HomeFragment : Fragment() { homeMenuContainer.visibility = GONE } }) + homeMenuShowMore.setOnClickListener { + (requireActivity() as MainActivity).change(R.id.nav_menu) + } /* * Tarjetas @@ -88,31 +92,37 @@ class HomeFragment : Fragment() { homeCardContainer.visibility = GONE } }) - homeCardContainer.setOnClickListener { + homeCard.setOnClickListener { UserOptionsDialog .newInstance(this, USER_OPTIONS_CODE, mUser) - .show(fragmentManager!!, "UserOptionsDialog") + .show(parentFragmentManager, "UserOptionsDialog") } - homeCardContainer.setOnLongClickListener { + homeCard.setOnLongClickListener { mUser.isLoading = true homeCard.setUser(mUser) mViewModel.downloadUsers(mUser) true } + homeCardShowMore.setOnClickListener { + (requireActivity() as MainActivity).change(R.id.nav_balance) + } /* * Medidor */ mViewModel.getServings().observe(this, Observer { if (it.isNotEmpty()) { - servingsPieChart.set(it) + homeServingsPieChart.set(it) } }) - servingsPieChart.setTouchEnabled(false) - homeServingsContainer.setOnClickListener { - mRootView.snack(R.string.snack_updating, LOADING) + homeServingsPieChart.setTouchEnabled(false) + homeServingsPieChart.setOnClickListener { + homeSwipeRefresh.isRefreshing = true mViewModel.updateServings() } + homeServingsShowMore.setOnClickListener { + (requireActivity() as MainActivity).change(R.id.nav_servings) + } /* * Reservas diff --git a/app/src/main/java/com/uncmorfi/menu/MenuAdapter.kt b/app/src/main/java/com/uncmorfi/menu/MenuAdapter.kt index 75cf346..787f79c 100644 --- a/app/src/main/java/com/uncmorfi/menu/MenuAdapter.kt +++ b/app/src/main/java/com/uncmorfi/menu/MenuAdapter.kt @@ -19,8 +19,8 @@ internal class MenuAdapter (private val mContext: Context, fun bind(day: DayMenu) { itemView.menuView.setDayMenu(day) - itemView.menuCard.setOnClickListener { mClickListener(day) } - itemView.menuCard.setOnLongClickListener { mLongClickListener(day); true } + itemView.menuView.setOnClickListener { mClickListener(day) } + itemView.menuView.setOnLongClickListener { mLongClickListener(day); true } } } diff --git a/app/src/main/java/com/uncmorfi/models/Reservation.kt b/app/src/main/java/com/uncmorfi/models/Reservation.kt index 9cb6b10..aec4e47 100644 --- a/app/src/main/java/com/uncmorfi/models/Reservation.kt +++ b/app/src/main/java/com/uncmorfi/models/Reservation.kt @@ -25,7 +25,7 @@ data class Reservation( childColumns = arrayOf("code_id"))]) data class Cookie( @PrimaryKey(autoGenerate = true) var cookieId: Int = 0, - @ColumnInfo(name = "code_id") var code: String, + @ColumnInfo(name = "code_id", index = true) var code: String, var domain: String = "", var value: String = "", diff --git a/app/src/main/java/com/uncmorfi/reservations/CaptchaDialog.kt b/app/src/main/java/com/uncmorfi/reservations/CaptchaDialog.kt index 8e747e5..479e1ac 100644 --- a/app/src/main/java/com/uncmorfi/reservations/CaptchaDialog.kt +++ b/app/src/main/java/com/uncmorfi/reservations/CaptchaDialog.kt @@ -48,7 +48,7 @@ class CaptchaDialog: BaseDialogHelper() { if (it == ReserveStatus.CACHED) { ReserveOptionsDialog .newInstance(this, 0, user) - .show(fragmentManager!!, "ReserveOptionsDialog") + .show(parentFragmentManager, "ReserveOptionsDialog") dismiss() } }) diff --git a/app/src/main/java/com/uncmorfi/servings/ServingsFragment.kt b/app/src/main/java/com/uncmorfi/servings/ServingsFragment.kt index 14f24f4..da0bd00 100644 --- a/app/src/main/java/com/uncmorfi/servings/ServingsFragment.kt +++ b/app/src/main/java/com/uncmorfi/servings/ServingsFragment.kt @@ -2,38 +2,29 @@ package com.uncmorfi.servings import android.os.Bundle import android.view.* -import android.widget.SeekBar import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import com.github.mikephil.charting.data.Entry -import com.github.mikephil.charting.interfaces.datasets.ILineDataSet import com.uncmorfi.R import com.uncmorfi.models.Serving -import com.uncmorfi.servings.StyledLineDataSet.Companion.ChartStyle.* +import com.uncmorfi.servings.StyledLineDataSet.Companion.ChartStyle.CUMULATIVE +import com.uncmorfi.servings.StyledLineDataSet.Companion.ChartStyle.RATIONS import com.uncmorfi.shared.StatusCode.BUSY import com.uncmorfi.shared.clearDate import com.uncmorfi.shared.init import com.uncmorfi.shared.startBrowser -import com.uncmorfi.shared.toFormat import com.uncmorfi.viewmodel.MainViewModel import kotlinx.android.synthetic.main.fragment_servings.* -import org.apache.commons.math3.stat.regression.SimpleRegression -import java.util.* -import kotlin.collections.ArrayList -import kotlin.math.roundToInt /** * Medidor de raciones. * Administra la UI con todas sus features. */ -class ServingsFragment : Fragment(), SeekBar.OnSeekBarChangeListener { +class ServingsFragment : Fragment() { private lateinit var mRootView: View private lateinit var mViewModel: MainViewModel - private val mEstimateList = ArrayList() - private var mEstimateFirst: Double = 0.0 - private val mSimpleRegression = SimpleRegression(true) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -51,7 +42,6 @@ class ServingsFragment : Fragment(), SeekBar.OnSeekBarChangeListener { mViewModel = ViewModelProvider(requireActivity()).get(MainViewModel::class.java) servingSwipeRefresh.init { refreshServings() } - servingEstimateChart.init(requireContext()) servingTimeChart.init(requireContext()) servingAccumulatedChart.init(requireContext()) @@ -62,14 +52,8 @@ class ServingsFragment : Fragment(), SeekBar.OnSeekBarChangeListener { servingAccumulatedChart, servingTimeChart) // Parametros especiales de ambos LineChart - servingEstimateChart.legend.isEnabled = false servingAccumulatedChart.xAxis.setDrawGridLines(false) - servingSeek.setOnSeekBarChangeListener(this) - servingSeek.progress = 99 - - servingEstimateButton.setOnClickListener { updateEstimate() } - mViewModel.getServings().observe(this, Observer { servingsPieChart.set(it) updateCharts(it) @@ -80,7 +64,6 @@ class ServingsFragment : Fragment(), SeekBar.OnSeekBarChangeListener { servingSwipeRefresh.isRefreshing = false } }) - refreshServings() } @@ -106,73 +89,6 @@ class ServingsFragment : Fragment(), SeekBar.OnSeekBarChangeListener { mViewModel.updateServings() } - override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { - if (fromUser) { - val windows = progress + 3 // Mínimo 3 ventanas - servingDistance.text = getString(R.string.servings_distance).format(windows) - } - } - - /** - * Estimar el tiempo de espera. - * @param x Distancia (cantidad de ventanas) - * @return Minutos estimados - */ - private fun getEstimateFromPosition(x: Int): Double { - return (x * (x * 0.062307 + 1.296347) - 2.190814) - } - - override fun onStartTrackingTouch(seekBar: SeekBar) {} - - override fun onStopTrackingTouch(seekBar: SeekBar) {} - - /* - * Perdón, esta función tambien horrible de entender. - */ - private fun updateEstimate() { - val windows = servingSeek.progress + 3 // Mínimo 3 ventanas - val time = Calendar.getInstance().clearDate() - val dataSets = ArrayList() - - mEstimateList.add(Entry(time.toFloat(), windows.toFloat())) - - mSimpleRegression.addData(time.toDouble(), windows.toDouble()) - var root = (-mSimpleRegression.intercept / mSimpleRegression.slope) - val estimateLine = ArrayList() - - if (root.isNaN()) { - // Primera estimación - mEstimateFirst = time.toDouble() - root = mEstimateFirst + getEstimateFromPosition(windows) * 60 - estimateLine.add(Entry(mEstimateFirst.toFloat(), windows.toFloat())) - estimateLine.add(Entry(root.toFloat(), 0f)) - } else { - // Estimación con 2 o más datos - estimateLine.add(Entry(mEstimateFirst.toFloat(), - mSimpleRegression.predict(mEstimateFirst).toFloat())) - estimateLine.add(Entry(root.toFloat(), 0f)) - } - - val lineSet = StyledLineDataSet(requireContext(), estimateLine, "", ESTIMATE) - val pointSet = StyledLineDataSet(requireContext(), mEstimateList, "", POINTS) - - dataSets.add(pointSet) - dataSets.add(lineSet) - - servingEstimateChart.visibility = View.VISIBLE - servingEstimateChart.update(dataSets) - - servingEstimateText.visibility = View.VISIBLE - - val timeStamp = Calendar.getInstance() - timeStamp.timeInMillis = root.toLong() * 1000 - val text = timeStamp.toFormat("HH:mm") - - val minutes = (root - time) / 60 - servingEstimateText.text = getString(R.string.servings_estimate) - .format(minutes.roundToInt(), text) - } - private fun updateCharts(items: List) { if (items.isNotEmpty()) { val data = items.map { s -> Entry(s.date.clearDate().toFloat(), s.serving.toFloat()) } diff --git a/app/src/main/java/com/uncmorfi/servings/TotalPieChartView.kt b/app/src/main/java/com/uncmorfi/servings/TotalPieChartView.kt index 6dfe576..c9ca1d8 100644 --- a/app/src/main/java/com/uncmorfi/servings/TotalPieChartView.kt +++ b/app/src/main/java/com/uncmorfi/servings/TotalPieChartView.kt @@ -9,7 +9,6 @@ import android.text.style.RelativeSizeSpan import android.text.style.StyleSpan import android.util.AttributeSet import android.view.MotionEvent -import com.github.mikephil.charting.animation.Easing import com.github.mikephil.charting.charts.PieChart import com.github.mikephil.charting.data.PieData import com.github.mikephil.charting.data.PieDataSet @@ -67,8 +66,7 @@ class TotalPieChartView: PieChart { return this } - private fun PieChart.update(dataSet: PieDataSet) { - animateY(800, Easing.EasingOption.EaseInOutCubic) + private fun update(dataSet: PieDataSet) { data = PieData(dataSet) invalidate() } @@ -108,7 +106,7 @@ class TotalPieChartView: PieChart { } companion object { - private const val FOOD_RATIONS = 1500 + private const val FOOD_RATIONS = 1700 private const val FOOD_LIMIT = 200 } } \ No newline at end of file diff --git a/app/src/main/java/com/uncmorfi/viewmodel/MainViewModel.kt b/app/src/main/java/com/uncmorfi/viewmodel/MainViewModel.kt index 0be7889..5f45717 100644 --- a/app/src/main/java/com/uncmorfi/viewmodel/MainViewModel.kt +++ b/app/src/main/java/com/uncmorfi/viewmodel/MainViewModel.kt @@ -132,7 +132,6 @@ class MainViewModel(val context: Application): AndroidViewModel(context) { /* * Menu stuff */ - fun getMenu(): LiveData> { if (menuLive.value == null) { mainDispatch { diff --git a/app/src/main/res/drawable/ic_arrow.xml b/app/src/main/res/drawable/ic_arrow.xml new file mode 100644 index 0000000..164b425 --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_balance.xml b/app/src/main/res/layout/fragment_balance.xml index 3fa0405..c96a80b 100644 --- a/app/src/main/res/layout/fragment_balance.xml +++ b/app/src/main/res/layout/fragment_balance.xml @@ -20,9 +20,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" - android:layout_marginBottom="12dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" style="@style/MaterialCard"> diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index c095cc4..1bac212 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -1,6 +1,5 @@ - - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + @@ -69,18 +82,36 @@ android:id="@+id/homeCardContainer" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_marginTop="6dp" android:layout_marginBottom="16dp" android:visibility="gone" tools:visibility="visible" style="@style/MaterialCard"> - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + + @@ -94,19 +125,36 @@ android:text="@string/home_servings"/> - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + + diff --git a/app/src/main/res/layout/fragment_servings.xml b/app/src/main/res/layout/fragment_servings.xml index ff0d4c4..bd48192 100644 --- a/app/src/main/res/layout/fragment_servings.xml +++ b/app/src/main/res/layout/fragment_servings.xml @@ -27,88 +27,13 @@ android:layout_marginLeft="16dp" android:layout_marginRight="16dp"/> - - - - - - - - - - - - -