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

Commit e48e44f8 authored by Luna Zhang's avatar Luna Zhang Committed by Android (Google) Code Review
Browse files

Merge "Revamp the bluetooth details view UI." into main

parents f45748d4 7d9a1caf
Loading
Loading
Loading
Loading
+254 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 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.
  -->

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:id="@+id/root"
    style="@style/Widget.SliceView.Panel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <View
        android:id="@+id/bluetooth_tile_dialog_progress_background"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintEnd_toEndOf="@id/bluetooth_tile_dialog_progress_animation"
        app:layout_constraintStart_toStartOf="@id/bluetooth_tile_dialog_progress_animation"
        app:layout_constraintTop_toTopOf="@id/bluetooth_tile_dialog_progress_animation"
        app:layout_constraintBottom_toBottomOf="@id/bluetooth_tile_dialog_progress_animation"
        android:background="?androidprv:attr/colorSurfaceVariant" />

    <ProgressBar
        android:id="@+id/bluetooth_tile_dialog_progress_animation"
        android:layout_width="152dp"
        android:layout_height="4dp"
        android:layout_marginTop="16dp"
        style="@style/TrimmedHorizontalProgressBar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:visibility="invisible"
        android:indeterminate="true" />

    <androidx.core.widget.NestedScrollView
        android:id="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="21dp"
        android:minHeight="@dimen/bluetooth_dialog_scroll_view_min_height"
        android:fillViewport="true"
        app:layout_constrainedHeight="true"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/bluetooth_tile_dialog_progress_animation">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/scroll_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/bluetooth_toggle_title"
                android:layout_width="0dp"
                android:layout_height="68dp"
                android:maxLines="2"
                android:ellipsize="end"
                android:gravity="start|center_vertical"
                android:paddingEnd="15dp"
                android:paddingStart="36dp"
                android:text="@string/turn_on_bluetooth"
                android:clickable="false"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:textSize="16sp"
                app:layout_constraintEnd_toStartOf="@+id/bluetooth_toggle"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <Switch
                android:id="@+id/bluetooth_toggle"
                android:layout_width="wrap_content"
                android:layout_height="68dp"
                android:gravity="start|center_vertical"
                android:paddingEnd="40dp"
                android:contentDescription="@string/turn_on_bluetooth"
                android:switchMinWidth="@dimen/settingslib_switch_track_width"
                android:theme="@style/MainSwitch.Settingslib"
                android:thumb="@drawable/settingslib_switch_thumb"
                android:track="@drawable/settingslib_switch_track"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@+id/bluetooth_toggle_title"
                app:layout_constraintTop_toTopOf="parent" />

            <androidx.constraintlayout.widget.Group
                android:id="@+id/bluetooth_auto_on_toggle_layout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                app:constraint_referenced_ids="bluetooth_auto_on_toggle_title,bluetooth_auto_on_toggle,bluetooth_auto_on_toggle_info_icon,bluetooth_auto_on_toggle_info_text" />

            <TextView
                android:id="@+id/bluetooth_auto_on_toggle_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:minHeight="68dp"
                android:layout_marginBottom="20dp"
                android:maxLines="2"
                android:ellipsize="end"
                android:text="@string/turn_on_bluetooth_auto_tomorrow"
                android:gravity="start|center_vertical"
                android:paddingEnd="15dp"
                android:paddingStart="36dp"
                android:clickable="false"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:textSize="16sp"
                app:layout_constraintEnd_toStartOf="@+id/bluetooth_auto_on_toggle"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/bluetooth_toggle_title" />

            <Switch
                android:id="@+id/bluetooth_auto_on_toggle"
                android:layout_width="wrap_content"
                android:layout_height="68dp"
                android:layout_marginBottom="20dp"
                android:gravity="start|center_vertical"
                android:paddingEnd="40dp"
                android:contentDescription="@string/turn_on_bluetooth_auto_tomorrow"
                android:switchMinWidth="@dimen/settingslib_switch_track_width"
                android:theme="@style/MainSwitch.Settingslib"
                android:thumb="@drawable/settingslib_switch_thumb"
                android:track="@drawable/settingslib_switch_track"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@+id/bluetooth_auto_on_toggle_title"
                app:layout_constraintTop_toBottomOf="@+id/bluetooth_toggle" />

            <ImageView
                android:id="@+id/bluetooth_auto_on_toggle_info_icon"
                android:src="@drawable/ic_info_outline"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:tint="?android:attr/textColorTertiary"
                android:paddingStart="36dp"
                android:layout_marginTop="20dp"
                android:layout_marginBottom="@dimen/bluetooth_dialog_layout_margin"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/bluetooth_auto_on_toggle" />

            <TextView
                android:id="@+id/bluetooth_auto_on_toggle_info_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:paddingStart="36dp"
                android:paddingEnd="40dp"
                android:textSize="14sp"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/bluetooth_auto_on_toggle_info_icon" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/device_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/bluetooth_toggle" />

            <Button
                android:id="@+id/see_all_button"
                style="@style/BluetoothTileDialog.Device"
                android:paddingEnd="0dp"
                android:paddingStart="26dp"
                android:background="@drawable/bluetooth_tile_dialog_bg_off"
                android:layout_width="0dp"
                android:layout_height="64dp"
                android:contentDescription="@string/accessibility_bluetooth_device_settings_see_all"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/device_list"
                app:layout_constraintBottom_toTopOf="@+id/pair_new_device_button"
                android:drawableStart="@drawable/ic_arrow_forward"
                android:drawablePadding="26dp"
                android:drawableTint="?android:attr/textColorPrimary"
                android:text="@string/see_all_bluetooth_devices"
                android:textSize="14sp"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:textDirection="locale"
                android:textAlignment="viewStart"
                android:maxLines="1"
                android:ellipsize="end"
                android:visibility="gone" />

            <Button
                android:id="@+id/pair_new_device_button"
                style="@style/BluetoothTileDialog.Device"
                android:paddingEnd="0dp"
                android:paddingStart="26dp"
                android:background="@drawable/bluetooth_tile_dialog_bg_off"
                android:layout_width="0dp"
                android:layout_height="64dp"
                android:contentDescription="@string/accessibility_bluetooth_device_settings_pair_new_device"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/see_all_button"
                android:drawableStart="@drawable/ic_add"
                android:drawablePadding="26dp"
                android:drawableTint="?android:attr/textColorPrimary"
                android:text="@string/pair_new_bluetooth_devices"
                android:textSize="14sp"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:textDirection="locale"
                android:textAlignment="viewStart"
                android:maxLines="1"
                android:ellipsize="end"
                android:visibility="gone" />

            <androidx.constraintlayout.widget.Barrier
                android:id="@+id/barrier"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:barrierDirection="bottom"
                app:constraint_referenced_ids="pair_new_device_button,bluetooth_auto_on_toggle_info_text" />

            <Button
                android:id="@+id/audio_sharing_button"
                style="@style/BluetoothTileDialog.AudioSharingButton"
                android:textAppearance="@style/TextAppearance.BluetoothTileDialog"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="9dp"
                android:layout_marginBottom="@dimen/dialog_bottom_padding"
                android:layout_marginEnd="@dimen/dialog_side_padding"
                android:layout_marginStart="@dimen/dialog_side_padding"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="@string/quick_settings_bluetooth_audio_sharing_button"
                android:drawableStart="@drawable/ic_bt_le_audio_sharing_18dp"
                android:drawablePadding="10dp"
                app:layout_constrainedWidth="true"
                app:layout_constraintHorizontal_bias="0"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/barrier"
                app:layout_constraintVertical_bias="1"
                android:visibility="gone" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ fun BluetoothDetailsContent(detailsContentViewModel: BluetoothDetailsContentView
            // Inflate with the existing dialog xml layout
            val view =
                LayoutInflater.from(context)
                    .inflate(R.layout.bluetooth_tile_dialog, /* root= */ null)
                    .inflate(R.layout.bluetooth_tile_details, /* root= */ null)
            detailsContentViewModel.bindDetailsView(view)
            view
        },
