diff --git a/src/app/build.gradle.kts b/src/app/build.gradle.kts index 4e3bb99..8e22f19 100644 --- a/src/app/build.gradle.kts +++ b/src/app/build.gradle.kts @@ -6,14 +6,14 @@ plugins { android { namespace = "com.helloyanis.rucoycalculator" - compileSdk = 33 + compileSdk = 34 defaultConfig { applicationId = "com.helloyanis.rucoycalculator" minSdk = 24 - targetSdk = 33 - versionCode = 1 - versionName = "3.0" + targetSdk = 34 + versionCode = 4 + versionName = "4.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/src/app/release/rucoy-calculator-v3.0.aab b/src/app/release/rucoy-calculator-v3.0.aab new file mode 100644 index 0000000..fa5cfab Binary files /dev/null and b/src/app/release/rucoy-calculator-v3.0.aab differ diff --git a/src/app/src/main/AndroidManifest.xml b/src/app/src/main/AndroidManifest.xml index c555805..0b6a35f 100644 --- a/src/app/src/main/AndroidManifest.xml +++ b/src/app/src/main/AndroidManifest.xml @@ -7,9 +7,9 @@ android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" - android:icon="@mipmap/ic_launcher" + android:icon="@mipmap/icon" android:label="@string/app_name" - android:roundIcon="@mipmap/ic_launcher_round" + android:roundIcon="@mipmap/icon" android:supportsRtl="true" android:theme="@style/Theme.RucoyCalculator" tools:targetApi="31"> diff --git a/src/app/src/main/java/com/helloyanis/rucoycalculator/GitHubReleaseChecker.kt b/src/app/src/main/java/com/helloyanis/rucoycalculator/GitHubReleaseChecker.kt index f435165..55d3a7e 100644 --- a/src/app/src/main/java/com/helloyanis/rucoycalculator/GitHubReleaseChecker.kt +++ b/src/app/src/main/java/com/helloyanis/rucoycalculator/GitHubReleaseChecker.kt @@ -49,7 +49,7 @@ class GitHubReleaseChecker(private val context: Context, private val repositoryU if (isUpdateAvailable(latestVersion)) { showToast("Update available: $latestVersion") - showToast("Go on GitHub to update!") + //showToast("Go on GitHub to update!") } else { //showToast("You are using the latest version.") } @@ -62,7 +62,7 @@ class GitHubReleaseChecker(private val context: Context, private val repositoryU private fun isUpdateAvailable(latestVersion: String): Boolean { // Replace this with the current installed version of your app. - val currentVersion = "3.0" + val currentVersion = "4.0" // Split the version strings into individual parts. val currentVersionParts = currentVersion.split(".") diff --git a/src/app/src/main/java/com/helloyanis/rucoycalculator/MainActivity.kt b/src/app/src/main/java/com/helloyanis/rucoycalculator/MainActivity.kt index aef3f5e..7d7af6d 100644 --- a/src/app/src/main/java/com/helloyanis/rucoycalculator/MainActivity.kt +++ b/src/app/src/main/java/com/helloyanis/rucoycalculator/MainActivity.kt @@ -1,8 +1,13 @@ package com.helloyanis.rucoycalculator +import GitHubReleaseChecker +import android.content.Context import android.os.Bundle import com.google.android.material.bottomnavigation.BottomNavigationView import androidx.appcompat.app.AppCompatActivity +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.preferencesDataStore import androidx.navigation.findNavController import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupActionBarWithNavController @@ -10,12 +15,12 @@ import androidx.navigation.ui.setupWithNavController import com.helloyanis.rucoycalculator.databinding.ActivityMainBinding class MainActivity : AppCompatActivity() { - + val dataStore: DataStore by preferencesDataStore(name = "savedvalues") private lateinit var binding: ActivityMainBinding - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - + val repositoryUrl = "https://api.github.com/repos/helloyanis/rucoy-calculator" + GitHubReleaseChecker(this, repositoryUrl).execute() binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) diff --git a/src/app/src/main/java/com/helloyanis/rucoycalculator/ui/skull/SkullFragment.kt b/src/app/src/main/java/com/helloyanis/rucoycalculator/ui/skull/SkullFragment.kt index fdae35d..d5cc668 100644 --- a/src/app/src/main/java/com/helloyanis/rucoycalculator/ui/skull/SkullFragment.kt +++ b/src/app/src/main/java/com/helloyanis/rucoycalculator/ui/skull/SkullFragment.kt @@ -8,31 +8,60 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.EditText +import android.widget.Spinner import android.widget.TextView -import android.widget.Toast import androidx.datastore.core.DataStore -import androidx.datastore.dataStore import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.lifecycleScope +import com.helloyanis.rucoycalculator.MainActivity import com.helloyanis.rucoycalculator.R import com.helloyanis.rucoycalculator.databinding.SkullBinding +import kotlinx.coroutines.launch class SkullFragment : Fragment() { - val Context.dataStore: DataStore by preferencesDataStore(name = "data") - private var _binding: SkullBinding? = null + var _binding: SkullBinding? = null private val binding get() = _binding!! - + private val dataStore: DataStore + get() = (requireActivity() as MainActivity).dataStore + private val STAT_KEY = stringPreferencesKey("stat_key") + private val WEAPON_ATK_KEY = stringPreferencesKey("weapon_atk_key") + private val BASE_LEVEL_KEY = stringPreferencesKey("base_level_key") + private val TICK_KEY = stringPreferencesKey("tick_key") + private val PTRAIN_CLASS_KEY = stringPreferencesKey("ptrain_class_key") + private val HOURS_KEY = stringPreferencesKey("hours_key") + private val STAT_GOAL_KEY = stringPreferencesKey("stat_goal_key") + // Define keys for other preferences as needed + private var isInit = true override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { _binding = SkullBinding.inflate(inflater, container, false) - setalldisplays("No data") - val editTextNumber = binding.root.findViewById(R.id.editTextNumber) + lifecycleScope.launch { + dataStore?.data?.collect { preferences -> + if(isInit) { + + binding.root.findViewById(R.id.baselevelskull).text = + Editable.Factory.getInstance().newEditable(preferences[BASE_LEVEL_KEY] ?: "") + + isInit = false + if (binding.root.findViewById(R.id.baselevelskull).text.toString()!="") { + calcskull(binding.root.findViewById(R.id.baselevelskull).text.toString().toDouble()) + }else{ + setalldisplays("No data") + } + + } + } + } + + val editTextNumber = binding.root.findViewById(R.id.baselevelskull) // Ajoutez un écouteur de texte à votre EditText editTextNumber.addTextChangedListener(object : TextWatcher { override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { @@ -59,19 +88,19 @@ class SkullFragment : Fragment() { _binding = null } private fun setalldisplays(string: String){ - binding.root.findViewById(R.id.whiteskullvalue).text = string binding.root.findViewById(R.id.yellowskullvalue).text = string binding.root.findViewById(R.id.orangeskullvalue).text = string binding.root.findViewById(R.id.redskullvalue).text = string binding.root.findViewById(R.id.blackskullvalue).text = string } private fun calcskull(double: Double) { - val str0 = if((double*50).toString().substringAfter(".").length==1){ - (double*50).toString().substringBefore(".") - }else { - (double * 50).toString() + val baseLevelValue = binding.root.findViewById(R.id.baselevelskull).text.toString() + lifecycleScope.launch { + // Save values to DataStore + dataStore?.edit { preferences -> + preferences[BASE_LEVEL_KEY] = baseLevelValue + } } - binding.root.findViewById(R.id.whiteskullvalue).text = str0 + "G needed" val str1 = if((double*150).toString().substringAfter(".").length==1){ (double*150).toString().substringBefore(".") }else { diff --git a/src/app/src/main/java/com/helloyanis/rucoycalculator/ui/train/TrainFragment.kt b/src/app/src/main/java/com/helloyanis/rucoycalculator/ui/train/TrainFragment.kt index d938d43..0e8f5d9 100644 --- a/src/app/src/main/java/com/helloyanis/rucoycalculator/ui/train/TrainFragment.kt +++ b/src/app/src/main/java/com/helloyanis/rucoycalculator/ui/train/TrainFragment.kt @@ -2,6 +2,7 @@ package com.helloyanis.rucoycalculator.ui.train import GitHubReleaseChecker import android.annotation.SuppressLint +import android.content.Context import android.os.Bundle import android.text.Editable import android.text.TextWatcher @@ -14,8 +15,15 @@ import android.widget.EditText import android.widget.Spinner import android.widget.TextView import android.widget.Toast +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.stringPreferencesKey +import androidx.datastore.preferences.preferencesDataStore import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.lifecycleScope +import com.helloyanis.rucoycalculator.MainActivity import com.helloyanis.rucoycalculator.R import com.helloyanis.rucoycalculator.databinding.TrainBinding import com.helloyanis.rucoycalculator.ui.train.Formulas.accuracy_Calc @@ -36,15 +44,27 @@ import com.helloyanis.rucoycalculator.ui.train.Formulas.stat55to99_Calc import com.helloyanis.rucoycalculator.ui.train.Formulas.threshold_Calc import com.helloyanis.rucoycalculator.ui.train.Formulas.time_to_kill_Calc import com.helloyanis.rucoycalculator.ui.train.Formulas.total_accuracy_Calc +import kotlinx.coroutines.launch +import java.util.concurrent.Flow + class TrainFragment : Fragment() { private var _binding: TrainBinding? = null - // This property is only valid between onCreateView and // onDestroyView. private val binding get() = _binding!! - + private val dataStore: DataStore + get() = (requireActivity() as MainActivity).dataStore + private val STAT_KEY = stringPreferencesKey("stat_key") + private val WEAPON_ATK_KEY = stringPreferencesKey("weapon_atk_key") + private val BASE_LEVEL_KEY = stringPreferencesKey("base_level_key") + private val TICK_KEY = stringPreferencesKey("tick_key") + private val PTRAIN_CLASS_KEY = stringPreferencesKey("ptrain_class_key") + private val HOURS_KEY = stringPreferencesKey("hours_key") + private val STAT_GOAL_KEY = stringPreferencesKey("stat_goal_key") + // Define keys for other preferences as needed + private var isInit = true @SuppressLint("CutPasteId") override fun onCreateView( inflater: LayoutInflater, @@ -53,11 +73,35 @@ class TrainFragment : Fragment() { ): View { val trainViewModel = ViewModelProvider(this).get(TrainViewModel::class.java) + lifecycleScope.launch { + dataStore?.data?.collect { preferences -> + if(isInit) { + + binding.root.findViewById(R.id.baselevel).text = + Editable.Factory.getInstance().newEditable(preferences[BASE_LEVEL_KEY] ?: "") + binding.root.findViewById(R.id.stat).text = + Editable.Factory.getInstance().newEditable(preferences[STAT_KEY] ?: "") + binding.root.findViewById(R.id.weaponatk).text = + Editable.Factory.getInstance().newEditable(preferences[WEAPON_ATK_KEY] ?: "") + binding.root.findViewById(R.id.tick).text = + Editable.Factory.getInstance().newEditable(preferences[TICK_KEY] ?: "4") + binding.root.findViewById(R.id.classspinner).setSelection( + preferences[PTRAIN_CLASS_KEY]?.toInt() ?: 0) + binding.root.findViewById(R.id.hours).text = + Editable.Factory.getInstance().newEditable(preferences[HOURS_KEY] ?: "") + binding.root.findViewById(R.id.statgoal).text = + Editable.Factory.getInstance().newEditable(preferences[STAT_GOAL_KEY] ?: "") + + isInit = false + } + } + updateoutput() // Call updateoutput() only once after restoring saved values + } + + _binding = TrainBinding.inflate(inflater, container, false) - updateoutput() - val repositoryUrl = "https://api.github.com/repos/helloyanis/rucoy-calculator" - GitHubReleaseChecker(requireContext(), repositoryUrl).execute() + binding.tickhelp.setOnClickListener{ Toast.makeText(context,"It's how many mobs you can hit with 1 power attack!", Toast.LENGTH_LONG).show() @@ -207,6 +251,27 @@ class TrainFragment : Fragment() { binding.root.findViewById(R.id.str3).text = "" binding.root.findViewById(R.id.str4).text = "" binding.root.findViewById(R.id.str5).text = "" + val baseLevelValue = binding.root.findViewById(R.id.baselevel).text.toString() + val statValue = binding.root.findViewById(R.id.stat).text.toString() + val weaponAtkValue = binding.root.findViewById(R.id.weaponatk).text.toString() + val tickValue = binding.root.findViewById(R.id.tick).text.toString() + val ptrainClassValue = binding.root.findViewById(R.id.trainstylespinner).selectedItemPosition.toString() + val hoursValue = binding.root.findViewById(R.id.hours).text.toString() + val statGoalValue = binding.root.findViewById(R.id.statgoal).text.toString() + lifecycleScope.launch { + // Save values to DataStore + dataStore?.edit { preferences -> + preferences[BASE_LEVEL_KEY] = baseLevelValue + preferences[STAT_KEY] = statValue + preferences[WEAPON_ATK_KEY] = weaponAtkValue + preferences[TICK_KEY] = tickValue + preferences[PTRAIN_CLASS_KEY] = ptrainClassValue + preferences[HOURS_KEY] = hoursValue + preferences[STAT_GOAL_KEY] = statGoalValue + } + } + + when(binding.root.findViewById(R.id.trainstylespinner).selectedItemPosition){ 0->{ binding.root.findViewById(R.id.classspinner).visibility = View.GONE @@ -255,7 +320,7 @@ class TrainFragment : Fragment() { val base = binding.root.findViewById(R.id.baselevel).text.toString().toDouble() val min_raw_damage: Double = Formulas.auto_min_raw_damage_Calc(stat1, weaponatk, base) val max_raw_damage: Double = Formulas.auto_max_raw_damage_Calc(stat1, weaponatk, base) - val max_raw_crit_damage: Double = Formulas.max_raw_crit_damage_Calc(max_raw_damage) + val max_raw_crit_damage: Double = max_raw_crit_damage_Calc(max_raw_damage) var accuracy = 0.0 var str0="" var str1="" @@ -277,7 +342,7 @@ class TrainFragment : Fragment() { continue } accuracy = - Formulas.accuracy_Calc(max_raw_crit_damage, max_raw_damage, min_raw_damage, x) + accuracy_Calc(max_raw_crit_damage, max_raw_damage, min_raw_damage, x) if (accuracy >= 0.1749) { pos = x break @@ -287,11 +352,11 @@ class TrainFragment : Fragment() { //Calculate average damage which you need for average time to kill //Calculate average damage which you need for average time to kill - val min_damage: Double = Formulas.min_damage_Calc(min_raw_damage, pos) - val max_damage: Double = Formulas.max_damage_Calc(max_raw_damage, pos) - val max_crit_damage: Double = Formulas.max_crit_damage_Calc(max_raw_crit_damage, pos) + val min_damage: Double = min_damage_Calc(min_raw_damage, pos) + val max_damage: Double = max_damage_Calc(max_raw_damage, pos) + val max_crit_damage: Double = max_crit_damage_Calc(max_raw_crit_damage, pos) val avgdmg: Double = - Formulas.average_damage_Calc(accuracy, max_damage, min_damage, max_crit_damage) + average_damage_Calc(accuracy, max_damage, min_damage, max_crit_damage) val tickrate: Double = Formulas.tickrate_Calc(accuracy, 3600.toDouble()) //In certain cases you can effective train on two mobs @@ -311,7 +376,7 @@ class TrainFragment : Fragment() { newpos++ } - val time: Double = Formulas.time_to_kill_Calc(avgdmg, pos) + val time: Double = time_to_kill_Calc(avgdmg, pos) str0 = """ ${ "👾 You can train effectively on " + mobs.get(pos).mob_name /*+ mobs.get(pos) @@ -320,7 +385,7 @@ class TrainFragment : Fragment() { """.trimIndent() if (!onemob) { - val time2: Double = Formulas.time_to_kill_Calc(avgdmg, pos + 1) + val time2: Double = time_to_kill_Calc(avgdmg, pos + 1) str0 = """ ${ "👾 You can train effectively on " + mobs.get(pos).mob_name /*+ mobs.get(pos) @@ -354,9 +419,9 @@ class TrainFragment : Fragment() { val new_max_raw_damage: Double = Formulas.auto_max_raw_damage_Calc(statneeded, weaponatk, base) val new_max_raw_critdamage: Double = - Formulas.max_raw_crit_damage_Calc(new_max_raw_damage) - new_max_damage = Formulas.max_damage_Calc(new_max_raw_damage, newpos) - newaccuracy = Formulas.accuracy_Calc( + max_raw_crit_damage_Calc(new_max_raw_damage) + new_max_damage = max_damage_Calc(new_max_raw_damage, newpos) + newaccuracy = accuracy_Calc( new_max_raw_critdamage, new_max_raw_damage, new_min_raw_damage, diff --git a/src/app/src/main/res/layout/activity_main.xml b/src/app/src/main/res/layout/activity_main.xml index 2130107..9012e8f 100644 --- a/src/app/src/main/res/layout/activity_main.xml +++ b/src/app/src/main/res/layout/activity_main.xml @@ -3,8 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/container" android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingTop="?attr/actionBarSize"> + android:layout_height="match_parent"> - - - - - + app:layout_constraintTop_toBottomOf="@+id/baselevelskull" /> + app:layout_constraintTop_toTopOf="@+id/redskullvalue" /> @@ -98,14 +80,16 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/skull_yellow" + app:layout_constraintBottom_toBottomOf="@+id/yellowskullvalue" app:layout_constraintEnd_toStartOf="@+id/yellowskullvalue" - app:layout_constraintTop_toBottomOf="@+id/whiteskullvalue" /> + app:layout_constraintTop_toTopOf="@+id/yellowskullvalue" /> diff --git a/src/app/src/main/res/mipmap-hdpi/icon.png b/src/app/src/main/res/mipmap-hdpi/icon.png new file mode 100644 index 0000000..ba2e27d Binary files /dev/null and b/src/app/src/main/res/mipmap-hdpi/icon.png differ diff --git a/src/app/src/main/res/values/strings.xml b/src/app/src/main/res/values/strings.xml index f47e0e6..26a8cae 100644 --- a/src/app/src/main/res/values/strings.xml +++ b/src/app/src/main/res/values/strings.xml @@ -22,7 +22,7 @@ Power training Offline training - Application made by helloyanis\nTraining formulas by Mims\nCode (sometimes) by ChatGPT!\nThis app is free and open-source! Check out the GitHub!\nSupport me to help me keep maintaining this application and add new features!\nA feature idea? A bug report? Go on GitHub and open an issue! + Application made by helloyanis\nTraining formulas by Mims\nCode (sometimes) by ChatGPT!\nThis app is free and open-source! Check out the GitHub!\nSupport me to help me keep maintaining this application and add new features!\nA feature idea? A bug report? Go on GitHub and open an issue!\n\nFAQ!!\n❓It says there is an update but it does not show on Google play store!\n❗You need to wait a few days to get the update from Google play store while they verify the app! You can get it earlier via GitHub. GitHub ❤️ Support me! diff --git a/src/gradle/libs.versions.toml b/src/gradle/libs.versions.toml index 9c82cc2..43fc356 100644 --- a/src/gradle/libs.versions.toml +++ b/src/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] agp = "8.1.1" org-jetbrains-kotlin-android = "1.9.0" -core-ktx = "1.9.0" +core-ktx = "1.12.0" junit = "4.13.2" androidx-test-ext-junit = "1.1.5" espresso-core = "3.5.1" diff --git a/src/gradle/wrapper/gradle-wrapper.properties b/src/gradle/wrapper/gradle-wrapper.properties index 3fddfdc..a9bb066 100644 --- a/src/gradle/wrapper/gradle-wrapper.properties +++ b/src/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Sep 08 17:01:14 CEST 2023 +#Thu Sep 21 19:45:34 CEST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-rc-1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists