• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.keyboard.shortcut.data.repository
18 
19 import android.content.Context
20 import android.view.KeyEvent.KEYCODE_ALT_LEFT
21 import android.view.KeyEvent.KEYCODE_ALT_RIGHT
22 import android.view.KeyEvent.KEYCODE_BACK
23 import android.view.KeyEvent.KEYCODE_BREAK
24 import android.view.KeyEvent.KEYCODE_BUTTON_A
25 import android.view.KeyEvent.KEYCODE_BUTTON_B
26 import android.view.KeyEvent.KEYCODE_BUTTON_C
27 import android.view.KeyEvent.KEYCODE_BUTTON_L1
28 import android.view.KeyEvent.KEYCODE_BUTTON_L2
29 import android.view.KeyEvent.KEYCODE_BUTTON_MODE
30 import android.view.KeyEvent.KEYCODE_BUTTON_R1
31 import android.view.KeyEvent.KEYCODE_BUTTON_R2
32 import android.view.KeyEvent.KEYCODE_BUTTON_SELECT
33 import android.view.KeyEvent.KEYCODE_BUTTON_START
34 import android.view.KeyEvent.KEYCODE_BUTTON_X
35 import android.view.KeyEvent.KEYCODE_BUTTON_Y
36 import android.view.KeyEvent.KEYCODE_BUTTON_Z
37 import android.view.KeyEvent.KEYCODE_CTRL_LEFT
38 import android.view.KeyEvent.KEYCODE_CTRL_RIGHT
39 import android.view.KeyEvent.KEYCODE_DEL
40 import android.view.KeyEvent.KEYCODE_DPAD_CENTER
41 import android.view.KeyEvent.KEYCODE_DPAD_DOWN
42 import android.view.KeyEvent.KEYCODE_DPAD_LEFT
43 import android.view.KeyEvent.KEYCODE_DPAD_RIGHT
44 import android.view.KeyEvent.KEYCODE_DPAD_UP
45 import android.view.KeyEvent.KEYCODE_EISU
46 import android.view.KeyEvent.KEYCODE_ENTER
47 import android.view.KeyEvent.KEYCODE_EQUALS
48 import android.view.KeyEvent.KEYCODE_ESCAPE
49 import android.view.KeyEvent.KEYCODE_F1
50 import android.view.KeyEvent.KEYCODE_F10
51 import android.view.KeyEvent.KEYCODE_F11
52 import android.view.KeyEvent.KEYCODE_F12
53 import android.view.KeyEvent.KEYCODE_F2
54 import android.view.KeyEvent.KEYCODE_F3
55 import android.view.KeyEvent.KEYCODE_F4
56 import android.view.KeyEvent.KEYCODE_F5
57 import android.view.KeyEvent.KEYCODE_F6
58 import android.view.KeyEvent.KEYCODE_F7
59 import android.view.KeyEvent.KEYCODE_F8
60 import android.view.KeyEvent.KEYCODE_F9
61 import android.view.KeyEvent.KEYCODE_FORWARD_DEL
62 import android.view.KeyEvent.KEYCODE_GRAVE
63 import android.view.KeyEvent.KEYCODE_HENKAN
64 import android.view.KeyEvent.KEYCODE_HOME
65 import android.view.KeyEvent.KEYCODE_INSERT
66 import android.view.KeyEvent.KEYCODE_KATAKANA_HIRAGANA
67 import android.view.KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
68 import android.view.KeyEvent.KEYCODE_MEDIA_NEXT
69 import android.view.KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
70 import android.view.KeyEvent.KEYCODE_MEDIA_PREVIOUS
71 import android.view.KeyEvent.KEYCODE_MEDIA_REWIND
72 import android.view.KeyEvent.KEYCODE_MEDIA_STOP
73 import android.view.KeyEvent.KEYCODE_MINUS
74 import android.view.KeyEvent.KEYCODE_MOVE_END
75 import android.view.KeyEvent.KEYCODE_MOVE_HOME
76 import android.view.KeyEvent.KEYCODE_MUHENKAN
77 import android.view.KeyEvent.KEYCODE_NUMPAD_0
78 import android.view.KeyEvent.KEYCODE_NUMPAD_1
79 import android.view.KeyEvent.KEYCODE_NUMPAD_2
80 import android.view.KeyEvent.KEYCODE_NUMPAD_3
81 import android.view.KeyEvent.KEYCODE_NUMPAD_4
82 import android.view.KeyEvent.KEYCODE_NUMPAD_5
83 import android.view.KeyEvent.KEYCODE_NUMPAD_6
84 import android.view.KeyEvent.KEYCODE_NUMPAD_7
85 import android.view.KeyEvent.KEYCODE_NUMPAD_8
86 import android.view.KeyEvent.KEYCODE_NUMPAD_9
87 import android.view.KeyEvent.KEYCODE_NUMPAD_ADD
88 import android.view.KeyEvent.KEYCODE_NUMPAD_COMMA
89 import android.view.KeyEvent.KEYCODE_NUMPAD_DIVIDE
90 import android.view.KeyEvent.KEYCODE_NUMPAD_DOT
91 import android.view.KeyEvent.KEYCODE_NUMPAD_ENTER
92 import android.view.KeyEvent.KEYCODE_NUMPAD_EQUALS
93 import android.view.KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN
94 import android.view.KeyEvent.KEYCODE_NUMPAD_MULTIPLY
95 import android.view.KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN
96 import android.view.KeyEvent.KEYCODE_NUMPAD_SUBTRACT
97 import android.view.KeyEvent.KEYCODE_NUM_LOCK
98 import android.view.KeyEvent.KEYCODE_PAGE_DOWN
99 import android.view.KeyEvent.KEYCODE_PAGE_UP
100 import android.view.KeyEvent.KEYCODE_PERIOD
101 import android.view.KeyEvent.KEYCODE_RECENT_APPS
102 import android.view.KeyEvent.KEYCODE_SCREENSHOT
103 import android.view.KeyEvent.KEYCODE_SCROLL_LOCK
104 import android.view.KeyEvent.KEYCODE_SHIFT_LEFT
105 import android.view.KeyEvent.KEYCODE_SHIFT_RIGHT
106 import android.view.KeyEvent.KEYCODE_SPACE
107 import android.view.KeyEvent.KEYCODE_SYSRQ
108 import android.view.KeyEvent.KEYCODE_TAB
109 import android.view.KeyEvent.KEYCODE_ZENKAKU_HANKAKU
110 import android.view.KeyEvent.META_ALT_ON
111 import android.view.KeyEvent.META_CTRL_ON
112 import android.view.KeyEvent.META_FUNCTION_ON
113 import android.view.KeyEvent.META_META_ON
114 import android.view.KeyEvent.META_SHIFT_ON
115 import android.view.KeyEvent.META_SYM_ON
116 import com.android.systemui.res.R
117 
118 object ShortcutHelperKeys {
119 
120     val metaModifierIconResId = R.drawable.ic_ksh_key_meta
121 
122     val keyIcons =
123         mapOf(
124             KEYCODE_BACK to R.drawable.ic_arrow_back_2,
125             KEYCODE_HOME to R.drawable.ic_radio_button_unchecked,
126             KEYCODE_RECENT_APPS to R.drawable.ic_check_box_outline_blank,
127         )
128 
129     val keyLabelResIds =
130         mapOf(
131             KEYCODE_BACK to R.string.group_system_go_back,
132             KEYCODE_HOME to R.string.group_system_access_home_screen,
133             KEYCODE_RECENT_APPS to R.string.group_system_overview_open_apps,
134             KEYCODE_SCREENSHOT to R.string.group_system_full_screenshot,
135         )
136 
137     val modifierLabels =
138         mapOf<Int, (Context) -> String>(
139             // Modifiers
140             META_META_ON to { "Meta" },
141             META_CTRL_ON to { "Ctrl" },
142             META_ALT_ON to { "Alt" },
143             META_SHIFT_ON to { "Shift" },
144             META_SYM_ON to { "Sym" },
145             META_FUNCTION_ON to { "Fn" },
146         )
147 
148     val specialKeyLabels =
149         mapOf<Int, (Context) -> String>(
150             KEYCODE_HOME to { context -> context.getString(R.string.keyboard_key_home) },
151             KEYCODE_BACK to { context -> context.getString(R.string.keyboard_key_back) },
152             KEYCODE_RECENT_APPS to { context -> context.getString(R.string.accessibility_recent) },
153             KEYCODE_DPAD_UP to { context -> context.getString(R.string.keyboard_key_dpad_up) },
154             KEYCODE_DPAD_DOWN to { context -> context.getString(R.string.keyboard_key_dpad_down) },
155             KEYCODE_DPAD_LEFT to { context -> context.getString(R.string.keyboard_key_dpad_left) },
156             KEYCODE_DPAD_RIGHT to
157                 { context ->
158                     context.getString(R.string.keyboard_key_dpad_right)
159                 },
160             KEYCODE_DPAD_CENTER to
161                 { context ->
162                     context.getString(R.string.keyboard_key_dpad_center)
163                 },
164             KEYCODE_PERIOD to { "." },
165             KEYCODE_TAB to { context -> context.getString(R.string.keyboard_key_tab) },
166             KEYCODE_SPACE to { context -> context.getString(R.string.keyboard_key_space) },
167             KEYCODE_ENTER to { context -> context.getString(R.string.keyboard_key_enter) },
168             KEYCODE_DEL to { context -> context.getString(R.string.keyboard_key_backspace) },
169             KEYCODE_MEDIA_PLAY_PAUSE to
170                 { context ->
171                     context.getString(R.string.keyboard_key_media_play_pause)
172                 },
173             KEYCODE_MEDIA_STOP to
174                 { context ->
175                     context.getString(R.string.keyboard_key_media_stop)
176                 },
177             KEYCODE_MEDIA_NEXT to
178                 { context ->
179                     context.getString(R.string.keyboard_key_media_next)
180                 },
181             KEYCODE_MEDIA_PREVIOUS to
182                 { context ->
183                     context.getString(R.string.keyboard_key_media_previous)
184                 },
185             KEYCODE_MEDIA_REWIND to
186                 { context ->
187                     context.getString(R.string.keyboard_key_media_rewind)
188                 },
189             KEYCODE_MEDIA_FAST_FORWARD to
190                 { context ->
191                     context.getString(R.string.keyboard_key_media_fast_forward)
192                 },
193             KEYCODE_PAGE_UP to { context -> context.getString(R.string.keyboard_key_page_up) },
194             KEYCODE_PAGE_DOWN to { context -> context.getString(R.string.keyboard_key_page_down) },
195             KEYCODE_BUTTON_A to
196                 { context ->
197                     context.getString(R.string.keyboard_key_button_template, "A")
198                 },
199             KEYCODE_BUTTON_B to
200                 { context ->
201                     context.getString(R.string.keyboard_key_button_template, "B")
202                 },
203             KEYCODE_BUTTON_C to
204                 { context ->
205                     context.getString(R.string.keyboard_key_button_template, "C")
206                 },
207             KEYCODE_BUTTON_X to
208                 { context ->
209                     context.getString(R.string.keyboard_key_button_template, "X")
210                 },
211             KEYCODE_BUTTON_Y to
212                 { context ->
213                     context.getString(R.string.keyboard_key_button_template, "Y")
214                 },
215             KEYCODE_BUTTON_Z to
216                 { context ->
217                     context.getString(R.string.keyboard_key_button_template, "Z")
218                 },
219             KEYCODE_BUTTON_L1 to
220                 { context ->
221                     context.getString(R.string.keyboard_key_button_template, "L1")
222                 },
223             KEYCODE_BUTTON_R1 to
224                 { context ->
225                     context.getString(R.string.keyboard_key_button_template, "R1")
226                 },
227             KEYCODE_BUTTON_L2 to
228                 { context ->
229                     context.getString(R.string.keyboard_key_button_template, "L2")
230                 },
231             KEYCODE_BUTTON_R2 to
232                 { context ->
233                     context.getString(R.string.keyboard_key_button_template, "R2")
234                 },
235             KEYCODE_BUTTON_START to
236                 { context ->
237                     context.getString(R.string.keyboard_key_button_template, "Start")
238                 },
239             KEYCODE_BUTTON_SELECT to
240                 { context ->
241                     context.getString(R.string.keyboard_key_button_template, "Select")
242                 },
243             KEYCODE_BUTTON_MODE to
244                 { context ->
245                     context.getString(R.string.keyboard_key_button_template, "Mode")
246                 },
247             KEYCODE_FORWARD_DEL to
248                 { context ->
249                     context.getString(R.string.keyboard_key_forward_del)
250                 },
251             KEYCODE_ESCAPE to { context -> context.getString(R.string.keyboard_key_esc) },
252             KEYCODE_SYSRQ to { "SysRq" },
253             KEYCODE_BREAK to { "Break" },
254             KEYCODE_SCROLL_LOCK to { "Scroll Lock" },
255             KEYCODE_MOVE_HOME to { context -> context.getString(R.string.keyboard_key_move_home) },
256             KEYCODE_MOVE_END to { context -> context.getString(R.string.keyboard_key_move_end) },
257             KEYCODE_INSERT to { context -> context.getString(R.string.keyboard_key_insert) },
258             KEYCODE_F1 to { "F1" },
259             KEYCODE_F2 to { "F2" },
260             KEYCODE_F3 to { "F3" },
261             KEYCODE_F4 to { "F4" },
262             KEYCODE_F5 to { "F5" },
263             KEYCODE_F6 to { "F6" },
264             KEYCODE_F7 to { "F7" },
265             KEYCODE_F8 to { "F8" },
266             KEYCODE_F9 to { "F9" },
267             KEYCODE_F10 to { "F10" },
268             KEYCODE_F11 to { "F11" },
269             KEYCODE_F12 to { "F12" },
270             KEYCODE_NUM_LOCK to { context -> context.getString(R.string.keyboard_key_num_lock) },
271             KEYCODE_MINUS to { "-" },
272             KEYCODE_GRAVE to { "`" },
273             KEYCODE_EQUALS to { "=" },
274             KEYCODE_NUMPAD_0 to
275                 { context ->
276                     context.getString(R.string.keyboard_key_numpad_template, "0")
277                 },
278             KEYCODE_NUMPAD_1 to
279                 { context ->
280                     context.getString(R.string.keyboard_key_numpad_template, "1")
281                 },
282             KEYCODE_NUMPAD_2 to
283                 { context ->
284                     context.getString(R.string.keyboard_key_numpad_template, "2")
285                 },
286             KEYCODE_NUMPAD_3 to
287                 { context ->
288                     context.getString(R.string.keyboard_key_numpad_template, "3")
289                 },
290             KEYCODE_NUMPAD_4 to
291                 { context ->
292                     context.getString(R.string.keyboard_key_numpad_template, "4")
293                 },
294             KEYCODE_NUMPAD_5 to
295                 { context ->
296                     context.getString(R.string.keyboard_key_numpad_template, "5")
297                 },
298             KEYCODE_NUMPAD_6 to
299                 { context ->
300                     context.getString(R.string.keyboard_key_numpad_template, "6")
301                 },
302             KEYCODE_NUMPAD_7 to
303                 { context ->
304                     context.getString(R.string.keyboard_key_numpad_template, "7")
305                 },
306             KEYCODE_NUMPAD_8 to
307                 { context ->
308                     context.getString(R.string.keyboard_key_numpad_template, "8")
309                 },
310             KEYCODE_NUMPAD_9 to
311                 { context ->
312                     context.getString(R.string.keyboard_key_numpad_template, "9")
313                 },
314             KEYCODE_NUMPAD_DIVIDE to
315                 { context ->
316                     context.getString(R.string.keyboard_key_numpad_template, "/")
317                 },
318             KEYCODE_NUMPAD_MULTIPLY to
319                 { context ->
320                     context.getString(R.string.keyboard_key_numpad_template, "*")
321                 },
322             KEYCODE_NUMPAD_SUBTRACT to
323                 { context ->
324                     context.getString(R.string.keyboard_key_numpad_template, "-")
325                 },
326             KEYCODE_NUMPAD_ADD to
327                 { context ->
328                     context.getString(R.string.keyboard_key_numpad_template, "+")
329                 },
330             KEYCODE_NUMPAD_DOT to
331                 { context ->
332                     context.getString(R.string.keyboard_key_numpad_template, ".")
333                 },
334             KEYCODE_NUMPAD_COMMA to
335                 { context ->
336                     context.getString(R.string.keyboard_key_numpad_template, ",")
337                 },
338             KEYCODE_NUMPAD_ENTER to
339                 { context ->
340                     context.getString(
341                         R.string.keyboard_key_numpad_template,
342                         context.getString(R.string.keyboard_key_enter),
343                     )
344                 },
345             KEYCODE_NUMPAD_EQUALS to
346                 { context ->
347                     context.getString(R.string.keyboard_key_numpad_template, "=")
348                 },
349             KEYCODE_NUMPAD_LEFT_PAREN to
350                 { context ->
351                     context.getString(R.string.keyboard_key_numpad_template, "(")
352                 },
353             KEYCODE_NUMPAD_RIGHT_PAREN to
354                 { context ->
355                     context.getString(R.string.keyboard_key_numpad_template, ")")
356                 },
357             KEYCODE_ZENKAKU_HANKAKU to { "半角/全角" },
358             KEYCODE_EISU to { "英数" },
359             KEYCODE_MUHENKAN to { "無変換" },
360             KEYCODE_HENKAN to { "変換" },
361             KEYCODE_KATAKANA_HIRAGANA to { "かな" },
362             KEYCODE_ALT_LEFT to { "Alt" },
363             KEYCODE_ALT_RIGHT to { "Alt" },
364             KEYCODE_CTRL_LEFT to { "Ctrl" },
365             KEYCODE_CTRL_RIGHT to { "Ctrl" },
366             KEYCODE_SHIFT_LEFT to { "Shift" },
367             KEYCODE_SHIFT_RIGHT to { "Shift" },
368         )
369 }
370