Skip to content

Commit

Permalink
Merge branch 'develop' into 1274-set-key-mapper-as-the-device-assista…
Browse files Browse the repository at this point in the history
…nt-to-trigger-key-maps
  • Loading branch information
sds100 committed Oct 3, 2024
2 parents bb01372 + a9159f3 commit e1c1afc
Show file tree
Hide file tree
Showing 39 changed files with 1,766 additions and 834 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ concurrency:
cancel-in-progress: true

jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: 17
cache: 'gradle'

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Unit tests
run: bash ./gradlew testDebugUnitTest

apk:
name: Build and release to production
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ on:
pull_request:

jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: 17
cache: 'gradle'

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Unit tests
run: bash ./gradlew testDebugUnitTest

style:
name: Code style check
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ concurrency:
cancel-in-progress: true

jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: 17
cache: 'gradle'

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Unit tests
run: bash ./gradlew testDebugUnitTest

style:
name: Code style check
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ dependencies {
compileOnly project(":systemstubs")

def room_version = "2.6.1"
def coroutinesVersion = "1.5.0"
def nav_version = "2.7.7"
def coroutinesVersion = "1.9.0"
def nav_version = '2.7.7'
def work_version = "2.9.1"
def epoxy_version = "4.6.2"
def splitties_version = "3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,7 @@ class ConstraintSnapshotImpl(
}
}

override fun isSatisfied(constraintState: ConstraintState): Boolean =
when (constraintState.mode) {
ConstraintMode.AND -> {
constraintState.constraints.all { isSatisfied(it) }
}

ConstraintMode.OR -> {
constraintState.constraints.any { isSatisfied(it) }
}
}

private fun isSatisfied(constraint: Constraint): Boolean {
override fun isSatisfied(constraint: Constraint): Boolean {
val isSatisfied = when (constraint) {
is Constraint.AppInForeground -> appInForeground == constraint.packageName
is Constraint.AppNotInForeground -> appInForeground != constraint.packageName
Expand Down Expand Up @@ -98,7 +87,6 @@ class ConstraintSnapshotImpl(
is Constraint.FlashlightOff -> !cameraAdapter.isFlashlightOn(constraint.lens)
is Constraint.FlashlightOn -> cameraAdapter.isFlashlightOn(constraint.lens)
is Constraint.WifiConnected -> {
Timber.d("Connected WiFi ssid = $connectedWifiSSID")
if (constraint.ssid == null) {
// connected to any network
connectedWifiSSID != null
Expand Down Expand Up @@ -139,5 +127,22 @@ class ConstraintSnapshotImpl(
}

interface ConstraintSnapshot {
fun isSatisfied(constraintState: ConstraintState): Boolean
fun isSatisfied(constraint: Constraint): Boolean
}

fun ConstraintSnapshot.isSatisfied(constraintState: ConstraintState): Boolean {
// Required in case OR is used with empty list of constraints.
if (constraintState.constraints.isEmpty()) {
return true
}

return when (constraintState.mode) {
ConstraintMode.AND -> {
constraintState.constraints.all { isSatisfied(it) }
}

ConstraintMode.OR -> {
constraintState.constraints.any { isSatisfied(it) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.github.sds100.keymapper.actions.Action
import io.github.sds100.keymapper.actions.PerformActionsUseCase
import io.github.sds100.keymapper.actions.RepeatMode
import io.github.sds100.keymapper.constraints.DetectConstraintsUseCase
import io.github.sds100.keymapper.constraints.isSatisfied
import io.github.sds100.keymapper.data.PreferenceDefaults
import io.github.sds100.keymapper.util.InputEventType
import kotlinx.coroutines.CoroutineScope
Expand Down
Loading

0 comments on commit e1c1afc

Please sign in to comment.