diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-05-15 13:55:57 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-05-16 13:11:00 -0700 |
commit | de7532154259ed79d7ed6d2fcc9e82ff2860a5a3 (patch) | |
tree | a8865d45fd1ce0b2dc6d01beee460e34b35d27a3 /src/com/android/launcher3/widget | |
parent | 6ae02c6a61e2d2c7014bd5f8b2a0266c5b802245 (diff) | |
download | android_packages_apps_Trebuchet-de7532154259ed79d7ed6d2fcc9e82ff2860a5a3.tar.gz android_packages_apps_Trebuchet-de7532154259ed79d7ed6d2fcc9e82ff2860a5a3.tar.bz2 android_packages_apps_Trebuchet-de7532154259ed79d7ed6d2fcc9e82ff2860a5a3.zip |
Fixing wrong accessibility focus when opening a floating view
> Using common logic for announcing a floating view for widgets and folders
Bug: 79091095
Bug: 79748886
Change-Id: Ibb3fe48e68e724f50d69f51a03d3b35ad0baf625
Diffstat (limited to 'src/com/android/launcher3/widget')
3 files changed, 27 insertions, 16 deletions
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java index a2584852b..5ce7e0453 100644 --- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java @@ -20,6 +20,7 @@ import android.animation.PropertyValuesHolder; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; +import android.util.Pair; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -72,7 +73,7 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable { mLauncher.getDragLayer().addView(this); mIsOpen = false; - open(true); + animateOpen(); } @Override @@ -129,20 +130,16 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable { return widget; } - private void open(boolean animate) { + private void animateOpen() { if (mIsOpen || mOpenCloseAnimator.isRunning()) { return; } mIsOpen = true; setupNavBarColor(); - if (animate) { - mOpenCloseAnimator.setValues( - PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED)); - mOpenCloseAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); - mOpenCloseAnimator.start(); - } else { - setTranslationShift(TRANSLATION_SHIFT_OPENED); - } + mOpenCloseAnimator.setValues( + PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED)); + mOpenCloseAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); + mOpenCloseAnimator.start(); } @Override @@ -170,4 +167,10 @@ public class WidgetsBottomSheet extends BaseWidgetSheet implements Insettable { protected int getElementsRowCount() { return 1; } + + @Override + protected Pair<View, String> getAccessibilityTarget() { + return Pair.create(findViewById(R.id.title), getContext().getString( + mIsOpen ? R.string.widgets_list : R.string.widgets_list_closed)); + } } diff --git a/src/com/android/launcher3/widget/WidgetsFullSheet.java b/src/com/android/launcher3/widget/WidgetsFullSheet.java index a622624dc..e94d81d75 100644 --- a/src/com/android/launcher3/widget/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/WidgetsFullSheet.java @@ -21,8 +21,10 @@ import android.animation.PropertyValuesHolder; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; +import android.util.Pair; import android.view.LayoutInflater; import android.view.MotionEvent; +import android.view.View; import android.view.animation.AnimationUtils; import com.android.launcher3.Insettable; @@ -55,6 +57,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet mAdapter = new WidgetsListAdapter(context, LayoutInflater.from(context), apps.getWidgetCache(), apps.getIconCache(), this, this); + } public WidgetsFullSheet(Context context, AttributeSet attrs) { @@ -77,6 +80,12 @@ public class WidgetsFullSheet extends BaseWidgetSheet } @Override + protected Pair<View, String> getAccessibilityTarget() { + return Pair.create(mRecyclerView, getContext().getString( + mIsOpen ? R.string.widgets_list : R.string.widgets_list_closed)); + } + + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); mLauncher.getAppWidgetHost().addProviderChangeListener(this); @@ -149,10 +158,6 @@ public class WidgetsFullSheet extends BaseWidgetSheet } private void open(boolean animate) { - if (mIsOpen) { - return; - } - mIsOpen = true; if (animate) { if (mLauncher.getDragLayer().getInsets().bottom > 0) { mContent.setAlpha(0); @@ -180,6 +185,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet } else { setTranslationShift(TRANSLATION_SHIFT_OPENED); mAdapter.setApplyBitmapDeferred(false, mRecyclerView); + post(this::announceAccessibilityChanges); } } @@ -212,6 +218,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet public static WidgetsFullSheet show(Launcher launcher, boolean animate) { WidgetsFullSheet sheet = (WidgetsFullSheet) launcher.getLayoutInflater() .inflate(R.layout.widgets_full_sheet, launcher.getDragLayer(), false); + sheet.mIsOpen = true; launcher.getDragLayer().addView(sheet); sheet.open(animate); return sheet; diff --git a/src/com/android/launcher3/widget/WidgetsRowViewHolder.java b/src/com/android/launcher3/widget/WidgetsRowViewHolder.java index bc85db610..8f269a643 100644 --- a/src/com/android/launcher3/widget/WidgetsRowViewHolder.java +++ b/src/com/android/launcher3/widget/WidgetsRowViewHolder.java @@ -29,7 +29,8 @@ public class WidgetsRowViewHolder extends ViewHolder { public WidgetsRowViewHolder(ViewGroup v) { super(v); - cellContainer = (ViewGroup) v.findViewById(R.id.widgets_cell_list); - title = (BubbleTextView) v.findViewById(R.id.section); + cellContainer = v.findViewById(R.id.widgets_cell_list); + title = v.findViewById(R.id.section); + title.setAccessibilityDelegate(null); } } |