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

Commit 8a4fdc10 authored by chelseahao's avatar chelseahao Committed by Chelsea Hao
Browse files

Layout tweak.

1) Made layout scrollable, so that the layout displays properly in landscape mode.
2) Fixed accessibility bug.

Test: atest -c com.android.systemui.qs.tiles.dialog.bluetooth
Bug: b/299568986 b/299569377
Change-Id: Ib6a2ce41fb162b6bf299f2f58b8bf64e83c21a90
parent 0bab1185
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -44,10 +44,9 @@
        android:paddingTop="10dp"
        android:maxLines="1"
        android:ellipsize="end"
        app:layout_constraintWidth_percent="0.7"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toEndOf="@+id/bluetooth_device_icon"
        app:layout_constraintEnd_toStartOf="@+id/gear_icon"
        app:layout_constraintEnd_toStartOf="@+id/guideline"
        app:layout_constraintBottom_toTopOf="@+id/bluetooth_device_summary"
        android:gravity="center_vertical"
        android:textSize="14sp" />
@@ -60,34 +59,35 @@
        android:paddingBottom="10dp"
        android:maxLines="1"
        android:ellipsize="end"
        app:layout_constraintWidth_percent="0.7"
        app:layout_constraintTop_toBottomOf="@+id/bluetooth_device_name"
        app:layout_constraintStart_toEndOf="@+id/bluetooth_device_icon"
        app:layout_constraintEnd_toStartOf="@+id/gear_icon"
        app:layout_constraintEnd_toStartOf="@+id/guideline"
        app:layout_constraintBottom_toBottomOf="parent"
        android:gravity="center_vertical" />

    <androidx.constraintlayout.widget.Guideline
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/guideline"
        app:layout_constraintGuide_percent="0.8"
        android:orientation="vertical"/>

    <View
        android:id="@+id/gear_icon"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:contentDescription="@string/accessibility_bluetooth_device_settings_gear"
        app:layout_constraintStart_toEndOf="@+id/bluetooth_device_name"
        app:layout_constraintEnd_toEndOf="@+id/gear_icon_image"
        app:layout_constraintStart_toEndOf="@+id/guideline"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent" />

    <ImageView
        android:id="@+id/gear_icon_image"
        android:src="@drawable/ic_settings_24dp"
        android:contentDescription="@string/accessibility_bluetooth_device_settings_gear"
        android:layout_width="0dp"
        android:layout_height="24dp"
        app:layout_constraintStart_toEndOf="@+id/bluetooth_device_name"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:src="@drawable/ic_settings_24dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintWidth_percent="0.3"
        android:gravity="center_vertical"
        android:paddingStart="10dp" />
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
 No newline at end of file
+143 −130
Original line number Diff line number Diff line
@@ -51,34 +51,48 @@
        android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toTopOf="@id/bluetooth_toggle_title"
        app:layout_constraintBottom_toTopOf="@+id/scroll_view"
        app:layout_constraintTop_toBottomOf="@id/bluetooth_tile_dialog_title" />

    <androidx.core.widget.NestedScrollView
        android:id="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constrainedHeight="true"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/bluetooth_tile_dialog_subtitle">

        <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"
        style="@style/BluetoothTileDialog.Device"
                android:layout_width="0dp"
                android:layout_height="64dp"
                android:maxLines="1"
                android:ellipsize="end"
        android:gravity="center_vertical"
        android:layout_marginTop="4dp"
                android:gravity="start|center_vertical"
                android:paddingEnd="0dp"
                android:paddingStart="36dp"
                android:text="@string/turn_on_bluetooth"
                android:clickable="false"
                android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
                android:textSize="16sp"
                app:layout_constraintEnd_toStartOf="@+id/bluetooth_toggle"
                app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/bluetooth_tile_dialog_subtitle" />
                app:layout_constraintBottom_toTopOf="@+id/device_list"
                app:layout_constraintTop_toTopOf="parent" />

            <Switch
                android:id="@+id/bluetooth_toggle"
        style="@style/BluetoothTileDialog.Device"
        android:layout_width="0dp"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
        android:gravity="center|center_vertical"
        android:paddingEnd="24dp"
        android:layout_marginTop="10dp"
                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"
