Skip to content

Commit d64109f

Browse files
committed
Merge branch 'refs/heads/develop'
2 parents e325ee2 + eaf9248 commit d64109f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+269
-45
lines changed

CHANGELOG.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1+
## [2.7.2](https://github.com/sds100/KeyMapper/releases/tag/v2.7.2)
2+
3+
#### 22 December 2024
4+
5+
## Added
6+
7+
- #1298 add action to launch the Android device controls screen for managing Home devices.
8+
9+
## Bug fixes
10+
11+
- #1342 add Meta modifier keys to the key event action.
12+
- #1101 deprecate the toggle split screen action on Android 12L and newer.
13+
- #1370 warn the user that extra permissions are required for the Launch app action on Xiaomi devices
14+
- #1371 try to fix the app not opening on people's devices
15+
116
## [2.7.1](https://github.com/sds100/KeyMapper/releases/tag/v2.7.1)
217

318
#### 13 December 2024
419

520
## Bug fixes
621

7-
- #1360 complete the documentation for advanced triggers at docs.keymapper.club
8-
- #1364 key event actions no longer crash when using Shizuku
9-
- #1362 backing up and restoring key maps works again
22+
- #1360 complete the documentation for advanced triggers at docs.keymapper.club.
23+
- #1364 key event actions no longer crash when using Shizuku.
24+
- #1362 backing up and restoring key maps works again.
1025

1126
## [2.7.0](https://github.com/sds100/KeyMapper/releases/tag/v2.7.0)
1227

app/src/main/java/io/github/sds100/keymapper/actions/ActionData.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,4 +647,9 @@ sealed class ActionData {
647647
object EndCall : ActionData() {
648648
override val id: ActionId = ActionId.END_PHONE_CALL
649649
}
650+
651+
@Serializable
652+
object DeviceControls : ActionData() {
653+
override val id: ActionId = ActionId.DEVICE_CONTROLS
654+
}
650655
}

app/src/main/java/io/github/sds100/keymapper/actions/ActionDataEntityMapper.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import io.github.sds100.keymapper.util.getKey
1515
import io.github.sds100.keymapper.util.success
1616
import io.github.sds100.keymapper.util.then
1717
import io.github.sds100.keymapper.util.valueOrNull
18-
import kotlinx.serialization.decodeFromString
1918
import kotlinx.serialization.encodeToString
2019
import kotlinx.serialization.json.Json
2120
import splitties.bitflags.hasFlag
@@ -482,6 +481,7 @@ object ActionDataEntityMapper {
482481
ActionId.DISMISS_ALL_NOTIFICATIONS -> ActionData.DismissAllNotifications
483482
ActionId.ANSWER_PHONE_CALL -> ActionData.AnswerCall
484483
ActionId.END_PHONE_CALL -> ActionData.EndCall
484+
ActionId.DEVICE_CONTROLS -> ActionData.DeviceControls
485485
}
486486
}
487487

@@ -806,5 +806,6 @@ object ActionDataEntityMapper {
806806

807807
ActionId.ANSWER_PHONE_CALL to "answer_phone_call",
808808
ActionId.END_PHONE_CALL to "end_phone_call",
809+
ActionId.DEVICE_CONTROLS to "device_controls",
809810
)
810811
}

app/src/main/java/io/github/sds100/keymapper/actions/ActionId.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,5 @@ enum class ActionId {
127127

128128
ANSWER_PHONE_CALL,
129129
END_PHONE_CALL,
130+
DEVICE_CONTROLS,
130131
}

app/src/main/java/io/github/sds100/keymapper/actions/ActionUtils.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ object ActionUtils {
157157

158158
ActionId.DISMISS_MOST_RECENT_NOTIFICATION -> ActionCategory.NOTIFICATIONS
159159
ActionId.DISMISS_ALL_NOTIFICATIONS -> ActionCategory.NOTIFICATIONS
160+
ActionId.DEVICE_CONTROLS -> ActionCategory.APPS
160161
}
161162

