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

Commit 74ca9f7d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix accessibility of build text" into main

parents a5360e8a b059e883
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -34,13 +34,14 @@
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical">

            <TextView
            <com.android.systemui.qs.BuildTextView
                android:id="@+id/build"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:paddingEnd="4dp"
                android:layout_weight="1"
                android:clickable="true"
                android:marqueeRepeatLimit="1"
                android:clickable="false"
                android:ellipsize="marquee"
                android:focusable="true"
                android:gravity="center_vertical"
+45 −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.qs

import android.content.Context
import android.util.AttributeSet
import android.view.accessibility.AccessibilityNodeInfo
import com.android.systemui.res.R
import com.android.systemui.util.DelayableMarqueeTextView

class BuildTextView
@JvmOverloads
constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0,
    defStyleRes: Int = 0,
) : DelayableMarqueeTextView(context, attrs, defStyleAttr, defStyleRes) {

    override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo?) {
        super.onInitializeAccessibilityNodeInfo(info)
        // Clear selected state so it's not announced by accessibility, but we can still marquee.
        info?.isSelected = false
        info?.addAction(
            AccessibilityNodeInfo.AccessibilityAction(
                AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK.id,
                resources.getString(R.string.copy_to_clipboard_a11y_action),
            )
        )
    }
}
+15 −9
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ import android.content.Context
import android.util.AttributeSet
import com.android.systemui.res.R

class DelayableMarqueeTextView @JvmOverloads constructor(
open class DelayableMarqueeTextView
@JvmOverloads
constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0,
    defStyleRes: Int = 0
    defStyleRes: Int = 0,
) : SafeMarqueeTextView(context, attrs, defStyleAttr, defStyleRes) {

    var marqueeDelay: Long = DEFAULT_MARQUEE_DELAY
@@ -39,16 +41,20 @@ class DelayableMarqueeTextView @JvmOverloads constructor(
    }

    init {
        val typedArray = context.theme.obtainStyledAttributes(
        val typedArray =
            context.theme.obtainStyledAttributes(
                attrs,
                R.styleable.DelayableMarqueeTextView,
                defStyleAttr,
                defStyleRes
                defStyleRes,
            )
        marqueeDelay = typedArray.getInteger(
        marqueeDelay =
            typedArray
                .getInteger(
                    R.styleable.DelayableMarqueeTextView_marqueeDelay,
                DEFAULT_MARQUEE_DELAY.toInt()
        ).toLong()
                    DEFAULT_MARQUEE_DELAY.toInt(),
                )
                .toLong()
        typedArray.recycle()
    }