Merge branch 'master' into develop
This commit is contained in:
@@ -4,21 +4,22 @@ apply plugin: 'kotlin-android-extensions'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 30
|
||||||
buildToolsVersion "30.0.1"
|
buildToolsVersion "30.0.2"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "me.zobrist.tichucounter"
|
applicationId "me.zobrist.tichucounter"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 1
|
versionCode 7
|
||||||
versionName "1.0"
|
versionName "1.0.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled true
|
||||||
|
shrinkResources true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,11 +38,14 @@ dependencies {
|
|||||||
implementation 'androidx.core:core-ktx:1.3.1'
|
implementation 'androidx.core:core-ktx:1.3.1'
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'com.google.android.material:material:1.2.0'
|
implementation 'com.google.android.material:material:1.2.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'com.google.android.play:core:1.8.0'
|
||||||
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
|
implementation 'com.google.code.gson:gson:2.8.5'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,8 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
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=".MainActivity"
|
||||||
android:windowSoftInputMode="adjustPan"
|
android:windowSoftInputMode="adjustPan"
|
||||||
|
|||||||
@@ -2,16 +2,10 @@
|
|||||||
|
|
||||||
package me.zobrist.tichucounter
|
package me.zobrist.tichucounter
|
||||||
|
|
||||||
import android.os.Parcel
|
|
||||||
import android.os.Parcelable
|
|
||||||
|
|
||||||
class History() : Parcelable {
|
class History {
|
||||||
private var scores: ArrayList<Round> = ArrayList()
|
private var scores: ArrayList<Round> = ArrayList()
|
||||||
|
|
||||||
constructor(parcel: Parcel) : this() {
|
|
||||||
scores = parcel.readSerializable() as ArrayList<Round>
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getScoreA(): Int {
|
fun getScoreA(): Int {
|
||||||
var tempScore = 0
|
var tempScore = 0
|
||||||
scores.forEach {
|
scores.forEach {
|
||||||
@@ -31,7 +25,7 @@ class History() : Parcelable {
|
|||||||
fun getHistoryA(): String {
|
fun getHistoryA(): String {
|
||||||
var tempHistory = String()
|
var tempHistory = String()
|
||||||
scores.forEach {
|
scores.forEach {
|
||||||
tempHistory = tempHistory.plus(it.scoreA.toString()).plus("\n")
|
tempHistory += it.scoreA.toString() + "\n"
|
||||||
}
|
}
|
||||||
return tempHistory
|
return tempHistory
|
||||||
}
|
}
|
||||||
@@ -39,7 +33,7 @@ class History() : Parcelable {
|
|||||||
fun getHistoryB(): String {
|
fun getHistoryB(): String {
|
||||||
var tempHistory = String()
|
var tempHistory = String()
|
||||||
scores.forEach {
|
scores.forEach {
|
||||||
tempHistory = tempHistory.plus(it.scoreB.toString()).plus("\n")
|
tempHistory += it.scoreB.toString() + "\n"
|
||||||
}
|
}
|
||||||
return tempHistory
|
return tempHistory
|
||||||
}
|
}
|
||||||
@@ -61,23 +55,4 @@ class History() : Parcelable {
|
|||||||
fun isEmpty(): Boolean {
|
fun isEmpty(): Boolean {
|
||||||
return scores.isEmpty()
|
return scores.isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeSerializable(scores)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<History> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): History {
|
|
||||||
return History(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<History?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,17 +6,17 @@ import android.os.Bundle
|
|||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.WindowManager
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
|
import com.google.gson.Gson
|
||||||
import kotlinx.android.synthetic.main.content_main.*
|
import kotlinx.android.synthetic.main.content_main.*
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private var invertA: Boolean = false
|
|
||||||
private var invertB: Boolean = false
|
|
||||||
|
|
||||||
private var updateOnChange: Boolean = true
|
private var updateOnChange: Boolean = true
|
||||||
|
|
||||||
private lateinit var history: History
|
private lateinit var history: History
|
||||||
@@ -31,11 +31,30 @@ class MainActivity : AppCompatActivity() {
|
|||||||
inputTeamA.requestFocus()
|
inputTeamA.requestFocus()
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
updateTheme(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2))
|
updateTheme(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2))
|
||||||
|
keepScreenOn(
|
||||||
|
this.getSharedPreferences("Settings", Context.MODE_PRIVATE)
|
||||||
|
.getBoolean("Screen_On", false)
|
||||||
|
)
|
||||||
|
|
||||||
history = savedInstanceState?.getParcelable("history") ?: History()
|
val json = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("history", "{\"scores\":[]}")
|
||||||
|
history = Gson().fromJson(json, History::class.java)
|
||||||
|
nameTeamA.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamA", "TeamA"))
|
||||||
|
nameTeamB.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamB", "TeamB"))
|
||||||
updateView()
|
updateView()
|
||||||
|
|
||||||
|
|
||||||
|
inputTeamA.setOnFocusChangeListener { view, b ->
|
||||||
|
if (b) {
|
||||||
|
hideKeyboard()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inputTeamB.setOnFocusChangeListener { view, b ->
|
||||||
|
if (b) {
|
||||||
|
hideKeyboard()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inputTeamA.doOnTextChanged { text, start, count, after ->
|
inputTeamA.doOnTextChanged { text, start, count, after ->
|
||||||
if (inputTeamA.isFocused) {
|
if (inputTeamA.isFocused) {
|
||||||
if (inputTeamA.text.isNotEmpty()) {
|
if (inputTeamA.text.isNotEmpty()) {
|
||||||
@@ -44,7 +63,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Round(text.toString().toInt(), true)
|
Round(text.toString().toInt(), true)
|
||||||
|
|
||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
Round(0, 0)
|
Round(1, 1)
|
||||||
}
|
}
|
||||||
inputTeamB.setText(currentRound.scoreB.toString())
|
inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
} else {
|
} else {
|
||||||
@@ -56,7 +75,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentRound.isValidRound()){
|
if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
||||||
enableSubmitButton()
|
enableSubmitButton()
|
||||||
} else {
|
} else {
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
@@ -73,7 +92,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Round(text.toString().toInt(), false)
|
Round(text.toString().toInt(), false)
|
||||||
|
|
||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
Round(0, 0)
|
Round(1, 1)
|
||||||
}
|
}
|
||||||
inputTeamA.setText(currentRound.scoreA.toString())
|
inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
|
|
||||||
@@ -87,7 +106,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentRound.isValidRound()){
|
if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
||||||
enableSubmitButton()
|
enableSubmitButton()
|
||||||
} else {
|
} else {
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
@@ -95,52 +114,61 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buttonAdd100.setOnClickListener {
|
buttonAdd100.setOnClickListener {
|
||||||
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (inputTeamA.isFocused) {
|
if (inputTeamA.isFocused) {
|
||||||
|
|
||||||
val temp = try {
|
currentRound.scoreA = try {
|
||||||
inputTeamA.text.toString().toInt() + 100
|
inputTeamA.text.toString().toInt() + 100
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
inputTeamB.setText(0.toString())
|
currentRound.scoreB = 0
|
||||||
|
inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
100
|
100
|
||||||
|
|
||||||
}
|
}
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
inputTeamA.setText(temp.toString())
|
inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputTeamB.isFocused) {
|
if (inputTeamB.isFocused) {
|
||||||
val temp = try {
|
currentRound.scoreB = try {
|
||||||
inputTeamB.text.toString().toInt() + 100
|
inputTeamB.text.toString().toInt() + 100
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
inputTeamA.setText(0.toString())
|
currentRound.scoreA = 0
|
||||||
|
inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
100
|
100
|
||||||
|
|
||||||
}
|
}
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
inputTeamB.setText(temp.toString())
|
inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonSub100.setOnClickListener {
|
buttonSub100.setOnClickListener {
|
||||||
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (inputTeamA.isFocused) {
|
if (inputTeamA.isFocused) {
|
||||||
val temp = try {
|
currentRound.scoreA = try {
|
||||||
inputTeamA.text.toString().toInt() - 100
|
inputTeamA.text.toString().toInt() - 100
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
currentRound.scoreB = 0
|
||||||
|
inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
-100
|
-100
|
||||||
}
|
}
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
inputTeamA.setText(temp.toString())
|
inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputTeamB.isFocused) {
|
if (inputTeamB.isFocused) {
|
||||||
val temp = try {
|
currentRound.scoreB = try {
|
||||||
inputTeamB.text.toString().toInt() - 100
|
inputTeamB.text.toString().toInt() - 100
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
currentRound.scoreA = 0
|
||||||
|
inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
-100
|
-100
|
||||||
}
|
}
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
inputTeamB.setText(temp.toString())
|
inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,22 +228,28 @@ class MainActivity : AppCompatActivity() {
|
|||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (inputTeamA.isFocused) {
|
if (inputTeamA.isFocused) {
|
||||||
if (inputTeamA.text.isNotEmpty()){
|
if (inputTeamA.text.toString().equals("-")) {
|
||||||
|
inputTeamA.text.clear()
|
||||||
|
} else if (inputTeamA.text.isNotEmpty()) {
|
||||||
tempInt = inputTeamA.text.toString().toInt() * -1
|
tempInt = inputTeamA.text.toString().toInt() * -1
|
||||||
inputTeamA.setText(tempInt.toString())
|
inputTeamA.setText(tempInt.toString())
|
||||||
} else {
|
} else {
|
||||||
invertB = false
|
updateOnChange = false
|
||||||
invertA = true
|
appendToFocusedInput('-')
|
||||||
|
currentRound = Round(1,1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (inputTeamB.isFocused) {
|
} else if (inputTeamB.isFocused) {
|
||||||
if(inputTeamB.text.isNotEmpty()){
|
if (inputTeamB.text.toString().equals("-")) {
|
||||||
|
inputTeamB.text.clear()
|
||||||
|
} else if (inputTeamB.text.isNotEmpty()) {
|
||||||
tempInt = inputTeamB.text.toString().toInt() * -1
|
tempInt = inputTeamB.text.toString().toInt() * -1
|
||||||
inputTeamB.setText(tempInt.toString())
|
inputTeamB.setText(tempInt.toString())
|
||||||
} else {
|
} else {
|
||||||
invertA = false
|
updateOnChange = false
|
||||||
invertB = true
|
appendToFocusedInput('-')
|
||||||
|
currentRound = Round(1,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,36 +276,62 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
||||||
|
|
||||||
history.logRound(Round(inputTeamA.text.toString().toInt(), inputTeamB.text.toString().toInt()))
|
history.logRound(
|
||||||
|
Round(
|
||||||
|
inputTeamA.text.toString().toInt(),
|
||||||
|
inputTeamB.text.toString().toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
updateView()
|
updateView()
|
||||||
|
|
||||||
|
|
||||||
inputTeamA.text.clear()
|
inputTeamA.text.clear()
|
||||||
inputTeamB.text.clear()
|
inputTeamB.text.clear()
|
||||||
|
disableSubmitButton()
|
||||||
|
|
||||||
scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
|
scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
outState.putParcelable("history", history)
|
|
||||||
|
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
||||||
|
prefs.putString("history", Gson().toJson(history))
|
||||||
|
prefs.putString("nameTeamA", nameTeamA.text.toString())
|
||||||
|
prefs.putString("nameTeamB", nameTeamB.text.toString())
|
||||||
|
prefs.apply()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
menu.findItem(R.id.action_screenOn).isChecked =
|
||||||
|
this.getSharedPreferences("Settings", Context.MODE_PRIVATE)
|
||||||
|
.getBoolean("Screen_On", false)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
builder.setMessage(getString(R.string.confirmClear))
|
||||||
|
.setTitle(R.string.clear)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(getString(R.string.yes)) { dialog, id ->
|
||||||
|
dialog.dismiss()
|
||||||
clearAll()
|
clearAll()
|
||||||
|
}
|
||||||
|
.setNegativeButton(getString(R.string.no)) { dialog, id ->
|
||||||
|
dialog.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.create().show()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_undo -> {
|
R.id.action_undo -> {
|
||||||
@@ -282,10 +342,21 @@ class MainActivity : AppCompatActivity() {
|
|||||||
chooseThemeDialog()
|
chooseThemeDialog()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
R.id.action_screenOn -> {
|
||||||
|
item.isChecked = !item.isChecked
|
||||||
|
keepScreenOn(item.isChecked)
|
||||||
|
true
|
||||||
|
}
|
||||||
else -> super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun hideKeyboard() {
|
||||||
|
val imm: InputMethodManager =
|
||||||
|
getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
imm.hideSoftInputFromWindow(currentFocus!!.windowToken, 0)
|
||||||
|
}
|
||||||
|
|
||||||
private fun giveFocusToAIfNone() {
|
private fun giveFocusToAIfNone() {
|
||||||
if (!inputTeamA.isFocused && !inputTeamB.isFocused) {
|
if (!inputTeamA.isFocused && !inputTeamB.isFocused) {
|
||||||
inputTeamA.requestFocus()
|
inputTeamA.requestFocus()
|
||||||
@@ -293,10 +364,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun undoLastRound() {
|
private fun undoLastRound() {
|
||||||
|
|
||||||
history.revertLastRound()
|
history.revertLastRound()
|
||||||
updateView()
|
updateView()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateView() {
|
private fun updateView() {
|
||||||
@@ -320,22 +389,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun appendToFocusedInput(toAppend: Char) {
|
private fun appendToFocusedInput(toAppend: Char) {
|
||||||
if (inputTeamA.isFocused) {
|
if (inputTeamA.isFocused) {
|
||||||
if(invertA){
|
|
||||||
invertA = false
|
|
||||||
inputTeamA.text.append('-')
|
|
||||||
}
|
|
||||||
|
|
||||||
inputTeamA.text.append(toAppend)
|
inputTeamA.text.append(toAppend)
|
||||||
}else if(inputTeamB.isFocused)
|
} else if (inputTeamB.isFocused) {
|
||||||
{
|
|
||||||
if(invertB){
|
|
||||||
invertB = false
|
|
||||||
inputTeamB.text.append('-')
|
|
||||||
}
|
|
||||||
inputTeamB.text.append(toAppend)
|
inputTeamB.text.append(toAppend)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun enableSubmitButton() {
|
private fun enableSubmitButton() {
|
||||||
@@ -354,7 +411,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
builder.setTitle(getString(R.string.choose_theme_text))
|
builder.setTitle(getString(R.string.choose_theme_text))
|
||||||
val styles = arrayOf("Light", "Dark", "System default")
|
val styles = arrayOf("Light", "Dark", "System default")
|
||||||
|
|
||||||
val checkedItem = this.getSharedPreferences("", Context.MODE_PRIVATE).getInt("Theme", 2)
|
val checkedItem =
|
||||||
|
this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2)
|
||||||
|
|
||||||
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
||||||
|
|
||||||
@@ -381,4 +439,16 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
delegate.applyDayNight()
|
delegate.applyDayNight()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun keepScreenOn(keepOn: Boolean) {
|
||||||
|
if (keepOn) {
|
||||||
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
} else {
|
||||||
|
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
}
|
||||||
|
|
||||||
|
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
||||||
|
prefs.putBoolean("Screen_On", keepOn)
|
||||||
|
prefs.apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,13 +17,13 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/Names"
|
android:id="@+id/viewNames"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/NameTeamA"
|
android:id="@+id/nameTeamA"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/NameTeamB"
|
android:id="@+id/nameTeamB"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/Score"
|
android:id="@+id/viewScore"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
@@ -86,7 +86,8 @@
|
|||||||
android:id="@+id/scrollViewHistory"
|
android:id="@+id/scrollViewHistory"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="16dp">
|
android:layout_marginTop="16dp"
|
||||||
|
android:clickable="false">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -123,7 +124,7 @@
|
|||||||
app:layout_constraintStart_toEndOf="@+id/left">
|
app:layout_constraintStart_toEndOf="@+id/left">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/Input"
|
android:id="@+id/viewInput"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
@@ -272,7 +273,8 @@
|
|||||||
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>
|
||||||
|
|
||||||
@@ -311,7 +313,8 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
app:srcCompat="@drawable/checkmark" />
|
app:srcCompat="@drawable/checkmark"
|
||||||
|
android:contentDescription="TODO" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,14 @@
|
|||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/Names"
|
android:id="@+id/viewNames"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/NameTeamA"
|
android:id="@+id/nameTeamA"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/NameTeamB"
|
android:id="@+id/nameTeamB"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -44,11 +44,11 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/Score"
|
android:id="@+id/viewScore"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/Names">
|
app:layout_constraintTop_toBottomOf="@+id/viewNames">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/scoreA"
|
android:id="@+id/scoreA"
|
||||||
@@ -86,8 +86,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/Input"
|
app:layout_constraintBottom_toTopOf="@+id/viewInput"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/Score">
|
app:layout_constraintTop_toBottomOf="@+id/viewScore">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -118,10 +118,10 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?android:attr/listDivider"
|
android:background="?android:attr/listDivider"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/Score" />
|
app:layout_constraintBottom_toBottomOf="@+id/viewScore" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/Input"
|
android:id="@+id/viewInput"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@@ -274,7 +274,8 @@
|
|||||||
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>
|
||||||
|
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
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>
|
||||||
@@ -17,4 +17,9 @@
|
|||||||
android:id="@+id/action_theme"
|
android:id="@+id/action_theme"
|
||||||
android:orderInCategory="15"
|
android:orderInCategory="15"
|
||||||
android:title="@string/choose_theme_text" />
|
android:title="@string/choose_theme_text" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_screenOn"
|
||||||
|
android:checkable="true"
|
||||||
|
android:orderInCategory="20"
|
||||||
|
android:title="@string/keep_screen_on" />
|
||||||
</menu>
|
</menu>
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="clear">Neues Spiel Starten</string>
|
<string name="clear">Neues Spiel starten</string>
|
||||||
<string name="undo">Letzte Runde Löschen</string>
|
<string name="undo">Letzte Runde löschen</string>
|
||||||
<string name="choose_theme_text">Theme auswählen</string>
|
<string name="choose_theme_text">Theme auswählen</string>
|
||||||
|
<string name="keep_screen_on">Bildschirm eingeschaltet lassen</string>
|
||||||
|
<string name="confirmClear">Möchten Sie das laufende Spiel wirklich löschen?</string>
|
||||||
|
<string name="yes">Ja</string>
|
||||||
|
<string name="no">Nein</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="clear">Neus Spil Starte</string>
|
<string name="clear">Neus Spil starte</string>
|
||||||
<string name="undo">Letschti Rundi Lösche</string>
|
<string name="undo">Letschti Rundi lösche</string>
|
||||||
<string name="choose_theme_text">Usgsehe ändere</string>
|
<string name="choose_theme_text">Usgsehe ändere</string>
|
||||||
|
<string name="keep_screen_on">Bildschirm igschalted la</string>
|
||||||
|
<string name="confirmClear">Wosch ds loufende Spil würklech lösche?</string>
|
||||||
|
<string name="yes">Ja</string>
|
||||||
|
<string name="no">Nei</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
<string name="team_a" translatable="false">Team A</string>
|
<string name="team_a" translatable="false">Team A</string>
|
||||||
<string name="team_b" translatable="false">Team B</string>
|
<string name="team_b" translatable="false">Team B</string>
|
||||||
<string name="clear">Start New Game</string>
|
<string name="clear">Start new game</string>
|
||||||
<string name="undo">Undo Last Round</string>
|
<string name="undo">Undo last round</string>
|
||||||
<string name="choose_theme_text">Choose theme</string>
|
<string name="choose_theme_text">Choose theme</string>
|
||||||
|
<string name="keep_screen_on">Keep screen on</string>
|
||||||
|
<string name="confirmClear">Do you really want to delete the current game?</string>
|
||||||
|
<string name="yes">Yes</string>
|
||||||
|
<string name="no">No</string>
|
||||||
</resources>
|
</resources>
|
||||||
4
app/src/main/res/xml/backup_descriptor.xml
Normal file
4
app/src/main/res/xml/backup_descriptor.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<full-backup-content>
|
||||||
|
<!-- Exclude specific shared preferences that contain GCM registration Id -->
|
||||||
|
</full-backup-content>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.3.72"
|
ext.kotlin_version = "1.4.10"
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
|||||||
Reference in New Issue
Block a user