Compare commits
16 Commits
1.0.0Beta2
...
1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 4eaf2b286e | |||
| 5b6e33304c | |||
| aa777ebe02 | |||
|
|
00fbc60eee | ||
| 16bfcd3288 | |||
| 92bb0dc86f | |||
| 2cb496ea8f | |||
| 3229e51d01 | |||
| ac468e2e84 | |||
| 437fae633a | |||
| f1dad279e0 | |||
| 214d5e61a4 | |||
| 20d9fa79a6 | |||
| be1e819f90 | |||
| 65581ae257 | |||
| be66a50541 |
@@ -10,8 +10,8 @@ android {
|
||||
applicationId "me.zobrist.tichucounter"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 3
|
||||
versionName "1.0.0Beta2"
|
||||
versionCode 7
|
||||
versionName "1.0.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -38,11 +38,14 @@ dependencies {
|
||||
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 '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-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'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
}
|
||||
@@ -8,7 +8,8 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/AppTheme"
|
||||
android:fullBackupContent="@xml/backup_descriptor">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
|
||||
@@ -2,16 +2,10 @@
|
||||
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
class History() : Parcelable {
|
||||
class History {
|
||||
private var scores: ArrayList<Round> = ArrayList()
|
||||
|
||||
constructor(parcel: Parcel) : this() {
|
||||
scores = parcel.readSerializable() as ArrayList<Round>
|
||||
}
|
||||
|
||||
fun getScoreA(): Int {
|
||||
var tempScore = 0
|
||||
scores.forEach {
|
||||
@@ -31,7 +25,7 @@ class History() : Parcelable {
|
||||
fun getHistoryA(): String {
|
||||
var tempHistory = String()
|
||||
scores.forEach {
|
||||
tempHistory = tempHistory.plus(it.scoreA.toString()).plus("\n")
|
||||
tempHistory += it.scoreA.toString() + "\n"
|
||||
}
|
||||
return tempHistory
|
||||
}
|
||||
@@ -39,7 +33,7 @@ class History() : Parcelable {
|
||||
fun getHistoryB(): String {
|
||||
var tempHistory = String()
|
||||
scores.forEach {
|
||||
tempHistory = tempHistory.plus(it.scoreB.toString()).plus("\n")
|
||||
tempHistory += it.scoreB.toString() + "\n"
|
||||
}
|
||||
return tempHistory
|
||||
}
|
||||
@@ -61,23 +55,4 @@ class History() : Parcelable {
|
||||
fun isEmpty(): Boolean {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,13 +12,11 @@ import android.widget.ScrollView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.android.synthetic.main.content_main.*
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private var invertA: Boolean = false
|
||||
private var invertB: Boolean = false
|
||||
|
||||
private var updateOnChange: Boolean = true
|
||||
|
||||
private lateinit var history: History
|
||||
@@ -38,9 +36,10 @@ class MainActivity : AppCompatActivity() {
|
||||
.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()
|
||||
|
||||
|
||||
@@ -64,7 +63,7 @@ class MainActivity : AppCompatActivity() {
|
||||
Round(text.toString().toInt(), true)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(0, 0)
|
||||
Round(1, 1)
|
||||
}
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
} else {
|
||||
@@ -93,7 +92,7 @@ class MainActivity : AppCompatActivity() {
|
||||
Round(text.toString().toInt(), false)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(0, 0)
|
||||
Round(1, 1)
|
||||
}
|
||||
inputTeamA.setText(currentRound.scoreA.toString())
|
||||
|
||||
@@ -229,22 +228,28 @@ class MainActivity : AppCompatActivity() {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
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
|
||||
inputTeamA.setText(tempInt.toString())
|
||||
} else {
|
||||
invertB = false
|
||||
invertA = true
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
currentRound = Round(1,1)
|
||||
}
|
||||
|
||||
|
||||
} 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
|
||||
inputTeamB.setText(tempInt.toString())
|
||||
} else {
|
||||
invertA = false
|
||||
invertB = true
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
currentRound = Round(1,1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,7 +296,13 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
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 {
|
||||
@@ -378,17 +389,8 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
private fun appendToFocusedInput(toAppend: Char) {
|
||||
if (inputTeamA.isFocused) {
|
||||
if (invertA) {
|
||||
invertA = false
|
||||
inputTeamA.text.append('-')
|
||||
}
|
||||
|
||||
inputTeamA.text.append(toAppend)
|
||||
} else if (inputTeamB.isFocused) {
|
||||
if (invertB) {
|
||||
invertB = false
|
||||
inputTeamB.text.append('-')
|
||||
}
|
||||
inputTeamB.text.append(toAppend)
|
||||
}
|
||||
}
|
||||
@@ -409,7 +411,8 @@ class MainActivity : AppCompatActivity() {
|
||||
builder.setTitle(getString(R.string.choose_theme_text))
|
||||
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()
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="16dp"
|
||||
android:clickable="true">
|
||||
android:clickable="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -273,7 +273,8 @@
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/back" />
|
||||
app:srcCompat="@drawable/back"
|
||||
android:contentDescription="TODO" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -312,7 +313,8 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.0"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/checkmark" />
|
||||
app:srcCompat="@drawable/checkmark"
|
||||
android:contentDescription="TODO" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:clickable="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/viewInput"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewScore">
|
||||
|
||||
@@ -275,7 +274,8 @@
|
||||
android:paddingTop="15dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/back" />
|
||||
app:srcCompat="@drawable/back"
|
||||
android:contentDescription="TODO" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -317,6 +317,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.0"
|
||||
android:scaleType="fitCenter"
|
||||
app:srcCompat="@drawable/checkmark" />
|
||||
app:srcCompat="@drawable/checkmark"
|
||||
android:contentDescription="TODO" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -4,7 +4,7 @@
|
||||
<string name="undo">Letzte Runde löschen</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öshen?</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>
|
||||
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.
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.4.0"
|
||||
ext.kotlin_version = "1.4.10"
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
Reference in New Issue
Block a user