summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherClings.java
diff options
context:
space:
mode:
authorJun Mukai <mukai@google.com>2015-08-05 17:25:29 -0700
committerJun Mukai <mukai@google.com>2015-08-05 17:25:29 -0700
commit464d13cd486a956ef6683e8d31386e13fa529f4c (patch)
treec4abcfbe395fbd81ac26c851e22d7aed7c855fbf /src/com/android/launcher3/LauncherClings.java
parentf0033da0dd659e822f17e306b268420deae2ef2b (diff)
downloadandroid_packages_apps_Trebuchet-464d13cd486a956ef6683e8d31386e13fa529f4c.tar.gz
android_packages_apps_Trebuchet-464d13cd486a956ef6683e8d31386e13fa529f4c.tar.bz2
android_packages_apps_Trebuchet-464d13cd486a956ef6683e8d31386e13fa529f4c.zip
Add KeyEvent handler to LauncherClings.
When the longpress clings such like welcome message appears, the key events should be limited as follows: - normal keys (generates printable glyphs) should be prevented, otherwise they come to the underlying searchbox. - it should be dismissed on Menu keys, which goes to the overview mode. Bug: 22982955 Change-Id: I7272b0809bfaa3c08ba77b01383cf54f19390d95
Diffstat (limited to 'src/com/android/launcher3/LauncherClings.java')
-rw-r--r--src/com/android/launcher3/LauncherClings.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/com/android/launcher3/LauncherClings.java b/src/com/android/launcher3/LauncherClings.java
index dceb16fb2..0315b5c8c 100644
--- a/src/com/android/launcher3/LauncherClings.java
+++ b/src/com/android/launcher3/LauncherClings.java
@@ -27,16 +27,19 @@ import android.os.Build;
import android.os.Bundle;
import android.os.UserManager;
import android.provider.Settings;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.View.OnKeyListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.accessibility.AccessibilityManager;
+
import com.android.launcher3.util.Thunk;
-class LauncherClings implements OnClickListener {
+class LauncherClings implements OnClickListener, OnKeyListener {
private static final String MIGRATION_CLING_DISMISSED_KEY = "cling_gel.migration.dismissed";
private static final String WORKSPACE_CLING_DISMISSED_KEY = "cling_gel.workspace.dismissed";
@@ -83,6 +86,20 @@ class LauncherClings implements OnClickListener {
}
}
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (event.isPrintingKey()) {
+ // Should ignore all printing keys, otherwise they come to the search box.
+ return true;
+ }
+ if (keyCode == KeyEvent.KEYCODE_MENU) {
+ // Menu key goes to the overview mode similar to longpress, therefore it needs to
+ // dismiss the clings.
+ dismissLongPressCling();
+ }
+ return false;
+ }
+
/**
* Shows the migration cling.
*
@@ -133,7 +150,9 @@ class LauncherClings implements OnClickListener {
final ViewGroup content = (ViewGroup) cling.findViewById(R.id.cling_content);
mInflater.inflate(showWelcome ? R.layout.longpress_cling_welcome_content
: R.layout.longpress_cling_content, content);
- content.findViewById(R.id.cling_dismiss_longpress_info).setOnClickListener(this);
+ final View button = content.findViewById(R.id.cling_dismiss_longpress_info);
+ button.setOnClickListener(this);
+ button.setOnKeyListener(this);
if (TAG_CROP_TOP_AND_SIDES.equals(content.getTag())) {
Drawable bg = new BorderCropDrawable(mLauncher.getResources().getDrawable(R.drawable.cling_bg),