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

Commit 6179ea31 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Adding accessibility support to the Status Bar.

1. Added content description to pretty much all animals
   in the zoo including buttons in the navigation bar,
   notifications and status icons for battery, signal,
   data, etc.

2. Rectored to avoid ovelaying views since they block
   touch exploratino. In general overlaying views
   cause trouble for touch exploration and accessibility
   in general.

3. Avoid sending accessibility events in case the user is
   touching outside of the StatauBAr panels to avoid
   confusion.

4. Added records to accessibility events in the places where
   this would help the presentation. So the event comes from
   a given "leaf" view and its predecessor is adding a record
   to the event for itself to provide more cotext. It is up
   to the accessiiblity service to choose how to present that.

bug:4686943

Change-Id: I1c1bd123d828fb10911bca92130e9a05c1f020b3
parent ac415954
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -97,9 +97,10 @@ public class StatusBarManager {
        }
    }

    public void setIcon(String slot, int iconId, int iconLevel) {
    public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) {
        try {
            mService.setIcon(slot, mContext.getPackageName(), iconId, iconLevel);
            mService.setIcon(slot, mContext.getPackageName(), iconId, iconLevel,
                    contentDescription);
        } catch (RemoteException ex) {
            // system process is dead anyway.
            throw new RuntimeException(ex);
+6 −3
Original line number Diff line number Diff line
@@ -2148,11 +2148,14 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        onPopulateAccessibilityEvent(event);
        // Let our children have a shot in populating the event.
        for (int i = 0, count = getChildCount(); i < count; i++) {
            View child = getChildAt(i);
            if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
                boolean handled = getChildAt(i).dispatchPopulateAccessibilityEvent(event);
                if (handled) {
                    return handled;
                }
            }
        }
        return false;
    }

+10 −9
Original line number Diff line number Diff line
@@ -902,16 +902,17 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {

    @Override
    public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
        if (super.onRequestSendAccessibilityEvent(child, event)) {
            // Add a record for ourselves as well.
            AccessibilityEvent record = AccessibilityEvent.obtain();
        record.setSource(this);
        // Set the class since it is not populated in #dispatchPopulateAccessibilityEvent
        record.setClassName(getClass().getName());
        child.onInitializeAccessibilityEvent(record);
            onInitializeAccessibilityEvent(record);
            // Populate with the text of the requesting child.
            child.dispatchPopulateAccessibilityEvent(record);
            event.appendRecord(record);
            return true;
        }
        return false;
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
+11 −2
Original line number Diff line number Diff line
@@ -30,14 +30,15 @@ import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.RemotableViewMethod;
import android.view.View;
import android.view.ViewDebug;
import android.view.accessibility.AccessibilityEvent;
import android.widget.RemoteViews.RemoteView;


/**
 * Displays an arbitrary image, such as an icon.  The ImageView class
 * can load images from various sources (such as resources or content
@@ -209,6 +210,14 @@ public class ImageView extends View {
        return false;
    }

    @Override
    public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
        CharSequence contentDescription = getContentDescription();
        if (!TextUtils.isEmpty(contentDescription)) {
            event.getText().add(contentDescription);
        }
    }

    /**
     * Set this to true if you want the ImageView to adjust its bounds
     * to preserve the aspect ratio of its drawable.
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ interface IStatusBarService
    void expand();
    void collapse();
    void disable(int what, IBinder token, String pkg);
    void setIcon(String slot, String iconPackage, int iconId, int iconLevel);
    void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription);
    void setIconVisibility(String slot, boolean visible);
    void removeIcon(String slot);
    void topAppWindowChanged(boolean menuVisible);
Loading