Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update project and dependencies, resolved deprecated functionalities #25

Merged
merged 5 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/androidTest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 11
java-version: 17
distribution: 'temurin'
cache: 'gradle'

Expand All @@ -26,9 +26,6 @@ jobs:
- name: Run local tests
run: ./gradlew testDebug --stacktrace

- name: Run ktlint
run: ./gradlew ktlintCheck

- name: Create AVD and Run androidTest
id: testing
uses: reactivecircus/android-emulator-runner@v2
Expand All @@ -47,20 +44,20 @@ jobs:

- name: Upload Failing Test Report Log
if: steps.testing.outcome != 'success'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: logs
path: app/build/outputs/androidTest-results/connected/flavors/*/failed/*.png

- name: Upload build outputs (APKs)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: build-outputs
path: ./app/build/outputs/**/*.apk

- name: Upload build reports
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: build-reports
path: ./app/build/reports
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 24 additions & 47 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id "org.jlleitschuh.gradle.ktlint" version "11.4.0"
id 'com.google.devtools.ksp'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'org.jetbrains.kotlin.plugin.compose' version "2.0.20"
}

apply plugin: "org.jlleitschuh.gradle.ktlint"

android {
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.developersbreach.hangman"
minSdk 24
targetSdk 33
targetSdk 34
versionCode 1
versionName "0.1.0"

Expand Down Expand Up @@ -52,22 +50,17 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
// To mark experimental features api
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
jvmTarget = '17'
}

buildFeatures {
compose true
}

composeOptions {
kotlinCompilerExtensionVersion compose_version
buildConfig true
}

packagingOptions {
Expand All @@ -79,67 +72,51 @@ android {
testOptions {
unitTests.includeAndroidResources = true
}

ktlint {
verbose = true
debug = false
android = true
ignoreFailures = false
outputToConsole = true
reporters {
reporter "json"
}
}
namespace 'com.developersbreach.hangman'
}

tasks.named("check") {
dependsOn("ktlintCheck")
}

gradle.projectsEvaluated {
assemble.dependsOn ktlintCheck
}
def compose_version = "1.7.5"

dependencies {

implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation "androidx.compose.material:material-icons-extended:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'androidx.activity:activity-compose:1.9.3'

// Observe state and livedata
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'

// Constraint Layout
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
implementation "androidx.constraintlayout:constraintlayout-compose:1.1.0"

// Navigation
implementation "androidx.navigation:navigation-compose:2.6.0"
implementation "androidx.navigation:navigation-compose:2.8.4"

// For persisting game difficulty, high score values.
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'androidx.preference:preference-ktx:1.2.1'

// Room
implementation "androidx.room:room-runtime:2.5.1"
implementation "androidx.room:room-ktx:2.5.1"
kapt "androidx.room:room-compiler:2.5.1"
implementation "androidx.room:room-runtime:2.6.1"
implementation "androidx.room:room-ktx:2.6.1"
ksp "androidx.room:room-compiler:2.6.1"

// Koin - Jetpack Compose
implementation "io.insert-koin:koin-androidx-compose:3.2.0-beta-1"

implementation platform('com.google.firebase:firebase-bom:32.1.0')
implementation platform('com.google.firebase:firebase-bom:33.6.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'

testImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
testImplementation "io.mockk:mockk:1.13.5"

androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.2.1'
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version")

debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version")
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.developersbreach.hangman">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:name="com.developersbreach.hangman.HangmanApp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import androidx.compose.runtime.Stable
data class Alphabets(
@Stable val alphabetId: Int,
val alphabet: String,
var isAlphabetGuessed: Boolean = false
val isAlphabetGuessed: Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ModalBottomSheetState
import androidx.compose.material.Text
Expand All @@ -27,7 +26,6 @@ import kotlinx.coroutines.launch
/**
* Modal sheet shows up when hits up navigation button.
*/
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun ShowExitGameModalSheet(
navigateUp: () -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.developersbreach.hangman.utils.SparkAnimateGuessedLetter
fun AlphabetsList(
modifier: Modifier,
alphabetsList: List<Alphabets>,
gameOverByNoAttemptsLeft: Boolean,
checkIfLetterMatches: (alphabet: Alphabets) -> Unit
) {
Box(
Expand All @@ -53,7 +52,6 @@ fun AlphabetsList(
) { alphabet ->
ItemAlphabetText(
alphabet = alphabet,
gameOverByNoAttemptsLeft = gameOverByNoAttemptsLeft,
checkIfLetterMatches = checkIfLetterMatches
)
}
Expand All @@ -69,7 +67,6 @@ fun AlphabetsList(
@Composable
private fun ItemAlphabetText(
alphabet: Alphabets,
gameOverByNoAttemptsLeft: Boolean,
checkIfLetterMatches: (alphabet: Alphabets) -> Unit
) {
// If alphabet is correctly guessed,
Expand All @@ -83,15 +80,7 @@ private fun ItemAlphabetText(
.background(color = MaterialTheme.colors.primary.copy(0.12f))
.clickable(
enabled = !alphabet.isAlphabetGuessed,
onClick = {
// Don't let player click items if game is over.
if (!gameOverByNoAttemptsLeft) {
// For each guess check if match is correct from ViewModel.
checkIfLetterMatches(alphabet)
// Immediately disable click and reduce alpha for this item.
alphabet.isAlphabetGuessed = true
}
}
onClick = { checkIfLetterMatches(alphabet) }
)
) {
val (alphabetText, clickEffectAnim) = createRefs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue

@Composable
fun animateCurrentLevelProgress(
currentPlayerLevel: Int
): Float {
var currentLevelProgress by remember { mutableStateOf(0f) }
var currentLevelProgress by remember { mutableFloatStateOf(0f) }

when (currentPlayerLevel) {
0 -> currentLevelProgress = 0f
Expand All @@ -34,7 +34,7 @@ fun animateCurrentLevelProgress(
fun animateAttemptsLeftProgress(
attemptsLeft: Int
): Float {
var currentAttemptsLeftProgress by remember { mutableStateOf(0f) }
var currentAttemptsLeftProgress by remember { mutableFloatStateOf(0f) }

when (attemptsLeft) {
8 -> currentAttemptsLeftProgress = 0f
Expand All @@ -61,6 +61,7 @@ private fun animateToTargetState(
easing: Easing = LinearEasing
): Float {
val animatedProgress by animateFloatAsState(
label = "AttemptsLeftAnimation",
targetValue = targetProgressValue,
animationSpec = tween(
durationMillis = durationMillis,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.developersbreach.hangman.ui.game

import androidx.activity.compose.BackHandler
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
Expand All @@ -20,7 +19,6 @@ import kotlinx.coroutines.launch
* Game screen, can be navigated from onboarding screen.
* This screen has it's own ViewModel [GameViewModel]
*/
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun GameScreen(
navigateUp: () -> Unit,
Expand Down Expand Up @@ -85,7 +83,6 @@ fun GameScreen(
maxLevelReached = viewModel.maxLevelReached,
alphabetsList = alphabetsList,
updateGuessesByPlayer = updateGuessesByPlayer,
gameOverByNoAttemptsLeft = viewModel.gameOverByNoAttemptsLeft,
checkIfLetterMatches = {
viewModel.checkIfLetterMatches(it)
}
Expand Down
Loading
Loading