1<?xml version="1.0" encoding="utf-8"?> 2<!-- 3 ~ Copyright (C) 2020 The Android Open Source Project 4 ~ 5 ~ Licensed under the Apache License, Version 2.0 (the "License"); 6 ~ you may not use this file except in compliance with the License. 7 ~ You may obtain a copy of the License at 8 ~ 9 ~ http://www.apache.org/licenses/LICENSE-2.0 10 ~ 11 ~ Unless required by applicable law or agreed to in writing, software 12 ~ distributed under the License is distributed on an "AS IS" BASIS, 13 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ~ See the License for the specific language governing permissions and 15 ~ limitations under the License. 16 --> 17<LinearLayout 18 xmlns:android="http://schemas.android.com/apk/res/android" 19 xmlns:app="http://schemas.android.com/apk/res-auto" 20 android:layout_width="match_parent" 21 android:layout_height="match_parent" 22 android:orientation="vertical"> 23 24 <com.android.car.ui.FocusArea 25 android:layout_margin="16dp" 26 android:layout_width="match_parent" 27 android:layout_height="wrap_content" 28 android:orientation="vertical"> 29 <EditText 30 android:layout_width="match_parent" 31 android:layout_height="wrap_content" 32 android:singleLine="true"> 33 </EditText> 34 </com.android.car.ui.FocusArea> 35 36 <HorizontalScrollView 37 android:layout_width="match_parent" 38 android:layout_height="wrap_content"> 39 <LinearLayout 40 android:layout_width="match_parent" 41 android:layout_height="wrap_content"> 42 43 <!-- A FocusArea with some buttons. 44 Upon nudging into this area, the default focus should land on the first 45 button in this container. Rotating the rotary controller clockwise will move the 46 focus from top to bottom. Counterclockwise to move the focus from bottom to up. 47 Nudge any direction to leave this focus area. The disabled button is skipped. --> 48 <com.android.car.ui.FocusArea 49 android:id="@+id/card_normal" 50 android:background="@color/card_background_color" 51 android:layout_margin="16dp" 52 android:layout_width="@dimen/card_width" 53 android:layout_height="match_parent" 54 android:padding="@dimen/card_padding" 55 android:orientation="vertical"> 56 <TextView 57 android:layout_height="@dimen/description_height" 58 android:layout_width="match_parent" 59 android:text="@string/card_normal_text" /> 60 <Button 61 android:layout_width="match_parent" 62 android:layout_height="50dp" 63 android:onClick="onRotaryButtonClick" 64 android:tag="test_button" 65 android:text="Button" /> 66 67 <!-- This button is disabled and is not focusable by RotaryService. 68 The RotaryService can see disabled views but it can't focus them. Android 69 doesn't allow disabled views to be focused. 70 The focus will skip this button when rotating the rotary countroller. --> 71 <Button 72 android:background="@color/button_disabled_background_color" 73 android:layout_width="match_parent" 74 android:layout_height="50dp" 75 android:onClick="onRotaryButtonClick" 76 android:enabled="false" 77 android:tag="test_button" 78 android:text="Disabled" /> 79 <Button 80 android:layout_width="match_parent" 81 android:layout_height="50dp" 82 android:onClick="onRotaryButtonClick" 83 android:tag="test_button" 84 android:text="Button" /> 85 <Button 86 android:layout_width="match_parent" 87 android:layout_height="50dp" 88 android:onClick="onRotaryButtonClick" 89 android:tag="test_button" 90 android:text="Button" /> 91 </com.android.car.ui.FocusArea> 92 93 <!-- A FocusArea where all elements are disabled. Elements that are disabled 94 (android:enabled="false") or not focusable (android:focusable="false") are 95 discoverable by the RotaryService, but the RotaryService will not focus them. 96 When no elements is focusable, nudging left and right from the adjacent cards 97 will cause focus to appear to skip this card --> 98 <com.android.car.ui.FocusArea 99 android:id="@+id/card_disabled" 100 android:background="@color/card_disabled_background_color" 101 android:layout_margin="16dp" 102 android:layout_width="@dimen/card_width" 103 android:layout_height="match_parent" 104 android:padding="@dimen/card_padding" 105 android:orientation="vertical"> 106 <TextView 107 android:layout_height="@dimen/description_height" 108 android:layout_width="match_parent" 109 android:text="@string/card_disabled_text" /> 110 <Button 111 android:layout_width="match_parent" 112 android:layout_height="50dp" 113 android:onClick="onRotaryButtonClick" 114 android:enabled="false" 115 android:tag="test_button" 116 android:text="Disabled" /> 117 <Button 118 android:layout_width="match_parent" 119 android:layout_height="50dp" 120 android:onClick="onRotaryButtonClick" 121 android:enabled="false" 122 android:tag="test_button" 123 android:text="Disabled" /> 124 <Button 125 android:layout_width="match_parent" 126 android:layout_height="50dp" 127 android:onClick="onRotaryButtonClick" 128 android:enabled="false" 129 android:tag="test_button" 130 android:text="Disabled" /> 131 <Button 132 android:layout_width="match_parent" 133 android:layout_height="50dp" 134 android:onClick="onRotaryButtonClick" 135 android:enabled="false" 136 android:tag="test_button" 137 android:text="Disabled" /> 138 </com.android.car.ui.FocusArea> 139 140 <!-- A FocusArea that contains a button with a default focus attribute. 141 Upon nudging into this area, the focus will land on the button with the default 142 focus attribute. Rotating the rotary controller clockwise will move the focus 143 from top to bottom. Counterclockwise to move the focus from bottom to up. 144 Nudge any direction to leave this focus area. --> 145 <com.android.car.ui.FocusArea 146 android:id="@+id/card_with_default_focus" 147 android:background="@color/card_background_color" 148 android:layout_margin="16dp" 149 android:layout_width="@dimen/card_width" 150 android:layout_height="match_parent" 151 android:padding="@dimen/card_padding" 152 android:orientation="vertical"> 153 <TextView 154 android:layout_height="@dimen/description_height" 155 android:layout_width="match_parent" 156 android:text="@string/card_with_default_focus_text" /> 157 <Button 158 android:layout_width="match_parent" 159 android:layout_height="50dp" 160 android:onClick="onRotaryButtonClick" 161 android:tag="test_button" 162 android:text="Button" /> 163 <!-- TODO(b/154180719): Make this button the default focus in this FocusArea --> 164 <Button 165 android:layout_width="match_parent" 166 android:layout_height="50dp" 167 android:onClick="onRotaryButtonClick" 168 android:tag="test_button" 169 android:text="Button (Default)" /> 170 <Button 171 android:layout_width="match_parent" 172 android:layout_height="50dp" 173 android:onClick="onRotaryButtonClick" 174 android:tag="test_button" 175 android:text="Button" /> 176 <Button 177 android:layout_width="match_parent" 178 android:layout_height="50dp" 179 android:onClick="onRotaryButtonClick" 180 android:tag="test_button" 181 android:text="Button" /> 182 </com.android.car.ui.FocusArea> 183 184 <!-- A FocusArea with buttons in a circle. The default focus should land on A. 185 Rotating clockwise moves the focus from A -> B -> C -> D -> E -> F -> G -> H, 186 and reverse counterclockwise. 187 Adding app:defaultFocus to A to make it the default focus on this card 188 Adding android:nextFocusForward is necessary to ensure the expected focus 189 order, without it, the focus will move from 190 G -> H -> F -> A -> E -> B -> D -> C. 191 Lastly, android:nextFocusForward is not added to H -> A, to avoid linking 192 the nodes in a circle. app:wrapAround="true" should be used instead. 193 --> 194 <!-- TODO(agathaman): add app:wrapAround to this card when b/155698037 is fixed --> 195 <!-- TODO(agathaman): add app:defaultFocus to this card when b/155698037 is fixed --> 196 <com.android.car.ui.FocusArea 197 android:id="@+id/card_that_wraps_around" 198 android:background="@color/card_background_color" 199 android:layout_margin="16dp" 200 android:layout_width="@dimen/card_width" 201 android:layout_height="match_parent" 202 android:padding="@dimen/card_padding" 203 android:orientation="vertical"> 204 <TextView 205 android:layout_height="@dimen/description_height" 206 android:layout_width="match_parent" 207 android:text="@string/card_that_wraps_around_text" /> 208 <androidx.constraintlayout.widget.ConstraintLayout 209 android:layout_width="match_parent" 210 android:layout_height="match_parent"> 211 <View 212 android:id="@+id/circle_center" 213 android:layout_width="wrap_content" 214 android:layout_height="wrap_content" 215 app:layout_constraintBottom_toBottomOf="parent" 216 app:layout_constraintLeft_toLeftOf="parent" 217 app:layout_constraintRight_toRightOf="parent" 218 app:layout_constraintTop_toTopOf="parent" /> 219 <Button 220 android:id="@+id/button_a" 221 android:layout_width="wrap_content" 222 android:layout_height="wrap_content" 223 android:nextFocusForward="@+id/button_b" 224 android:padding="20dp" 225 android:text="A" 226 app:layout_constraintCircle="@id/circle_center" 227 app:layout_constraintCircleAngle="0" 228 app:layout_constraintCircleRadius="90dp" 229 /> 230 <Button 231 android:id="@+id/button_b" 232 android:layout_width="wrap_content" 233 android:layout_height="wrap_content" 234 android:nextFocusForward="@+id/button_c" 235 android:padding="20dp" 236 android:text="B" 237 app:layout_constraintCircle="@id/circle_center" 238 app:layout_constraintCircleAngle="45" 239 app:layout_constraintCircleRadius="90dp" 240 /> 241 <Button 242 android:id="@+id/button_c" 243 android:layout_width="wrap_content" 244 android:layout_height="wrap_content" 245 android:nextFocusForward="@+id/button_d" 246 android:padding="20dp" 247 android:text="C" 248 app:layout_constraintCircle="@id/circle_center" 249 app:layout_constraintCircleAngle="90" 250 app:layout_constraintCircleRadius="90dp" 251 /> 252 <Button 253 android:id="@+id/button_d" 254 android:layout_width="wrap_content" 255 android:layout_height="wrap_content" 256 android:nextFocusForward="@+id/button_e" 257 android:padding="20dp" 258 android:text="D" 259 app:layout_constraintCircle="@id/circle_center" 260 app:layout_constraintCircleAngle="135" 261 app:layout_constraintCircleRadius="90dp" 262 /> 263 <Button 264 android:id="@+id/button_e" 265 android:layout_width="wrap_content" 266 android:layout_height="wrap_content" 267 android:nextFocusForward="@+id/button_f" 268 android:padding="20dp" 269 android:text="E" 270 app:layout_constraintCircle="@id/circle_center" 271 app:layout_constraintCircleAngle="180" 272 app:layout_constraintCircleRadius="90dp" 273 /> 274 <Button 275 android:id="@+id/button_f" 276 android:layout_width="wrap_content" 277 android:layout_height="wrap_content" 278 android:nextFocusForward="@+id/button_g" 279 android:padding="20dp" 280 android:text="F" 281 app:layout_constraintCircle="@id/circle_center" 282 app:layout_constraintCircleAngle="225" 283 app:layout_constraintCircleRadius="90dp" 284 /> 285 <Button 286 android:id="@+id/button_g" 287 android:layout_width="wrap_content" 288 android:layout_height="wrap_content" 289 android:nextFocusForward="@+id/button_h" 290 android:padding="20dp" 291 android:text="G" 292 app:layout_constraintCircle="@id/circle_center" 293 app:layout_constraintCircleAngle="270" 294 app:layout_constraintCircleRadius="90dp" 295 /> 296 <Button 297 android:id="@+id/button_h" 298 android:layout_width="wrap_content" 299 android:layout_height="wrap_content" 300 android:padding="20dp" 301 android:text="H" 302 app:layout_constraintCircle="@id/circle_center" 303 app:layout_constraintCircleAngle="315" 304 app:layout_constraintCircleRadius="90dp" 305 /> 306 </androidx.constraintlayout.widget.ConstraintLayout> 307 </com.android.car.ui.FocusArea> 308 </LinearLayout> 309 </HorizontalScrollView> 310</LinearLayout>