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

Commit f311c6dc authored by Chelsea Hao's avatar Chelsea Hao Committed by Android (Google) Code Review
Browse files

Merge changes from topic "bt-tile" into main

* changes:
  Handle bluetooth callback and toggle switch, also moved `getDeviceItems` to background thread.
  Filled in devices for BluetoothTileDialog and implemented click callback.
  Create BluetoothTileDialog.
parents f360c91f 23affd99
Loading
Loading
Loading
Loading
+68 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2023 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.
  -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/bluetooth_device_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_marginBottom="4dp">

    <LinearLayout
        android:id="@+id/bluetooth_device"
        style="@style/BluetoothTileDialog.Device"
        android:layout_height="@dimen/bluetooth_dialog_device_height"
        android:paddingEnd="24dp"
        android:paddingStart="20dp"
        android:baselineAligned="false">

        <FrameLayout
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_gravity="center_vertical|start"
            android:clickable="false">

            <ImageView
                android:id="@+id/bluetooth_device_icon"
                android:contentDescription="@string/accessibility_bluetooth_device_icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center" />
        </FrameLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="@dimen/bluetooth_dialog_device_height"
            android:paddingStart="20dp"
            android:paddingEnd="24dp"
            android:layout_marginEnd="30dp"
            android:layout_weight="1"
            android:clickable="false"
            android:gravity="start|center_vertical"
            android:orientation="vertical">

            <TextView
                android:id="@+id/bluetooth_device_name"
                style="@style/BluetoothTileDialog.DeviceName"
                android:textSize="14sp" />

            <TextView
                android:id="@+id/bluetooth_device_summary"
                style="@style/BluetoothTileDialog.DeviceSummary" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>
 No newline at end of file
+168 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2023 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.
  -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root"
    android:layout_width="@dimen/large_dialog_width"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
        style="@style/Widget.SliceView.Panel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/bluetooth_dialog_layout_margin"
        android:layout_marginTop="24dp"
        android:gravity="center_vertical|center_horizontal"
        android:orientation="vertical">

        <TextView
            android:id="@+id/bluetooth_tile_dialog_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:gravity="center_vertical|center_horizontal"
            android:text="@string/quick_settings_bluetooth_label"
            android:textAppearance="@style/TextAppearance.Dialog.Title"
            android:textSize="24sp" />

        <TextView
            android:id="@+id/bluetooth_tile_dialog_subtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:ellipsize="end"
            android:gravity="center_vertical|center_horizontal"
            android:maxLines="1"
            android:text="@string/quick_settings_bluetooth_tile_subtitle"
            android:textAppearance="@style/TextAppearance.Dialog.Body.Message" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/turn_on_bluetooth_layout"
        style="@style/BluetoothTileDialog.Device"
        android:layout_height="@dimen/bluetooth_dialog_device_height"
        android:gravity="center"
        android:clickable="false"
        android:focusable="false"
        android:baselineAligned="false">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="start|center_vertical"
            android:orientation="vertical"
            android:clickable="false">
            <TextView
                android:id="@+id/bluetooth_toggle_title"
                android:text="@string/turn_on_bluetooth"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="start|center_vertical"
                android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
                android:textSize="16sp"/>
        </LinearLayout>

        <FrameLayout
            android:layout_width="@dimen/settingslib_switch_track_width"
            android:layout_height="48dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp">
            <Switch
                android:id="@+id/bluetooth_toggle"
                android:contentDescription="@string/turn_on_bluetooth"
                android:switchMinWidth="@dimen/settingslib_switch_track_width"
                android:layout_gravity="center"
                android:layout_width="@dimen/settingslib_switch_track_width"
                android:layout_height="match_parent"
                android:track="@drawable/settingslib_track_selector"
                android:thumb="@drawable/settingslib_thumb_selector"
                android:theme="@style/MainSwitch.Settingslib"/>
        </FrameLayout>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/body_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/device_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:nestedScrollingEnabled="false"
            android:overScrollMode="never"
            android:scrollbars="vertical" />

        <LinearLayout
            android:id="@+id/see_all_layout"
            style="@style/BluetoothTileDialog.Device"
            android:layout_height="64dp"
            android:paddingStart="20dp"
            android:visibility="gone">

            <FrameLayout
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_gravity="center_vertical|start"
                android:clickable="false">

                <ImageView
                    android:id="@+id/arrow_forward"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_arrow_forward"
                    android:importantForAccessibility="no" />
            </FrameLayout>

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginStart="@dimen/bluetooth_dialog_layout_margin"
                android:clickable="false"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:gravity="start|center_vertical"
                    android:text="@string/see_all_bluetooth_devices"
                    android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
                    android:textSize="14sp" />
            </FrameLayout>
        </LinearLayout>

        <Button
            android:id="@+id/done_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginStart="@dimen/dialog_side_padding"
            android:layout_marginEnd="@dimen/dialog_side_padding"
            android:layout_marginBottom="@dimen/dialog_bottom_padding"
            android:text="@string/inline_done_button"
            android:layout_gravity="end|center_vertical"
            style="@style/Widget.Dialog.Button"
            android:maxLines="1"
            android:ellipsize="end"
            android:clickable="true"
            android:focusable="true"/>
    </LinearLayout>
