1<?xml version="1.0" encoding="utf-8"?> 2<!-- Copyright (C) 2021 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<resources> 17 <!-- Attributes for IFocusArea. --> 18 <declare-styleable name="IFocusArea"> 19 <!-- The ID of the default focus view. The view will be prioritized when searching for a 20 focus target. 21 (1) When the user nudges the rotary controller, it will search for a target IFocusArea, 22 then search for a target view within the target IFocusArea, and focus on the target 23 view. The target view is chosen in the following order: 24 1. the "android:focusedByDefault" view, if any 25 2. the "app:defaultFocus" view, if any 26 3. the selected item in a scrollable container, if any 27 4. the first focusable item in a scrollable container, if any 28 5. the first selected view, if any 29 6. previously focused view, if any and the cache is not stale 30 7. the first focusable view, if any 31 Note that 6 will be prioritized over 1, 2, 3, 4, and 5 when 32 "app:defaultFocusOverridesHistory" is false. 33 (2) When it needs to initialize the focus (such as when a window is opened), it will 34 search for a view in the window and focus on it. The view is chosen in the 35 following order: 36 1. the first "android:focusedByDefault" view, if any 37 2. the first "app:defaultFocus" view, if any 38 3. the selected item in a scrollable container, if any 39 4. the first focusable item in a scrollable container, if any 40 5. the first selected view, if any 41 6. the first focusable view that is not a FocusParkingView, if any 42 If there is only one IFocusArea that needs to set default focus, you can use either 43 "app:defaultFocus" or "android:focusedByDefault". If there are more than one, you 44 should use "android:focusedByDefault" in the primary IFocusArea, and use 45 "app:defaultFocus" in other IFocusAreas. --> 46 <attr name="defaultFocus" format="reference"/> 47 48 <!-- Whether to focus on the default focus view when nudging to the IFocusArea, even if there 49 was another view in the IFocusArea focused before. --> 50 <attr name="defaultFocusOverridesHistory" format="boolean"/> 51 52 <!-- The paddings of IFocusArea highlight. It doesn't impact the paddings on its child views, 53 or vice versa. --> 54 <!-- The start padding of the IFocusArea highlight. --> 55 <attr name="highlightPaddingStart" format="dimension"/> 56 <!-- The end padding of the IFocusArea highlight. --> 57 <attr name="highlightPaddingEnd" format="dimension"/> 58 <!-- The top padding of the IFocusArea highlight. --> 59 <attr name="highlightPaddingTop" format="dimension"/> 60 <!-- The bottom padding of the IFocusArea highlight. --> 61 <attr name="highlightPaddingBottom" format="dimension"/> 62 <!-- The horizontal padding of the IFocusArea highlight. It can be overridden by 63 highlightPaddingStart or highlightPaddingEnd. --> 64 <attr name="highlightPaddingHorizontal" format="dimension"/> 65 <!-- The vertical padding of the IFocusArea highlight. It can be overridden by 66 highlightPaddingTop or highlightPaddingBottom. --> 67 <attr name="highlightPaddingVertical" format="dimension"/> 68 69 <!-- The offset of the IFocusArea's bounds. It only affects the perceived bounds for the 70 purposes of finding the nudge target. It doesn't affect the IFocusArea's view bounds or 71 highlight bounds. The offset should only be used when IFocusAreas are overlapping and 72 nudge interaction is ambiguous. --> 73 <!-- The offset of the IFocusArea's start bound. --> 74 <attr name="startBoundOffset" format="dimension"/> 75 <!-- The offset of the IFocusArea's end bound. --> 76 <attr name="endBoundOffset" format="dimension"/> 77 <!-- The offset of the IFocusArea's top bound. --> 78 <attr name="topBoundOffset" format="dimension"/> 79 <!-- The offset of the IFocusArea's bottom bound. --> 80 <attr name="bottomBoundOffset" format="dimension"/> 81 <!-- The offset of the IFocusArea's horizontal bounds. It can be overridden by 82 startBoundOffset or endBoundOffset. --> 83 <attr name="horizontalBoundOffset" format="dimension"/> 84 <!-- The offset of the IFocusArea's vertical bounds. It can be overridden by topBoundOffset 85 or bottomBoundOffset. --> 86 <attr name="verticalBoundOffset" format="dimension"/> 87 88 <!-- New attributes for nudge shortcuts. Usually nudge is used to navigate to another 89 IFocusArea, but when a nudge shortcut is specified, it's used to navigate to the 90 given view within the same IFocusArea. A nudge shortcut can be specified for each 91 direction. --> 92 <!-- The ID of the nudge left shortcut view. --> 93 <attr name="nudgeLeftShortcut" format="reference"/> 94 <!-- The ID of the nudge right shortcut view. --> 95 <attr name="nudgeRightShortcut" format="reference"/> 96 <!-- The ID of the nudge up shortcut view. --> 97 <attr name="nudgeUpShortcut" format="reference"/> 98 <!-- The ID of the nudge down shortcut view. --> 99 <attr name="nudgeDownShortcut" format="reference"/> 100 101 <!-- Legacy attributes for nudge shortcut. Usually nudge is used to navigate to another 102 IFocusArea, but when a nudge shortcut is specified, it's used to navigate to the given 103 view within the same IFocusArea. If using these legacy attributes, the two must be 104 specified together and the new attributes cannot be used. --> 105 <!-- The ID of the nudge shortcut view. --> 106 <attr name="nudgeShortcut" format="reference"/> 107 <!-- The direction of the nudge shortcut. --> 108 <attr name="nudgeShortcutDirection"> 109 <!-- View.FOCUS_LEFT --> 110 <flag name="left" value="0x11" /> 111 <!-- View.FOCUS_RIGHT --> 112 <flag name="right" value="0x42" /> 113 <!-- View.FOCUS_UP --> 114 <flag name="up" value="0x21" /> 115 <!-- View.FOCUS_DOWN --> 116 <flag name="down" value="0x82" /> 117 </attr> 118 119 <!-- Attributes to specify the target IFocusArea for a nudge. --> 120 <!-- The ID of the target IFocusArea when nudging to the left. --> 121 <attr name="nudgeLeft" format="reference"/> 122 <!-- The ID of the target IFocusArea when nudging to the right. --> 123 <attr name="nudgeRight" format="reference"/> 124 <!-- The ID of the target IFocusArea when nudging up. --> 125 <attr name="nudgeUp" format="reference"/> 126 <!-- The ID of the target IFocusArea when nudging down. --> 127 <attr name="nudgeDown" format="reference"/> 128 129 <!-- Whether rotation wraps around. When true, rotation wraps around, staying within the 130 IFocusArea, when it reaches the first or last focusable view in the IFocusArea. When 131 false, rotation does nothing in this case. --> 132 <attr name="wrapAround" format="boolean"/> 133 </declare-styleable> 134 135 <!-- Attributes for FocusParkingView. --> 136 <declare-styleable name="FocusParkingView"> 137 <!-- Whether to restore focus when the frameworks wants to focus the FocusParkingView. When 138 false, the FocusParkingView allows itself to be focused instead. This should be false 139 for the FocusParkingView in an ActivityView. The default value is true. --> 140 <attr name="shouldRestoreFocus" format="boolean"/> 141 </declare-styleable> 142</resources> 143