commit 5f0d8a058b53c136e83f054875daf43e80ddec3a Author: litingting Date: Tue Apr 16 18:29:10 2024 +0800 V1.0.0(1) 无Ad版本 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2bfca55 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties +.idea/ +app/release/ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/DrinkWater.jks b/app/DrinkWater.jks new file mode 100644 index 0000000..c9453d1 Binary files /dev/null and b/app/DrinkWater.jks differ diff --git a/app/SignInfo b/app/SignInfo new file mode 100644 index 0000000..43ceca7 --- /dev/null +++ b/app/SignInfo @@ -0,0 +1,3 @@ +签名文件:DrinkWater.jks +别名:DrinkWaterkey0 +密码:DrinkWater \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..40e93f5 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,56 @@ +import java.util.Date +import java.text.SimpleDateFormat +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id ("kotlin-kapt") +} +val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date()) +android { + namespace = "com.drink.water.test" + compileSdk = 34 + + defaultConfig { + applicationId = "com.drink.water.test" + minSdk = 23 + targetSdk = 34 + versionCode = 1 + versionName = "1.0.0" + setProperty("archivesBaseName", "DrinkWater_V" + versionName + "(${versionCode})_$timestamp") + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + + buildFeatures{ + viewBinding = true + } +} + +dependencies { + implementation("androidx.core:core-ktx:1.9.0") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("com.google.android.material:material:1.11.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + implementation ("androidx.room:room-ktx:2.6.1") + implementation ("androidx.room:room-runtime:2.6.1") + kapt ("androidx.room:room-compiler:2.6.1") +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..8c10452 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,35 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + +-keep class com.drink.water.test.roombean.** {*;} +-dontwarn com.drink.water.test.roombean.** +-keep class com.drink.water.test.room.** {*;} +-dontwarn com.drink.water.test.room.** + + #room + -keepclassmembers class com.drink.water.test.utls.ConstStr{ + public static final java.lang.String room_name; + public static final int room_version; + } + -keepclassmembers class *{ + @androidx.room.Query ; + } diff --git a/app/src/androidTest/java/com/drink/water/test/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/drink/water/test/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..efb97c2 --- /dev/null +++ b/app/src/androidTest/java/com/drink/water/test/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.drink.water.test + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.drink.water.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..74b4d88 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/font_medium.ttf b/app/src/main/assets/font_medium.ttf new file mode 100644 index 0000000..4012225 Binary files /dev/null and b/app/src/main/assets/font_medium.ttf differ diff --git a/app/src/main/java/com/drink/water/test/DrinkWater.kt b/app/src/main/java/com/drink/water/test/DrinkWater.kt new file mode 100644 index 0000000..118ad25 --- /dev/null +++ b/app/src/main/java/com/drink/water/test/DrinkWater.kt @@ -0,0 +1,20 @@ +package com.drink.water.test + +import android.app.Application +import android.content.Context +import android.graphics.Typeface + +class DrinkWater :Application() { + companion object{ + public lateinit var appContext: Context + + lateinit var textFont: Typeface + } + + override fun onCreate() { + super.onCreate() + + appContext = this + textFont = Typeface.createFromAsset(assets, "font_medium.ttf") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/GenderActivity.kt b/app/src/main/java/com/drink/water/test/GenderActivity.kt new file mode 100644 index 0000000..d4fc7d3 --- /dev/null +++ b/app/src/main/java/com/drink/water/test/GenderActivity.kt @@ -0,0 +1,56 @@ +package com.drink.water.test + +import android.content.Intent +import android.os.Bundle +import android.view.View +import androidx.appcompat.app.AppCompatActivity +import com.drink.water.test.databinding.ActivityGenderBinding +import com.drink.water.test.utls.SharePreference + +class GenderActivity : AppCompatActivity() { + private lateinit var binding: ActivityGenderBinding + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityGenderBinding.inflate(layoutInflater) + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + setContentView(binding.root) + onUI() + onGender() + + + binding.imageViewBack.setOnClickListener { + finish() + } + binding.tvSave.setOnClickListener { + + SharePreference.run { + saveGender(binding.tvGirls.isSelected) + saveWeight(binding.etWeight.text.toString().toInt()) + } + startActivity(Intent(this, MainActivity::class.java)) + finish() + + } + + + } + + private fun onUI() { + val gender = SharePreference.getGender() + val weight = SharePreference.getWeight() + binding.tvGirls.isSelected = gender + binding.tvBoys.isSelected = !gender + binding.etWeight.setText(weight.toString()) + } + + private fun onGender() { + binding.imGirls.setOnClickListener { + binding.tvBoys.isSelected = false + binding.tvGirls.isSelected = true + } + binding.imBoy.setOnClickListener { + binding.tvBoys.isSelected = true + binding.tvGirls.isSelected = false + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/LauncherActivity.kt b/app/src/main/java/com/drink/water/test/LauncherActivity.kt new file mode 100644 index 0000000..3ae48de --- /dev/null +++ b/app/src/main/java/com/drink/water/test/LauncherActivity.kt @@ -0,0 +1,50 @@ +package com.drink.water.test + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.os.CountDownTimer +import android.view.View +import android.widget.TextView +import com.drink.water.test.utls.SharePreference + +class LauncherActivity : AppCompatActivity() { + + private lateinit var tvHi: TextView + private lateinit var countDownTimer: CountDownTimer + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + setContentView(R.layout.activity_launcher) + tvHi = findViewById(R.id.tv_hi) + onUI() + goCount() + } + + fun onUI() { + tvHi.typeface = DrinkWater.textFont + countDownTimer = object : CountDownTimer(2000, 1000) { + override fun onTick(millisUntilFinished: Long) { + + } + + override fun onFinish() { + val isFirst = SharePreference.getIsFirst() + if(isFirst){ + SharePreference.saveIsFirst() + startActivity(Intent(this@LauncherActivity,GenderActivity::class.java)) + }else{ + startActivity(Intent(this@LauncherActivity,MainActivity::class.java)) + } + finish() + + } + + } + + } + + fun goCount() { + countDownTimer.start() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/MainActivity.kt b/app/src/main/java/com/drink/water/test/MainActivity.kt new file mode 100644 index 0000000..fa07d41 --- /dev/null +++ b/app/src/main/java/com/drink/water/test/MainActivity.kt @@ -0,0 +1,146 @@ +package com.drink.water.test + +import android.annotation.SuppressLint +import android.graphics.drawable.Drawable +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.view.View +import android.widget.ImageView +import androidx.core.content.ContextCompat +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentStatePagerAdapter +import androidx.viewpager.widget.ViewPager +import androidx.viewpager.widget.ViewPager.OnPageChangeListener +import com.drink.water.test.databinding.TabCustomViewBinding +import com.drink.water.test.fragments.HomeFragment +import com.drink.water.test.fragments.RecordFragment +import com.drink.water.test.fragments.SettingsFragment +import com.google.android.material.tabs.TabLayout +import com.google.android.material.tabs.TabLayout.OnTabSelectedListener + +class MainActivity : AppCompatActivity() { + + private lateinit var tabLayout: TabLayout + private lateinit var viewPager: ViewPager + + private lateinit var strings: MutableList + private lateinit var mutableListOf: MutableList + + private lateinit var tabsIcons :MutableList + + @SuppressLint("MissingInflatedId") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + setContentView(R.layout.activity_main) + tabLayout = findViewById(R.id.tab_layout) + viewPager = findViewById(R.id.view_pager) + + strings = mutableListOf( + getString(R.string.tab_name_home), + getString(R.string.tab_name_records), + getString(R.string.tab_name_set) + ) + mutableListOf = mutableListOf( + HomeFragment.newInstance(), + RecordFragment.newInstance(), + SettingsFragment.newInstance() + ) + + tabsIcons = mutableListOf(ContextCompat.getDrawable(this@MainActivity,R.drawable.selector_tab_home), + ContextCompat.getDrawable(this@MainActivity,R.drawable.selector_tab_record), + ContextCompat.getDrawable(this@MainActivity,R.drawable.selector_tab_settings)) + onUI() + onViewPager() + } + + + + private fun onUI() { + + mutableListOf.forEachIndexed { i, v -> + val newTab = tabLayout.newTab() + newTab.customView = TabCustomViewBinding.inflate(layoutInflater).root.apply { + findViewById(R.id.image_view_tab).let { + it.setImageDrawable(tabsIcons[i]) + } + } + tabLayout.addTab(newTab) + + } + + tabLayout.addOnTabSelectedListener(object :OnTabSelectedListener{ + override fun onTabSelected(tab: TabLayout.Tab?) { + if (tab != null) { + viewPager.currentItem = tab.position + + when(tab.position){ + 0->{ + val homeFragment = mutableListOf[0] as HomeFragment + + homeFragment.updatePersonal() + } + 1->{ + val recordFragment = mutableListOf[1] as RecordFragment + + recordFragment.updateRecordList() + } + 2->{ + val settingsFragment = mutableListOf[2] as SettingsFragment + + settingsFragment.updateInfo() + + } + } + } + + } + + override fun onTabUnselected(tab: TabLayout.Tab?) { + + } + + override fun onTabReselected(tab: TabLayout.Tab?) { + + } + + }) + + + } + + private fun onViewPager() { + viewPager.run { + addOnPageChangeListener(object : OnPageChangeListener { + override fun onPageScrolled( + position: Int, + positionOffset: Float, + positionOffsetPixels: Int + ) { + + } + + override fun onPageSelected(position: Int) { + tabLayout.getTabAt(position)?.select() + } + + override fun onPageScrollStateChanged(state: Int) { + + } + + }) + adapter = object : FragmentStatePagerAdapter(supportFragmentManager) { + override fun getCount(): Int { + + return mutableListOf.size + } + + override fun getItem(position: Int): Fragment { + + return mutableListOf[position] + } + + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/fragments/HomeFragment.kt b/app/src/main/java/com/drink/water/test/fragments/HomeFragment.kt new file mode 100644 index 0000000..978f690 --- /dev/null +++ b/app/src/main/java/com/drink/water/test/fragments/HomeFragment.kt @@ -0,0 +1,156 @@ +package com.drink.water.test.fragments + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.core.content.ContextCompat +import androidx.fragment.app.Fragment +import com.drink.water.test.R +import com.drink.water.test.databinding.FragmentHomeBinding +import com.drink.water.test.room.RoomBase +import com.drink.water.test.roombean.WaterRecord +import com.drink.water.test.utls.SharePreference +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import java.util.Calendar + + +class HomeFragment : Fragment() { + + private lateinit var binding: FragmentHomeBinding + + private var selectDrink: Int = 100 + + private var todayDrink: Int = 0 + + private var todayTimeKey :Long = 0L + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) +// arguments?.let { +// param1 = it.getString(ARG_PARAM1) +// param2 = it.getString(ARG_PARAM2) +// } + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + binding = FragmentHomeBinding.inflate(layoutInflater) + val instance = Calendar.getInstance() + val year = instance.get(Calendar.YEAR) + val month = instance.get(Calendar.MONTH)+1 + val day = instance.get(Calendar.DAY_OF_MONTH) + instance.set(Calendar.HOUR_OF_DAY, 0) + instance.set(Calendar.MINUTE, 0) + instance.set(Calendar.SECOND, 0) + instance.set(Calendar.MILLISECOND, 0) + + + todayTimeKey = instance.timeInMillis + + onUI() + onClick() + + return binding.root + } + + + private fun updateToday() { + todayDrink = SharePreference.getTodayDrink() + binding.textViewDrunk.text = String.format(getString(R.string.text_ml), todayDrink) + } + + private fun onUI() { + updateToday() + updatePersonal() + + } + fun updatePersonal(){ + val gender = SharePreference.getGender() + val weight = SharePreference.getWeight() + binding.textViewToday.text = String.format(getString(R.string.text_ml), weight * 40) + if (gender) { + binding.imageViewHeader.setImageDrawable( + ContextCompat.getDrawable( + requireContext(), + R.mipmap.girls + ) + ) + } else { + binding.imageViewHeader.setImageDrawable( + ContextCompat.getDrawable( + requireContext(), + R.mipmap.boys + ) + ) + } + } + + private fun onClick() { + + binding.radioGroup.setOnCheckedChangeListener { group, checkedId -> + + when (checkedId) { + R.id.rb_1 -> { + selectDrink = 100 + } + + R.id.rb_2 -> { + selectDrink = 200 + } + + R.id.rb_3 -> { + selectDrink = 300 + } + + R.id.rb_4 -> { + selectDrink = 400 + } + + R.id.rb_5 -> { + selectDrink = 500 + } + } + + + } + + binding.textTodayAdd.setOnClickListener { + todayDrink += selectDrink + SharePreference.saveTodayDrink(todayDrink) + addDrinkRecord(selectDrink) + updateToday() + } + + } + + + + private fun addDrinkRecord(drink: Int) { + CoroutineScope(Dispatchers.IO).launch { + RoomBase.database.getRoomDao().addRecord( + WaterRecord( + timeKey = todayTimeKey, + time = System.currentTimeMillis(), + capacity = drink + ) + ) + + + } + } + + companion object { + @JvmStatic + fun newInstance() = + HomeFragment().apply { +// arguments = Bundle().apply { +// putString(ARG_PARAM1, param1) +// putString(ARG_PARAM2, param2) +// } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/fragments/RecordFragment.kt b/app/src/main/java/com/drink/water/test/fragments/RecordFragment.kt new file mode 100644 index 0000000..bc711ad --- /dev/null +++ b/app/src/main/java/com/drink/water/test/fragments/RecordFragment.kt @@ -0,0 +1,160 @@ +package com.drink.water.test.fragments + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.RadioButton +import androidx.core.view.forEachIndexed +import androidx.recyclerview.widget.LinearLayoutManager +import com.drink.water.test.R +import com.drink.water.test.databinding.FragmentRecordBinding +import com.drink.water.test.room.RoomBase +import com.drink.water.test.utls.RecordAdapter +import com.drink.water.test.utls.Utils +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import java.util.Calendar + + +class RecordFragment : Fragment() { + + + private lateinit var binding: FragmentRecordBinding + + private var timeKey: MutableList = mutableListOf() + + private lateinit var adapter: RecordAdapter + private var curSelectTimkey = 0L + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + arguments?.let { + + } + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + binding = FragmentRecordBinding.inflate(layoutInflater) + + onUI() + curSelectTimkey = timeKey[0] + onList() + updateRecordList() + onClick() + + return binding.root + } + + private fun onUI() { + var strList = mutableListOf() + val instance = Calendar.getInstance() + val year = instance.get(Calendar.YEAR) + val month = instance.get(Calendar.MONTH) + 1 + val day = instance.get(Calendar.DAY_OF_MONTH) + val month1 = Utils.getMonth(month, day) + timeKey.add(getTimeKey(instance)) + strList.add(month1) + + + val beforeDate1 = Utils.beforeDate(-1) + val beforeDate2 = Utils.beforeDate(-2) + val beforeDate3 = Utils.beforeDate(-3) + val beforeDate4 = Utils.beforeDate(-4) + instance.timeInMillis = beforeDate1 + timeKey.add(getTimeKey(instance)) + strList.add(getStr(instance)) + + instance.timeInMillis = beforeDate2 + timeKey.add(getTimeKey(instance)) + strList.add(getStr(instance)) + + instance.timeInMillis = beforeDate3 + timeKey.add(getTimeKey(instance)) + strList.add(getStr(instance)) + + + instance.timeInMillis = beforeDate4 + timeKey.add(getTimeKey(instance)) + strList.add(getStr(instance)) + + + binding.radioGroup.forEachIndexed { index, view -> + view as RadioButton + view.text = strList[index] + } + + + + + } + + private fun onClick(){ + binding.radioGroup.setOnCheckedChangeListener { group, checkedId -> + when(checkedId){ + R.id.rb1-> curSelectTimkey = timeKey[0] + R.id.rb2-> curSelectTimkey = timeKey[1] + R.id.rb3-> curSelectTimkey = timeKey[2] + R.id.rb4-> curSelectTimkey = timeKey[3] + R.id.rb5-> curSelectTimkey = timeKey[4] + + } + + updateRecordList() + + } + } + + private fun onList() { + adapter = RecordAdapter(requireContext()) + binding.recyclerViewRecord.adapter = adapter + binding.recyclerViewRecord.layoutManager = LinearLayoutManager(requireContext()) + + + } + + fun updateRecordList(){ + CoroutineScope(Dispatchers.IO).launch{ + val waterRecord = RoomBase.database.getRoomDao().getWaterRecord(curSelectTimkey) + + withContext(Dispatchers.Main){ + adapter.updateRecord(waterRecord) + + } + + + } + } + + private fun getStr(calendar: Calendar): String { + val month = calendar.get(Calendar.MONTH) + 1 + val day = calendar.get(Calendar.DAY_OF_MONTH) + return Utils.getMonth(month, day) + } + + private fun getTimeKey(calendar: Calendar): Long { + calendar.set(Calendar.HOUR_OF_DAY, 0) + calendar.set(Calendar.MINUTE, 0) + calendar.set(Calendar.SECOND, 0) + calendar.set(Calendar.MILLISECOND, 0) + return calendar.timeInMillis + + } + + companion object { + + @JvmStatic + fun newInstance() = + RecordFragment().apply { + arguments = Bundle().apply { + + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/fragments/SettingsFragment.kt b/app/src/main/java/com/drink/water/test/fragments/SettingsFragment.kt new file mode 100644 index 0000000..9f5bf8e --- /dev/null +++ b/app/src/main/java/com/drink/water/test/fragments/SettingsFragment.kt @@ -0,0 +1,87 @@ +package com.drink.water.test.fragments + +import android.content.Intent +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.core.content.ContextCompat +import com.drink.water.test.GenderActivity +import com.drink.water.test.R +import com.drink.water.test.databinding.FragmentSettingsBinding +import com.drink.water.test.utls.SharePreference + +// TODO: Rename parameter arguments, choose names that match +// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER +private const val ARG_PARAM1 = "param1" +private const val ARG_PARAM2 = "param2" + +/** + * A simple [Fragment] subclass. + * Use the [SettingsFragment.newInstance] factory method to + * create an instance of this fragment. + */ +class SettingsFragment : Fragment() { + + + private lateinit var binging: FragmentSettingsBinding + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + arguments?.let { + + } + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + binging = FragmentSettingsBinding.inflate(layoutInflater) + onUI() + return binging.root + } + + private fun onUI() { + updateInfo() + binging.cardViewSet.setOnClickListener { + startActivity(Intent(requireContext(), GenderActivity::class.java)) + } + + } + + fun updateInfo(){ + val gender = SharePreference.getGender() + val weight = SharePreference.getWeight() + binging.textViewWeight.text = "${getString(R.string.text_weight)}:$weight kg" + if (gender) { + binging.textViewGender.text = "${getString(R.string.text_gender)}:girl" + binging.imageViewHeader.setImageDrawable( + ContextCompat.getDrawable( + requireContext(), + R.mipmap.girls + ) + ) + } else { + binging.textViewGender.text = "${getString(R.string.text_gender)}:boy" + binging.imageViewHeader.setImageDrawable( + ContextCompat.getDrawable( + requireContext(), + R.mipmap.boys + ) + ) + } + } + + + + companion object { + @JvmStatic + fun newInstance() = + SettingsFragment().apply { + arguments = Bundle().apply { + + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/room/RoomBase.kt b/app/src/main/java/com/drink/water/test/room/RoomBase.kt new file mode 100644 index 0000000..9a57ae0 --- /dev/null +++ b/app/src/main/java/com/drink/water/test/room/RoomBase.kt @@ -0,0 +1,21 @@ +package com.drink.water.test.room + +import androidx.room.Database +import androidx.room.Room +import androidx.room.RoomDatabase +import com.drink.water.test.DrinkWater +import com.drink.water.test.roombean.WaterRecord +import com.drink.water.test.utls.ConstStr + + +@Database(entities = [WaterRecord::class], version = ConstStr.room_version, exportSchema = false) +abstract class RoomBase : RoomDatabase() { + companion object { + val database = + Room.databaseBuilder(DrinkWater.appContext, RoomBase::class.java, ConstStr.room_name) + .build() + } + + abstract fun getRoomDao(): RoomDao + +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/room/RoomDao.kt b/app/src/main/java/com/drink/water/test/room/RoomDao.kt new file mode 100644 index 0000000..21f52dc --- /dev/null +++ b/app/src/main/java/com/drink/water/test/room/RoomDao.kt @@ -0,0 +1,35 @@ +package com.drink.water.test.room + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.Query +import com.drink.water.test.roombean.WaterRecord + + +@Dao +interface RoomDao { + + @Insert + fun addRecord(record: WaterRecord) + + @Query("select * from water_record where timeKey= :timeKey") + fun getWaterRecord(timeKey:Long):List + +// @Query("select * from water_record where isHome= :home ") +// fun getHomeFile(home: Boolean = true):List +// +// @Query("select * from water_record where isRecent= :recent") +// fun getRecentFile(recent: Boolean = true):List + + + + +// @Update +// fun updatePdfFile(file: PdfFile) +} + + + + + + diff --git a/app/src/main/java/com/drink/water/test/roombean/WaterRecord.kt b/app/src/main/java/com/drink/water/test/roombean/WaterRecord.kt new file mode 100644 index 0000000..d93a597 --- /dev/null +++ b/app/src/main/java/com/drink/water/test/roombean/WaterRecord.kt @@ -0,0 +1,15 @@ +package com.drink.water.test.roombean + +import androidx.room.Entity +import androidx.room.PrimaryKey +import com.drink.water.test.utls.ConstStr + + +@Entity(tableName = ConstStr.room_table_name) +class WaterRecord( + @PrimaryKey(autoGenerate = true) + var id: Int = 0, + var timeKey:Long, + var time: Long, var capacity: Int +) { +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/utls/ConstStr.kt b/app/src/main/java/com/drink/water/test/utls/ConstStr.kt new file mode 100644 index 0000000..f5ddb59 --- /dev/null +++ b/app/src/main/java/com/drink/water/test/utls/ConstStr.kt @@ -0,0 +1,19 @@ +package com.drink.water.test.utls + + + +object ConstStr { + + const val room_name = "room_name" + const val room_version = 1 + const val room_table_name="water_record" + const val sharedPreferencesName:String = "shared_preference_name" + + const val KEY_IS_GIRLS = "is_girls" + + const val KEY_WEIGHT = "weight" + + const val KEY_DRINK = "today_drink" + + const val KEY_FIRST = "open_first" +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/utls/RecordAdapter.kt b/app/src/main/java/com/drink/water/test/utls/RecordAdapter.kt new file mode 100644 index 0000000..d524a6a --- /dev/null +++ b/app/src/main/java/com/drink/water/test/utls/RecordAdapter.kt @@ -0,0 +1,42 @@ +package com.drink.water.test.utls + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.drink.water.test.databinding.ItemRecordBinding +import com.drink.water.test.roombean.WaterRecord + +class RecordAdapter(var con: Context) : RecyclerView.Adapter() { + + private var data: List = emptyList() + + fun updateRecord(list: List) { + data = list + notifyDataSetChanged() + } + + inner class RecordVh(var binding: ItemRecordBinding) : RecyclerView.ViewHolder(binding.root) { + + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecordVh { + + return RecordVh(ItemRecordBinding.inflate(LayoutInflater.from(con), parent, false)) + } + + override fun getItemCount(): Int { + + return data.size + } + + override fun onBindViewHolder(holder: RecordVh, position: Int) { + data[position].let { + + holder.binding.tvDrinkTime.text = Utils.formatTime(it.time) + holder.binding.tvDrinkCount.text = "${it.capacity}ml" + } + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/utls/SharePreference.kt b/app/src/main/java/com/drink/water/test/utls/SharePreference.kt new file mode 100644 index 0000000..701d09f --- /dev/null +++ b/app/src/main/java/com/drink/water/test/utls/SharePreference.kt @@ -0,0 +1,53 @@ +package com.drink.water.test.utls + +import android.content.Context +import android.content.SharedPreferences +import com.drink.water.test.DrinkWater + +object SharePreference { + private fun getShared(): SharedPreferences { + return DrinkWater.appContext.getSharedPreferences(ConstStr.sharedPreferencesName, Context.MODE_PRIVATE) + } + + fun saveGender(isGirls: Boolean) { + getEditor().putBoolean(ConstStr.KEY_IS_GIRLS, isGirls).apply() + } + + fun getGender( ): Boolean { + return getShared() + .getBoolean(ConstStr.KEY_IS_GIRLS,true) + } + + private fun getEditor(): SharedPreferences.Editor { + return DrinkWater.appContext.getSharedPreferences(ConstStr.sharedPreferencesName, Context.MODE_PRIVATE).edit() + } + + fun saveWeight(weight: Int) { + getEditor().putInt(ConstStr.KEY_WEIGHT, weight).apply() + } + + fun getWeight( ): Int { + return getShared() + .getInt(ConstStr.KEY_WEIGHT,60) + } + + + fun saveIsFirst() { + getEditor().putBoolean(ConstStr.KEY_FIRST, false).apply() + } + + fun getIsFirst( ): Boolean { + return getShared().getBoolean(ConstStr.KEY_FIRST,true) + } + + + + fun saveTodayDrink(drink: Int) { + getEditor().putInt(ConstStr.KEY_DRINK, drink).apply() + } + + fun getTodayDrink( ): Int { + return getShared() + .getInt(ConstStr.KEY_DRINK,0) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/drink/water/test/utls/Utils.kt b/app/src/main/java/com/drink/water/test/utls/Utils.kt new file mode 100644 index 0000000..63b233d --- /dev/null +++ b/app/src/main/java/com/drink/water/test/utls/Utils.kt @@ -0,0 +1,41 @@ +package com.drink.water.test.utls + +import android.annotation.SuppressLint +import java.text.SimpleDateFormat + + +object Utils { + fun beforeDate(days: Int): Long { + val nowTime = System.currentTimeMillis() + val changeTimes = days * 24L * 60 * 60 * 1000 + return nowTime + changeTimes + } + + + @SuppressLint("SimpleDateFormat") + fun formatTime(timestamp: Long): String? { + var dayFormat = SimpleDateFormat("HH:mm") + return dayFormat.format(timestamp) + } + + fun getMonth(mon: Int, day: Int): String { + return when (mon) { + 1 -> "Jan$day" + 2 -> "Feb$day" + 3 -> "Mar$day" + 4 -> "Apr$day" + 5 -> "May$day" + 6 -> "Jun$day" + 7 -> "Jul$day" + 8 -> "Aug$day" + 9 -> "Sep$day" + 10 -> "Oct$day" + 11 -> "Nov$day" + 12 -> "Dec$day" + else -> { + "Jan$day" + } + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/color/selector_color_add_water.xml b/app/src/main/res/color/selector_color_add_water.xml new file mode 100644 index 0000000..c45715d --- /dev/null +++ b/app/src/main/res/color/selector_color_add_water.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/color/selector_color_gender.xml b/app/src/main/res/color/selector_color_gender.xml new file mode 100644 index 0000000..163e1b6 --- /dev/null +++ b/app/src/main/res/color/selector_color_gender.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/add_water_false.xml b/app/src/main/res/drawable/add_water_false.xml new file mode 100644 index 0000000..1b014eb --- /dev/null +++ b/app/src/main/res/drawable/add_water_false.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/add_water_true.xml b/app/src/main/res/drawable/add_water_true.xml new file mode 100644 index 0000000..3c7a97d --- /dev/null +++ b/app/src/main/res/drawable/add_water_true.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_record.xml b/app/src/main/res/drawable/bg_record.xml new file mode 100644 index 0000000..4f742f5 --- /dev/null +++ b/app/src/main/res/drawable/bg_record.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/boys.xml b/app/src/main/res/drawable/boys.xml new file mode 100644 index 0000000..782b5e6 --- /dev/null +++ b/app/src/main/res/drawable/boys.xml @@ -0,0 +1,30 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/btn_bg_add_water.xml b/app/src/main/res/drawable/btn_bg_add_water.xml new file mode 100644 index 0000000..7b9b37a --- /dev/null +++ b/app/src/main/res/drawable/btn_bg_add_water.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/girls.xml b/app/src/main/res/drawable/girls.xml new file mode 100644 index 0000000..e617615 --- /dev/null +++ b/app/src/main/res/drawable/girls.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/selector_add_water.xml b/app/src/main/res/drawable/selector_add_water.xml new file mode 100644 index 0000000..dbd4db1 --- /dev/null +++ b/app/src/main/res/drawable/selector_add_water.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_tab_home.xml b/app/src/main/res/drawable/selector_tab_home.xml new file mode 100644 index 0000000..a1d637d --- /dev/null +++ b/app/src/main/res/drawable/selector_tab_home.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_tab_record.xml b/app/src/main/res/drawable/selector_tab_record.xml new file mode 100644 index 0000000..2aa5942 --- /dev/null +++ b/app/src/main/res/drawable/selector_tab_record.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_tab_settings.xml b/app/src/main/res/drawable/selector_tab_settings.xml new file mode 100644 index 0000000..4474c9e --- /dev/null +++ b/app/src/main/res/drawable/selector_tab_settings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_save_info.xml b/app/src/main/res/drawable/shape_save_info.xml new file mode 100644 index 0000000..14d2d73 --- /dev/null +++ b/app/src/main/res/drawable/shape_save_info.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_gender.xml b/app/src/main/res/layout/activity_gender.xml new file mode 100644 index 0000000..18a7110 --- /dev/null +++ b/app/src/main/res/layout/activity_gender.xml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_launcher.xml b/app/src/main/res/layout/activity_launcher.xml new file mode 100644 index 0000000..0bea3d2 --- /dev/null +++ b/app/src/main/res/layout/activity_launcher.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..145e355 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml new file mode 100644 index 0000000..4e903eb --- /dev/null +++ b/app/src/main/res/layout/fragment_home.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_record.xml b/app/src/main/res/layout/fragment_record.xml new file mode 100644 index 0000000..0bd1603 --- /dev/null +++ b/app/src/main/res/layout/fragment_record.xml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml new file mode 100644 index 0000000..57291a0 --- /dev/null +++ b/app/src/main/res/layout/fragment_settings.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_record.xml b/app/src/main/res/layout/item_record.xml new file mode 100644 index 0000000..2878fa5 --- /dev/null +++ b/app/src/main/res/layout/item_record.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/tab_custom_view.xml b/app/src/main/res/layout/tab_custom_view.xml new file mode 100644 index 0000000..9cc19be --- /dev/null +++ b/app/src/main/res/layout/tab_custom_view.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/arrow_circle_left.png b/app/src/main/res/mipmap-xxxhdpi/arrow_circle_left.png new file mode 100644 index 0000000..02075a1 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/arrow_circle_left.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/arrow_right.png b/app/src/main/res/mipmap-xxxhdpi/arrow_right.png new file mode 100644 index 0000000..10ea98e Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/arrow_right.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/boys.png b/app/src/main/res/mipmap-xxxhdpi/boys.png new file mode 100644 index 0000000..01ddcbb Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/boys.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/girls.png b/app/src/main/res/mipmap-xxxhdpi/girls.png new file mode 100644 index 0000000..ec17cb6 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/girls.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/home_bg.png b/app/src/main/res/mipmap-xxxhdpi/home_bg.png new file mode 100644 index 0000000..9436279 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/home_bg.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/logo.png b/app/src/main/res/mipmap-xxxhdpi/logo.png new file mode 100644 index 0000000..fed7071 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/logo.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/tab_home_0.png b/app/src/main/res/mipmap-xxxhdpi/tab_home_0.png new file mode 100644 index 0000000..2f628c3 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/tab_home_0.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/tab_home_1.png b/app/src/main/res/mipmap-xxxhdpi/tab_home_1.png new file mode 100644 index 0000000..169afef Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/tab_home_1.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/tab_record_0.png b/app/src/main/res/mipmap-xxxhdpi/tab_record_0.png new file mode 100644 index 0000000..ab614e4 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/tab_record_0.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/tab_record_1.png b/app/src/main/res/mipmap-xxxhdpi/tab_record_1.png new file mode 100644 index 0000000..dcd519e Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/tab_record_1.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/tab_settings_0.png b/app/src/main/res/mipmap-xxxhdpi/tab_settings_0.png new file mode 100644 index 0000000..62a86a4 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/tab_settings_0.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/tab_settings_1.png b/app/src/main/res/mipmap-xxxhdpi/tab_settings_1.png new file mode 100644 index 0000000..b3ec841 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/tab_settings_1.png differ diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..927126d --- /dev/null +++ b/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..972142d --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,17 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FEBEBE + #FF018786 + #FF000000 + #FFFFFFFF + #333333 + #FF03DAC5 + #FEBEBE + #9287FF + #C1C1C1 + #F1F1F1 + #D2EFF3 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..ed25529 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,32 @@ + + DrinkWater + Let’s start \nour daily hydration journey together + Gender + Weight + Basic Information + Female + Male + kg + Hello! + Sex selection: + Weight setting: + Today\'s goal + %sml + Have drunk water + Added water + Add + Welcome back + Save + Water record + Drinking time: + Water: + Past water records + Water records for 5 days + Personal information + + Hello blank fragment + Home + Records + Settings + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..b5b98db --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/backup_rules.xml b/app/src/main/res/xml/backup_rules.xml new file mode 100644 index 0000000..fa0f996 --- /dev/null +++ b/app/src/main/res/xml/backup_rules.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000..9ee9997 --- /dev/null +++ b/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/test/java/com/drink/water/test/ExampleUnitTest.kt b/app/src/test/java/com/drink/water/test/ExampleUnitTest.kt new file mode 100644 index 0000000..e252351 --- /dev/null +++ b/app/src/test/java/com/drink/water/test/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.drink.water.test + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/app/testDrinkWater.jks b/app/testDrinkWater.jks new file mode 100644 index 0000000..1aafc3d Binary files /dev/null and b/app/testDrinkWater.jks differ diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..1bc1d16 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,5 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + id("com.android.application") version "8.1.3" apply false + id("org.jetbrains.kotlin.android") version "1.9.0" apply false +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..3c5031e --- /dev/null +++ b/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e7bcabc --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Mar 18 14:40:10 CST 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..3a34b58 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,18 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "DrinkWater" +include(":app") + \ No newline at end of file