Add drone build script. #3

Merged
fabian merged 11 commits from feature/droneBuild into master 2022-12-08 23:24:51 +01:00
2 changed files with 132 additions and 117 deletions
Showing only changes of commit 0ed30dc87a - Show all commits

View File

@@ -1,14 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 30
compileSdkVersion 32
defaultConfig {
applicationId "me.zobrist.tichucounter"
minSdkVersion 16
targetSdkVersion 30
targetSdkVersion 32
versionCode 7
versionName "1.0.0"
@@ -22,6 +21,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
@@ -34,17 +38,17 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
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 'com.google.android.play:core:1.8.0'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
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'
implementation 'com.google.android.play:core-ktx:1.8.1'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

View File

@@ -15,7 +15,7 @@ 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.*
import me.zobrist.tichucounter.databinding.ContentMainBinding
import java.util.*
class MainActivity : AppCompatActivity() {
@@ -26,21 +26,31 @@ class MainActivity : AppCompatActivity() {
private var currentRound = Round()
private var systemLocale = Locale.getDefault()
private lateinit var binding: ContentMainBinding
override fun attachBaseContext(newBase: Context) {
// get chosen language from shread preference
val localeString = newBase.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("Language", systemLocale.toString())
if(localeString != null)
{
val localeToSwitchTo = Locale(localeString)
val localeUpdatedContext: ContextWrapper = ContextUtils.updateLocale(newBase, localeToSwitchTo)
super.attachBaseContext(localeUpdatedContext)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ContentMainBinding.inflate(layoutInflater)
setContentView(R.layout.activity_main)
setSupportActionBar(findViewById(R.id.toolbar))
inputTeamA.setRawInputType(InputType.TYPE_NULL)
inputTeamB.setRawInputType(InputType.TYPE_NULL)
inputTeamA.requestFocus()
binding.inputTeamA.setRawInputType(InputType.TYPE_NULL)
binding.inputTeamB.setRawInputType(InputType.TYPE_NULL)
binding.inputTeamA.requestFocus()
disableSubmitButton()
updateTheme(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2))
keepScreenOn(
@@ -51,31 +61,32 @@ class MainActivity : AppCompatActivity() {
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"))
binding.nameTeamA.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamA", "TeamA"))
binding.nameTeamB.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamB", "TeamB"))
updateView()
this.setListenes()
}
private fun setListenes()
{
inputTeamA.setOnFocusChangeListener { _, b ->
binding.inputTeamA.setOnFocusChangeListener { _, b ->
if (b) {
hideKeyboard()
}
}
inputTeamB.setOnFocusChangeListener { _, b ->
binding.inputTeamB.setOnFocusChangeListener { _, b ->
if (b) {
hideKeyboard()
}
}
inputTeamA.doOnTextChanged { text, _, _, _ ->
if (inputTeamA.isFocused) {
if (inputTeamA.text.isNotEmpty()) {
binding.inputTeamA.doOnTextChanged { text, _, _, _ ->
if (binding.inputTeamA.isFocused) {
if (binding.inputTeamA.text.isNotEmpty()) {
if (updateOnChange) {
currentRound = try {
Round(text.toString().toInt(), true)
@@ -83,26 +94,26 @@ class MainActivity : AppCompatActivity() {
} catch (e: java.lang.Exception) {
Round(1, 1)
}
inputTeamB.setText(currentRound.scoreB.toString())
binding.inputTeamB.setText(currentRound.scoreB.toString())
} else {
updateOnChange = true
}
} else {
inputTeamA.text.clear()
inputTeamB.text.clear()
binding.inputTeamA.text.clear()
binding.inputTeamB.text.clear()
}
}
if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
if (currentRound.isValidRound() && binding.inputTeamA.text.isNotEmpty() && binding.inputTeamB.text.isNotEmpty()) {
enableSubmitButton()
} else {
disableSubmitButton()
}
}
inputTeamB.doOnTextChanged { text, _, _, _ ->
if (inputTeamB.isFocused) {
if (inputTeamB.text.isNotEmpty()) {
binding.inputTeamB.doOnTextChanged { text, _, _, _ ->
if (binding.inputTeamB.isFocused) {
if (binding.inputTeamB.text.isNotEmpty()) {
if (updateOnChange) {
currentRound = try {
Round(text.toString().toInt(), false)
@@ -110,145 +121,145 @@ class MainActivity : AppCompatActivity() {
} catch (e: java.lang.Exception) {
Round(1, 1)
}
inputTeamA.setText(currentRound.scoreA.toString())
binding.inputTeamA.setText(currentRound.scoreA.toString())
} else {
updateOnChange = true
}
} else {
inputTeamA.text.clear()
inputTeamB.text.clear()
binding.inputTeamA.text.clear()
binding.inputTeamB.text.clear()
}
}
if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
if (currentRound.isValidRound() && binding.inputTeamA.text.isNotEmpty() && binding.inputTeamB.text.isNotEmpty()) {
enableSubmitButton()
} else {
disableSubmitButton()
}
}
buttonAdd100.setOnClickListener {
binding.buttonAdd100.setOnClickListener {
giveFocusToAIfNone()
if (inputTeamA.isFocused) {
if (binding.inputTeamA.isFocused) {
currentRound.scoreA = try {
inputTeamA.text.toString().toInt() + 100
binding.inputTeamA.text.toString().toInt() + 100
} catch (e: Exception) {
currentRound.scoreB = 0
inputTeamB.setText(currentRound.scoreB.toString())
binding.inputTeamB.setText(currentRound.scoreB.toString())
100
}
updateOnChange = false
inputTeamA.setText(currentRound.scoreA.toString())
binding.inputTeamA.setText(currentRound.scoreA.toString())
}
if (inputTeamB.isFocused) {
if (binding.inputTeamB.isFocused) {
currentRound.scoreB = try {
inputTeamB.text.toString().toInt() + 100
binding.inputTeamB.text.toString().toInt() + 100
} catch (e: Exception) {
currentRound.scoreA = 0
inputTeamA.setText(currentRound.scoreA.toString())
binding.inputTeamA.setText(currentRound.scoreA.toString())
100
}
updateOnChange = false
inputTeamB.setText(currentRound.scoreB.toString())
binding.inputTeamB.setText(currentRound.scoreB.toString())
}
}
buttonSub100.setOnClickListener {
binding.buttonSub100.setOnClickListener {
giveFocusToAIfNone()
if (inputTeamA.isFocused) {
if (binding.inputTeamA.isFocused) {
currentRound.scoreA = try {
inputTeamA.text.toString().toInt() - 100
binding.inputTeamA.text.toString().toInt() - 100
} catch (e: Exception) {
currentRound.scoreB = 0
inputTeamB.setText(currentRound.scoreB.toString())
binding.inputTeamB.setText(currentRound.scoreB.toString())
-100
}
updateOnChange = false
inputTeamA.setText(currentRound.scoreA.toString())
binding.inputTeamA.setText(currentRound.scoreA.toString())
}
if (inputTeamB.isFocused) {
if (binding.inputTeamB.isFocused) {
currentRound.scoreB = try {
inputTeamB.text.toString().toInt() - 100
binding.inputTeamB.text.toString().toInt() - 100
} catch (e: Exception) {
currentRound.scoreA = 0
inputTeamA.setText(currentRound.scoreA.toString())
binding.inputTeamA.setText(currentRound.scoreA.toString())
-100
}
updateOnChange = false
inputTeamB.setText(currentRound.scoreB.toString())
binding.inputTeamB.setText(currentRound.scoreB.toString())
}
}
button0.setOnClickListener {
binding.button0.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('0')
}
button1.setOnClickListener {
binding.button1.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('1')
}
button2.setOnClickListener {
binding.button2.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('2')
}
button3.setOnClickListener {
binding.button3.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('3')
}
button4.setOnClickListener {
binding.button4.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('4')
}
button5.setOnClickListener {
binding.button5.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('5')
}
button6.setOnClickListener {
binding.button6.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('6')
}
button7.setOnClickListener {
binding.button7.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('7')
}
button8.setOnClickListener {
binding.button8.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('8')
}
button9.setOnClickListener {
binding.button9.setOnClickListener {
giveFocusToAIfNone()
appendToFocusedInput('9')
}
buttonInv.setOnClickListener {
binding.buttonInv.setOnClickListener {
val tempInt: Int
giveFocusToAIfNone()
if (inputTeamA.isFocused) {
if (inputTeamA.text.toString().equals("-")) {
inputTeamA.text.clear()
} else if (inputTeamA.text.isNotEmpty()) {
tempInt = inputTeamA.text.toString().toInt() * -1
inputTeamA.setText(tempInt.toString())
if (binding.inputTeamA.isFocused) {
if (binding.inputTeamA.text.toString().equals("-")) {
binding.inputTeamA.text.clear()
} else if (binding.inputTeamA.text.isNotEmpty()) {
tempInt = binding.inputTeamA.text.toString().toInt() * -1
binding.inputTeamA.setText(tempInt.toString())
} else {
updateOnChange = false
appendToFocusedInput('-')
@@ -256,12 +267,12 @@ class MainActivity : AppCompatActivity() {
}
} else if (inputTeamB.isFocused) {
if (inputTeamB.text.toString().equals("-")) {
inputTeamB.text.clear()
} else if (inputTeamB.text.isNotEmpty()) {
tempInt = inputTeamB.text.toString().toInt() * -1
inputTeamB.setText(tempInt.toString())
} else if (binding.inputTeamB.isFocused) {
if (binding.inputTeamB.text.toString().equals("-")) {
binding.inputTeamB.text.clear()
} else if (binding.inputTeamB.text.isNotEmpty()) {
tempInt = binding.inputTeamB.text.toString().toInt() * -1
binding.inputTeamB.setText(tempInt.toString())
} else {
updateOnChange = false
appendToFocusedInput('-')
@@ -270,42 +281,42 @@ class MainActivity : AppCompatActivity() {
}
}
buttonBack.setOnClickListener {
binding.buttonBack.setOnClickListener {
giveFocusToAIfNone()
if (inputTeamA.isFocused) {
if (inputTeamA.text.isNotEmpty()) {
val string = inputTeamA.text.toString()
inputTeamA.setText(string.substring(0, string.length - 1))
if (binding.inputTeamA.isFocused) {
if (binding.inputTeamA.text.isNotEmpty()) {
val string = binding.inputTeamA.text.toString()
binding.inputTeamA.setText(string.substring(0, string.length - 1))
}
} else if (inputTeamB.isFocused) {
if (inputTeamB.text.isNotEmpty()) {
val string = inputTeamB.text.toString()
inputTeamB.setText(string.substring(0, string.length - 1))
} else if (binding.inputTeamB.isFocused) {
if (binding.inputTeamB.text.isNotEmpty()) {
val string = binding.inputTeamB.text.toString()
binding.inputTeamB.setText(string.substring(0, string.length - 1))
}
}
}
submit.setOnClickListener {
binding.submit.setOnClickListener {
giveFocusToAIfNone()
if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
if (binding.inputTeamA.text.isNotEmpty() && binding.inputTeamB.text.isNotEmpty()) {
history.logRound(
Round(
inputTeamA.text.toString().toInt(),
inputTeamB.text.toString().toInt()
binding.inputTeamA.text.toString().toInt(),
binding.inputTeamB.text.toString().toInt()
)
)
updateView()
inputTeamA.text.clear()
inputTeamB.text.clear()
binding.inputTeamA.text.clear()
binding.inputTeamB.text.clear()
disableSubmitButton()
scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
binding.scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
}
}
}
@@ -315,8 +326,8 @@ class MainActivity : AppCompatActivity() {
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.putString("nameTeamA", binding.nameTeamA.text.toString())
prefs.putString("nameTeamB", binding.nameTeamB.text.toString())
prefs.apply()
}
@@ -378,8 +389,8 @@ class MainActivity : AppCompatActivity() {
}
private fun giveFocusToAIfNone() {
if (!inputTeamA.isFocused && !inputTeamB.isFocused) {
inputTeamA.requestFocus()
if (!binding.inputTeamA.isFocused && !binding.inputTeamB.isFocused) {
binding.inputTeamA.requestFocus()
}
}
@@ -389,40 +400,40 @@ class MainActivity : AppCompatActivity() {
}
private fun updateView() {
scoreA.text = history.getScoreA().toString()
scoreB.text = history.getScoreB().toString()
binding.scoreA.text = history.getScoreA().toString()
binding.scoreB.text = history.getScoreB().toString()
historyA.text = history.getHistoryA()
historyB.text = history.getHistoryB()
binding.historyA.text = history.getHistoryA()
binding.historyB.text = history.getHistoryB()
}
private fun clearAll() {
historyA.text = ""
historyB.text = ""
inputTeamA.text.clear()
inputTeamB.text.clear()
scoreA.text = "0"
scoreB.text = "0"
binding.historyA.text = ""
binding.historyB.text = ""
binding.inputTeamA.text.clear()
binding.inputTeamB.text.clear()
binding.scoreA.text = "0"
binding.scoreB.text = "0"
history.clearAll()
}
private fun appendToFocusedInput(toAppend: Char) {
if (inputTeamA.isFocused) {
inputTeamA.text.append(toAppend)
} else if (inputTeamB.isFocused) {
inputTeamB.text.append(toAppend)
if (binding.inputTeamA.isFocused) {
binding.inputTeamA.text.append(toAppend)
} else if (binding.inputTeamB.isFocused) {
binding.inputTeamB.text.append(toAppend)
}
}
private fun enableSubmitButton() {
submit.imageAlpha = 255 // 0 being transparent and 255 being opaque
submit.isEnabled = true
binding.submit.imageAlpha = 255 // 0 being transparent and 255 being opaque
binding.submit.isEnabled = true
}
private fun disableSubmitButton() {
submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
submit.isEnabled = false
binding.submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
binding.submit.isEnabled = false
}
private fun chooseThemeDialog() {