Marks ScrimView unimportant for accessibility when Widgets screen is opened.

This prevents it from holding focus while the Widgets screen is visible
(after using Widgets action from the All Apps caret thingy).

Test: Manually followed steps provided in bug, and issue not seen after this change.
Fixes: 139918680
Change-Id: I280ac97fb7ff9fa67f1c6a1ce9cdfa9e451231eb
This commit is contained in:
Andy Wickham 2019-08-29 23:11:30 -07:00
parent 505a88140e
commit c40872b913
3 changed files with 42 additions and 22 deletions

View File

@ -153,15 +153,15 @@ public abstract class AbstractSlideInView extends AbstractFloatingView
}
protected void handleClose(boolean animate, long defaultDuration) {
if (mIsOpen && !animate) {
if (!mIsOpen) {
return;
}
if (!animate) {
mOpenCloseAnimator.cancel();
setTranslationShift(TRANSLATION_SHIFT_CLOSED);
onCloseComplete();
return;
}
if (!mIsOpen) {
return;
}
mOpenCloseAnimator.setValues(
PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_CLOSED));
mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() {

View File

@ -18,10 +18,8 @@ package com.android.launcher3.views;
import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_FLAVOR;
import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_OFFSET;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.Rect;
import android.graphics.RectF;
import android.text.TextUtils;
@ -33,6 +31,9 @@ import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@ -46,7 +47,6 @@ import com.android.launcher3.widget.WidgetsFullSheet;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.VisibleForTesting;
/**
* Popup shown on long pressing an empty space in launcher
@ -169,16 +169,17 @@ public class OptionsPopupView extends ArrowPopup
}
public static boolean onWidgetsClicked(View view) {
return openWidgets(Launcher.getLauncher(view.getContext()));
return openWidgets(Launcher.getLauncher(view.getContext())) != null;
}
public static boolean openWidgets(Launcher launcher) {
/** Returns WidgetsFullSheet that was opened, or null if nothing was opened. */
@Nullable
public static WidgetsFullSheet openWidgets(Launcher launcher) {
if (launcher.getPackageManager().isSafeMode()) {
Toast.makeText(launcher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
return false;
return null;
} else {
WidgetsFullSheet.show(launcher, true /* animated */);
return true;
return WidgetsFullSheet.show(launcher, true /* animated */);
}
}

View File

@ -18,14 +18,14 @@ package com.android.launcher3.views;
import static android.content.Context.ACCESSIBILITY_SERVICE;
import static android.view.MotionEvent.ACTION_DOWN;
import static androidx.core.graphics.ColorUtils.compositeColors;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
import static androidx.core.graphics.ColorUtils.compositeColors;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.Keyframe;
@ -47,6 +47,13 @@ import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat;
import androidx.customview.widget.ExploreByTouchHelper;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
@ -62,15 +69,10 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.Themes;
import com.android.launcher3.widget.WidgetsFullSheet;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat;
import androidx.customview.widget.ExploreByTouchHelper;
/**
* Simple scrim which draws a flat color
@ -325,7 +327,7 @@ public class ScrimView extends View implements Insettable, OnChangeListener,
if (enabled) {
stateManager.addStateListener(this);
handleStateChangedComplete(mLauncher.getStateManager().getState());
handleStateChangedComplete(stateManager.getState());
} else {
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
}
@ -437,7 +439,24 @@ public class ScrimView extends View implements Insettable, OnChangeListener,
} else if (action == WALLPAPERS) {
return OptionsPopupView.startWallpaperPicker(ScrimView.this);
} else if (action == WIDGETS) {
return OptionsPopupView.onWidgetsClicked(ScrimView.this);
int originalImportanceForAccessibility = getImportantForAccessibility();
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
WidgetsFullSheet widgetsFullSheet = OptionsPopupView.openWidgets(mLauncher);
if (widgetsFullSheet == null) {
setImportantForAccessibility(originalImportanceForAccessibility);
return false;
}
widgetsFullSheet.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {}
@Override
public void onViewDetachedFromWindow(View view) {
setImportantForAccessibility(originalImportanceForAccessibility);
widgetsFullSheet.removeOnAttachStateChangeListener(this);
}
});
return true;
} else if (action == SETTINGS) {
return OptionsPopupView.startSettings(ScrimView.this);
}