diff --git a/.idea/misc.xml b/.idea/misc.xml index 7bfef59..37a7509 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 7ba3bfa..8fa2767 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,4 +41,6 @@ dependencies { implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' implementation 'androidx.cardview:cardview:1.0.0' 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' } diff --git a/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/MainActivity.kt b/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/MainActivity.kt index 44b270c..aec0b72 100644 --- a/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/MainActivity.kt +++ b/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/MainActivity.kt @@ -5,6 +5,8 @@ import android.content.SharedPreferences import android.os.Bundle import android.util.TypedValue 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 io.github.z3r0c00l_2k.aquadroid.fragments.BottomSheetFragment import io.github.z3r0c00l_2k.aquadroid.helpers.AlarmHelper @@ -68,27 +70,28 @@ class MainActivity : AppCompatActivity() { fabAdd.setOnClickListener { if (selectedOption != null && selectedOptionName != null) { if ((inTook * 100 / totalIntake) <= 140) { - snackbar = Snackbar.make(it, "Did you drank $selectedOptionName..?", Snackbar.LENGTH_SHORT) - snackbar!!.setAction("\t\t\tYes\t\t\t") { - if (sqliteHelper.addIntook(dateNow, selectedOption!!) > 0) { - inTook += selectedOption!! - setWaterLevel(inTook, totalIntake) + if (sqliteHelper.addIntook(dateNow, selectedOption!!) > 0) { + inTook += selectedOption!! + setWaterLevel(inTook, totalIntake) - 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) + Snackbar.make(it, "Your water intake was saved...!!", Snackbar.LENGTH_SHORT).show() - } - }.show() + } } 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 { + YoYo.with(Techniques.Shake) + .duration(700) + .playOn(cardView) 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) { + + YoYo.with(Techniques.SlideInDown) + .duration(500) + .playOn(tvIntook) tvIntook.text = "$inTook" tvTotalIntake.text = "/$totalIntake ml" val progress = ((inTook / totalIntake.toFloat()) * 100).toInt() + YoYo.with(Techniques.Pulse) + .duration(500) + .playOn(intakeProgress) intakeProgress.currentProgress = progress if ((inTook * 100 / totalIntake) > 140) { Snackbar.make(main_activity_parent, "You achieved the goal", Snackbar.LENGTH_SHORT).show()