@@ -86,19 +100,17 @@
                android:track="@drawable/settingslib_track_selector"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@+id/bluetooth_toggle_title"
        app:layout_constraintTop_toBottomOf="@id/bluetooth_tile_dialog_subtitle" />
                app:layout_constraintBottom_toTopOf="@+id/device_list"
                app:layout_constraintTop_toTopOf="parent" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/device_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:nestedScrollingEnabled="false"
        android:overScrollMode="never"
        android:scrollbars="vertical"
                android:layout_marginTop="10dp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/bluetooth_toggle"
                app:layout_constraintTop_toBottomOf="@+id/bluetooth_toggle"
                app:layout_constraintBottom_toTopOf="@+id/see_all_text" />

            <androidx.constraintlayout.widget.Group
@@ -173,7 +185,6 @@
                android:text="@string/pair_new_bluetooth_devices"
                android:textSize="14sp"
                android:textAppearance="@style/TextAppearance.Dialog.Title"
        app:layout_constraintBottom_toTopOf="@id/done_button"
                app:layout_constraintStart_toEndOf="@+id/ic_add"
                app:layout_constraintTop_toBottomOf="@id/see_all_text"
                app:layout_constraintEnd_toEndOf="parent" />
@@ -191,7 +202,9 @@
                android:focusable="true"
                android:maxLines="1"
                android:text="@string/inline_done_button"
        app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/pair_new_device_text" />
                app:layout_constraintTop_toBottomOf="@id/pair_new_device_text"
                app:layout_constraintBottom_toBottomOf="parent" />
        </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
@@ -466,7 +466,7 @@
    <string name="accessibility_bluetooth_device_icon">Bluetooth device icon</string>

    <!-- Content description of the bluetooth device settings gear icon. [CHAR LIMIT=NONE] -->
    <string name="accessibility_bluetooth_device_settings_gear">Bluetooth device settings gear</string>
    <string name="accessibility_bluetooth_device_settings_gear">Click to configure device detail</string>

    <!-- Content description of the battery when battery state is unknown for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_battery_unknown">Battery percentage unknown.</string>
+16 −3
Original line number Diff line number Diff line
@@ -78,7 +78,10 @@ constructor(
        super.onCreate(savedInstanceState)
        uiEventLogger.log(BluetoothTileDialogUiEvent.BLUETOOTH_TILE_DIALOG_SHOWN)

        setContentView(LayoutInflater.from(context).inflate(R.layout.bluetooth_tile_dialog, null))
        LayoutInflater.from(context).inflate(R.layout.bluetooth_tile_dialog, null).apply {
            accessibilityPaneTitle = context.getText(R.string.accessibility_desc_quick_settings)
            setContentView(this)
        }

        toggleView = requireViewById(R.id.bluetooth_toggle)
        subtitleTextView = requireViewById(R.id.bluetooth_tile_dialog_subtitle) as TextView
@@ -114,14 +117,22 @@ constructor(
    }

    internal fun onBluetoothStateUpdated(isEnabled: Boolean, subtitleResId: Int) {
        toggleView.isChecked = isEnabled
        toggleView.apply {
            isChecked = isEnabled
            setEnabled(true)
            alpha = ENABLED_ALPHA
        }
        subtitleTextView.text = context.getString(subtitleResId)
    }

    private fun setupToggle() {
        toggleView.isChecked = bluetoothToggleInitialValue
        toggleView.setOnCheckedChangeListener { _, isChecked ->
        toggleView.setOnCheckedChangeListener { view, isChecked ->
            mutableBluetoothStateToggle.value = isChecked
            view.apply {
                isEnabled = false
                alpha = DISABLED_ALPHA
            }
            logger.logBluetoothState(BluetoothStateStage.USER_TOGGLED, isChecked.toString())
            uiEventLogger.log(BluetoothTileDialogUiEvent.BLUETOOTH_TOGGLE_CLICKED)
        }
@@ -225,5 +236,7 @@ constructor(
        const val ACTION_PREVIOUSLY_CONNECTED_DEVICE =
            "com.android.settings.PREVIOUSLY_CONNECTED_DEVICE"
        const val ACTION_PAIR_NEW_DEVICE = "android.settings.BLUETOOTH_PAIRING_SETTINGS"
        const val DISABLED_ALPHA = 0.3f
        const val ENABLED_ALPHA = 1f
    }
}