Skip to content

Commit

Permalink
4.3 update!
Browse files Browse the repository at this point in the history
  • Loading branch information
helloyanis committed Sep 27, 2023
1 parent dfed4ad commit 24bbbe5
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 40 deletions.
5 changes: 3 additions & 2 deletions src/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "com.helloyanis.rucoycalculator"
minSdk = 24
targetSdk = 34
versionCode = 6
versionName = "4.2"
versionCode = 7
versionName = "4.3"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -57,5 +57,6 @@ dependencies {
implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("androidx.datastore:datastore-preferences-rxjava2:1.0.0")
implementation("androidx.datastore:datastore-preferences-rxjava3:1.0.0")
implementation("com.google.android.play:core-ktx:1.8.1")

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "4.1"
val currentVersion = "4.3"

// Split the version strings into individual parts.
val currentVersionParts = currentVersion.split(".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.helloyanis.rucoycalculator.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding

companion object {
val Context.dataStore: DataStore<Preferences> by preferencesDataStore("savedvalues")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.google.android.play.core.review.ReviewManagerFactory
import com.helloyanis.rucoycalculator.R
import com.helloyanis.rucoycalculator.databinding.CreditsBinding

class CreditsFragment : Fragment() {
Expand All @@ -19,7 +23,7 @@ class CreditsFragment : Fragment() {
private val binding get() = _binding!!

private val colors = listOf(
Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA
Color.RED, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA
)
private var currentIndex = 0
private val handler = Handler(Looper.getMainLooper())
Expand All @@ -36,6 +40,7 @@ class CreditsFragment : Fragment() {
_binding = CreditsBinding.inflate(inflater, container, false)
val root: View = binding.root


// Get the button view
val supportMeButton = binding.supportMe

Expand All @@ -60,6 +65,33 @@ class CreditsFragment : Fragment() {
startActivity(i)
}

val ratebutton = binding.rate

ratebutton.setOnClickListener{
val manager = ReviewManagerFactory.create(requireContext())
val request = manager.requestReviewFlow()
request.addOnCompleteListener { request ->
if (request.isSuccessful) {
// We got the ReviewInfo object
val reviewInfo = request.result
val flow = manager.launchReviewFlow(requireActivity(), reviewInfo)
flow.addOnCompleteListener { _ ->
binding.root.findViewById<TextView>(R.id.rate).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.ratebackup).visibility=View.VISIBLE

}
} else {
Toast.makeText(context, "Could not find the Play Store installed on your device!", Toast.LENGTH_LONG).show()
}
}
}

val ratebackupbutton = binding.ratebackup

ratebackupbutton.setOnClickListener{
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.helloyanis.rucoycalculator")))
}

return root
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,38 +273,56 @@ class TrainFragment : Fragment() {
0->{
binding.root.findViewById<Spinner>(R.id.classspinner).visibility = View.GONE
binding.root.findViewById<EditText>(R.id.baselevel).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.baselevellabel).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.stat).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.statlabel).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.statgoal).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.statgoallabel).visibility=View.GONE
binding.root.findViewById<EditText>(R.id.weaponatk).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.weaponatklabel).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.tick).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.ticklabel).visibility=View.GONE
binding.root.findViewById<Button>(R.id.tickhelp).visibility=View.GONE
binding.root.findViewById<EditText>(R.id.hours).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.hourslabel).visibility=View.GONE
if (binding.root.findViewById<EditText>(R.id.baselevel).text.toString()!="" && binding.root.findViewById<EditText>(R.id.stat).text.toString()!="" && binding.root.findViewById<EditText>(R.id.weaponatk).text.toString()!="") {
train()
}
}
1->{
binding.root.findViewById<Spinner>(R.id.classspinner).visibility = View.VISIBLE
binding.root.findViewById<EditText>(R.id.baselevel).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.baselevellabel).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.stat).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.statlabel).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.statgoal).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.statgoallabel).visibility=View.GONE
binding.root.findViewById<EditText>(R.id.weaponatk).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.weaponatklabel).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.tick).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.ticklabel).visibility=View.VISIBLE
binding.root.findViewById<Button>(R.id.tickhelp).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.hours).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.hourslabel).visibility=View.GONE
if (binding.root.findViewById<EditText>(R.id.baselevel).text.toString()!="" && binding.root.findViewById<EditText>(R.id.stat).text.toString()!="" && binding.root.findViewById<EditText>(R.id.weaponatk).text.toString()!="") {
ptrain()
}
}
2->{
binding.root.findViewById<Spinner>(R.id.classspinner).visibility = View.GONE
binding.root.findViewById<EditText>(R.id.baselevel).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.baselevellabel).visibility=View.GONE
binding.root.findViewById<EditText>(R.id.stat).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.statlabel).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.statgoal).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.statgoallabel).visibility=View.VISIBLE
binding.root.findViewById<EditText>(R.id.weaponatk).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.weaponatklabel).visibility=View.GONE
binding.root.findViewById<EditText>(R.id.tick).visibility=View.GONE
binding.root.findViewById<TextView>(R.id.ticklabel).visibility=View.GONE
binding.root.findViewById<Button>(R.id.tickhelp).visibility=View.GONE
binding.root.findViewById<EditText>(R.id.hours).visibility=View.VISIBLE
binding.root.findViewById<TextView>(R.id.hourslabel).visibility=View.VISIBLE
if(binding.root.findViewById<EditText>(R.id.stat).text.toString()!="") {
offline()
}
Expand Down Expand Up @@ -650,17 +668,17 @@ class TrainFragment : Fragment() {

@SuppressLint("SetTextI18n")
private fun offline(){
var stat1 = 0
var stat1 = 0.toDouble()
if(binding.root.findViewById<EditText>(R.id.stat).text.toString()!=""){
stat1 = binding.root.findViewById<EditText>(R.id.stat).text.toString().toInt()
stat1 = binding.root.findViewById<EditText>(R.id.stat).text.toString().toDouble()
}
var stat2 = 0
var stat2 = 0.toDouble()
if(binding.root.findViewById<EditText>(R.id.statgoal).text.toString()!=""){
stat2 = binding.root.findViewById<EditText>(R.id.statgoal).text.toString().toInt()
stat2 = binding.root.findViewById<EditText>(R.id.statgoal).text.toString().toDouble()
}
var hours = 0
var hours = 0.toDouble()
if(binding.root.findViewById<EditText>(R.id.hours).text.toString()!=""){
hours = binding.root.findViewById<EditText>(R.id.hours).text.toString().toInt()
hours = binding.root.findViewById<EditText>(R.id.hours).text.toString().toDouble()
}
if (stat2 > 0 && hours <= 0) {
if (stat1 > stat2) {
Expand Down Expand Up @@ -696,7 +714,7 @@ class TrainFragment : Fragment() {
) + " hours of offline training at 600 exp/hr"
}
} else if (hours > 0 && stat2 <= 0) {
val tickstrained: Int = 600 * hours
val tickstrained: Double = 600 * hours
val ticks1: Double
val ticks2: Double
if (stat1 <= 54) {
Expand All @@ -711,7 +729,7 @@ class TrainFragment : Fragment() {
}

binding.root.findViewById<TextView>(R.id.str0).text=
"⏱️ Your new stat will be approximately: $newStat with $hours hours of offline training"
"⏱️ Your new stat will be approximately: ${newStat.toInt()} with ${hours.toInt()} hours of offline training"

} else {
binding.root.findViewById<TextView>(R.id.str0).text="❗Please enter either hours OR stat goal"
Expand Down
Binary file added src/app/src/main/res/drawable/title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 38 additions & 7 deletions src/app/src/main/res/layout/credits.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
Expand All @@ -17,14 +18,16 @@
android:layout_height="wrap_content"
android:text="@string/credits_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@+id/imageView" />

<Button
android:id="@+id/github"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@string/github"
app:layout_constraintBottom_toBottomOf="@+id/privacy"
app:layout_constraintEnd_toStartOf="@+id/privacy"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/privacy" />

Expand All @@ -33,19 +36,47 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/support_me"
app:layout_constraintBottom_toBottomOf="@+id/privacy"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/privacy" />
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ratebackup" />

<Button
android:id="@+id/privacy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="@string/privacy"
app:layout_constraintEnd_toStartOf="@+id/support_me"
app:layout_constraintStart_toEndOf="@+id/github"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/credits_content" />

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/title" />

<Button
android:id="@+id/rate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/rate"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/privacy" />

<Button
android:id="@+id/ratebackup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/ratebackup"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rate"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Loading

0 comments on commit 24bbbe5

Please sign in to comment.