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

Commit a839a08a authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Revert prototype RON changes:

Revert "Fix EnRouteView expand button not expanding issue."
This reverts commit 51f6923b.

Revert "[RON] Scaffolding for EnRouteStyle content extraction and view inflation."
This reverts commit e0612f97.

Revert "[RONs] Fix NRCBI to support expanded/headsup state"
This reverts commit ab283522.

Revert "Some UI updates to timer RON per the initial UX mock."
This reverts commit ede75a98.

Revert "[RON] Inflate and bind Rich Ongoing Views"
This reverts commit 87d79dd9.

Revert "[RON] Extract a RichOngoingContentModel from timer notifications for testing."
This reverts commit 5a8fde05.

Flag: android.app.api_rich_ongoing
Flag: com.android.systemui.notification_row_content_binder_refactor
Bug: 343942780
Test: SystemUITests
Change-Id: I484598ea525211227314085d4176e42eb8faade1
parent 98e0bab7
Loading
Loading
Loading
Loading
+0 −85
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */

@file:OptIn(ExperimentalCoroutinesApi::class)

package com.android.systemui.statusbar.notification.row.ui.viewmodel

import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.statusbar.notification.row.data.repository.fakeNotificationRowRepository
import com.android.systemui.statusbar.notification.row.shared.EnRouteContentModel
import com.android.systemui.statusbar.notification.row.shared.IconModel
import com.android.systemui.statusbar.notification.row.shared.RichOngoingNotificationFlag
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.mock

@RunWith(AndroidJUnit4::class)
@SmallTest
@EnableFlags(RichOngoingNotificationFlag.FLAG_NAME)
class EnRouteViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val repository = kosmos.fakeNotificationRowRepository

    private var contentModel: EnRouteContentModel?
        get() = repository.richOngoingContentModel.value as? EnRouteContentModel
        set(value) {
            repository.richOngoingContentModel.value = value
        }

    private lateinit var underTest: EnRouteViewModel

    @Before
    fun setup() {
        underTest = kosmos.getEnRouteViewModel(repository)
    }

    @Test
    fun viewModelShowsContent() =
        testScope.runTest {
            val title by collectLastValue(underTest.title)
            val text by collectLastValue(underTest.text)
            contentModel =
                exampleEnRouteContent(
                    title = "Example EnRoute Title",
                    text = "Example EnRoute Text",
                )
            assertThat(title).isEqualTo("Example EnRoute Title")
            assertThat(text).isEqualTo("Example EnRoute Text")
        }

    private fun exampleEnRouteContent(
        icon: IconModel = mock(),
        title: CharSequence = "example text",
        text: CharSequence = "example title",
    ) =
        EnRouteContentModel(
            smallIcon = icon,
            title = title,
            text = text,
        )
}
+0 −108
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */

@file:OptIn(ExperimentalCoroutinesApi::class)

package com.android.systemui.statusbar.notification.row.ui.viewmodel

import android.app.Notification
import android.app.PendingIntent
import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.statusbar.notification.row.data.repository.fakeNotificationRowRepository
import com.android.systemui.statusbar.notification.row.shared.IconModel
import com.android.systemui.statusbar.notification.row.shared.RichOngoingNotificationFlag
import com.android.systemui.statusbar.notification.row.shared.TimerContentModel
import com.android.systemui.statusbar.notification.row.shared.TimerContentModel.TimerState.Paused
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import java.time.Duration
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.mock

@RunWith(AndroidJUnit4::class)
@SmallTest
@EnableFlags(RichOngoingNotificationFlag.FLAG_NAME)
class TimerViewModelTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val repository = kosmos.fakeNotificationRowRepository

    private var contentModel: TimerContentModel?
        get() = repository.richOngoingContentModel.value as? TimerContentModel
        set(value) {
            repository.richOngoingContentModel.value = value
        }

    private lateinit var underTest: TimerViewModel

    @Before
    fun setup() {
        underTest = kosmos.getTimerViewModel(repository)
    }

    @Test
    fun labelShowsTheTimerName() =
        testScope.runTest {
            val label by collectLastValue(underTest.label)
            contentModel = pausedTimer(name = "Example Timer Name")
            assertThat(label).isEqualTo("Example Timer Name")
        }

    @Test
    fun pausedTimeRemainingFormatsWell() =
        testScope.runTest {
            val label by collectLastValue(underTest.pausedTime)
            contentModel = pausedTimer(timeRemaining = Duration.ofMinutes(3))
            assertThat(label).isEqualTo("3:00")
            contentModel = pausedTimer(timeRemaining = Duration.ofSeconds(119))
            assertThat(label).isEqualTo("1:59")
            contentModel = pausedTimer(timeRemaining = Duration.ofSeconds(121))
            assertThat(label).isEqualTo("2:01")
            contentModel = pausedTimer(timeRemaining = Duration.ofHours(1))
            assertThat(label).isEqualTo("1:00:00")
            contentModel = pausedTimer(timeRemaining = Duration.ofHours(24))
            assertThat(label).isEqualTo("24:00:00")
        }

    private fun pausedTimer(
        icon: IconModel = mock(),
        name: String = "example",
        timeRemaining: Duration = Duration.ofMinutes(3),
        resumeIntent: PendingIntent? = null,
        addMinuteAction: Notification.Action? = null,
        resetAction: Notification.Action? = null
    ) =
        TimerContentModel(
            icon = icon,
            name = name,
            state =
                Paused(
                    timeRemaining = timeRemaining,
                    resumeIntent = resumeIntent,
                    addMinuteAction = addMinuteAction,
                    resetAction = resetAction,
                )
        )
}
+0 −29
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2024 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.
  -->

