diff options
author | Tony Wickham <twickham@google.com> | 2016-02-12 22:07:26 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-02-12 22:07:27 +0000 |
commit | 187b8f547d2112e8d0384cf1c2077beb969dfec6 (patch) | |
tree | 727a667ad4ec6e3c5de317f7533d75534517359c /src | |
parent | bb702584fa551fab8cffbb0ae5459d9efd16ce2a (diff) | |
parent | 71255bb04fd2af3f27364f1545edc2eec27d27ce (diff) | |
download | android_packages_apps_Trebuchet-187b8f547d2112e8d0384cf1c2077beb969dfec6.tar.gz android_packages_apps_Trebuchet-187b8f547d2112e8d0384cf1c2077beb969dfec6.tar.bz2 android_packages_apps_Trebuchet-187b8f547d2112e8d0384cf1c2077beb969dfec6.zip |
Merge "Clears the widget resize frame when a directional key is pressed." into ub-launcher3-burnaby-polish
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/AppWidgetResizeFrame.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index d86853608..6b7ff886c 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -11,12 +11,15 @@ import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; import android.view.Gravity; +import android.view.KeyEvent; +import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; import com.android.launcher3.accessibility.DragViewStateAnnouncer; +import com.android.launcher3.util.FocusLogic; -public class AppWidgetResizeFrame extends FrameLayout { +public class AppWidgetResizeFrame extends FrameLayout implements View.OnKeyListener { private static final int SNAP_DURATION = 150; private static final float DIMMED_HANDLE_ALPHA = 0f; private static final float RESIZE_THRESHOLD = 0.66f; @@ -143,6 +146,8 @@ public class AppWidgetResizeFrame extends FrameLayout { // cells (same if not resized, or different) will be marked as occupied when the resize // frame is dismissed. mCellLayout.markCellsAsUnoccupiedForView(mWidgetView); + + setOnKeyListener(this); } public boolean beginResizeIfPointInRegion(int x, int y) { @@ -474,5 +479,19 @@ public class AppWidgetResizeFrame extends FrameLayout { set.setDuration(SNAP_DURATION); set.start(); } + + setFocusableInTouchMode(true); + requestFocus(); + } + + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + // Clear the frame and give focus to the widget host view when a directional key is pressed. + if (FocusLogic.shouldConsume(keyCode)) { + mDragLayer.clearAllResizeFrames(); + mWidgetView.requestFocus(); + return true; + } + return false; } } |