Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
FleetAdmiralJakob committed Nov 12, 2022
1 parent 2fef672 commit 974c105
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .idea/codestream.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdk 30
targetSdk 33
versionCode 1
versionName "1.0"
versionName "1.6.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"versionName": "1.6.0",
"outputFile": "app-release.apk"
}
],
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/com/jakob/tippy/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class MainActivity : AppCompatActivity() {
updateTipDescription(INITIAL_TIP_PERCENT)
getCurrencyTypeFromSharedPreferences()

etPeopleAmount.setText("1")

updateTvPerPerson()

ivGitHub.setOnClickListener(View.OnClickListener {
// This is the link to my GitHub
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/FleetAdmiralJakob/Tippy"))
Expand Down Expand Up @@ -138,16 +142,27 @@ class MainActivity : AppCompatActivity() {
})

etPeopleAmount.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}

override fun afterTextChanged(s: Editable?) {
computeTipAndTotal()
// If the text equals 1, then tvperperson should display nothing
updateTvPerPerson()
}
})
}

private fun updateTvPerPerson() {
if (etPeopleAmount.text.toString() == "1") {
tvPerPerson.text = ""
} else {
updateLanguage()
}
}

private fun updateLanguage() {
// Every string of a language is located in a own string.xml file so I call the right language based on the selected position of my country spinner.
when (countrySpinner.selectedItemPosition) {
Expand Down Expand Up @@ -213,6 +228,7 @@ class MainActivity : AppCompatActivity() {
// RU
}
}
updateTvPerPerson()
}

private fun updateCurrencySpinner() {
Expand Down

0 comments on commit 974c105

Please sign in to comment.