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