diff options
author | Jim Miller <jaggies@google.com> | 2012-05-21 13:37:27 -0700 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2012-05-21 13:55:44 -0700 |
commit | 998bb765290066822ff8a3b378dadd71deb0ce73 (patch) | |
tree | 519f6516e74edd30ca6e939d62dcedf307b4d24b /packages | |
parent | af0a15c820c0cdffcaf198e599cb55098510ad0a (diff) | |
download | frameworks_base-998bb765290066822ff8a3b378dadd71deb0ce73.zip frameworks_base-998bb765290066822ff8a3b378dadd71deb0ce73.tar.gz frameworks_base-998bb765290066822ff8a3b378dadd71deb0ce73.tar.bz2 |
Fix6398209: reveal search when home button is long-pressed
This change add a feature to reveal the swipe to search interface
when the home key is pressed for longer than 50ms. It progressively
reveals the interface. It still requires a bit of tuning, but all
the basic parameters are in this CL.
Change-Id: I1d3a5bb7b912265eb41da68bc9313eee1af2e415
Diffstat (limited to 'packages')
3 files changed, 36 insertions, 26 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java index 6b0bb87..478d652 100644 --- a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java @@ -18,6 +18,8 @@ package com.android.systemui; import android.animation.Animator; import android.animation.LayoutTransition; +import android.app.ActivityManagerNative; +import android.app.ActivityOptions; import android.app.SearchManager; import android.content.ActivityNotFoundException; import android.content.ComponentName; @@ -36,6 +38,7 @@ import android.widget.FrameLayout; import com.android.internal.widget.multiwaveview.MultiWaveView; import com.android.internal.widget.multiwaveview.MultiWaveView.OnTriggerListener; +import com.android.server.am.ActivityManagerService; import com.android.systemui.R; import com.android.systemui.recent.StatusBarTouchProxy; import com.android.systemui.statusbar.BaseStatusBar; @@ -103,26 +106,20 @@ public class SearchPanelView extends FrameLayout implements } private void startAssistActivity() { - if (mSearchManager != null) { - ComponentName globalSearchActivity = mSearchManager.getGlobalSearchActivity(); - if (globalSearchActivity != null) { - Intent intent = new Intent(Intent.ACTION_ASSIST); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.setPackage(globalSearchActivity.getPackageName()); - try { - mContext.startActivity(intent); - } catch (ActivityNotFoundException e) { - Slog.w(TAG, "Activity not found for " + intent.getAction()); - } - } else { - Slog.w(TAG, "No global search activity"); - } + Intent intent = getAssistIntent(); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + try { + mContext.startActivity(intent); + } catch (ActivityNotFoundException e) { + Slog.w(TAG, "Activity not found for " + intent.getAction()); } } final MultiWaveView.OnTriggerListener mMultiWaveViewListener = new MultiWaveView.OnTriggerListener() { + private int mTarget = -1; + public void onGrabbed(View v, int handle) { } @@ -136,11 +133,18 @@ public class SearchPanelView extends FrameLayout implements } public void onTrigger(View v, int target) { - final int resId = mMultiWaveView.getResourceIdForTarget(target); - switch (resId) { - case com.android.internal.R.drawable.ic_lockscreen_search: - startAssistActivity(); - break; + mTarget = target; + } + + public void onFinishFinalAnimation() { + if (mTarget != -1) { + final int resId = mMultiWaveView.getResourceIdForTarget(mTarget); + mTarget = -1; // a safety to make sure we never launch w/o prior call to onTrigger + switch (resId) { + case com.android.internal.R.drawable.ic_lockscreen_search: + startAssistActivity(); + break; + } } mBar.hideSearchPanel(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 69d2e73..d38611d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -515,14 +515,8 @@ public class PhoneStatusBar extends BaseStatusBar { public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: - Slog.d(TAG, "showing search panel"); showSearchPanel(); break; - - case MotionEvent.ACTION_UP: - Slog.d(TAG, "hiding search panel"); - hideSearchPanel(); - break; } return false; } @@ -533,8 +527,8 @@ public class PhoneStatusBar extends BaseStatusBar { mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); mNavigationBarView.getRecentsButton().setOnTouchListener(mRecentsPanel); + mNavigationBarView.getHomeButton().setOnTouchListener(mHomeSearchActionListener); updateSearchPanel(); -// mNavigationBarView.getHomeButton().setOnTouchListener(mHomeSearchActionListener); } // For small-screen devices (read: phones) that lack hardware navigation buttons diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index dba1606..10c5dd8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -188,6 +188,17 @@ public class TabletStatusBar extends BaseStatusBar implements public Context getContext() { return mContext; } + private View.OnTouchListener mHomeSearchActionListener = new View.OnTouchListener() { + public boolean onTouch(View v, MotionEvent event) { + switch(event.getAction()) { + case MotionEvent.ACTION_DOWN: + showSearchPanel(); + break; + } + return false; + } + }; + @Override protected void createAndAddWindows() { addStatusBarWindow(); @@ -290,6 +301,7 @@ public class TabletStatusBar extends BaseStatusBar implements // Search Panel mStatusBarView.setBar(this); + mHomeButton.setOnTouchListener(mHomeSearchActionListener); updateSearchPanel(); // Input methods Panel |