From 85555bd93b9f5b67db3cec7dabc6d4526f950c1a Mon Sep 17 00:00:00 2001 From: AlinaStepanova Date: Mon, 13 Jun 2022 21:07:35 +0200 Subject: [PATCH 01/18] upgrade dependencies --- .idea/gradle.xml | 1 - app/build.gradle | 18 +++++++++--------- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index f4ef529..ce86a83 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -14,7 +14,6 @@ - diff --git a/app/build.gradle b/app/build.gradle index 7b77835..af84cd7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,12 +11,12 @@ def keystoreProperties = new Properties() keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) android { - compileSdkVersion 31 + compileSdkVersion 32 buildToolsVersion '30.0.3' defaultConfig { applicationId "com.avs.sea.battle" minSdkVersion 19 - targetSdkVersion 31 + targetSdkVersion 32 versionCode 8 versionName "8" vectorDrawables.useSupportLibrary = true @@ -46,22 +46,22 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.4.0' - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.2' + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'androidx.core:core-ktx:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' testImplementation "org.mockito:mockito-core:3.3.0" androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0" + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1" kapt "com.android.databinding:compiler:3.1.4" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' androidTestImplementation 'androidx.test:rules:1.4.0' - implementation 'com.google.android.play:core:1.10.2' + implementation 'com.google.android.play:core:1.10.3' implementation 'com.google.android.play:core-ktx:1.8.1' } diff --git a/build.gradle b/build.gradle index e7c78fb..e50e635 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.7.0' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' + classpath 'com.android.tools.build:gradle:7.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3468112..701b567 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip From 233b2d25d4d57905a8737a69bba780c37f5da5fa Mon Sep 17 00:00:00 2001 From: AlinaStepanova Date: Mon, 13 Jun 2022 21:29:06 +0200 Subject: [PATCH 02/18] polish code --- .../com/avs/sea/battle/main/MainActivity.kt | 44 ++++---- .../com/avs/sea/battle/main/ShotManager.kt | 100 ++++++++++-------- .../java/com/avs/sea/battle/ships/ShipTest.kt | 2 +- 3 files changed, 81 insertions(+), 65 deletions(-) diff --git a/app/src/main/java/com/avs/sea/battle/main/MainActivity.kt b/app/src/main/java/com/avs/sea/battle/main/MainActivity.kt index e056efa..6cead35 100644 --- a/app/src/main/java/com/avs/sea/battle/main/MainActivity.kt +++ b/app/src/main/java/com/avs/sea/battle/main/MainActivity.kt @@ -37,55 +37,55 @@ class MainActivity : AppCompatActivity(), PopupMenu.OnMenuItemClickListener { binding.viewComputer.provideViewModel(viewModel) - viewModel.status.observe(this, { newStatusId -> + viewModel.status.observe(this) { newStatusId -> binding.tvStatus.text = resources.getText(newStatusId) - }) + } - viewModel.selectedByPersonCoordinate.observe(this, { point -> + viewModel.selectedByPersonCoordinate.observe(this) { point -> binding.viewComputer.getSelectedCoordinate(point) binding.viewFire.visibility = if (point == null) View.INVISIBLE else View.VISIBLE - }) + } - viewModel.selectedByComputerCoordinate.observe(this, { + viewModel.selectedByComputerCoordinate.observe(this) { binding.progressBar.visibility = View.VISIBLE - }) + } - viewModel.personShips.observe(this, { coordinates -> + viewModel.personShips.observe(this) { coordinates -> binding.viewPerson.getShipsCoordinates(coordinates) if (coordinates.isNotEmpty()) { binding.viewStart.visibility = View.VISIBLE } - }) + } - viewModel.computerShips.observe(this, { coordinates -> + viewModel.computerShips.observe(this) { coordinates -> binding.viewComputer.setShipsCoordinates(coordinates) - }) + } - viewModel.personSuccessfulShots.observe(this, { coordinates -> + viewModel.personSuccessfulShots.observe(this) { coordinates -> binding.viewComputer.getCrossesCoordinates(coordinates) - }) + } - viewModel.personFailedShots.observe(this, { coordinates -> + viewModel.personFailedShots.observe(this) { coordinates -> binding.viewComputer.getDotsCoordinates(coordinates) - }) + } - viewModel.computerSuccessfulShots.observe(this, { coordinates -> + viewModel.computerSuccessfulShots.observe(this) { coordinates -> binding.viewPerson.getCrossesCoordinates(coordinates) binding.progressBar.visibility = View.INVISIBLE - }) + } - viewModel.computerFailedShots.observe(this, { coordinates -> + viewModel.computerFailedShots.observe(this) { coordinates -> binding.viewPerson.getDotsCoordinates(coordinates) binding.progressBar.visibility = View.INVISIBLE - }) + } - viewModel.startGameEvent.observe(this, { isStarted -> + viewModel.startGameEvent.observe(this) { isStarted -> if (isStarted) binding.viewStart.visibility = View.GONE if (!isStarted) binding.viewNewGame.visibility = View.INVISIBLE binding.viewGenerate.visibility = if (isStarted) View.INVISIBLE else View.VISIBLE - }) + } - viewModel.endGameEvent.observe(this, { eventPair -> + viewModel.endGameEvent.observe(this) { eventPair -> if (eventPair.first) { binding.viewNewGame.visibility = View.VISIBLE if (eventPair.second == Player.PERSON) { @@ -94,7 +94,7 @@ class MainActivity : AppCompatActivity(), PopupMenu.OnMenuItemClickListener { } else { binding.viewNewGame.visibility = View.INVISIBLE } - }) + } binding.ivMore.setOnClickListener { view -> showPopup(view) } binding.viewGenerate.setOnTouchListener(customOnTouchListener) binding.viewFire.setOnTouchListener(customOnTouchListener) diff --git a/app/src/main/java/com/avs/sea/battle/main/ShotManager.kt b/app/src/main/java/com/avs/sea/battle/main/ShotManager.kt index b9eaff5..0a30868 100644 --- a/app/src/main/java/com/avs/sea/battle/main/ShotManager.kt +++ b/app/src/main/java/com/avs/sea/battle/main/ShotManager.kt @@ -54,53 +54,16 @@ class ShotManager { } else if (firstCell.isState(SHOT_SUCCESS) && (secondCell.isState(EMPTY) || secondCell.isState(SHOT_FAILURE)) ) { - if (ships.contains(TWO_DECK_SHIP_SIZE) - || ships.contains(THREE_DECK_SHIP_SIZE) - || ships.contains(FOUR_DECK_SHIP_SIZE) - ) { - coordinate = getNextCoordinateToShot(firstCell) - } - if (coordinate.x == -1) { - coordinate = resetValuesAfterShipIsDead( - ONE_DECK_SHIP_SIZE, - mutableListOf(firstCell.getCoordinate()) - ) - } else { - secondCell = Cell(coordinate.x, coordinate.y) - } + coordinate = shotSecondCell(coordinate) } else if (firstCell.isState(SHOT_SUCCESS) && secondCell.isState(SHOT_SUCCESS) && (thirdCell.isState(EMPTY) || thirdCell.isState(SHOT_FAILURE)) ) { - if (ships.contains(THREE_DECK_SHIP_SIZE) - || ships.contains(FOUR_DECK_SHIP_SIZE) - ) { - coordinate = checkNeighbourCells(firstCell, secondCell) - } - if (coordinate.x == -1) { - coordinate = resetValuesAfterShipIsDead( - TWO_DECK_SHIP_SIZE, - mutableListOf(firstCell.getCoordinate(), secondCell.getCoordinate()) - ) - } else { - thirdCell = Cell(coordinate.x, coordinate.y) - } + coordinate = shotThirdCell(coordinate) } else if (firstCell.isState(SHOT_SUCCESS) && secondCell.isState(SHOT_SUCCESS) - && thirdCell.isState(SHOT_SUCCESS) - && (fourthCell.isState(EMPTY) || fourthCell.isState(SHOT_FAILURE)) + && thirdCell.isState(SHOT_SUCCESS) && (fourthCell.isState(EMPTY) + || fourthCell.isState(SHOT_FAILURE)) ) { - if (ships.contains(FOUR_DECK_SHIP_SIZE)) { - coordinate = checkNeighbourCells(firstCell, thirdCell) - } - if (coordinate.x == -1) { - coordinate = resetValuesAfterShipIsDead( - THREE_DECK_SHIP_SIZE, mutableListOf( - firstCell.getCoordinate(), - secondCell.getCoordinate(), thirdCell.getCoordinate() - ) - ) - } else { - fourthCell = Cell(coordinate.x, coordinate.y) - } + coordinate = shotFourthCell(coordinate) } else { coordinate = resetValuesAfterShipIsDead( FOUR_DECK_SHIP_SIZE, mutableListOf( @@ -112,6 +75,59 @@ class ShotManager { return coordinate } + private fun shotFourthCell(coordinate: Coordinate): Coordinate { + var coordinateFourth = coordinate + if (ships.contains(FOUR_DECK_SHIP_SIZE)) { + coordinateFourth = checkNeighbourCells(firstCell, thirdCell) + } + if (coordinateFourth.x == -1) { + coordinateFourth = resetValuesAfterShipIsDead( + THREE_DECK_SHIP_SIZE, mutableListOf( + firstCell.getCoordinate(), secondCell.getCoordinate(), thirdCell.getCoordinate() + ) + ) + } else { + fourthCell = Cell(coordinateFourth.x, coordinateFourth.y) + } + return coordinateFourth + } + + private fun shotThirdCell(coordinate: Coordinate): Coordinate { + var coordinateThird = coordinate + if (ships.contains(THREE_DECK_SHIP_SIZE) || ships.contains(FOUR_DECK_SHIP_SIZE) + ) { + coordinateThird = checkNeighbourCells(firstCell, secondCell) + } + if (coordinateThird.x == -1) { + coordinateThird = resetValuesAfterShipIsDead( + TWO_DECK_SHIP_SIZE, + mutableListOf(firstCell.getCoordinate(), secondCell.getCoordinate()) + ) + } else { + thirdCell = Cell(coordinateThird.x, coordinateThird.y) + } + return coordinateThird + } + + private fun shotSecondCell(coordinate: Coordinate): Coordinate { + var coordinateSecond = coordinate + if (ships.contains(TWO_DECK_SHIP_SIZE) + || ships.contains(THREE_DECK_SHIP_SIZE) + || ships.contains(FOUR_DECK_SHIP_SIZE) + ) { + coordinateSecond = getNextCoordinateToShot(firstCell) + } + if (coordinateSecond.x == -1) { + coordinateSecond = resetValuesAfterShipIsDead( + ONE_DECK_SHIP_SIZE, + mutableListOf(firstCell.getCoordinate()) + ) + } else { + secondCell = Cell(coordinateSecond.x, coordinateSecond.y) + } + return coordinateSecond + } + fun resetValuesAfterShipIsDead( deadShip: Int, cells: MutableList diff --git a/app/src/test/java/com/avs/sea/battle/ships/ShipTest.kt b/app/src/test/java/com/avs/sea/battle/ships/ShipTest.kt index 5ee9d9f..616011f 100644 --- a/app/src/test/java/com/avs/sea/battle/ships/ShipTest.kt +++ b/app/src/test/java/com/avs/sea/battle/ships/ShipTest.kt @@ -28,7 +28,7 @@ class ShipTest { @Test fun getShipCells() { - assertFalse(fourDeckShip.getShipCells().isNullOrEmpty()) + assertFalse(fourDeckShip.getShipCells().isEmpty()) assertEquals(fourDeckShip.getShipCells().size, FOUR_DECK_SHIP_SIZE) assertEquals(threeDeckShip.getShipCells().size, THREE_DECK_SHIP_SIZE) assertEquals(twoDeckShip.getShipCells().size, TWO_DECK_SHIP_SIZE) From 2455b6a3e593cbd03bf34b976f5b75315b12716b Mon Sep 17 00:00:00 2001 From: Alina Stepanova Date: Thu, 16 Jun 2022 21:18:10 +0200 Subject: [PATCH 03/18] Update README.md --- README.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 090d7c7..4e8df07 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,27 @@ Sea Battle - a classic puzzle 2D-game created using Canvas, Custom Views, Corout ![push](https://github.com/AlinaStepanova/SeaBattle/workflows/Android%20Build/badge.svg?branch=dev&event=push) -Play Market: https://play.google.com/store/apps/details?id=com.avs.sea.battle +[Play Market](https://play.google.com/store/apps/details?id=com.avs.sea.battle) 10K+ downloads -How to play: https://youtu.be/ZrbtILJjqpU +[How to play](https://youtu.be/ZrbtILJjqpU) + +

Active branches:

+ +
    dev - contains stable implementation of main functionality and tests.
+ +

Architecture approach

+ + + +

Main libraries used:

+ + Coroutines - for performing delayes with respect of lifecycle
+ Lifecycle - for performing actions in response to a change in the lifecycle status of activities and fragments
+ Databinding - for binding UI components in layouts to data sources
+ JUnit 4, Mockito - tests

- - - + + +

From 6afc437d315c90f93223cb2dbf996a39143135dc Mon Sep 17 00:00:00 2001 From: Alina Stepanova Date: Thu, 16 Jun 2022 21:21:22 +0200 Subject: [PATCH 04/18] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4e8df07..82e869d 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,10 @@ Sea Battle - a classic puzzle 2D-game created using Canvas, Custom Views, Corout Databinding - for binding UI components in layouts to data sources
JUnit 4, Mockito - tests
+--- +

- - - + + +

From f57bd92d729d41c13b66a8b110d47152f35590ab Mon Sep 17 00:00:00 2001 From: AlinaStepanova Date: Sat, 30 Dec 2023 21:34:37 +0100 Subject: [PATCH 05/18] update dependencies --- .idea/deploymentTargetDropDown.xml | 30 ++++++++++++++---------- .idea/gradle.xml | 5 ++-- .idea/kotlinc.xml | 6 +++++ .idea/migrations.xml | 10 ++++++++ .idea/misc.xml | 2 +- app/build.gradle | 3 ++- app/src/main/AndroidManifest.xml | 3 +-- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 9 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/migrations.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index c00d563..f51a409 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -1,17 +1,23 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index ce86a83..0897082 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,16 +4,15 @@ diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..ff9696e --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 1ea0cd8..6b043fd 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -16,7 +16,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index af84cd7..3499bca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,7 @@ android { versionCode 8 versionName "8" vectorDrawables.useSupportLibrary = true - resConfigs "en", "uk", "ru" + resConfigs 'en', 'uk', 'ru' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { @@ -41,6 +41,7 @@ android { dataBinding { enabled = true } + namespace 'com.avs.sea.battle' } dependencies { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4983ed6..d3463a3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index e50e635..615c520 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 701b567..6af3199 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip From 148c3a8d1555a4e4d763b188c3b2e2f053af9aa3 Mon Sep 17 00:00:00 2001 From: AlinaStepanova Date: Sat, 30 Dec 2023 23:08:38 +0100 Subject: [PATCH 06/18] upgrade to sdk 33 --- .idea/compiler.xml | 2 +- .idea/kotlinc.xml | 2 +- .idea/misc.xml | 2 +- app/build.gradle | 20 ++++++++++++++------ build.gradle | 4 ++-- gradle.properties | 3 +++ gradle/wrapper/gradle-wrapper.properties | 2 +- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8..b589d56 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index ff9696e..fdf8d99 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 6b043fd..c69f4ce 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -16,7 +16,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 3499bca..dd7ae79 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,8 +2,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - apply plugin: 'kotlin-kapt' def keystorePropertiesFile = rootProject.file("keystore.properties") @@ -11,16 +9,16 @@ def keystoreProperties = new Properties() keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) android { - compileSdkVersion 32 + compileSdkVersion 33 buildToolsVersion '30.0.3' defaultConfig { applicationId "com.avs.sea.battle" minSdkVersion 19 - targetSdkVersion 32 + targetSdkVersion 33 versionCode 8 versionName "8" vectorDrawables.useSupportLibrary = true - resConfigs 'en', 'uk', 'ru' + resourceConfigurations += ['en', 'uk', 'ru'] testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { @@ -41,6 +39,16 @@ android { dataBinding { enabled = true } + buildFeatures { + viewBinding = true + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = '17' + } namespace 'com.avs.sea.battle' } @@ -48,7 +56,7 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.4.2' - implementation 'androidx.core:core-ktx:1.8.0' + implementation 'androidx.core:core-ktx:1.10.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' diff --git a/build.gradle b/build.gradle index 615c520..0659ab7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.7.0' + ext.kotlin_version = '1.9.0' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index 23339e0..9e73ebc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,3 +19,6 @@ android.useAndroidX=true android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6af3199..1fb451e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip From 07f3d23586e94a5c0ed1f6514dccb24885901afc Mon Sep 17 00:00:00 2001 From: AlinaStepanova Date: Sat, 30 Dec 2023 23:14:45 +0100 Subject: [PATCH 07/18] upgrade to sdk 34 --- app/build.gradle | 6 +++--- .../com/avs/sea/battle/views/ComputerSquareView.kt | 10 +++++----- .../java/com/avs/sea/battle/views/PersonSquareView.kt | 8 ++++---- .../main/java/com/avs/sea/battle/views/SquareView.kt | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index dd7ae79..1e21455 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,12 +9,12 @@ def keystoreProperties = new Properties() keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) android { - compileSdkVersion 33 - buildToolsVersion '30.0.3' + compileSdk 34 + buildToolsVersion = '30.0.3' defaultConfig { applicationId "com.avs.sea.battle" minSdkVersion 19 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 8 versionName "8" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/com/avs/sea/battle/views/ComputerSquareView.kt b/app/src/main/java/com/avs/sea/battle/views/ComputerSquareView.kt index 0fd3110..1c273ef 100644 --- a/app/src/main/java/com/avs/sea/battle/views/ComputerSquareView.kt +++ b/app/src/main/java/com/avs/sea/battle/views/ComputerSquareView.kt @@ -40,25 +40,25 @@ class ComputerSquareView : SquareView { setOnTouchListener(OnTouchListener(getCustomOnTouchListener())) } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) if (shipsCoordinates.isNotEmpty()) { for (ship in shipsCoordinates) { - canvas?.drawSquare(ship.y, ship.x, paintShipSquare) + canvas.drawSquare(ship.y, ship.x, paintShipSquare) } } if (dotsCoordinates.isNotEmpty()) { for (coordinate in dotsCoordinates) { - canvas?.drawDot(coordinate) + canvas.drawDot(coordinate) } } if (crossesCoordinates.isNotEmpty()) { for (cross in crossesCoordinates) { - canvas?.drawCross(cross.y, cross.x) + canvas.drawCross(cross.y, cross.x) } } if (selectedSquare != null) { - canvas?.drawSquare(selectedSquare!!.x, selectedSquare!!.y, paintSelected) + canvas.drawSquare(selectedSquare!!.x, selectedSquare!!.y, paintSelected) } } diff --git a/app/src/main/java/com/avs/sea/battle/views/PersonSquareView.kt b/app/src/main/java/com/avs/sea/battle/views/PersonSquareView.kt index 2057878..c04e8ed 100644 --- a/app/src/main/java/com/avs/sea/battle/views/PersonSquareView.kt +++ b/app/src/main/java/com/avs/sea/battle/views/PersonSquareView.kt @@ -30,21 +30,21 @@ class PersonSquareView : SquareView { crossesCoordinates = arrayListOf() } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) if (shipsCoordinates.isNotEmpty()) { for (ship in shipsCoordinates) { - canvas?.drawSquare(ship.y, ship.x, paintShipSquare) + canvas.drawSquare(ship.y, ship.x, paintShipSquare) } } if (dotsCoordinates.isNotEmpty()) { for (coordinate in dotsCoordinates) { - canvas?.drawDot(coordinate) + canvas.drawDot(coordinate) } } if (crossesCoordinates.isNotEmpty()) { for (cross in crossesCoordinates) { - canvas?.drawCross(cross.y, cross.x) + canvas.drawCross(cross.y, cross.x) } } } diff --git a/app/src/main/java/com/avs/sea/battle/views/SquareView.kt b/app/src/main/java/com/avs/sea/battle/views/SquareView.kt index 944e57a..e76be13 100644 --- a/app/src/main/java/com/avs/sea/battle/views/SquareView.kt +++ b/app/src/main/java/com/avs/sea/battle/views/SquareView.kt @@ -65,10 +65,10 @@ abstract class SquareView : View { screenWidth = MeasureSpec.getSize(widthMeasureSpec).toFloat() } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { paint.color = Color.BLACK paint.strokeWidth = lineWidth - canvas?.let { + canvas.let { drawHorizontalLines(it) drawVerticalLines(it) } From fe4996efead257b50e32053ce8c1817de309c772 Mon Sep 17 00:00:00 2001 From: AlinaStepanova Date: Sat, 30 Dec 2023 23:40:47 +0100 Subject: [PATCH 08/18] upgrade dependencies --- app/build.gradle | 16 ++++++++-------- gradle.properties | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1e21455..24f6cca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,22 +55,22 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.4.2' - implementation 'androidx.core:core-ktx:1.10.0' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' testImplementation "org.mockito:mockito-core:3.3.0" - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1" + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2" kapt "com.android.databinding:compiler:3.1.4" implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - androidTestImplementation 'androidx.test:rules:1.4.0' + androidTestImplementation 'androidx.test:rules:1.5.0' implementation 'com.google.android.play:core:1.10.3' implementation 'com.google.android.play:core-ktx:1.8.1' } diff --git a/gradle.properties b/gradle.properties index 9e73ebc..95b9377 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,5 +20,5 @@ android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official android.defaults.buildfeatures.buildconfig=true -android.nonTransitiveRClass=false +android.nonTransitiveRClass=true android.nonFinalResIds=false From debcf0073c8838160f1408f06338ad223a317aa5 Mon Sep 17 00:00:00 2001 From: AlinaStepanova Date: Sun, 7 Jan 2024 21:37:25 +0100 Subject: [PATCH 09/18] start to implement dark theme --- .idea/deploymentTargetDropDown.xml | 4 ++-- .idea/misc.xml | 1 - app/build.gradle | 1 + app/src/main/java/com/avs/sea/battle/Utils.kt | 7 +++++++ .../java/com/avs/sea/battle/views/SquareView.kt | 14 +++++++++++--- app/src/main/res/drawable/square_background.xml | 4 ++-- app/src/main/res/layout-v21/activity_main.xml | 4 +--- app/src/main/res/values/styles.xml | 11 ++++++----- 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index f51a409..551cab9 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -10,12 +10,12 @@ - + - + diff --git a/.idea/misc.xml b/.idea/misc.xml index c69f4ce..1180ed2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ -