Skip to content
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ktlint_standard_function-expression-body = disabled
ktlint_function_naming_ignore_when_annotated_with = Composable
ktlint_ignore_back_ticked_identifier = true
ktlint_code_style = intellij_idea # Use IntelliJ style because it has trailing commas
ij_kotlin_indent_before_arrow_on_new_line = true

[base/src/main/java/io/github/sds100/keymapper/base/utils/ui/compose/icons/*.{kt,kts}]
ktlint_standard_property-naming = disabled
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- #1773 Option to show floating buttons on top of keyboard or notification panel.
- #1335 Intent API to enable/disable/toggle a key map.
- #114 action to force stop app, and an action to clear an app from recents
- #727 Actions to send SMS messages: "Send SMS" and "Compose SMS"

## Removed

Expand Down
2 changes: 2 additions & 0 deletions base/src/main/assets/whats-new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Action to force stop an app or clear it from recents.

Action to send SMS message.

Enable/disable all the key maps in a group. Intent API to enable/disable/toggle a key map.

Option to show floating buttons on top of keyboard or notification panel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ abstract class BaseMainActivity : AppCompatActivity() {
)
super.onCreate(savedInstanceState)

if (viewModel.previousNightMode != currentNightMode) {
resourceProvider.onThemeChange()
}

requestPermissionDelegate = RequestPermissionDelegate(
this,
showDialogs = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,32 @@ sealed class ActionData : Comparable<ActionData> {
}
}

@Serializable
data class SendSms(
val number: String,
val message: String,
) : ActionData() {
override val id = ActionId.SEND_SMS

override fun compareTo(other: ActionData) = when (other) {
is SendSms -> compareValuesBy(this, other, { it.number }, { it.message })
else -> super.compareTo(other)
}
}

@Serializable
data class ComposeSms(
val number: String,
val message: String,
) : ActionData() {
override val id = ActionId.COMPOSE_SMS

override fun compareTo(other: ActionData) = when (other) {
is ComposeSms -> compareValuesBy(this, other, { it.number }, { it.message })
else -> super.compareTo(other)
}
}

@Serializable
data class Url(
val url: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ object ActionDataEntityMapper {
ActionEntity.Type.PINCH_COORDINATE -> ActionId.PINCH_SCREEN
ActionEntity.Type.INTENT -> ActionId.INTENT
ActionEntity.Type.PHONE_CALL -> ActionId.PHONE_CALL
ActionEntity.Type.SEND_SMS -> ActionId.SEND_SMS
ActionEntity.Type.COMPOSE_SMS -> ActionId.COMPOSE_SMS
ActionEntity.Type.SOUND -> ActionId.SOUND
ActionEntity.Type.SYSTEM_ACTION -> {
SYSTEM_ACTION_ID_MAP.getKey(entity.data) ?: return null
Expand Down Expand Up @@ -229,6 +231,23 @@ object ActionDataEntityMapper {

ActionId.PHONE_CALL -> ActionData.PhoneCall(number = entity.data)

ActionId.SEND_SMS, ActionId.COMPOSE_SMS -> {
val message = entity.extras.getData(ActionEntity.EXTRA_SMS_MESSAGE)
.valueOrNull() ?: return null

when (actionId) {
ActionId.SEND_SMS -> ActionData.SendSms(
number = entity.data,
message = message,
)
ActionId.COMPOSE_SMS -> ActionData.ComposeSms(
number = entity.data,
message = message,
)
else -> return null
}
}

ActionId.SOUND -> {
val isRingtoneUri = try {
entity.data.toUri().scheme != null
Expand Down Expand Up @@ -651,6 +670,8 @@ object ActionDataEntityMapper {
is ActionData.App -> ActionEntity.Type.APP
is ActionData.AppShortcut -> ActionEntity.Type.APP_SHORTCUT
is ActionData.PhoneCall -> ActionEntity.Type.PHONE_CALL
is ActionData.SendSms -> ActionEntity.Type.SEND_SMS
is ActionData.ComposeSms -> ActionEntity.Type.COMPOSE_SMS
is ActionData.TapScreen -> ActionEntity.Type.TAP_COORDINATE
is ActionData.SwipeScreen -> ActionEntity.Type.SWIPE_COORDINATE
is ActionData.PinchScreen -> ActionEntity.Type.PINCH_COORDINATE
Expand Down Expand Up @@ -693,6 +714,8 @@ object ActionDataEntityMapper {
is ActionData.App -> data.packageName
is ActionData.AppShortcut -> data.uri
is ActionData.PhoneCall -> data.number
is ActionData.SendSms -> data.number
is ActionData.ComposeSms -> data.number
is ActionData.TapScreen -> "${data.x},${data.y}"
is ActionData.SwipeScreen -> "${data.xStart},${data.yStart},${data.xEnd},${data.yEnd},${data.fingerCount},${data.duration}"
is ActionData.PinchScreen -> "${data.x},${data.y},${data.distance},${data.pinchType},${data.fingerCount},${data.duration}"
Expand Down Expand Up @@ -752,6 +775,14 @@ object ActionDataEntityMapper {

is ActionData.PhoneCall -> emptyList()

is ActionData.SendSms -> listOf(
EntityExtra(ActionEntity.EXTRA_SMS_MESSAGE, data.message),
)

is ActionData.ComposeSms -> listOf(
EntityExtra(ActionEntity.EXTRA_SMS_MESSAGE, data.message),
)

is ActionData.DoNotDisturb.Enable -> listOf(
EntityExtra(ActionEntity.EXTRA_DND_MODE, DND_MODE_MAP[data.dndMode]!!),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ enum class ActionId {

ANSWER_PHONE_CALL,
END_PHONE_CALL,
SEND_SMS,
COMPOSE_SMS,
DEVICE_CONTROLS,

FORCE_STOP_APP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,15 @@ class ActionUiHelper(

ActionData.ClearRecentApp -> getString(R.string.action_clear_recent_app)
ActionData.ForceStopApp -> getString(R.string.action_force_stop_app)
is ActionData.ComposeSms -> getString(
R.string.action_compose_sms_description,
arrayOf(action.message, action.number)
)

is ActionData.SendSms -> getString(
R.string.action_send_sms_description,
arrayOf(action.message, action.number)
)
}

fun getIcon(action: ActionData): ComposeIconInfo = when (action) {
Expand Down
Loading
Loading