Merge "Add a11y action for expand / collapse items in WidgetsFullSheet" into sc-dev
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
tools:src="@drawable/ic_corp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/app_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
||||
@@ -19,7 +19,10 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -94,6 +97,32 @@ public final class WidgetsListHeader extends LinearLayout implements ItemInfoUpd
|
||||
mTitle = findViewById(R.id.app_title);
|
||||
mSubtitle = findViewById(R.id.app_subtitle);
|
||||
mExpandToggle = findViewById(R.id.toggle);
|
||||
findViewById(R.id.app_container).setAccessibilityDelegate(new AccessibilityDelegate() {
|
||||
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
||||
if (mIsExpanded) {
|
||||
info.removeAction(AccessibilityNodeInfo.ACTION_EXPAND);
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_COLLAPSE);
|
||||
} else {
|
||||
info.removeAction(AccessibilityNodeInfo.ACTION_COLLAPSE);
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_EXPAND);
|
||||
}
|
||||
super.onInitializeAccessibilityNodeInfo(host, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityAction(View host, int action, Bundle args) {
|
||||
switch (action) {
|
||||
case AccessibilityNodeInfo.ACTION_EXPAND:
|
||||
case AccessibilityNodeInfo.ACTION_COLLAPSE:
|
||||
callOnClick();
|
||||
return true;
|
||||
default:
|
||||
return super.performAccessibilityAction(host, action, args);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +135,9 @@ public final class WidgetsListHeader extends LinearLayout implements ItemInfoUpd
|
||||
// Use the entire touch area of this view to expand / collapse an app widgets section.
|
||||
setOnClickListener(view -> {
|
||||
setExpanded(!mIsExpanded);
|
||||
onExpandChangeListener.onExpansionChange(mIsExpanded);
|
||||
if (onExpandChangeListener != null) {
|
||||
onExpandChangeListener.onExpansionChange(mIsExpanded);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user