Expand resolver drawer on accessibility gesture animation
Add a accessibility delegate to the target list view that exapnds drawer when a11y navigation reaches a partially hidden item in the list. Fix: 287389443 Test: manual testing for various resolver layouts: "regular", with a default/recent, and a miniresolver Change-Id: I4b751cc19241ff9601e98bad78d270a1c74fe3f1
This commit is contained in:
@@ -39,6 +39,7 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTE
|
||||
|
||||
import static com.android.internal.annotations.VisibleForTesting.Visibility.PROTECTED;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.StringRes;
|
||||
import android.annotation.UiThread;
|
||||
@@ -67,6 +68,7 @@ import android.content.pm.UserInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
@@ -92,6 +94,7 @@ import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.Window;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
@@ -481,6 +484,14 @@ public class ResolverActivity extends Activity implements
|
||||
rdl.setOnApplyWindowInsetsListener(this::onApplyWindowInsets);
|
||||
|
||||
mResolverDrawerLayout = rdl;
|
||||
|
||||
for (int i = 0, size = mMultiProfilePagerAdapter.getCount(); i < size; i++) {
|
||||
View view = mMultiProfilePagerAdapter.getItem(i).rootView.findViewById(
|
||||
R.id.resolver_list);
|
||||
if (view != null) {
|
||||
view.setAccessibilityDelegate(new AppListAccessibilityDelegate(rdl));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mProfileView = findViewById(R.id.profile_button);
|
||||
@@ -2600,4 +2611,41 @@ public class ResolverActivity extends Activity implements
|
||||
}
|
||||
return resolveInfo.userHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* An a11y delegate that expands resolver drawer when gesture navigation reaches a partially
|
||||
* invisible target in the list.
|
||||
*/
|
||||
private static class AppListAccessibilityDelegate extends View.AccessibilityDelegate {
|
||||
private final ResolverDrawerLayout mDrawer;
|
||||
@Nullable
|
||||
private final View mBottomBar;
|
||||
private final Rect mRect = new Rect();
|
||||
|
||||
private AppListAccessibilityDelegate(ResolverDrawerLayout drawer) {
|
||||
mDrawer = drawer;
|
||||
mBottomBar = mDrawer.findViewById(R.id.button_bar_container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onRequestSendAccessibilityEvent(@androidx.annotation.NonNull ViewGroup host,
|
||||
@NonNull View child,
|
||||
@NonNull AccessibilityEvent event) {
|
||||
boolean result = super.onRequestSendAccessibilityEvent(host, child, event);
|
||||
if (result && event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED
|
||||
&& mDrawer.isCollapsed()) {
|
||||
child.getBoundsOnScreen(mRect);
|
||||
int childTop = mRect.top;
|
||||
int childBottom = mRect.bottom;
|
||||
mDrawer.getBoundsOnScreen(mRect, true);
|
||||
int bottomBarHeight = mBottomBar == null ? 0 : mBottomBar.getHeight();
|
||||
int drawerTop = mRect.top;
|
||||
int drawerBottom = mRect.bottom - bottomBarHeight;
|
||||
if (drawerTop > childTop || childBottom > drawerBottom) {
|
||||
mDrawer.setCollapsed(false);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user