• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * 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.model
18 
19 import android.graphics.drawable.Icon
20 import android.hardware.input.InputGestureData
21 import android.view.KeyboardShortcutGroup
22 import com.android.systemui.keyboard.shortcut.data.repository.ShortcutCategoriesUtils
23 import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategory
24 import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType
25 
26 /**
27  * Internal Keyboard Shortcut models to use with [ShortcutCategoriesUtils.fetchShortcutCategory]
28  * when converting API models to Shortcut Helper Model [ShortcutCategory]. These Internal Models
29  * bridge the Gap between [InputGestureData] from custom shortcuts API and [KeyboardShortcutGroup]
30  * from default shortcuts API allowing us to have a single Utility Class that converts API models to
31  * Shortcut Helper models
32  *
33  * @param label Equivalent to shortcut helper's subcategory label
34  * @param items Keyboard Shortcuts received from API
35  * @param packageName package name of current app shortcut if available.
36  */
37 data class InternalKeyboardShortcutGroup(
38     val label: String,
39     val items: List<InternalKeyboardShortcutInfo>,
40     val packageName: String? = null,
41 )
42 
43 /**
44  * @param label Shortcut label
45  * @param keycode Key to trigger shortcut
46  * @param modifiers Mask of shortcut modifiers
47  * @param baseCharacter Key to trigger shortcut if is a character
48  * @param icon Shortcut icon if available - often used for app launch shortcuts
49  * @param isCustomShortcut If Shortcut is user customized or system defined.
50  */
51 data class InternalKeyboardShortcutInfo(
52     val label: String = "",
53     val keycode: Int,
54     val modifiers: Int,
55     val baseCharacter: Char = Char.MIN_VALUE,
56     val icon: Icon? = null,
57     val isCustomShortcut: Boolean = false,
58 )
59 
60 data class InternalGroupsSource(
61     val groups: List<InternalKeyboardShortcutGroup>,
62     val type: ShortcutCategoryType,
63 )
64