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

Commit 9a345f31 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Reload content description of KeyButtonView" into mnc-dr-dev

parents 986d4b48 3bab515b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
        <attr name="keyCode" format="integer" />
        <!-- does this button generate longpress / repeat events? -->
        <attr name="keyRepeat" format="boolean" />
        <attr name="android:contentDescription" />
    </declare-styleable>
    <declare-styleable name="ToggleSlider">
        <attr name="text" format="string" />
+18 −0
Original line number Diff line number Diff line
@@ -18,12 +18,14 @@ package com.android.systemui.statusbar.policy;

import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.hardware.input.InputManager;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
@@ -43,6 +45,7 @@ import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK

public class KeyButtonView extends ImageView {

    private int mContentDescriptionRes;
    private long mDownTime;
    private int mCode;
    private int mTouchSlop;
@@ -79,14 +82,29 @@ public class KeyButtonView extends ImageView {

        mSupportsLongpress = a.getBoolean(R.styleable.KeyButtonView_keyRepeat, true);

        TypedValue value = new TypedValue();
        if (a.getValue(R.styleable.KeyButtonView_android_contentDescription, value)) {
            mContentDescriptionRes = value.resourceId;
        }

        a.recycle();


        setClickable(true);
        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        setBackground(new KeyButtonRipple(context, this));
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        if (mContentDescriptionRes != 0) {
            setContentDescription(mContext.getString(mContentDescriptionRes));
        }
    }

    @Override
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);