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

Commit c46b6adf authored by Aaron Liu's avatar Aaron Liu Committed by Android (Google) Code Review
Browse files

Merge "Home Controls: Add chevron icon"

parents fba1cbe1 12572a74
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line

<!--
  ~ Copyright (C) 2022 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="18dp"
    android:height="31dp"
    android:viewportWidth="18"
    android:viewportHeight="31">
  <path
      android:pathData="M0.0061,27.8986L2.6906,30.5831L17.9219,15.3518L2.6906,0.1206L0.0061,2.8051L12.5338,15.3518"
      android:strokeAlpha="0.7"
      android:fillColor="#FFFFFF"
      android:fillAlpha="0.7"/>
</vector>
+12 −0
Original line number Diff line number Diff line
@@ -113,4 +113,16 @@
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

    <ImageView
        android:id="@+id/chevron_icon"
        android:autoMirrored="true"
        android:src="@drawable/ic_chevron_icon"
        android:visibility="invisible"
        android:layout_width="@dimen/control_chevron_icon_size"
        android:layout_height="@dimen/control_chevron_icon_size"
        android:clickable="false"
        android:focusable="false"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
+1 −0
Original line number Diff line number Diff line
@@ -1038,6 +1038,7 @@
    <dimen name="control_spinner_padding_horizontal">20dp</dimen>
    <dimen name="control_text_size">14sp</dimen>
    <dimen name="control_icon_size">24dp</dimen>
    <dimen name="control_chevron_icon_size">20dp</dimen>
    <dimen name="control_spacing">8dp</dimen>
    <dimen name="control_list_divider">1dp</dimen>
    <dimen name="control_corner_radius">14dp</dimen>
+3 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ class ControlViewHolder(
    private var nextStatusText: CharSequence = ""
    val title: TextView = layout.requireViewById(R.id.title)
    val subtitle: TextView = layout.requireViewById(R.id.subtitle)
    val chevronIcon: ImageView = layout.requireViewById(R.id.chevron_icon)
    val context: Context = layout.getContext()
    val clipLayer: ClipDrawable
    lateinit var cws: ControlWithState
@@ -163,6 +164,7 @@ class ControlViewHolder(
            cws.control?.let {
                title.setText(it.title)
                subtitle.setText(it.subtitle)
                chevronIcon.visibility = if (usePanel()) View.VISIBLE else View.INVISIBLE
            }
        }

@@ -469,6 +471,7 @@ class ControlViewHolder(
        updateContentDescription()

        status.setTextColor(color)
        chevronIcon.imageTintList = color

        control?.getCustomIcon()?.let {
            icon.setImageIcon(it)
+26 −4
Original line number Diff line number Diff line
@@ -23,22 +23,24 @@ import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.Icon
import android.service.controls.Control
import android.service.controls.DeviceTypes
import android.service.controls.templates.ControlTemplate
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.controls.controller.ControlsController
import com.android.systemui.util.time.FakeSystemClock
import org.junit.runner.RunWith
import com.android.systemui.SysuiTestCase
import com.android.systemui.controls.ControlsMetricsLogger
import com.android.systemui.controls.controller.ControlInfo
import com.android.systemui.controls.controller.ControlsController
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.mock

@SmallTest
@@ -49,11 +51,12 @@ class ControlViewHolderTest : SysuiTestCase() {
    private val clock = FakeSystemClock()

    private lateinit var cvh: ControlViewHolder
    private lateinit var baseLayout: ViewGroup

    @Before
    fun setUp() {
        TestableLooper.get(this).runWithLooper {
            val baseLayout = LayoutInflater.from(mContext).inflate(
            baseLayout = LayoutInflater.from(mContext).inflate(
                    R.layout.controls_base_item, null, false) as ViewGroup

            cvh = ControlViewHolder(
@@ -106,6 +109,25 @@ class ControlViewHolderTest : SysuiTestCase() {

        assertThat(cvh.icon.imageTintList).isEqualTo(customIconTintList)
    }

    @Test
    fun chevronIcon() {
        val control = Control.StatefulBuilder(CONTROL_ID, mock(PendingIntent::class.java))
            .setStatus(Control.STATUS_OK)
            .setControlTemplate(ControlTemplate.NO_TEMPLATE)
            .build()
        val cws = ControlWithState(
            ComponentName.createRelative("pkg", "cls"),
            ControlInfo(
                CONTROL_ID, CONTROL_TITLE, "subtitle", DeviceTypes.TYPE_AIR_FRESHENER
            ),
            control
        )
        cvh.bindData(cws, false)
        val chevronIcon = baseLayout.findViewById<View>(R.id.chevron_icon)

        assertThat(chevronIcon.visibility).isEqualTo(View.VISIBLE)
    }
}

private const val CONTROL_ID = "CONTROL_ID"