162163
@StringRes
@@ -267,6 +268,7 @@ object ActionUtils {
267268
ActionId.DISMISS_ALL_NOTIFICATIONS -> R.string.action_dismiss_all_notifications
268269
ActionId.ANSWER_PHONE_CALL -> R.string.action_answer_call
269270
ActionId.END_PHONE_CALL -> R.string.action_end_call
271+
ActionId.DEVICE_CONTROLS -> R.string.action_device_controls
270272
}
271273

272274
@DrawableRes
@@ -378,6 +380,7 @@ object ActionUtils {
378380
ActionId.DISMISS_ALL_NOTIFICATIONS -> R.drawable.ic_baseline_clear_all_24
379381
ActionId.ANSWER_PHONE_CALL -> R.drawable.ic_outline_call_24
380382
ActionId.END_PHONE_CALL -> R.drawable.ic_outline_call_end_24
383+
ActionId.DEVICE_CONTROLS -> R.drawable.ic_home_automation
381384
}
382385

383386
fun getMinApi(id: ActionId): Int = when (id) {
@@ -412,6 +415,7 @@ object ActionUtils {
412415
-> Build.VERSION_CODES.JELLY_BEAN_MR2
413416

414417
ActionId.SHOW_POWER_MENU -> Build.VERSION_CODES.LOLLIPOP
418+
ActionId.DEVICE_CONTROLS -> Build.VERSION_CODES.S
415419

416420
else -> Constants.MIN_API
417421
}
@@ -427,6 +431,10 @@ object ActionUtils {
427431
ActionId.TOGGLE_BLUETOOTH,
428432
-> Build.VERSION_CODES.S_V2
429433

434+
// See https://issuetracker.google.com/issues/225186417. The global action
435+
// is not marked as deprecated even though it doesn't work.
436+
ActionId.TOGGLE_SPLIT_SCREEN -> Build.VERSION_CODES.S
437+
430438
else -> Constants.MAX_API
431439
}
432440

@@ -561,6 +569,13 @@ object ActionUtils {
561569
ActionId.END_PHONE_CALL,
562570
-> return listOf(Permission.ANSWER_PHONE_CALL)
563571

572+
ActionId.PHONE_CALL -> return listOf(Permission.CALL_PHONE)
573+
574+
ActionId.ENABLE_BLUETOOTH, ActionId.DISABLE_BLUETOOTH, ActionId.TOGGLE_BLUETOOTH ->
575+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
576+
return listOf(Permission.FIND_NEARBY_DEVICES)
577+
}
578+
564579
else -> Unit
565580
}
566581

app/src/main/java/io/github/sds100/keymapper/actions/BaseActionUiHelper.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ abstract class BaseActionUiHelper<MAPPING : Mapping<A>, A : Action>(
456456

457457
ActionData.AnswerCall -> getString(R.string.action_answer_call)
458458
ActionData.EndCall -> getString(R.string.action_end_call)
459+
460+
ActionData.DeviceControls -> getString(R.string.action_device_controls)
459461
}
460462

