File tree Expand file tree Collapse file tree
java/io/github/sds100/keymapper/api
java/io/github/sds100/keymapper/base
data/src/main/java/io/github/sds100/keymapper/data Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212- Show tips for parallel and sequence triggers, and constraints in the trigger screen
1313- #397 enable/disable all key maps in a group
1414- #1773 Option to show floating buttons on top of keyboard or notification panel.
15+ - #1335 Intent API to enable/disable/toggle a key map.
1516
1617## Removed
1718
Original file line number Diff line number Diff line change 3636 </intent-filter >
3737 </receiver >
3838
39+ <receiver
40+ android : name =" .EnableKeyMapsBroadcastReceiver"
41+ android : exported =" true" >
42+ <intent-filter >
43+ <action android : name =" io.github.sds100.keymapper.ACTION_ENABLE_KEY_MAP" />
44+ <action android : name =" io.github.sds100.keymapper.ACTION_DISABLE_KEY_MAP" />
45+ <action android : name =" io.github.sds100.keymapper.ACTION_TOGGLE_KEY_MAP" />
46+ </intent-filter >
47+ </receiver >
48+
3949 <!-- Don't require a permission because we want other apps to bind
4050 to this service. The permission wouldn't be signature-level so
4151 if a nefarious app wants to talk to Key Mapper they could add the permission anyway. -->
Original file line number Diff line number Diff line change @@ -4,9 +4,13 @@ object Api {
44 // Do not use the package name for debug/ci builds
55 const val ACTION_TRIGGER_KEYMAP_BY_UID =
66 " io.github.sds100.keymapper.ACTION_TRIGGER_KEYMAP_BY_UID"
7- const val EXTRA_KEYMAP_UID = " io.github.sds100.keymapper.EXTRA_KEYMAP_UID"
7+ const val EXTRA_KEYMAP_ID = " io.github.sds100.keymapper.EXTRA_KEYMAP_UID"
88
99 const val ACTION_PAUSE_MAPPINGS = " io.github.sds100.keymapper.ACTION_PAUSE_MAPPINGS"
1010 const val ACTION_RESUME_MAPPINGS = " io.github.sds100.keymapper.ACTION_RESUME_MAPPINGS"
1111 const val ACTION_TOGGLE_MAPPINGS = " io.github.sds100.keymapper.ACTION_TOGGLE_MAPPINGS"
12+
13+ const val ACTION_ENABLE_KEY_MAP = " io.github.sds100.keymapper.ACTION_ENABLE_KEY_MAP"
14+ const val ACTION_DISABLE_KEY_MAP = " io.github.sds100.keymapper.ACTION_DISABLE_KEY_MAP"
15+ const val ACTION_TOGGLE_KEY_MAP = " io.github.sds100.keymapper.ACTION_TOGGLE_KEY_MAP"
1216}
Original file line number Diff line number Diff line change 1+ package io.github.sds100.keymapper.api
2+
3+ import android.content.BroadcastReceiver
4+ import android.content.Context
5+ import android.content.Intent
6+ import dagger.hilt.android.AndroidEntryPoint
7+ import io.github.sds100.keymapper.base.keymaps.EnableKeyMapsUseCase
8+ import javax.inject.Inject
9+
10+ // DON'T MOVE THIS CLASS TO A DIFFERENT PACKAGE OR RENAME BECAUSE IT BREAKS THE API
11+ @AndroidEntryPoint
12+ class EnableKeyMapsBroadcastReceiver : BroadcastReceiver () {
13+
14+ @Inject
15+ lateinit var useCase: EnableKeyMapsUseCase
16+
17+ override fun onReceive (context : Context ? , intent : Intent ? ) {
18+ context ? : return
19+ intent?.action ? : return
20+
21+ if (intent.action != Api .ACTION_ENABLE_KEY_MAP &&
22+ intent.action != Api .ACTION_DISABLE_KEY_MAP &&
23+ intent.action != Api .ACTION_TOGGLE_KEY_MAP
24+ ) {
25+ return
26+ }
27+
28+ val keyMapUid = intent.getStringExtra(Api .EXTRA_KEYMAP_ID ) ? : return
29+
30+ when (intent.action) {
31+ Api .ACTION_ENABLE_KEY_MAP -> useCase.enable(keyMapUid)
32+ Api .ACTION_DISABLE_KEY_MAP -> useCase.disable(keyMapUid)
33+ Api .ACTION_TOGGLE_KEY_MAP -> useCase.toggle(keyMapUid)
34+ }
35+ }
36+ }
Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ class LaunchKeyMapShortcutActivity : ComponentActivity() {
3333 Intent (Api .ACTION_TRIGGER_KEYMAP_BY_UID ).apply {
3434 setPackage(packageName)
3535
36- val uuid = intent.getStringExtra(Api .EXTRA_KEYMAP_UID )
37- putExtra(Api .EXTRA_KEYMAP_UID , uuid)
36+ val uuid = intent.getStringExtra(Api .EXTRA_KEYMAP_ID )
37+ putExtra(Api .EXTRA_KEYMAP_ID , uuid)
3838
3939 sendBroadcast(this )
4040 }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import io.github.sds100.keymapper.base.keymaps.PauseKeyMapsUseCase
88import io.github.sds100.keymapper.common.utils.firstBlocking
99import javax.inject.Inject
1010
11- // DON'T MOVE THIS CLASS TO A DIFFERENT PACKAGE BECAUSE IT BREAKS THE API
11+ // DON'T MOVE THIS CLASS TO A DIFFERENT PACKAGE OR RENAME BECAUSE IT BREAKS THE API
1212@AndroidEntryPoint
1313class PauseMappingsBroadcastReceiver : BroadcastReceiver () {
1414
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class TriggerKeyMapsBroadcastReceiver : BroadcastReceiver() {
2626
2727 when (intent.action) {
2828 Api .ACTION_TRIGGER_KEYMAP_BY_UID -> {
29- intent.getStringExtra(Api .EXTRA_KEYMAP_UID )?.let { uid ->
29+ intent.getStringExtra(Api .EXTRA_KEYMAP_ID )?.let { uid ->
3030 coroutineScope.launch {
3131 serviceAdapter.send(TriggerKeyMapEvent (uid))
3232 }
Original file line number Diff line number Diff line change 1- Version 4.0! 🎉
2-
31📲 You can now remap buttons when the screen is off for FREE using PRO mode!
42
5- Remap your power button and more
3+ Remap your power button and more!
64
7- Enable/disable all the key maps in a group
5+ Enable/disable all the key maps in a group. Intent API to enable/disable/toggle a key map.
86
9- Option to show floating buttons on top of keyboard or notification panel
7+ Option to show floating buttons on top of keyboard or notification panel.
108
11- Many other bug fixes and optimisations
9+ Many other bug fixes and optimisations.
1210
13- See all the changes at http://changelog.keymapper.club.
11+ See all the changes at http://changelog.keymapper.club
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ import io.github.sds100.keymapper.base.input.InputEventHub
1818import io.github.sds100.keymapper.base.input.InputEventHubImpl
1919import io.github.sds100.keymapper.base.keymaps.ConfigKeyMapState
2020import io.github.sds100.keymapper.base.keymaps.ConfigKeyMapStateImpl
21+ import io.github.sds100.keymapper.base.keymaps.EnableKeyMapsUseCase
22+ import io.github.sds100.keymapper.base.keymaps.EnableKeyMapsUseCaseImpl
2123import io.github.sds100.keymapper.base.keymaps.FingerprintGesturesSupportedUseCase
2224import io.github.sds100.keymapper.base.keymaps.FingerprintGesturesSupportedUseCaseImpl
2325import io.github.sds100.keymapper.base.keymaps.GetDefaultKeyMapOptionsUseCase
@@ -164,4 +166,8 @@ abstract class BaseSingletonHiltModule {
164166 @Binds
165167 @Singleton
166168 abstract fun bindSwitchImeInterface (impl : SwitchImeAsyncImpl ): SwitchImeInterface
169+
170+ @Binds
171+ @Singleton
172+ abstract fun bindEnableKeyMapsUseCase (impl : EnableKeyMapsUseCaseImpl ): EnableKeyMapsUseCase
167173}
Original file line number Diff line number Diff line change 1+ package io.github.sds100.keymapper.base.keymaps
2+
3+ import io.github.sds100.keymapper.data.repositories.KeyMapRepository
4+ import javax.inject.Inject
5+ import javax.inject.Singleton
6+
7+ @Singleton
8+ class EnableKeyMapsUseCaseImpl @Inject constructor(
9+ private val keyMapRepository : KeyMapRepository
10+ ) : EnableKeyMapsUseCase {
11+
12+ override fun enable (uid : String ) {
13+ keyMapRepository.enableById(uid)
14+ }
15+
16+ override fun toggle (uid : String ) {
17+ keyMapRepository.toggleById(uid)
18+ }
19+
20+ override fun disable (uid : String ) {
21+ keyMapRepository.disableById(uid)
22+ }
23+ }
24+
25+ interface EnableKeyMapsUseCase {
26+ fun enable (uid : String )
27+ fun toggle (uid : String )
28+ fun disable (uid : String )
29+ }
You can’t perform that action at this time.
0 commit comments