Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef02e3e5 authored by Cole Faust's avatar Cole Faust
Browse files

Create ux restricted customizations for DeviceDefault buttons and switches

In automotive, onscreen components can be "ux restricted",
which means you can't use them at the moment for safety reasons,
for example while driving. Make DeviceDefaults buttons and
switches visually change to indicate to the user that they
are ux restricted.

Fixes: 178644245
Test: Manually
Change-Id: I5bccf4c0331fa496be9b90fb41381c9b674bf237
parent 6c1e9153
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,5 +16,6 @@ limitations under the License.
<!-- Default text colors for car buttons when enabled/disabled. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@*android:color/car_grey_700" android:state_enabled="false"/>
    <item android:color="@*android:color/car_grey_700" android:state_ux_restricted="true"/>
    <item android:color="?android:attr/colorButtonNormal"/>
</selector>
+27 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<!-- copy of switch_track_material, but with a ux restricted state -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false"
          android:color="?attr/colorForeground"
          android:alpha="?attr/disabledAlpha" />
    <item android:state_ux_restricted="true"
          android:color="?attr/colorForeground"
          android:alpha="?attr/disabledAlpha" />
    <item android:state_checked="true"
          android:color="?attr/colorControlActivated" />
    <item android:color="?attr/colorForeground" />
</selector>
+22 −0
Original line number Diff line number Diff line
@@ -25,6 +25,22 @@ limitations under the License.
                    android:color="#0059B3"/>
        </shape>
    </item>
    <item android:state_focused="true" android:state_pressed="true" android:state_ux_restricted="true">
        <shape android:shape="rectangle">
            <corners android:radius="@*android:dimen/car_button_radius"/>
            <solid android:color="@*android:color/car_grey_300"/>
            <stroke android:width="4dp"
                    android:color="#0059B3"/>
        </shape>
    </item>
    <item android:state_focused="true" android:state_ux_restricted="true">
        <shape android:shape="rectangle">
            <corners android:radius="@*android:dimen/car_button_radius"/>
            <solid android:color="@*android:color/car_grey_300"/>
            <stroke android:width="8dp"
                    android:color="#0059B3"/>
        </shape>
    </item>
    <item android:state_focused="true" android:state_pressed="true">
        <shape android:shape="rectangle">
            <corners android:radius="@*android:dimen/car_button_radius"/>
@@ -47,6 +63,12 @@ limitations under the License.
            <solid android:color="@*android:color/car_grey_300"/>
        </shape>
    </item>
    <item android:state_ux_restricted="true">
        <shape android:shape="rectangle">
            <corners android:radius="@*android:dimen/car_button_radius"/>
            <solid android:color="@*android:color/car_grey_300"/>
        </shape>
    </item>
    <item>
        <ripple android:color="?android:attr/colorControlHighlight">
            <item>
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@
      android:right="@dimen/car_switch_track_margin_size">
    <shape
        android:shape="rectangle"
        android:tint="@color/switch_track_material">
        android:tint="@color/car_switch_track">
      <corners android:radius="7dp" />
      <solid android:color="@color/white_disabled_material" />
      <size android:height="14dp" />
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- Formatting note: terminate all comments with a period, to avoid breaking
     the documentation output. To suppress comment lines from the documentation
     output, insert an eat-comment element after the comment lines.
-->

<resources>
     <attr name="state_ux_restricted" format="boolean"/>
</resources>