461463
override fun getIcon(action: ActionData): IconInfo? = when (action) {

app/src/main/java/io/github/sds100/keymapper/actions/ChooseActionViewModel.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.github.sds100.keymapper.actions
22

3-
import androidx.annotation.StringRes
43
import androidx.lifecycle.ViewModel
54
import androidx.lifecycle.ViewModelProvider
65
import androidx.lifecycle.viewModelScope
@@ -10,6 +9,7 @@ import io.github.sds100.keymapper.util.State
109
import io.github.sds100.keymapper.util.containsQuery
1110
import io.github.sds100.keymapper.util.getFullMessage
1211
import io.github.sds100.keymapper.util.ui.DefaultSimpleListItem
12+
import io.github.sds100.keymapper.util.ui.DialogResponse
1313
import io.github.sds100.keymapper.util.ui.IconInfo
1414
import io.github.sds100.keymapper.util.ui.ListItem
1515
import io.github.sds100.keymapper.util.ui.PopupUi
@@ -163,7 +163,31 @@ class ChooseActionViewModel(
163163
* @return whether the user approved the message
164164
*/
165165
private suspend fun showMessageForAction(id: ActionId): Boolean {
166-
@StringRes val messageToShow: Int? = when (id) {
166+
// See issue #1379
167+
if (id == ActionId.APP) {
168+
val response = showPopup(
169+
"show_app_action_warning_dialog",
170+
PopupUi.Dialog(
171+
message = getString(R.string.action_open_app_dialog_message),
172+
title = getString(R.string.action_open_app_dialog_title),
173+
positiveButtonText = getString(R.string.action_open_app_dialog_read_more_button),
174+
negativeButtonText = getString(R.string.action_open_app_dialog_ignore_button)
175+
),
176+
)
177+
178+
if (response == DialogResponse.POSITIVE) {
179+
showPopup(
180+
"app_action_permission_info",
181+
PopupUi.OpenUrl(getString(R.string.url_action_guide))
182+
)
183+
return false
184+
185+
} else {
186+
return response != null
187+
}
188+
}
189+
190+
val messageToShow: Int? = when (id) {
167191
ActionId.FAST_FORWARD_PACKAGE,
168192
ActionId.FAST_FORWARD,
169193
-> R.string.action_fast_forward_message

app/src/main/java/io/github/sds100/keymapper/actions/CreateActionViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ class CreateActionViewModelImpl(
596596
ActionId.DISMISS_ALL_NOTIFICATIONS -> return ActionData.DismissAllNotifications
597597
ActionId.ANSWER_PHONE_CALL -> return ActionData.AnswerCall
598598
ActionId.END_PHONE_CALL -> return ActionData.EndCall
599+
ActionId.DEVICE_CONTROLS -> return ActionData.DeviceControls
599600
}
600601
}
601602
}

app/src/main/java/io/github/sds100/keymapper/actions/GetActionErrorUseCase.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ class GetActionErrorUseCaseImpl(
100100
return Error.SdkVersionTooLow(Build.VERSION_CODES.N)
101101
}
102102

103-
is ActionData.PhoneCall ->
104-
if (!permissionAdapter.isGranted(Permission.CALL_PHONE)) {
105-
return Error.PermissionDenied(Permission.CALL_PHONE)
106-
}
107-
108103
is ActionData.Sound -> {
109104
soundsManager.getSound(action.soundUid).onFailure { error ->
110105
return error
@@ -130,13 +125,6 @@ class GetActionErrorUseCaseImpl(
130125
return it
131126
}
132127

133-
is ActionData.Bluetooth ->
134-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
135-
!permissionAdapter.isGranted(Permission.FIND_NEARBY_DEVICES)
136-
) {
137-
return Error.PermissionDenied(Permission.FIND_NEARBY_DEVICES)
138-
}
139-
140128
else -> Unit
141129
}
142130

app/src/main/java/io/github/sds100/keymapper/actions/PerformActionsUseCase.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import io.github.sds100.keymapper.system.inputmethod.InputKeyModel
2727
import io.github.sds100.keymapper.system.inputmethod.InputMethodAdapter
2828
import io.github.sds100.keymapper.system.inputmethod.KeyMapperImeMessenger
2929
import io.github.sds100.keymapper.system.intents.IntentAdapter
30+
import io.github.sds100.keymapper.system.intents.IntentTarget
3031
import io.github.sds100.keymapper.system.keyevents.KeyEventUtils
3132
import io.github.sds100.keymapper.system.lock.LockScreenAdapter
3233
import io.github.sds100.keymapper.system.media.MediaAdapter
@@ -786,6 +787,14 @@ class PerformActionsUseCaseImpl(
786787
phoneAdapter.endCall()
787788
result = success()
788789
}
790+
791+
ActionData.DeviceControls -> {
792+
result = intentAdapter.send(
793+
IntentTarget.ACTIVITY,
794+
uri = "#Intent;action=android.intent.action.MAIN;package=com.android.systemui;component=com.android.systemui/.controls.ui.ControlsActivity;end",
795+
extras = emptyList(),
796+
)
797+
}
789798
}
790799

791800
when (result) {

0 commit comments

Comments
 (0)