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

Commit ef0a3d90 authored by chelseahao's avatar chelseahao
Browse files

Update auto on text based on toggle value.

Test: atest -c com.android.systemui.qs.tiles.dialog.bluetooth
Bug: b/316822488 b/316985153
Flag: ACONFIG com.android.settingslib.flags.bluetooth_qs_tile_dialog_auto_on_toggle DISABLED
Change-Id: I28b1f8c7a855eeff890c26ba3cbc8dd4139e883d
parent a8f16894
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -181,12 +181,11 @@

            <TextView
                android:id="@+id/bluetooth_auto_on_toggle_info_text"
                android:layout_width="wrap_content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:paddingStart="36dp"
                android:paddingEnd="40dp"
                android:text="@string/turn_on_bluetooth_auto_info"
                android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
+4 −2
Original line number Diff line number Diff line
@@ -675,8 +675,10 @@
    <string name="accessibility_quick_settings_bluetooth_device_tap_to_activate">activate</string>
    <!-- QuickSettings: Bluetooth auto on tomorrow [CHAR LIMIT=NONE]-->
    <string name="turn_on_bluetooth_auto_tomorrow">Automatically turn on again tomorrow</string>
    <!-- QuickSettings: Bluetooth auto on info text [CHAR LIMIT=NONE]-->
    <string name="turn_on_bluetooth_auto_info">Features like Quick Share, Find My Device, and device location use Bluetooth</string>
    <!-- QuickSettings: Bluetooth auto on info text when disabled [CHAR LIMIT=NONE]-->
    <string name="turn_on_bluetooth_auto_info_disabled">Features like Quick Share, Find My Device, and device location use Bluetooth</string>
    <!-- QuickSettings: Bluetooth auto on info text when enabled [CHAR LIMIT=NONE]-->
    <string name="turn_on_bluetooth_auto_info_enabled">Bluetooth will turn on tomorrow at 5 AM</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>
+11 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.Switch
import android.widget.TextView
import androidx.annotation.StringRes
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
@@ -204,12 +205,17 @@ internal constructor(
        getAutoOnToggleView(dialog).visibility = uiProperties.autoOnToggleVisibility
    }

    internal fun onBluetoothAutoOnUpdated(dialog: SystemUIDialog, isEnabled: Boolean) {
    internal fun onBluetoothAutoOnUpdated(
        dialog: SystemUIDialog,
        isEnabled: Boolean,
        @StringRes infoResId: Int
    ) {
        getAutoOnToggle(dialog).apply {
            isChecked = isEnabled
            setEnabled(true)
            alpha = ENABLED_ALPHA
        }
        getAutoOnToggleInfoTextView(dialog).text = context.getString(infoResId)
    }

    private fun setupToggle(dialog: SystemUIDialog) {
@@ -264,6 +270,10 @@ internal constructor(
        return dialog.requireViewById(R.id.bluetooth_auto_on_toggle_layout)
    }

    private fun getAutoOnToggleInfoTextView(dialog: SystemUIDialog): TextView {
        return dialog.requireViewById(R.id.bluetooth_auto_on_toggle_info_text)
    }

    private fun getProgressBarAnimation(dialog: SystemUIDialog): ProgressBar {
        return dialog.requireViewById(R.id.bluetooth_tile_dialog_progress_animation)
    }
+8 −1
Original line number Diff line number Diff line
@@ -191,7 +191,14 @@ constructor(
                    // bluetoothAutoOnUpdate is emitted when bluetooth auto on on/off state is
                    // changed.
                    bluetoothAutoOnInteractor.isEnabled
                        .onEach { dialogDelegate.onBluetoothAutoOnUpdated(dialog, it) }
                        .onEach {
                            dialogDelegate.onBluetoothAutoOnUpdated(
                                dialog,
                                it,
                                if (it) R.string.turn_on_bluetooth_auto_info_enabled
                                else R.string.turn_on_bluetooth_auto_info_disabled
                            )
                        }
                        .launchIn(this)

                    // bluetoothAutoOnToggle is emitted when user toggles the bluetooth auto on