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 d3c8407..8dc6a21 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 @@ -3,8 +3,8 @@ package io.github.z3r0c00l_2k.aquadroid import android.content.Intent import android.content.SharedPreferences import android.os.Bundle -import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import com.google.android.material.snackbar.Snackbar import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() { @@ -33,16 +33,21 @@ class MainActivity : AppCompatActivity() { val r = sqliteHelper.addAll(dateNow, 20, totalIntake) - Toast.makeText(this, "" + r, Toast.LENGTH_SHORT).show() inTook = sqliteHelper.getIntook(dateNow) setWaterLevel(inTook, totalIntake) fabAdd.setOnClickListener { - if (sqliteHelper.addIntook(dateNow) > 0) { - inTook++ - setWaterLevel(inTook, totalIntake) + if (inTook < totalIntake) { + Snackbar.make(it, "Did you drank a glass of water..?", Snackbar.LENGTH_SHORT).setAction(" Yes ") { + if (sqliteHelper.addIntook(dateNow) > 0) { + inTook++ + setWaterLevel(inTook, totalIntake) + } + }.show() + } else { + Snackbar.make(it, "You achieved the goal", Snackbar.LENGTH_SHORT).show() } } @@ -54,6 +59,9 @@ class MainActivity : AppCompatActivity() { val progress = ((inTook / totalIntake.toFloat()) * 100).toInt() waterLevelView.centerTitle = "" + progress + "%" waterLevelView.progressValue = progress + if (inTook >= totalIntake) { + Snackbar.make(main_activity_parent, "You achieved the goal", Snackbar.LENGTH_SHORT).show() + } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 1082fcc..f101ef7 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -5,6 +5,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" + android:id="@+id/main_activity_parent" android:background="@drawable/main_bg_gradiant" tools:context=".MainActivity">