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

Commit 41937766 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Introduce SwitchBar widget

- SwitchBar is a LinearLayout that containts a TextView and a Switch and
is intended to replace all Switches that are put in the ActionBar as a
custom view
- use the new SwitchBar for WifiSetting only for now (a later CL will
take care of all the other Setting that are using a Switch in the
ActionBar)

Related to bug #14898161 On/Off switches must move down from Action Bar

Change-Id: I5e98dbe995bba8f440d08459e09ca3ac09d3464b
parent a1ebae6f
Loading
Loading
Loading
Loading
+36 −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.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:state_checked="true">
        <nine-patch android:src="@*android:drawable/switch_on_qntm_alpha"
                    android:tint="?android:attr/colorControlNormal"
                    android:alpha="?android:attr/disabledAlpha" />
    </item>
    <item android:state_enabled="false">
        <nine-patch android:src="@*android:drawable/switch_off_qntm_alpha"
                    android:tint="?android:attr/colorControlNormal"
                    android:alpha="?android:attr/disabledAlpha" />
    </item>
    <item android:state_checked="true">
        <nine-patch android:src="@*android:drawable/switch_on_qntm_alpha"
                    android:tint="@color/switch_accent_color" />
    </item>
    <item>
        <nine-patch android:src="@*android:drawable/switch_off_qntm_alpha"
                    android:tint="?android:attr/colorControlNormal" />
    </item>
</selector>
+26 −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.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true">
        <nine-patch android:src="@*android:drawable/switch_track_qntm_alpha"
                    android:tint="@color/switch_accent_color" />
    </item>
    <item>
        <nine-patch android:src="@*android:drawable/switch_track_qntm_alpha"
                    android:tint="?android:attr/colorControlNormal" />
    </item>
</selector>
+7 −0
Original line number Diff line number Diff line
@@ -27,6 +27,12 @@
            android:layout_height="match_parent"
            android:layout_width="match_parent">

        <com.android.settings.widget.SwitchBar android:id="@+id/switch_bar"
                  android:layout_height="?android:attr/actionBarSize"
                  android:layout_width="match_parent"
                  android:background="@color/switch_bar_background_color"
                  android:theme="@android:style/Theme.Quantum" />

        <FrameLayout
                android:id="@+id/prefs"
                android:layout_width="match_parent"
@@ -49,6 +55,7 @@
                android:layout_alignParentStart="true"
                android:text="@*android:string/back_button_label"
                />

        <LinearLayout
                android:orientation="horizontal"
                android:layout_width="wrap_content"
+37 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 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.
*/
-->

<merge xmlns:android="http://schemas.android.com/apk/res/android" >

    <TextView android:id="@+id/switch_text"
              android:layout_height="wrap_content"
              android:layout_width="0dp"
              android:layout_weight="1"
              android:paddingStart="32dp"
              android:layout_gravity="center_vertical"
              android:textAppearance="@style/TextAppearance.Switch"
              android:textAlignment="viewStart" />

    <Switch android:id="@+id/switch_widget"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:paddingEnd="32dp" />
</merge>
+2 −0
Original line number Diff line number Diff line
@@ -62,4 +62,6 @@

    <color name="actionbar_background_color">#ff263238</color>
    <color name="dashboard_background_color">#ffe1e1e0</color>
    <color name="switch_bar_background_color">#ff384248</color>
    <color name="switch_accent_color">#ff7fcac3</color>
</resources>
Loading