Removed confirmation on intake report, Adding some animations
This commit is contained in:
parent
0fe76623f5
commit
ab48de1665
3 changed files with 29 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -41,4 +41,6 @@ dependencies {
|
||||||
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
|
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
|
||||||
implementation 'androidx.cardview:cardview:1.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
implementation 'com.params.progressview:step-progress:1.0.2'
|
implementation 'com.params.progressview:step-progress:1.0.2'
|
||||||
|
implementation 'com.daimajia.easing:library:2.0@aar'
|
||||||
|
implementation 'com.daimajia.androidanimations:library:2.3@aar'
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.daimajia.androidanimations.library.Techniques
|
||||||
|
import com.daimajia.androidanimations.library.YoYo
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import io.github.z3r0c00l_2k.aquadroid.fragments.BottomSheetFragment
|
import io.github.z3r0c00l_2k.aquadroid.fragments.BottomSheetFragment
|
||||||
import io.github.z3r0c00l_2k.aquadroid.helpers.AlarmHelper
|
import io.github.z3r0c00l_2k.aquadroid.helpers.AlarmHelper
|
||||||
|
@ -68,27 +70,28 @@ class MainActivity : AppCompatActivity() {
|
||||||
fabAdd.setOnClickListener {
|
fabAdd.setOnClickListener {
|
||||||
if (selectedOption != null && selectedOptionName != null) {
|
if (selectedOption != null && selectedOptionName != null) {
|
||||||
if ((inTook * 100 / totalIntake) <= 140) {
|
if ((inTook * 100 / totalIntake) <= 140) {
|
||||||
snackbar = Snackbar.make(it, "Did you drank $selectedOptionName..?", Snackbar.LENGTH_SHORT)
|
if (sqliteHelper.addIntook(dateNow, selectedOption!!) > 0) {
|
||||||
snackbar!!.setAction("\t\t\tYes\t\t\t") {
|
inTook += selectedOption!!
|
||||||
if (sqliteHelper.addIntook(dateNow, selectedOption!!) > 0) {
|
setWaterLevel(inTook, totalIntake)
|
||||||
inTook += selectedOption!!
|
|
||||||
setWaterLevel(inTook, totalIntake)
|
|
||||||
|
|
||||||
selectedOption = null
|
Snackbar.make(it, "Your water intake was saved...!!", Snackbar.LENGTH_SHORT).show()
|
||||||
selectedOptionName = null
|
|
||||||
opAqua.background = getDrawable(outValue.resourceId)
|
|
||||||
opCoffee.background = getDrawable(outValue.resourceId)
|
|
||||||
opTea.background = getDrawable(outValue.resourceId)
|
|
||||||
opSoftDrink.background = getDrawable(outValue.resourceId)
|
|
||||||
opJuice.background = getDrawable(outValue.resourceId)
|
|
||||||
opMilk.background = getDrawable(outValue.resourceId)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}.show()
|
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(it, "You achieved the goal", Snackbar.LENGTH_SHORT).show()
|
Snackbar.make(it, "You already achieved the goal", Snackbar.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
selectedOption = null
|
||||||
|
selectedOptionName = null
|
||||||
|
opAqua.background = getDrawable(outValue.resourceId)
|
||||||
|
opCoffee.background = getDrawable(outValue.resourceId)
|
||||||
|
opTea.background = getDrawable(outValue.resourceId)
|
||||||
|
opSoftDrink.background = getDrawable(outValue.resourceId)
|
||||||
|
opJuice.background = getDrawable(outValue.resourceId)
|
||||||
|
opMilk.background = getDrawable(outValue.resourceId)
|
||||||
} else {
|
} else {
|
||||||
|
YoYo.with(Techniques.Shake)
|
||||||
|
.duration(700)
|
||||||
|
.playOn(cardView)
|
||||||
Snackbar.make(it, "Please select an option", Snackbar.LENGTH_SHORT).show()
|
Snackbar.make(it, "Please select an option", Snackbar.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,9 +208,16 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setWaterLevel(inTook: Int, totalIntake: Int) {
|
private fun setWaterLevel(inTook: Int, totalIntake: Int) {
|
||||||
|
|
||||||
|
YoYo.with(Techniques.SlideInDown)
|
||||||
|
.duration(500)
|
||||||
|
.playOn(tvIntook)
|
||||||
tvIntook.text = "$inTook"
|
tvIntook.text = "$inTook"
|
||||||
tvTotalIntake.text = "/$totalIntake ml"
|
tvTotalIntake.text = "/$totalIntake ml"
|
||||||
val progress = ((inTook / totalIntake.toFloat()) * 100).toInt()
|
val progress = ((inTook / totalIntake.toFloat()) * 100).toInt()
|
||||||
|
YoYo.with(Techniques.Pulse)
|
||||||
|
.duration(500)
|
||||||
|
.playOn(intakeProgress)
|
||||||
intakeProgress.currentProgress = progress
|
intakeProgress.currentProgress = progress
|
||||||
if ((inTook * 100 / totalIntake) > 140) {
|
if ((inTook * 100 / totalIntake) > 140) {
|
||||||
Snackbar.make(main_activity_parent, "You achieved the goal", Snackbar.LENGTH_SHORT).show()
|
Snackbar.make(main_activity_parent, "You achieved the goal", Snackbar.LENGTH_SHORT).show()
|
||||||
|
|
Loading…
Reference in a new issue