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

Commit 54e6a7fa authored by Jiaming Cheng's avatar Jiaming Cheng
Browse files

[QSDetailedView] Add layout constraint for the apm and share button

Also truncate the text.

Bug: 430145412
Flag: com.android.systemui.qs_tile_detailed_view
Test: UI change only. Existing unit tests still pass.

Change-Id: I84d3c5d93ced44efc669ec4dc6d2de5acb540955
parent 85e714a0
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -501,15 +501,14 @@
                    app:layout_goneMarginEnd="16dp"
                    android:layout_height="@dimen/tile_details_button_row_height"
                    android:layout_width="0dp"
                    app:layout_constrainedWidth="true"
                    app:layout_constraintEnd_toStartOf="@id/share_wifi_button"
                    app:layout_constraintHorizontal_bias="0.0"
                    app:layout_constraintHorizontal_chainStyle="packed"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintBottom_toBottomOf="parent"
                    android:background="@drawable/settingslib_entry_bg_off"
                    android:gravity="center"
                    app:layout_constraintWidth_default="spread"
                    app:layout_constraintHorizontal_chainStyle="spread"
                    android:visibility="gone">

                    <FrameLayout
@@ -535,6 +534,8 @@
                            android:text="@string/turn_off_airplane_mode"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:ellipsize="marquee"
                            android:singleLine="true"
                            android:textAppearance="@style/TextAppearance.TileDetailsEntryTitle" />
                    </FrameLayout>
                </LinearLayout>
@@ -547,7 +548,6 @@
                    app:layout_goneMarginStart="16dp"
                    android:layout_height="@dimen/tile_details_button_row_height"
                    android:layout_width="0dp"
                    app:layout_constrainedWidth="true"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toEndOf="@id/apm_button"
                    app:layout_constraintTop_toTopOf="parent"
@@ -577,6 +577,8 @@
                            android:text="@string/share_wifi_button_text"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:ellipsize="marquee"
                            android:singleLine="true"
                            android:textAppearance="@style/TextAppearance.TileDetailsEntryTitle" />
                    </FrameLayout>
                </LinearLayout>
+33 −3
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import androidx.annotation.WorkerThread
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
@@ -135,6 +136,7 @@ constructor(
    private lateinit var shareWifiButton: LinearLayout
    private lateinit var addNetworkButton: LinearLayout
    private lateinit var airplaneModeButton: LinearLayout
    private lateinit var wifiButtonsContainer: ConstraintLayout
    private var alertDialog: AlertDialog? = null
    private var canChangeWifiState = false
    private var wifiNetworkHeight = 0
@@ -276,6 +278,7 @@ constructor(
            internetDetailsContentController.setAirplaneModeDisabled()
        }
        airplaneModeSummaryTextView = contentView.requireViewById(R.id.airplane_mode_summary)
        wifiButtonsContainer = contentView.requireViewById(R.id.wifi_buttons_container)
    }

    private fun setWifiLayout() {
@@ -442,12 +445,10 @@ constructor(
            setProgressBarVisible(false)
        }

        airplaneModeButton.visibility =
            if (internetContent.isAirplaneModeEnabled) View.VISIBLE else View.GONE

        updateEthernetUI(internetContent)
        updateMobileUI(internetContent)
        updateWifiUI(internetContent)
        updateButtonsLayout(internetContent)
    }

    private fun getStartingInternetContent(): InternetContent {
@@ -740,6 +741,35 @@ constructor(
        }
    }

    @MainThread
    private fun updateButtonsLayout(internetContent: InternetContent) {
        airplaneModeButton.visibility =
            if (internetContent.isAirplaneModeEnabled) View.VISIBLE else View.GONE

        val apmVisible = airplaneModeButton.visibility == View.VISIBLE
        val shareVisible = shareWifiButton.visibility == View.VISIBLE
        if (!apmVisible && !shareVisible) return

        val shareParams = shareWifiButton.layoutParams as ConstraintLayout.LayoutParams
        shareWifiButton.minimumWidth = 0

        if (apmVisible) {
            shareParams.matchConstraintDefaultWidth =
                ConstraintLayout.LayoutParams.MATCH_CONSTRAINT_WRAP
        } else {
            shareParams.matchConstraintDefaultWidth =
                ConstraintLayout.LayoutParams.MATCH_CONSTRAINT_SPREAD

            // By setting `MATCH_CONSTRAINT_SPREAD`, we ask ConstraintLayout to expand this
            // `shareWifiButton`. However, due to layout timing, this change may not be reflected
            // immediately. To force the button to occupy the full width on the very next layout
            // pass, we set its minimumWidth to the exact current width of the parent container.
            shareWifiButton.minimumWidth = wifiButtonsContainer.width
        }

        shareWifiButton.layoutParams = shareParams
    }

    @MainThread
    private fun updateConnectedWifi(internetContent: InternetContent) {
        if (