Skip to content

Commit

Permalink
style: reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
sds100 committed Sep 24, 2023
1 parent d19d045 commit d445fad
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ object ActionDataEntityMapper {
ActionId.PINCH_SCREEN -> {
val splitData = entity.data.trim().split(',')

var x = 0;
var y = 0;
var pinchType = PinchScreenType.PINCH_IN;
var distance = 0;
var fingerCount = 2;
var duration = 250;
var x = 0
var y = 0
var pinchType = PinchScreenType.PINCH_IN
var distance = 0
var fingerCount = 2
var duration = 250

if (splitData.isNotEmpty()) {
x = splitData[0].trim().toInt()
Expand All @@ -174,12 +174,12 @@ object ActionDataEntityMapper {
}

if (splitData.size >= 4) {
val tempType = splitData[3].trim();
val tempType = splitData[3].trim()

pinchType = if (tempType == PinchScreenType.PINCH_IN.name) {
PinchScreenType.PINCH_IN;
PinchScreenType.PINCH_IN
} else {
PinchScreenType.PINCH_OUT;
PinchScreenType.PINCH_OUT
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,14 @@ abstract class BaseActionUiHelper<MAPPING : Mapping<A>, A : Action>(

getString(
R.string.description_pinch_coordinate_default,
arrayOf(pinchTypeDisplayName, action.fingerCount, action.x, action.y, action.distance, action.duration)
arrayOf(
pinchTypeDisplayName,
action.fingerCount,
action.x,
action.y,
action.distance,
action.duration
)
)
} else {
val pinchTypeDisplayName = if (action.pinchType == PinchScreenType.PINCH_IN) {
Expand All @@ -339,7 +346,15 @@ abstract class BaseActionUiHelper<MAPPING : Mapping<A>, A : Action>(

getString(
R.string.description_pinch_coordinate_with_description,
arrayOf(pinchTypeDisplayName, action.fingerCount, action.x, action.y, action.distance, action.duration, action.description)
arrayOf(
pinchTypeDisplayName,
action.fingerCount,
action.x,
action.y,
action.distance,
action.duration,
action.description
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,15 @@ class PerformActionsUseCaseImpl(
}

is ActionData.PinchScreen -> {
result = accessibilityService.pinchScreen(action.x, action.y, action.distance, action.pinchType, action.fingerCount, action.duration, inputEventType)
result = accessibilityService.pinchScreen(
action.x,
action.y,
action.distance,
action.pinchType,
action.fingerCount,
action.duration,
inputEventType
)
}

is ActionData.Text -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.*
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import io.github.sds100.keymapper.R
import io.github.sds100.keymapper.databinding.FragmentPinchPickCoordinatesBinding
import io.github.sds100.keymapper.system.files.FileUtils
import io.github.sds100.keymapper.util.*
Expand All @@ -30,7 +31,6 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import io.github.sds100.keymapper.R

class PinchPickDisplayCoordinateFragment : Fragment() {
companion object {
Expand Down Expand Up @@ -77,7 +77,7 @@ class PinchPickDisplayCoordinateFragment : Fragment() {
pinchTypesDisplayValues = arrayOf(
str(R.string.hint_coordinate_type_pinch_in),
str(R.string.hint_coordinate_type_pinch_out)
).toMutableList();
).toMutableList()

args.result?.let {
viewModel.loadResult(Json.decodeFromString(it))
Expand All @@ -102,7 +102,8 @@ class PinchPickDisplayCoordinateFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)

binding.viewModel = viewModel
binding.pinchTypeSpinnerAdapter = ArrayAdapter(this.requireActivity(), android.R.layout.simple_spinner_dropdown_item, pinchTypesDisplayValues)
binding.pinchTypeSpinnerAdapter =
ArrayAdapter(this.requireActivity(), android.R.layout.simple_spinner_dropdown_item, pinchTypesDisplayValues)
viewModel.showPopups(this, binding)

requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.ViewTreeObserver
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.sds100.keymapper.reportbug

import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
import androidx.activity.viewModels
import androidx.core.os.bundleOf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
import androidx.lifecycle.Lifecycle
import androidx.navigation.fragment.findNavController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IAccessibilityService {
fun doGlobalAction(action: Int): Result<*>

fun tapScreen(x: Int, y: Int, inputEventType: InputEventType): Result<*>

fun swipeScreen(
xStart: Int,
yStart: Int,
Expand All @@ -24,7 +24,16 @@ interface IAccessibilityService {
duration: Int,
inputEventType: InputEventType
): Result<*>
fun pinchScreen(x: Int, y: Int, distance: Int, pinchType: PinchScreenType, fingerCount: Int, duration: Int, inputEventType: InputEventType): Result<*>

fun pinchScreen(
x: Int,
y: Int,
distance: Int,
pinchType: PinchScreenType,
fingerCount: Int,
duration: Int,
inputEventType: InputEventType
): Result<*>

val isFingerprintGestureDetectionAvailable: Boolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ class MyAccessibilityService : AccessibilityService(), LifecycleOwner, IAccessib
gestureBuilder.addStroke(StrokeDescription(p, 0, duration.toLong()))
}

val success = dispatchGesture(gestureBuilder.build(), null, null);
val success = dispatchGesture(gestureBuilder.build(), null, null)

return if (success) {
Success(Unit)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.sds100.keymapper.util

import android.R.attr
import android.graphics.Point
import kotlin.math.atan2
import kotlin.math.cos
Expand Down Expand Up @@ -68,10 +67,10 @@ object MathUtils {
(circleCenter.y + circleRadius * sin(angle)).toInt().coerceAtLeast(0)
)
)
angle += step;
angle += step
}

return points;
return points

}
}
4 changes: 2 additions & 2 deletions app/src/main/java/io/github/sds100/keymapper/util/Result.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ sealed class Error : Result<Nothing>() {

object CantShowImePickerInBackground : Error()
object CantFindImeSettings : Error()
object GestureStrokeCountTooHigh: Error()
object GestureDurationTooHigh: Error()
object GestureStrokeCountTooHigh : Error()
object GestureDurationTooHigh : Error()

data class PermissionDenied(val permission: Permission) : Error() {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fun NavigationViewModel.setupNavigation(fragment: Fragment) {
NavAppDirections.swipePickDisplayCoordinate(requestKey, json)
}

is NavDestination.PickPinchCoordinate -> {
is NavDestination.PickPinchCoordinate -> {
val json = destination.result?.let {
Json.encodeToString(it)
}
Expand Down

0 comments on commit d445fad

Please sign in to comment.