Skip to content

Commit

Permalink
v4 yooo
Browse files Browse the repository at this point in the history
  • Loading branch information
helloyanis committed Sep 23, 2023
1 parent 9a2954b commit eda3a8b
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 72 deletions.
8 changes: 4 additions & 4 deletions src/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Binary file added src/app/release/rucoy-calculator-v3.0.aab
Binary file not shown.
4 changes: 2 additions & 2 deletions src/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand All @@ -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(".")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
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
import androidx.navigation.ui.setupWithNavController
import com.helloyanis.rucoycalculator.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

val dataStore: DataStore<Preferences> 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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Preferences> by preferencesDataStore(name = "data")
private var _binding: SkullBinding? = null
var _binding: SkullBinding? = null
private val binding get() = _binding!!

private val dataStore: DataStore<Preferences>
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<EditText>(R.id.editTextNumber)
lifecycleScope.launch {
dataStore?.data?.collect { preferences ->
if(isInit) {

binding.root.findViewById<EditText>(R.id.baselevelskull).text =
Editable.Factory.getInstance().newEditable(preferences[BASE_LEVEL_KEY] ?: "")

isInit = false
if (binding.root.findViewById<EditText>(R.id.baselevelskull).text.toString()!="") {
calcskull(binding.root.findViewById<EditText>(R.id.baselevelskull).text.toString().toDouble())
}else{
setalldisplays("No data")
}

}
}
}

val editTextNumber = binding.root.findViewById<EditText>(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) {
Expand All @@ -59,19 +88,19 @@ class SkullFragment : Fragment() {
_binding = null
}
private fun setalldisplays(string: String){
binding.root.findViewById<TextView>(R.id.whiteskullvalue).text = string
binding.root.findViewById<TextView>(R.id.yellowskullvalue).text = string
binding.root.findViewById<TextView>(R.id.orangeskullvalue).text = string
binding.root.findViewById<TextView>(R.id.redskullvalue).text = string
binding.root.findViewById<TextView>(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<EditText>(R.id.baselevelskull).text.toString()
lifecycleScope.launch {
// Save values to DataStore
dataStore?.edit { preferences ->
preferences[BASE_LEVEL_KEY] = baseLevelValue
}
}
binding.root.findViewById<TextView>(R.id.whiteskullvalue).text = str0 + "G needed"
val str1 = if((double*150).toString().substringAfter(".").length==1){
(double*150).toString().substringBefore(".")
}else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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<Preferences>
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,
Expand All @@ -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<EditText>(R.id.baselevel).text =
Editable.Factory.getInstance().newEditable(preferences[BASE_LEVEL_KEY] ?: "")
binding.root.findViewById<EditText>(R.id.stat).text =
Editable.Factory.getInstance().newEditable(preferences[STAT_KEY] ?: "")
binding.root.findViewById<EditText>(R.id.weaponatk).text =
Editable.Factory.getInstance().newEditable(preferences[WEAPON_ATK_KEY] ?: "")
binding.root.findViewById<EditText>(R.id.tick).text =
Editable.Factory.getInstance().newEditable(preferences[TICK_KEY] ?: "4")
binding.root.findViewById<Spinner>(R.id.classspinner).setSelection(
preferences[PTRAIN_CLASS_KEY]?.toInt() ?: 0)
binding.root.findViewById<EditText>(R.id.hours).text =
Editable.Factory.getInstance().newEditable(preferences[HOURS_KEY] ?: "")
binding.root.findViewById<EditText>(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()
Expand Down Expand Up @@ -207,6 +251,27 @@ class TrainFragment : Fragment() {
binding.root.findViewById<TextView>(R.id.str3).text = ""
binding.root.findViewById<TextView>(R.id.str4).text = ""
binding.root.findViewById<TextView>(R.id.str5).text = ""
val baseLevelValue = binding.root.findViewById<EditText>(R.id.baselevel).text.toString()
val statValue = binding.root.findViewById<EditText>(R.id.stat).text.toString()
val weaponAtkValue = binding.root.findViewById<EditText>(R.id.weaponatk).text.toString()
val tickValue = binding.root.findViewById<EditText>(R.id.tick).text.toString()
val ptrainClassValue = binding.root.findViewById<Spinner>(R.id.trainstylespinner).selectedItemPosition.toString()
val hoursValue = binding.root.findViewById<EditText>(R.id.hours).text.toString()
val statGoalValue = binding.root.findViewById<EditText>(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<Spinner>(R.id.trainstylespinner).selectedItemPosition){
0->{
binding.root.findViewById<Spinner>(R.id.classspinner).visibility = View.GONE
Expand Down Expand Up @@ -255,7 +320,7 @@ class TrainFragment : Fragment() {
val base = binding.root.findViewById<EditText>(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=""
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
Expand Down
Loading

0 comments on commit eda3a8b

Please sign in to comment.