+19 −25
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.bluetooth.ui.viewModel.BluetoothDetailsContentViewModel
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.qs.flags.QsDetailedView
import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.util.annotations.DeprecatedSysuiVisibleForTesting
@@ -127,10 +128,7 @@ constructor(

    // UI Components
    private lateinit var contentView: View
    private lateinit var doneButton: Button
    private lateinit var bluetoothToggle: Switch
    private lateinit var titleTextView: TextView
    private lateinit var subtitleTextView: TextView
    private lateinit var seeAllButton: View
    private lateinit var pairNewDeviceButton: View
    private lateinit var deviceListView: RecyclerView
@@ -142,6 +140,11 @@ constructor(
    private lateinit var progressBarBackground: View
    private lateinit var scrollViewContent: View

    // UI Components that only exist in dialog, but not tile details view.
    private var doneButton: Button? = null
    private var titleTextView: TextView? = null
    private var subtitleTextView: TextView? = null

    @AssistedFactory
    interface Factory {
        fun create(
@@ -162,10 +165,7 @@ constructor(
        this.contentView = contentView
        this.coroutineScope = coroutineScope

        doneButton = contentView.requireViewById(R.id.done_button)
        bluetoothToggle = contentView.requireViewById(R.id.bluetooth_toggle)
        titleTextView = contentView.requireViewById(R.id.bluetooth_tile_dialog_title)
        subtitleTextView = contentView.requireViewById(R.id.bluetooth_tile_dialog_subtitle)
        seeAllButton = contentView.requireViewById(R.id.see_all_button)
        pairNewDeviceButton = contentView.requireViewById(R.id.pair_new_device_button)
        deviceListView = contentView.requireViewById(R.id.device_list)
@@ -180,19 +180,23 @@ constructor(
            contentView.requireViewById(R.id.bluetooth_tile_dialog_progress_background)
        scrollViewContent = contentView.requireViewById(R.id.scroll_view)

        setupToggle()
        setupRecyclerView()
        setupDoneButton()

        if (isInDialog) {
            subtitleTextView.text = contentView.context.getString(initialUiProperties.subTitleResId)
        } else {
            // If `QsDetailedView` is enabled, it should show the details view.
            QsDetailedView.assertInLegacyMode()

            // If rendering with tile details view, the title and subtitle will be added in the
            // `TileDetails`
            titleTextView.visibility = GONE
            subtitleTextView.visibility = GONE
            titleTextView = contentView.requireViewById(R.id.bluetooth_tile_dialog_title)
            subtitleTextView = contentView.requireViewById(R.id.bluetooth_tile_dialog_subtitle)
            // If rendering with tile details view, done button shouldn't exist.
            doneButton = contentView.requireViewById(R.id.done_button)
        }

        setupToggle()
        setupRecyclerView()

        doneButton?.setOnClickListener { doneButtonCallback() }
        subtitleTextView?.text = contentView.context.getString(initialUiProperties.subTitleResId)
        seeAllButton.setOnClickListener { onSeeAllClicked(it) }
        pairNewDeviceButton.setOnClickListener { onPairNewDeviceClicked(it) }
        audioSharingButton.apply {
@@ -342,9 +346,7 @@ constructor(
            setEnabled(true)
            alpha = ENABLED_ALPHA
        }
        if (isInDialog) {
            subtitleTextView.text = contentView.context.getString(uiProperties.subTitleResId)
        }
        subtitleTextView?.text = contentView.context.getString(uiProperties.subTitleResId)
        autoOnToggleLayout.visibility = uiProperties.autoOnToggleVisibility
    }

@@ -392,14 +394,6 @@ constructor(
        }
    }

    private fun setupDoneButton() {
        if (isInDialog) {
            doneButton.setOnClickListener { doneButtonCallback() }
        } else {
            doneButton.visibility = GONE
        }
    }

    private fun setupRecyclerView() {
        deviceListView.apply {
            layoutManager = LinearLayoutManager(contentView.context)