diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 88ea3aa..3cc336b 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,6 +1,22 @@ + + diff --git a/.idea/dictionaries/fabian.xml b/.idea/dictionaries/fabian.xml index 92342ab..0fad81e 100644 --- a/.idea/dictionaries/fabian.xml +++ b/.idea/dictionaries/fabian.xml @@ -1,7 +1,9 @@ + checkmark tichu + tichucounter zobrist diff --git a/.idea/misc.xml b/.idea/misc.xml index 7bfef59..ae2bfea 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,44 @@ + + + + diff --git a/app/build.gradle b/app/build.gradle index d57e2cd..335d9cc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,12 +34,12 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.1.0' - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.core:core-ktx:1.3.1' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0' - implementation 'androidx.navigation:navigation-ui-ktx:2.1.0' + implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0' + implementation 'androidx.navigation:navigation-ui-ktx:2.3.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 17bec36..d7ced19 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ android:theme="@style/AppTheme"> diff --git a/app/src/main/java/me/zobrist/tichucounter/History.kt b/app/src/main/java/me/zobrist/tichucounter/History.kt index 556408c..9f2cd3a 100644 --- a/app/src/main/java/me/zobrist/tichucounter/History.kt +++ b/app/src/main/java/me/zobrist/tichucounter/History.kt @@ -1,3 +1,5 @@ +@file:Suppress("unused") + package me.zobrist.tichucounter import android.os.Parcel @@ -6,7 +8,7 @@ import android.os.Parcelable class History() : Parcelable { private var scores: ArrayList = ArrayList() - constructor(parcel: Parcel) : this(){ + constructor(parcel: Parcel) : this() { scores = parcel.readSerializable() as ArrayList } diff --git a/app/src/main/java/me/zobrist/tichucounter/MainActivity.kt b/app/src/main/java/me/zobrist/tichucounter/MainActivity.kt index c7b9b2f..7da4264 100644 --- a/app/src/main/java/me/zobrist/tichucounter/MainActivity.kt +++ b/app/src/main/java/me/zobrist/tichucounter/MainActivity.kt @@ -145,48 +145,59 @@ class MainActivity : AppCompatActivity() { } button0.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('0') } button1.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('1') } button2.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('2') } button3.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('3') } button4.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('4') } button5.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('5') } button6.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('6') } button7.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('7') } button8.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('8') } button9.setOnClickListener { + giveFocusToAIfNone() appendToFocusedInput('9') } buttonInv.setOnClickListener { val tempInt: Int + giveFocusToAIfNone() if(inputTeamA.isFocused ){ if (inputTeamA.text.isNotEmpty()){ @@ -209,15 +220,17 @@ class MainActivity : AppCompatActivity() { } } - buttonBack.setOnClickListener{ - if(inputTeamA.isFocused ){ - if(inputTeamA.text.isNotEmpty()){ + buttonBack.setOnClickListener { + giveFocusToAIfNone() + + if (inputTeamA.isFocused) { + if (inputTeamA.text.isNotEmpty()) { val string = inputTeamA.text.toString() - inputTeamA.setText(string.substring(0, string.length -1)) + inputTeamA.setText(string.substring(0, string.length - 1)) } - }else if(inputTeamB.isFocused) { - if(inputTeamB.text.isNotEmpty()) { + } else if (inputTeamB.isFocused) { + if (inputTeamB.text.isNotEmpty()) { val string = inputTeamB.text.toString() inputTeamB.setText(string.substring(0, string.length - 1)) } @@ -225,6 +238,7 @@ class MainActivity : AppCompatActivity() { } submit.setOnClickListener { + giveFocusToAIfNone() if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) { @@ -237,7 +251,7 @@ class MainActivity : AppCompatActivity() { inputTeamA.text.clear() inputTeamB.text.clear() - scrolViewHistory.fullScroll(ScrollView.FOCUS_DOWN) + scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN) } } @@ -260,7 +274,7 @@ class MainActivity : AppCompatActivity() { clearAll() true } - R.id.action_undo -> { + R.id.action_undo -> { undoLastRound() true } @@ -272,7 +286,13 @@ class MainActivity : AppCompatActivity() { } } - private fun undoLastRound(){ + private fun giveFocusToAIfNone() { + if (!inputTeamA.isFocused && !inputTeamB.isFocused) { + inputTeamA.requestFocus() + } + } + + private fun undoLastRound() { history.revertLastRound() updateView() diff --git a/app/src/main/java/me/zobrist/tichucounter/Round.kt b/app/src/main/java/me/zobrist/tichucounter/Round.kt index 88fc5d4..fad6b61 100644 --- a/app/src/main/java/me/zobrist/tichucounter/Round.kt +++ b/app/src/main/java/me/zobrist/tichucounter/Round.kt @@ -14,8 +14,6 @@ class Round() { } } - constructor(score: String, isScoreA: Boolean): this(score.toInt(), isScoreA) - constructor(scoreA: Int, scoreB: Int) : this() { this.scoreA = scoreA this.scoreB = scoreB diff --git a/app/src/main/res/layout-land/content_main.xml b/app/src/main/res/layout-land/content_main.xml index 3171189..de790fa 100644 --- a/app/src/main/res/layout-land/content_main.xml +++ b/app/src/main/res/layout-land/content_main.xml @@ -29,7 +29,10 @@ android:layout_weight="1" android:autofillHints="" android:gravity="center" + android:imeOptions="actionDone" android:inputType="text" + android:selectAllOnFocus="true" + android:singleLine="true" android:text="@string/team_a" android:textAppearance="@style/TextAppearance.AppCompat.Display1" /> @@ -40,7 +43,10 @@ android:layout_weight="1" android:autofillHints="" android:gravity="center" + android:imeOptions="actionDone" android:inputType="text" + android:selectAllOnFocus="true" + android:singleLine="true" android:text="@string/team_b" android:textAppearance="@style/TextAppearance.AppCompat.Display1" /> @@ -75,7 +81,7 @@ @@ -145,12 +151,14 @@