Target API33. Setup Hilt DI framework. Apply formatting
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
apply plugin: 'com.android.application'
|
plugins {
|
||||||
apply plugin: 'kotlin-android'
|
id 'com.android.application'
|
||||||
|
id 'kotlin-android'
|
||||||
|
id 'kotlin-kapt'
|
||||||
|
id 'com.google.dagger.hilt.android'
|
||||||
|
}
|
||||||
|
|
||||||
// Create a variable called keystorePropertiesFile, and initialize it to your
|
// Create a variable called keystorePropertiesFile, and initialize it to your
|
||||||
// keystore.properties file, in the rootProject folder.
|
// keystore.properties file, in the rootProject folder.
|
||||||
@@ -16,15 +20,17 @@ def versionProperties = new Properties()
|
|||||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||||
versionProperties.load(new FileInputStream(versionPropertiesFile))
|
versionProperties.load(new FileInputStream(versionPropertiesFile))
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 32
|
compileSdkVersion 33
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "me.zobrist.tichucounter"
|
applicationId "me.zobrist.tichucounter"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 32
|
targetSdkVersion 33
|
||||||
versionCode versionProperties["versionCode"].toInteger()
|
versionCode versionProperties["versionCode"].toInteger()
|
||||||
versionName "1.1.0Beta1"
|
versionName "1.1.0Beta1"
|
||||||
|
resConfigs("de", "en")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -62,17 +68,23 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.core:core-ktx:1.8.0'
|
implementation 'androidx.core:core-ktx:1.9.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.0-alpha05'
|
implementation 'androidx.appcompat:appcompat:1.6.0-rc01'
|
||||||
implementation 'com.google.android.material:material:1.6.1'
|
implementation 'com.google.android.material:material:1.7.0'
|
||||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.code.gson:gson:2.8.9'
|
implementation 'com.google.code.gson:gson:2.8.9'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
|
||||||
|
implementation "com.google.dagger:hilt-android:2.44"
|
||||||
|
kapt "com.google.dagger:hilt-compiler:2.44"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow references to generated code
|
||||||
|
kapt {
|
||||||
|
correctErrorTypes true
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
package me.zobrist.tichucounter
|
package me.zobrist.tichucounter
|
||||||
|
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import org.junit.Assert.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
import org.junit.Assert.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instrumented test, which will execute on an Android device.
|
* Instrumented test, which will execute on an Android device.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,19 +2,20 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
android:name=".framework.TichuCounterApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
android:fullBackupContent="@xml/backup_descriptor"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:localeConfig="@xml/locales_config"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme">
|
||||||
android:fullBackupContent="@xml/backup_descriptor">
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".viewModel.MainActivity"
|
||||||
android:windowSoftInputMode="adjustPan"
|
android:exported="true"
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
android:exported="true">
|
android:windowSoftInputMode="adjustPan">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package me.zobrist.tichucounter
|
|
||||||
|
|
||||||
fun Int.isMultipleOf5(): Boolean
|
|
||||||
{
|
|
||||||
return (this % 5) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Int.isMultipleOf100(): Boolean
|
|
||||||
{
|
|
||||||
return (this % 100) == 0
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
package me.zobrist.tichucounter
|
|
||||||
|
|
||||||
class History
|
|
||||||
{
|
|
||||||
private var scores=ArrayList<Round>()
|
|
||||||
|
|
||||||
fun getScoreA(): Int
|
|
||||||
{
|
|
||||||
var tempScore=0
|
|
||||||
scores.forEach {
|
|
||||||
tempScore+=it.scoreA
|
|
||||||
}
|
|
||||||
return tempScore
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getScoreB(): Int
|
|
||||||
{
|
|
||||||
var tempScore=0
|
|
||||||
scores.forEach {
|
|
||||||
tempScore+=it.scoreB
|
|
||||||
}
|
|
||||||
return tempScore
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getHistoryA(): String
|
|
||||||
{
|
|
||||||
var tempHistory=String()
|
|
||||||
scores.forEach {
|
|
||||||
tempHistory+=it.scoreA.toString() + "\n"
|
|
||||||
}
|
|
||||||
return tempHistory
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getHistoryB(): String
|
|
||||||
{
|
|
||||||
var tempHistory=String()
|
|
||||||
scores.forEach {
|
|
||||||
tempHistory+=it.scoreB.toString() + "\n"
|
|
||||||
}
|
|
||||||
return tempHistory
|
|
||||||
}
|
|
||||||
|
|
||||||
fun logRound(round: Round)
|
|
||||||
{
|
|
||||||
scores.add(round)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun revertLastRound()
|
|
||||||
{
|
|
||||||
if (scores.isNotEmpty())
|
|
||||||
{
|
|
||||||
scores.removeAt(scores.size - 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearAll()
|
|
||||||
{
|
|
||||||
scores.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isEmpty(): Boolean
|
|
||||||
{
|
|
||||||
return scores.isEmpty()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package me.zobrist.tichucounter
|
|
||||||
|
|
||||||
import java.io.Serializable
|
|
||||||
|
|
||||||
class Round() : Serializable
|
|
||||||
{
|
|
||||||
var scoreA: Int=0
|
|
||||||
var scoreB: Int=0
|
|
||||||
|
|
||||||
constructor(score: Int , isScoreA: Boolean) : this()
|
|
||||||
{
|
|
||||||
if (isScoreA)
|
|
||||||
{
|
|
||||||
scoreA=score
|
|
||||||
scoreB=calculateOtherScore(scoreA)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scoreB=score
|
|
||||||
scoreA=calculateOtherScore(scoreB)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(scoreA: Int , scoreB: Int) : this()
|
|
||||||
{
|
|
||||||
this.scoreA=scoreA
|
|
||||||
this.scoreB=scoreB
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun calculateOtherScore(score: Int): Int
|
|
||||||
{
|
|
||||||
if (score.isMultipleOf100() && score != 0)
|
|
||||||
{
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
if (score in 101 ..125)
|
|
||||||
{
|
|
||||||
return 0 - (score % 100)
|
|
||||||
}
|
|
||||||
return 100 - (score % 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isValidRound(): Boolean
|
|
||||||
{
|
|
||||||
return (scoreA.isMultipleOf5()) && scoreB.isMultipleOf5() && (scoreA + scoreB).isMultipleOf100()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
60
app/src/main/java/me/zobrist/tichucounter/domain/History.kt
Normal file
60
app/src/main/java/me/zobrist/tichucounter/domain/History.kt
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package me.zobrist.tichucounter.domain
|
||||||
|
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class History {
|
||||||
|
private var scores = ArrayList<Round>()
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
constructor()
|
||||||
|
|
||||||
|
fun getScoreA(): Int {
|
||||||
|
var tempScore = 0
|
||||||
|
scores.forEach {
|
||||||
|
tempScore += it.scoreA
|
||||||
|
}
|
||||||
|
return tempScore
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getScoreB(): Int {
|
||||||
|
var tempScore = 0
|
||||||
|
scores.forEach {
|
||||||
|
tempScore += it.scoreB
|
||||||
|
}
|
||||||
|
return tempScore
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getHistoryA(): String {
|
||||||
|
var tempHistory = String()
|
||||||
|
scores.forEach {
|
||||||
|
tempHistory += it.scoreA.toString() + "\n"
|
||||||
|
}
|
||||||
|
return tempHistory
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getHistoryB(): String {
|
||||||
|
var tempHistory = String()
|
||||||
|
scores.forEach {
|
||||||
|
tempHistory += it.scoreB.toString() + "\n"
|
||||||
|
}
|
||||||
|
return tempHistory
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logRound(round: Round) {
|
||||||
|
scores.add(round)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun revertLastRound() {
|
||||||
|
if (scores.isNotEmpty()) {
|
||||||
|
scores.removeAt(scores.size - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearAll() {
|
||||||
|
scores.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isEmpty(): Boolean {
|
||||||
|
return scores.isEmpty()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package me.zobrist.tichucounter.domain
|
||||||
|
|
||||||
|
fun Int.isMultipleOf5(): Boolean {
|
||||||
|
return (this % 5) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Int.isMultipleOf100(): Boolean {
|
||||||
|
return (this % 100) == 0
|
||||||
|
}
|
||||||
37
app/src/main/java/me/zobrist/tichucounter/domain/Round.kt
Normal file
37
app/src/main/java/me/zobrist/tichucounter/domain/Round.kt
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package me.zobrist.tichucounter.domain
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
class Round() : Serializable {
|
||||||
|
var scoreA: Int = 0
|
||||||
|
var scoreB: Int = 0
|
||||||
|
|
||||||
|
constructor(score: Int, isScoreA: Boolean) : this() {
|
||||||
|
if (isScoreA) {
|
||||||
|
scoreA = score
|
||||||
|
scoreB = calculateOtherScore(scoreA)
|
||||||
|
} else {
|
||||||
|
scoreB = score
|
||||||
|
scoreA = calculateOtherScore(scoreB)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(scoreA: Int, scoreB: Int) : this() {
|
||||||
|
this.scoreA = scoreA
|
||||||
|
this.scoreB = scoreB
|
||||||
|
}
|
||||||
|
|
||||||
|
fun calculateOtherScore(score: Int): Int {
|
||||||
|
if (score.isMultipleOf100() && score != 0) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if (score in 101..125) {
|
||||||
|
return 0 - (score % 100)
|
||||||
|
}
|
||||||
|
return 100 - (score % 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isValidRound(): Boolean {
|
||||||
|
return (scoreA.isMultipleOf5()) && scoreB.isMultipleOf5() && (scoreA + scoreB).isMultipleOf100()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package me.zobrist.tichucounter.framework
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
|
|
||||||
|
@HiltAndroidApp
|
||||||
|
class TichuCounterApplication : Application() {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package me.zobrist.tichucounter
|
package me.zobrist.tichucounter.viewModel
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@@ -14,24 +14,30 @@ import androidx.appcompat.app.AppCompatDelegate
|
|||||||
import androidx.core.os.LocaleListCompat
|
import androidx.core.os.LocaleListCompat
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import me.zobrist.tichucounter.R
|
||||||
import me.zobrist.tichucounter.databinding.ActivityMainBinding
|
import me.zobrist.tichucounter.databinding.ActivityMainBinding
|
||||||
|
import me.zobrist.tichucounter.domain.History
|
||||||
|
import me.zobrist.tichucounter.domain.Round
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity()
|
@AndroidEntryPoint
|
||||||
{
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private var updateOnChange: Boolean = true
|
private var updateOnChange: Boolean = true
|
||||||
|
|
||||||
private lateinit var history: History
|
@Inject
|
||||||
private var currentRound=Round()
|
lateinit var history: History
|
||||||
|
lateinit var currentRound: Round
|
||||||
|
|
||||||
private var systemLocale = Locale.getDefault()
|
private var systemLocale = Locale.getDefault()
|
||||||
|
|
||||||
|
|
||||||
private lateinit var binding: ActivityMainBinding
|
private lateinit var binding: ActivityMainBinding
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?)
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
{
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
@@ -60,105 +66,76 @@ class MainActivity : AppCompatActivity()
|
|||||||
)
|
)
|
||||||
updateView()
|
updateView()
|
||||||
|
|
||||||
this.setListenes()
|
this.setListeners()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setListenes()
|
private fun setListeners() {
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamA.setOnFocusChangeListener { _, b ->
|
binding.contentMain.inputTeamA.setOnFocusChangeListener { _, b ->
|
||||||
if (b)
|
if (b) {
|
||||||
{
|
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.contentMain.inputTeamB.setOnFocusChangeListener { _, b ->
|
binding.contentMain.inputTeamB.setOnFocusChangeListener { _, b ->
|
||||||
if (b)
|
if (b) {
|
||||||
{
|
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.contentMain.inputTeamA.doOnTextChanged { text, _, _, _ ->
|
binding.contentMain.inputTeamA.doOnTextChanged { text, _, _, _ ->
|
||||||
if (binding.contentMain.inputTeamA.isFocused)
|
if (binding.contentMain.inputTeamA.isFocused) {
|
||||||
{
|
if (binding.contentMain.inputTeamA.text.isNotEmpty()) {
|
||||||
if (binding.contentMain.inputTeamA.text.isNotEmpty())
|
if (updateOnChange) {
|
||||||
{
|
currentRound = try {
|
||||||
if (updateOnChange)
|
|
||||||
{
|
|
||||||
currentRound=try
|
|
||||||
{
|
|
||||||
Round(text.toString().toInt(), true)
|
Round(text.toString().toInt(), true)
|
||||||
|
|
||||||
}
|
} catch (e: java.lang.Exception) {
|
||||||
catch (e: java.lang.Exception)
|
|
||||||
{
|
|
||||||
Round(1, 1)
|
Round(1, 1)
|
||||||
}
|
}
|
||||||
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
updateOnChange = true
|
updateOnChange = true
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamA.text.clear()
|
binding.contentMain.inputTeamA.text.clear()
|
||||||
binding.contentMain.inputTeamB.text.clear()
|
binding.contentMain.inputTeamB.text.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRound.isValidRound() && binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty())
|
if (currentRound.isValidRound() && binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||||
{
|
|
||||||
enableSubmitButton()
|
enableSubmitButton()
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.contentMain.inputTeamB.doOnTextChanged { text, _, _, _ ->
|
binding.contentMain.inputTeamB.doOnTextChanged { text, _, _, _ ->
|
||||||
if (binding.contentMain.inputTeamB.isFocused)
|
if (binding.contentMain.inputTeamB.isFocused) {
|
||||||
{
|
if (binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||||
if (binding.contentMain.inputTeamB.text.isNotEmpty())
|
if (updateOnChange) {
|
||||||
{
|
currentRound = try {
|
||||||
if (updateOnChange)
|
|
||||||
{
|
|
||||||
currentRound=try
|
|
||||||
{
|
|
||||||
Round(text.toString().toInt(), false)
|
Round(text.toString().toInt(), false)
|
||||||
|
|
||||||
}
|
} catch (e: java.lang.Exception) {
|
||||||
catch (e: java.lang.Exception)
|
|
||||||
{
|
|
||||||
Round(1, 1)
|
Round(1, 1)
|
||||||
}
|
}
|
||||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
updateOnChange = true
|
updateOnChange = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamA.text.clear()
|
binding.contentMain.inputTeamA.text.clear()
|
||||||
binding.contentMain.inputTeamB.text.clear()
|
binding.contentMain.inputTeamB.text.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRound.isValidRound() && binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty())
|
if (currentRound.isValidRound() && binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||||
{
|
|
||||||
enableSubmitButton()
|
enableSubmitButton()
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,15 +143,11 @@ class MainActivity : AppCompatActivity()
|
|||||||
binding.contentMain.buttonAdd100.setOnClickListener {
|
binding.contentMain.buttonAdd100.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (binding.contentMain.inputTeamA.isFocused)
|
if (binding.contentMain.inputTeamA.isFocused) {
|
||||||
{
|
|
||||||
|
|
||||||
currentRound.scoreA=try
|
currentRound.scoreA = try {
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamA.text.toString().toInt() + 100
|
binding.contentMain.inputTeamA.text.toString().toInt() + 100
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e: Exception)
|
|
||||||
{
|
|
||||||
currentRound.scoreB = 0
|
currentRound.scoreB = 0
|
||||||
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
100
|
100
|
||||||
@@ -183,14 +156,10 @@ class MainActivity : AppCompatActivity()
|
|||||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding.contentMain.inputTeamB.isFocused)
|
if (binding.contentMain.inputTeamB.isFocused) {
|
||||||
{
|
currentRound.scoreB = try {
|
||||||
currentRound.scoreB=try
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamB.text.toString().toInt() + 100
|
binding.contentMain.inputTeamB.text.toString().toInt() + 100
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e: Exception)
|
|
||||||
{
|
|
||||||
currentRound.scoreA = 0
|
currentRound.scoreA = 0
|
||||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
100
|
100
|
||||||
@@ -205,14 +174,10 @@ class MainActivity : AppCompatActivity()
|
|||||||
binding.contentMain.buttonSub100.setOnClickListener {
|
binding.contentMain.buttonSub100.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (binding.contentMain.inputTeamA.isFocused)
|
if (binding.contentMain.inputTeamA.isFocused) {
|
||||||
{
|
currentRound.scoreA = try {
|
||||||
currentRound.scoreA=try
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamA.text.toString().toInt() - 100
|
binding.contentMain.inputTeamA.text.toString().toInt() - 100
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e: Exception)
|
|
||||||
{
|
|
||||||
currentRound.scoreB = 0
|
currentRound.scoreB = 0
|
||||||
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
-100
|
-100
|
||||||
@@ -221,14 +186,10 @@ class MainActivity : AppCompatActivity()
|
|||||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding.contentMain.inputTeamB.isFocused)
|
if (binding.contentMain.inputTeamB.isFocused) {
|
||||||
{
|
currentRound.scoreB = try {
|
||||||
currentRound.scoreB=try
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamB.text.toString().toInt() - 100
|
binding.contentMain.inputTeamB.text.toString().toInt() - 100
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e: Exception)
|
|
||||||
{
|
|
||||||
currentRound.scoreA = 0
|
currentRound.scoreA = 0
|
||||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
-100
|
-100
|
||||||
@@ -293,39 +254,26 @@ class MainActivity : AppCompatActivity()
|
|||||||
|
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (binding.contentMain.inputTeamA.isFocused)
|
if (binding.contentMain.inputTeamA.isFocused) {
|
||||||
{
|
if (binding.contentMain.inputTeamA.text.toString() == "-") {
|
||||||
if (binding.contentMain.inputTeamA.text.toString().equals("-"))
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamA.text.clear()
|
binding.contentMain.inputTeamA.text.clear()
|
||||||
}
|
} else if (binding.contentMain.inputTeamA.text.isNotEmpty()) {
|
||||||
else if (binding.contentMain.inputTeamA.text.isNotEmpty())
|
|
||||||
{
|
|
||||||
tempInt = binding.contentMain.inputTeamA.text.toString().toInt() * -1
|
tempInt = binding.contentMain.inputTeamA.text.toString().toInt() * -1
|
||||||
binding.contentMain.inputTeamA.setText(tempInt.toString())
|
binding.contentMain.inputTeamA.setText(tempInt.toString())
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
appendToFocusedInput('-')
|
appendToFocusedInput('-')
|
||||||
currentRound = Round(1, 1)
|
currentRound = Round(1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
} else if (binding.contentMain.inputTeamB.isFocused) {
|
||||||
else if (binding.contentMain.inputTeamB.isFocused)
|
if (binding.contentMain.inputTeamB.text.toString() == "-") {
|
||||||
{
|
|
||||||
if (binding.contentMain.inputTeamB.text.toString().equals("-"))
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamB.text.clear()
|
binding.contentMain.inputTeamB.text.clear()
|
||||||
}
|
} else if (binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||||
else if (binding.contentMain.inputTeamB.text.isNotEmpty())
|
|
||||||
{
|
|
||||||
tempInt = binding.contentMain.inputTeamB.text.toString().toInt() * -1
|
tempInt = binding.contentMain.inputTeamB.text.toString().toInt() * -1
|
||||||
binding.contentMain.inputTeamB.setText(tempInt.toString())
|
binding.contentMain.inputTeamB.setText(tempInt.toString())
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
appendToFocusedInput('-')
|
appendToFocusedInput('-')
|
||||||
currentRound = Round(1, 1)
|
currentRound = Round(1, 1)
|
||||||
@@ -336,19 +284,14 @@ class MainActivity : AppCompatActivity()
|
|||||||
binding.contentMain.buttonBack.setOnClickListener {
|
binding.contentMain.buttonBack.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (binding.contentMain.inputTeamA.isFocused)
|
if (binding.contentMain.inputTeamA.isFocused) {
|
||||||
{
|
if (binding.contentMain.inputTeamA.text.isNotEmpty()) {
|
||||||
if (binding.contentMain.inputTeamA.text.isNotEmpty())
|
|
||||||
{
|
|
||||||
val string = binding.contentMain.inputTeamA.text.toString()
|
val string = binding.contentMain.inputTeamA.text.toString()
|
||||||
binding.contentMain.inputTeamA.setText(string.substring(0, string.length - 1))
|
binding.contentMain.inputTeamA.setText(string.substring(0, string.length - 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if (binding.contentMain.inputTeamB.isFocused) {
|
||||||
else if (binding.contentMain.inputTeamB.isFocused)
|
if (binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||||
{
|
|
||||||
if (binding.contentMain.inputTeamB.text.isNotEmpty())
|
|
||||||
{
|
|
||||||
val string = binding.contentMain.inputTeamB.text.toString()
|
val string = binding.contentMain.inputTeamB.text.toString()
|
||||||
binding.contentMain.inputTeamB.setText(string.substring(0, string.length - 1))
|
binding.contentMain.inputTeamB.setText(string.substring(0, string.length - 1))
|
||||||
}
|
}
|
||||||
@@ -358,8 +301,7 @@ class MainActivity : AppCompatActivity()
|
|||||||
binding.contentMain.submit.setOnClickListener {
|
binding.contentMain.submit.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty())
|
if (binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||||
{
|
|
||||||
|
|
||||||
history.logRound(
|
history.logRound(
|
||||||
Round(
|
Round(
|
||||||
@@ -379,8 +321,7 @@ class MainActivity : AppCompatActivity()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle)
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
{
|
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
|
|
||||||
val prefs = this.getSharedPreferences("Settings", MODE_PRIVATE).edit()
|
val prefs = this.getSharedPreferences("Settings", MODE_PRIVATE).edit()
|
||||||
@@ -391,8 +332,7 @@ class MainActivity : AppCompatActivity()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
{
|
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
menuInflater.inflate(R.menu.menu_main, menu)
|
menuInflater.inflate(R.menu.menu_main, menu)
|
||||||
|
|
||||||
@@ -403,12 +343,9 @@ class MainActivity : AppCompatActivity()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
{
|
return when (item.itemId) {
|
||||||
return when (item.itemId)
|
R.id.action_clear -> {
|
||||||
{
|
|
||||||
R.id.action_clear ->
|
|
||||||
{
|
|
||||||
val builder = AlertDialog.Builder(this)
|
val builder = AlertDialog.Builder(this)
|
||||||
builder.setMessage(getString(R.string.confirmClear))
|
builder.setMessage(getString(R.string.confirmClear))
|
||||||
.setTitle(R.string.clear)
|
.setTitle(R.string.clear)
|
||||||
@@ -424,23 +361,19 @@ class MainActivity : AppCompatActivity()
|
|||||||
builder.create().show()
|
builder.create().show()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_undo ->
|
R.id.action_undo -> {
|
||||||
{
|
|
||||||
undoLastRound()
|
undoLastRound()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_theme ->
|
R.id.action_theme -> {
|
||||||
{
|
|
||||||
chooseThemeDialog()
|
chooseThemeDialog()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_language ->
|
R.id.action_language -> {
|
||||||
{
|
|
||||||
chooseLanguageDialog()
|
chooseLanguageDialog()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_screenOn ->
|
R.id.action_screenOn -> {
|
||||||
{
|
|
||||||
item.isChecked = !item.isChecked
|
item.isChecked = !item.isChecked
|
||||||
keepScreenOn(item.isChecked)
|
keepScreenOn(item.isChecked)
|
||||||
true
|
true
|
||||||
@@ -449,29 +382,24 @@ class MainActivity : AppCompatActivity()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideKeyboard()
|
private fun hideKeyboard() {
|
||||||
{
|
|
||||||
val imm: InputMethodManager =
|
val imm: InputMethodManager =
|
||||||
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
imm.hideSoftInputFromWindow(currentFocus!!.windowToken, 0)
|
imm.hideSoftInputFromWindow(currentFocus!!.windowToken, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun giveFocusToAIfNone()
|
private fun giveFocusToAIfNone() {
|
||||||
{
|
if (!binding.contentMain.inputTeamA.isFocused && !binding.contentMain.inputTeamB.isFocused) {
|
||||||
if (!binding.contentMain.inputTeamA.isFocused && !binding.contentMain.inputTeamB.isFocused)
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamA.requestFocus()
|
binding.contentMain.inputTeamA.requestFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun undoLastRound()
|
private fun undoLastRound() {
|
||||||
{
|
|
||||||
history.revertLastRound()
|
history.revertLastRound()
|
||||||
updateView()
|
updateView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateView()
|
private fun updateView() {
|
||||||
{
|
|
||||||
binding.contentMain.scoreA.text = history.getScoreA().toString()
|
binding.contentMain.scoreA.text = history.getScoreA().toString()
|
||||||
binding.contentMain.scoreB.text = history.getScoreB().toString()
|
binding.contentMain.scoreB.text = history.getScoreB().toString()
|
||||||
|
|
||||||
@@ -479,8 +407,7 @@ class MainActivity : AppCompatActivity()
|
|||||||
binding.contentMain.historyB.text = history.getHistoryB()
|
binding.contentMain.historyB.text = history.getHistoryB()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearAll()
|
private fun clearAll() {
|
||||||
{
|
|
||||||
binding.contentMain.historyA.text = ""
|
binding.contentMain.historyA.text = ""
|
||||||
binding.contentMain.historyB.text = ""
|
binding.contentMain.historyB.text = ""
|
||||||
binding.contentMain.inputTeamA.text.clear()
|
binding.contentMain.inputTeamA.text.clear()
|
||||||
@@ -491,32 +418,25 @@ class MainActivity : AppCompatActivity()
|
|||||||
history.clearAll()
|
history.clearAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun appendToFocusedInput(toAppend: Char)
|
private fun appendToFocusedInput(toAppend: Char) {
|
||||||
{
|
if (binding.contentMain.inputTeamA.isFocused) {
|
||||||
if (binding.contentMain.inputTeamA.isFocused)
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamA.text.append(toAppend)
|
binding.contentMain.inputTeamA.text.append(toAppend)
|
||||||
}
|
} else if (binding.contentMain.inputTeamB.isFocused) {
|
||||||
else if (binding.contentMain.inputTeamB.isFocused)
|
|
||||||
{
|
|
||||||
binding.contentMain.inputTeamB.text.append(toAppend)
|
binding.contentMain.inputTeamB.text.append(toAppend)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun enableSubmitButton()
|
private fun enableSubmitButton() {
|
||||||
{
|
|
||||||
binding.contentMain.submit.imageAlpha = 255 // 0 being transparent and 255 being opaque
|
binding.contentMain.submit.imageAlpha = 255 // 0 being transparent and 255 being opaque
|
||||||
binding.contentMain.submit.isEnabled = true
|
binding.contentMain.submit.isEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun disableSubmitButton()
|
private fun disableSubmitButton() {
|
||||||
{
|
|
||||||
binding.contentMain.submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
binding.contentMain.submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
||||||
binding.contentMain.submit.isEnabled = false
|
binding.contentMain.submit.isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseThemeDialog()
|
private fun chooseThemeDialog() {
|
||||||
{
|
|
||||||
|
|
||||||
val builder = AlertDialog.Builder(this)
|
val builder = AlertDialog.Builder(this)
|
||||||
builder.setTitle(getString(R.string.choose_theme_text))
|
builder.setTitle(getString(R.string.choose_theme_text))
|
||||||
@@ -546,32 +466,30 @@ class MainActivity : AppCompatActivity()
|
|||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseLanguageDialog()
|
private fun chooseLanguageDialog() {
|
||||||
{
|
|
||||||
|
|
||||||
val builder = AlertDialog.Builder(this)
|
val builder = AlertDialog.Builder(this)
|
||||||
builder.setTitle(getString(R.string.choose_language_text))
|
builder.setTitle(getString(R.string.choose_language_text))
|
||||||
|
|
||||||
val languages_map=mapOf(
|
val languagesMap = mapOf(
|
||||||
getString(R.string.english) to "en",
|
getString(R.string.english) to "en",
|
||||||
getString(R.string.german) to "de"
|
getString(R.string.german) to "de"
|
||||||
)
|
)
|
||||||
|
|
||||||
val languages_display_keys=languages_map.keys.toTypedArray()
|
val languagesDisplayKeys = languagesMap.keys.toTypedArray()
|
||||||
val languages_display_values=languages_map.values.toTypedArray()
|
val languagesDisplayValues = languagesMap.values.toTypedArray()
|
||||||
|
|
||||||
val checkedItem = AppCompatDelegate.getApplicationLocales()[0].toString()
|
val checkedItem = AppCompatDelegate.getApplicationLocales()[0].toString()
|
||||||
var checkedItemIndex=languages_display_values.indexOf(checkedItem)
|
var checkedItemIndex = languagesDisplayValues.indexOf(checkedItem)
|
||||||
|
|
||||||
if (checkedItemIndex == -1)
|
if (checkedItemIndex == -1) {
|
||||||
{
|
|
||||||
checkedItemIndex = 0
|
checkedItemIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setSingleChoiceItems(languages_display_keys , checkedItemIndex) { dialog , which ->
|
builder.setSingleChoiceItems(languagesDisplayKeys, checkedItemIndex) { dialog, which ->
|
||||||
|
|
||||||
val newLocale =
|
val newLocale =
|
||||||
LocaleListCompat.forLanguageTags(languages_map[languages_display_keys[which]])
|
LocaleListCompat.forLanguageTags(languagesMap[languagesDisplayKeys[which]])
|
||||||
|
|
||||||
AppCompatDelegate.setApplicationLocales(newLocale)
|
AppCompatDelegate.setApplicationLocales(newLocale)
|
||||||
|
|
||||||
@@ -585,10 +503,8 @@ class MainActivity : AppCompatActivity()
|
|||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTheme(which: Int)
|
private fun updateTheme(which: Int) {
|
||||||
{
|
when (which) {
|
||||||
when (which)
|
|
||||||
{
|
|
||||||
0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||||
1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||||
2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||||
@@ -596,14 +512,10 @@ class MainActivity : AppCompatActivity()
|
|||||||
delegate.applyDayNight()
|
delegate.applyDayNight()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun keepScreenOn(keepOn: Boolean)
|
private fun keepScreenOn(keepOn: Boolean) {
|
||||||
{
|
if (keepOn) {
|
||||||
if (keepOn)
|
|
||||||
{
|
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,12 +269,12 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:contentDescription="TODO"
|
||||||
android:cropToPadding="false"
|
android:cropToPadding="false"
|
||||||
android:paddingTop="15dp"
|
android:paddingTop="15dp"
|
||||||
android:paddingBottom="15dp"
|
android:paddingBottom="15dp"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
app:srcCompat="@drawable/back"
|
app:srcCompat="@drawable/back" />
|
||||||
android:contentDescription="TODO" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -312,9 +312,9 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
|
android:contentDescription="TODO"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
app:srcCompat="@drawable/checkmark"
|
app:srcCompat="@drawable/checkmark" />
|
||||||
android:contentDescription="TODO" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".viewModel.MainActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -285,12 +285,12 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:contentDescription="@string/back"
|
||||||
android:cropToPadding="false"
|
android:cropToPadding="false"
|
||||||
android:paddingTop="15dp"
|
android:paddingTop="15dp"
|
||||||
android:paddingBottom="15dp"
|
android:paddingBottom="15dp"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
app:srcCompat="@drawable/back"
|
app:srcCompat="@drawable/back" />
|
||||||
android:contentDescription="@string/back" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -331,8 +331,8 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
|
android:contentDescription="TODO"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
app:srcCompat="@drawable/checkmark"
|
app:srcCompat="@drawable/checkmark" />
|
||||||
android:contentDescription="TODO" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="me.zobrist.tichucounter.MainActivity">
|
tools:context="me.zobrist.tichucounter.viewModel.MainActivity">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_undo"
|
android:id="@+id/action_undo"
|
||||||
android:icon="@android:drawable/ic_menu_revert"
|
android:icon="@android:drawable/ic_menu_revert"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package me.zobrist.tichucounter
|
package me.zobrist.tichucounter
|
||||||
|
|
||||||
|
import me.zobrist.tichucounter.domain.History
|
||||||
|
import me.zobrist.tichucounter.domain.Round
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertNotEquals
|
import org.junit.Assert.assertNotEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -9,11 +11,9 @@ import org.junit.Test
|
|||||||
*
|
*
|
||||||
* See [testing documentation](http://d.android.com/tools/testing).
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
*/
|
*/
|
||||||
class HistoryUnitTest
|
class HistoryUnitTest {
|
||||||
{
|
|
||||||
@Test
|
@Test
|
||||||
fun calculation_isCorrect()
|
fun calculation_isCorrect() {
|
||||||
{
|
|
||||||
val history = History()
|
val history = History()
|
||||||
|
|
||||||
history.revertLastRound()
|
history.revertLastRound()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package me.zobrist.tichucounter
|
package me.zobrist.tichucounter
|
||||||
|
|
||||||
|
import me.zobrist.tichucounter.domain.Round
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
@@ -8,19 +9,16 @@ import org.junit.Test
|
|||||||
*
|
*
|
||||||
* See [testing documentation](http://d.android.com/tools/testing).
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
*/
|
*/
|
||||||
class RoundUnitTest
|
class RoundUnitTest {
|
||||||
{
|
|
||||||
@Test
|
@Test
|
||||||
fun calculation_isCorrect()
|
fun calculation_isCorrect() {
|
||||||
{
|
|
||||||
|
|
||||||
var inputScoreA = 125
|
var inputScoreA = 125
|
||||||
var inputScoreB = -25
|
var inputScoreB = -25
|
||||||
var temp: Round
|
var temp: Round
|
||||||
|
|
||||||
// Normal round range -25 to 125 as input
|
// Normal round range -25 to 125 as input
|
||||||
while (inputScoreB <= 125)
|
while (inputScoreB <= 125) {
|
||||||
{
|
|
||||||
temp = Round(inputScoreA, true)
|
temp = Round(inputScoreA, true)
|
||||||
assertEquals(inputScoreB, temp.scoreB)
|
assertEquals(inputScoreB, temp.scoreB)
|
||||||
assertTrue(temp.isValidRound())
|
assertTrue(temp.isValidRound())
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'com.google.dagger.hilt.android' version '2.44' apply false
|
||||||
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
|||||||
Reference in New Issue
Block a user