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

Commit a1beec22 authored by Yein Jo's avatar Yein Jo Committed by Android (Google) Code Review
Browse files

Merge "Use new LoadingEffect in UMO" into main

parents 3caf5acf b8ebdf76
Loading
Loading
Loading
Loading
+51 −0
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.
 */

package com.android.systemui.surfaceeffects.loadingeffect

import android.content.Context
import android.graphics.BlendMode
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View

/** Custom View for drawing the [LoadingEffect] with [Canvas.drawPaint]. */
open class LoadingEffectView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {

    private var paint: Paint? = null
    private var blendMode: BlendMode = BlendMode.SRC_OVER

    override fun onDraw(canvas: Canvas) {
        if (!canvas.isHardwareAccelerated) {
            return
        }
        paint?.let { canvas.drawPaint(it) }
    }

    /** Designed to be called on [LoadingEffect.PaintDrawCallback.onDraw]. */
    fun draw(paint: Paint) {
        this.paint = paint
        this.paint!!.blendMode = blendMode

        invalidate()
    }

    /** Sets the blend mode of the [Paint]. */
    fun setBlendMode(blendMode: BlendMode) {
        this.blendMode = blendMode
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -67,6 +67,18 @@
        android:background="@drawable/qs_media_outline_layout_bg"
        />

    <com.android.systemui.surfaceeffects.loadingeffect.LoadingEffectView
        android:id="@+id/loading_effect_view"
        android:layout_width="match_parent"
        android:layout_height="@dimen/qs_media_session_height_expanded"
        app:layout_constraintStart_toStartOf="@id/album_art"
        app:layout_constraintEnd_toEndOf="@id/album_art"
        app:layout_constraintTop_toTopOf="@id/album_art"
        app:layout_constraintBottom_toBottomOf="@id/album_art"
        android:clipToOutline="true"
        android:background="@drawable/qs_media_outline_layout_bg"
        />

    <!-- Guideline for output switcher -->
    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/center_vertical_guideline"
+9 −0
Original line number Diff line number Diff line
@@ -54,6 +54,15 @@
        app:layout_constraintTop_toTopOf="@+id/album_art"
        app:layout_constraintBottom_toBottomOf="@+id/album_art" />

    <Constraint
        android:id="@+id/loading_effect_view"
        android:layout_width="match_parent"
        android:layout_height="@dimen/qs_media_session_height_collapsed"
        app:layout_constraintStart_toStartOf="@+id/album_art"
        app:layout_constraintEnd_toEndOf="@+id/album_art"
        app:layout_constraintTop_toTopOf="@+id/album_art"
        app:layout_constraintBottom_toBottomOf="@+id/album_art" />

    <Constraint
        android:id="@+id/header_title"
        android:layout_width="wrap_content"
+9 −0
Original line number Diff line number Diff line
@@ -47,6 +47,15 @@
        app:layout_constraintTop_toTopOf="@+id/album_art"
        app:layout_constraintBottom_toBottomOf="@+id/album_art" />

    <Constraint
        android:id="@+id/loading_effect_view"
        android:layout_width="match_parent"
        android:layout_height="@dimen/qs_media_session_height_expanded"
        app:layout_constraintStart_toStartOf="@+id/album_art"
        app:layout_constraintEnd_toEndOf="@+id/album_art"
        app:layout_constraintTop_toTopOf="@+id/album_art"
        app:layout_constraintBottom_toBottomOf="@+id/album_art" />

    <Constraint
        android:id="@+id/header_title"
        android:layout_width="wrap_content"
+4 −1
Original line number Diff line number Diff line
@@ -25,8 +25,9 @@ import android.widget.SeekBar
import android.widget.TextView
import androidx.constraintlayout.widget.Barrier
import com.android.internal.widget.CachingIconView
import com.android.systemui.res.R
import com.android.systemui.media.controls.models.GutsViewHolder
import com.android.systemui.res.R
import com.android.systemui.surfaceeffects.loadingeffect.LoadingEffectView
import com.android.systemui.surfaceeffects.ripple.MultiRippleView
import com.android.systemui.surfaceeffects.turbulencenoise.TurbulenceNoiseView
import com.android.systemui.util.animation.TransitionLayout
@@ -42,6 +43,7 @@ class MediaViewHolder constructor(itemView: View) {
    val multiRippleView = itemView.requireViewById<MultiRippleView>(R.id.touch_ripple_view)
    val turbulenceNoiseView =
        itemView.requireViewById<TurbulenceNoiseView>(R.id.turbulence_noise_view)
    val loadingEffectView = itemView.requireViewById<LoadingEffectView>(R.id.loading_effect_view)
    val appIcon = itemView.requireViewById<ImageView>(R.id.icon)
    val titleText = itemView.requireViewById<TextView>(R.id.header_title)
    val artistText = itemView.requireViewById<TextView>(R.id.header_artist)
@@ -171,6 +173,7 @@ class MediaViewHolder constructor(itemView: View) {
            setOf(
                R.id.album_art,
                R.id.turbulence_noise_view,
                R.id.loading_effect_view,
                R.id.touch_ripple_view,
            )
    }
Loading