From 62b9b6054e46074f57ccf156a8663b4392cd82d9 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 18 Nov 2015 10:56:35 -0800 Subject: [PATCH] Hide the focus indicator view when going to a fullscreen page. Bug: 25649853 Change-Id: I9f2f221020548b48d816924a1803a1a70d11c412 --- .../android/launcher3/FocusIndicatorView.java | 19 +++++++++++++++++++ src/com/android/launcher3/Workspace.java | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/com/android/launcher3/FocusIndicatorView.java b/src/com/android/launcher3/FocusIndicatorView.java index ecf93e4b3d..58b38ebcd2 100644 --- a/src/com/android/launcher3/FocusIndicatorView.java +++ b/src/com/android/launcher3/FocusIndicatorView.java @@ -30,6 +30,7 @@ public class FocusIndicatorView extends View implements View.OnFocusChangeListen // It can be any number >0. The view is resized using scaleX and scaleY. static final int DEFAULT_LAYOUT_SIZE = 100; + private static final float MIN_VISIBLE_ALPHA = 0.2f; private static final long ANIM_DURATION = 150; @@ -41,6 +42,7 @@ public class FocusIndicatorView extends View implements View.OnFocusChangeListen private View mLastFocusedView; private boolean mInitiated; + private final OnFocusChangeListener mHideIndicatorOnFocusListener; private Pair mPendingCall; @@ -52,6 +54,16 @@ public class FocusIndicatorView extends View implements View.OnFocusChangeListen super(context, attrs); setAlpha(0); setBackgroundColor(getResources().getColor(R.color.focused_background)); + + mHideIndicatorOnFocusListener = new OnFocusChangeListener() { + @Override + public void onFocusChange(View v, boolean hasFocus) { + if (hasFocus) { + endCurrentAnimation(); + setAlpha(0); + } + } + }; } @Override @@ -66,6 +78,13 @@ public class FocusIndicatorView extends View implements View.OnFocusChangeListen } } + /** + * Sets the alpha of this FocusIndicatorView to 0 when a view with this listener receives focus. + */ + public View.OnFocusChangeListener getHideIndicatorOnFocusListener() { + return mHideIndicatorOnFocusListener; + } + @Override public void onFocusChange(View v, boolean hasFocus) { mPendingCall = null; diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 8b639d2ae1..94cbc7a129 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -653,6 +653,8 @@ public class Workspace extends PagedView customScreen.removeAllViews(); customContent.setFocusable(true); customContent.setOnKeyListener(new FullscreenKeyEventListener()); + customContent.setOnFocusChangeListener(mLauncher.mFocusHandler + .getHideIndicatorOnFocusListener()); customScreen.addViewToCellLayout(customContent, 0, 0, lp, true); mCustomContentDescription = description;