<com.android.systemui.statusbar.notification.row.ui.view.EnRouteView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@*android:id/status_bar_latest_event_content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:minHeight="@*android:dimen/notification_headerless_min_height"
    android:tag="enroute"
    >

    <include layout="@*android:layout/notification_template_material_base" />

</com.android.systemui.statusbar.notification.row.ui.view.EnRouteView>
 No newline at end of file
+0 −86
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2014 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
  -->
<com.android.systemui.statusbar.notification.row.ui.view.EnRouteView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@*android:id/status_bar_latest_event_content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:clipChildren="false"
    android:tag="big"
    >

    <LinearLayout
        android:id="@*android:id/notification_action_list_margin_target"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@*android:dimen/notification_content_margin"
        android:orientation="vertical"
        >

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="top"
            >

            <include layout="@*android:layout/notification_template_header" />

            <LinearLayout
                android:id="@*android:id/notification_main_column"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@*android:dimen/notification_content_margin_start"
                android:layout_marginEnd="@*android:dimen/notification_content_margin_end"
                android:layout_marginTop="@*android:dimen/notification_content_margin_top"
                android:orientation="vertical"
                >

                <include layout="@*android:layout/notification_template_part_line1" />

                <include layout="@*android:layout/notification_template_text_multiline" />

                <include
                    android:layout_width="match_parent"
                    android:layout_height="@*android:dimen/notification_progress_bar_height"
                    android:layout_marginTop="@*android:dimen/notification_progress_margin_top"
                    layout="@*android:layout/notification_template_progress"
                    />
            </LinearLayout>

            <include layout="@*android:layout/notification_template_right_icon" />
        </FrameLayout>

        <ViewStub
            android:layout="@*android:layout/notification_material_reply_text"
            android:id="@*android:id/notification_material_reply_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />

        <include
            layout="@*android:layout/notification_template_smart_reply_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@*android:dimen/notification_content_margin_start"
            android:layout_marginEnd="@*android:dimen/notification_content_margin_end"
            android:layout_marginTop="@*android:dimen/notification_content_margin"
            />

        <include layout="@*android:layout/notification_material_action_list" />
    </LinearLayout>
</com.android.systemui.statusbar.notification.row.ui.view.EnRouteView>
+0 −122
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2024 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
  -->
<com.android.systemui.statusbar.notification.row.ui.view.TimerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/topBaseline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_begin="22sp"
        />

    <ImageView
        android:id="@+id/icon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        app:tint="@android:color/white"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toStartOf="@id/label"
        android:baseline="18dp"
        app:layout_constraintBaseline_toTopOf="@id/topBaseline"
        />
    <TextView
        android:id="@+id/label"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toEndOf="@id/icon"
        app:layout_constraintEnd_toStartOf="@id/chronoRemaining"
        android:singleLine="true"
        tools:text="15s Timer"
        app:layout_constraintBaseline_toTopOf="@id/topBaseline"
        android:paddingEnd="4dp"
        />
    <Chronometer
        android:id="@+id/chronoRemaining"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:textSize="20sp"
        android:gravity="end"
        tools:text="0:12"
        app:layout_constraintBaseline_toTopOf="@id/topBaseline"
        app:layout_constraintEnd_toStartOf="@id/pausedTimeRemaining"
        app:layout_constraintStart_toEndOf="@id/label"
        android:countDown="true"
        android:paddingEnd="4dp"
        />
    <TextView
        android:id="@+id/pausedTimeRemaining"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:textSize="20sp"
        android:gravity="end"
        tools:text="0:12"
        app:layout_constraintBaseline_toTopOf="@id/topBaseline"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/chronoRemaining"
        android:paddingEnd="4dp"
        />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/bottomOfTop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:barrierDirection="bottom"
        app:constraint_referenced_ids="icon,label,chronoRemaining,pausedTimeRemaining"
        />

    <com.android.systemui.statusbar.notification.row.ui.view.TimerButtonView
        style="@*android:style/NotificationEmphasizedAction"
        android:id="@+id/mainButton"
        android:layout_width="124dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toStartOf="@id/altButton"
        app:layout_constraintTop_toBottomOf="@id/bottomOfTop"
        app:layout_constraintHorizontal_chainStyle="spread"
        android:paddingEnd="4dp"
        />

    <com.android.systemui.statusbar.notification.row.ui.view.TimerButtonView
        style="@*android:style/NotificationEmphasizedAction"
        android:id="@+id/altButton"
        android:layout_width="124dp"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/bottomOfTop"
        app:layout_constraintStart_toEndOf="@id/mainButton"
        app:layout_constraintEnd_toEndOf="@id/resetButton"
        android:paddingEnd="4dp"
        />

    <com.android.systemui.statusbar.notification.row.ui.view.TimerButtonView
        style="@*android:style/NotificationEmphasizedAction"
        android:id="@+id/resetButton"
        android:layout_width="124dp"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/bottomOfTop"
        app:layout_constraintStart_toEndOf="@id/altButton"
        app:layout_constraintEnd_toEndOf="parent"
        android:paddingEnd="4dp"
        />
</com.android.systemui.statusbar.notification.row.ui.view.TimerView>
 No newline at end of file
Loading