</LinearLayout>
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -1643,6 +1643,11 @@
    <!-- Radius of switch track -->
    <dimen name="settingslib_switch_track_radius">35dp</dimen>

    <!-- Bluetooth dialog related dimensions -->
    <dimen name="bluetooth_dialog_layout_margin">16dp</dimen>
    <!-- The height of the bluetooth device in bluetooth dialog. -->
    <dimen name="bluetooth_dialog_device_height">72dp</dimen>

    <!-- Height percentage of the parent container occupied by the communal view -->
    <item name="communal_source_height_percentage" format="float" type="dimen">0.80</item>

+14 −0
Original line number Diff line number Diff line
@@ -459,6 +459,9 @@

    <!-- Content description of the bluetooth icon when connected for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_bluetooth_connected">Bluetooth connected.</string>

    <!-- Content description of the bluetooth device icon. [CHAR LIMIT=NONE] -->
    <string name="accessibility_bluetooth_device_icon">Bluetooth device icon</string>
    <!-- Content description of the bluetooth icon when connecting for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->

    <!-- Content description of the battery when battery state is unknown for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
@@ -621,6 +624,17 @@
    <!-- QuickSettings: Bluetooth (Off) [CHAR LIMIT=NONE] -->
    <!-- QuickSettings: Bluetooth detail panel, text when there are no items [CHAR LIMIT=NONE] -->
    <string name="quick_settings_bluetooth_detail_empty_text">No paired devices available</string>
    <!-- QuickSettings: Bluetooth dialog subtitle [CHAR LIMIT=NONE]-->
    <string name="quick_settings_bluetooth_tile_subtitle">Tap to connect or disconnect</string>
    <!-- QuickSettings: Bluetooth dialog see all devices [CHAR LIMIT=NONE]-->
    <string name="see_all_bluetooth_devices">See all</string>
    <!-- QuickSettings: Bluetooth dialog turn on Bluetooth [CHAR LIMIT=NONE]-->
    <string name="turn_on_bluetooth">Use Bluetooth</string>
    <!-- QuickSettings: Bluetooth dialog device connected default summary [CHAR LIMIT=NONE]-->
    <string name="quick_settings_bluetooth_device_connected">Connected</string>
    <!-- QuickSettings: Bluetooth dialog device saved default summary [CHAR LIMIT=NONE]-->
    <string name="quick_settings_bluetooth_device_saved">Saved</string>

    <!-- QuickSettings: Bluetooth secondary label for the battery level of a connected device [CHAR LIMIT=20]-->
    <string name="quick_settings_bluetooth_secondary_label_battery_level"><xliff:g id="battery_level_as_percentage">%s</xliff:g> battery</string>
    <!-- QuickSettings: Bluetooth secondary label for an audio device being connected [CHAR LIMIT=20]-->
+57 −25
Original line number Diff line number Diff line
@@ -929,7 +929,8 @@
        <item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
    </style>

     <style name="Theme.SystemUI.Dialog.Control.DetailPanel" parent="@android:style/Theme.DeviceDefault.Dialog.NoActionBar">
    <style name="Theme.SystemUI.Dialog.Control.DetailPanel"
           parent="@android:style/Theme.DeviceDefault.Dialog.NoActionBar">
        <item name="android:windowFullscreen">false</item>
        <item name="android:windowIsFloating">false</item>
        <item name="android:windowBackground">@color/controls_task_view_bg</item>
@@ -1254,6 +1255,37 @@
        <item name="android:textColor">?android:attr/textColorSecondary</item>
    </style>

    <style name="BluetoothTileDialog">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_gravity">center_vertical|start</item>
    </style>

    <style name="BluetoothTileDialog.Device">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">88dp</item>
        <item name="android:layout_gravity">center_vertical|start</item>
        <item name="android:layout_marginStart">@dimen/bluetooth_dialog_layout_margin</item>
        <item name="android:layout_marginEnd">@dimen/bluetooth_dialog_layout_margin</item>
        <item name="android:paddingStart">22dp</item>
        <item name="android:paddingEnd">22dp</item>
        <item name="android:orientation">horizontal</item>
        <item name="android:focusable">true</item>
        <item name="android:clickable">true</item>
    </style>

    <style name="BluetoothTileDialog.DeviceName">
        <item name="android:textSize">14sp</item>
        <item name="android:textAppearance">@style/TextAppearance.Dialog.Title</item>
    </style>

    <style name="BluetoothTileDialog.DeviceSummary">
        <item name="android:layout_marginEnd">7dp</item>
        <item name="android:ellipsize">end</item>
        <item name="android:maxLines">2</item>
        <item name="android:textAppearance">@style/TextAppearance.Dialog.Body.Message</item>
    </style>

    <style name="BroadcastDialog">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
Loading