summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/AppWidgetResizeFrame.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-02-12 22:16:32 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-02-12 22:16:32 +0000
commitc338ea74c2c909927246fc604b049d5dcc773f81 (patch)
treed1a0d04a0f56c7a454fb0c9013d6b49acce861c6 /src/com/android/launcher3/AppWidgetResizeFrame.java
parentcb1edd20e1072ff00992c09ca99ab412e1252761 (diff)
parent187b8f547d2112e8d0384cf1c2077beb969dfec6 (diff)
downloadandroid_packages_apps_Trebuchet-c338ea74c2c909927246fc604b049d5dcc773f81.tar.gz
android_packages_apps_Trebuchet-c338ea74c2c909927246fc604b049d5dcc773f81.tar.bz2
android_packages_apps_Trebuchet-c338ea74c2c909927246fc604b049d5dcc773f81.zip
Merge "Clears the widget resize frame when a directional key is pressed." into ub-launcher3-burnaby-polish
am: 187b8f547d * commit '187b8f547d2112e8d0384cf1c2077beb969dfec6': Clears the widget resize frame when a directional key is pressed.
Diffstat (limited to 'src/com/android/launcher3/AppWidgetResizeFrame.java')
-rw-r--r--src/com/android/launcher3/AppWidgetResizeFrame.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index 7bd5284fc..0ba94995b 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -14,12 +14,15 @@ import android.content.res.Resources;
import android.graphics.Point;
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;
@@ -149,6 +152,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) {
@@ -479,5 +484,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;
}
}