Skip to content

Commit d8c5f10

Browse files
Jim MillerAndroid (Google) Code Review
authored andcommitted
Merge "Fix 6398209: SearchPanel gesture improvements" into jb-dev
2 parents 20c15a4 + 9a720f5 commit d8c5f10

File tree

8 files changed

+117
-55
lines changed

8 files changed

+117
-55
lines changed

core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ private void doFinish() {
519519
// Inform listener of any active targets. Typically only one will be active.
520520
deactivateHandle(RETURN_TO_HOME_DURATION, RETURN_TO_HOME_DELAY, 0.0f, mResetListener);
521521
dispatchTriggerEvent(activeTarget);
522+
if (!mAlwaysTrackFinger) {
523+
// Force ring and targets to finish animation to final expanded state
524+
mTargetAnimations.stop();
525+
}
522526
} else {
523527
// Animate handle back to the center based on current state.
524528
deactivateHandle(HIDE_ANIMATION_DURATION, HIDE_ANIMATION_DELAY, 1.0f,
@@ -542,7 +546,6 @@ private void hideUnselected(int active) {
542546
mTargetDrawables.get(i).setAlpha(0.0f);
543547
}
544548
}
545-
mOuterRing.setAlpha(0.0f);
546549
}
547550

548551
private void hideTargets(boolean animate, boolean expanded) {
@@ -809,7 +812,6 @@ private void handleDown(MotionEvent event) {
809812
switchToState(STATE_START, eventX, eventY);
810813
if (!trySwitchToFirstTouchState(eventX, eventY)) {
811814
mDragging = false;
812-
mTargetAnimations.cancel();
813815
ping();
814816
}
815817
}

packages/SystemUI/res/values/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
<!-- Show rotation lock button in phone-style notification panel. -->
5858
<bool name="config_showRotationLock">true</bool>
5959

60+
<!-- Amount of time to hold off before showing the search panel when the user presses home -->
61+
<integer name="config_show_search_delay">200</integer>
62+
6063
<!-- Vibration duration for MultiWaveView used in SearchPanelView -->
6164
<integer translatable="false" name="config_vibration_duration">20</integer>
6265
</resources>

packages/SystemUI/src/com/android/systemui/SearchPanelView.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
package com.android.systemui;
1818

19-
import android.animation.Animator;
2019
import android.animation.LayoutTransition;
21-
import android.app.ActivityManagerNative;
2220
import android.app.ActivityOptions;
2321
import android.app.SearchManager;
2422
import android.content.ActivityNotFoundException;
@@ -40,6 +38,7 @@
4038
import com.android.systemui.R;
4139
import com.android.systemui.recent.StatusBarTouchProxy;
4240
import com.android.systemui.statusbar.BaseStatusBar;
41+
import com.android.systemui.statusbar.CommandQueue;
4342
import com.android.systemui.statusbar.phone.PhoneStatusBar;
4443
import com.android.systemui.statusbar.tablet.StatusBarPanel;
4544
import com.android.systemui.statusbar.tablet.TabletStatusBar;
@@ -49,7 +48,7 @@ public class SearchPanelView extends FrameLayout implements
4948
private static final int SEARCH_PANEL_HOLD_DURATION = 500;
5049
static final String TAG = "SearchPanelView";
5150
static final boolean DEBUG = TabletStatusBar.DEBUG || PhoneStatusBar.DEBUG || false;
52-
private Context mContext;
51+
private final Context mContext;
5352
private BaseStatusBar mBar;
5453
private StatusBarTouchProxy mStatusBarTouchProxy;
5554

@@ -106,7 +105,7 @@ private SearchManager getSearchManager() {
106105

107106
private void startAssistActivity() {
108107
// Close Recent Apps if needed
109-
mBar.animateCollapse();
108+
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
110109
// Launch Assist
111110
Intent intent = getAssistIntent();
112111
try {
@@ -160,7 +159,7 @@ public void onFinishFinalAnimation() {
160159
protected void onFinishInflate() {
161160
super.onFinishInflate();
162161
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
163-
mSearchTargetsContainer = (ViewGroup) findViewById(R.id.search_panel_container);
162+
mSearchTargetsContainer = findViewById(R.id.search_panel_container);
164163
mStatusBarTouchProxy = (StatusBarTouchProxy) findViewById(R.id.status_bar_touch_proxy);
165164
// TODO: fetch views
166165
mMultiWaveView = (MultiWaveView) findViewById(R.id.multi_wave_view);
@@ -186,7 +185,7 @@ public boolean isInContentArea(int x, int y) {
186185
}
187186
}
188187

189-
private OnPreDrawListener mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
188+
private final OnPreDrawListener mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
190189
public boolean onPreDraw() {
191190
getViewTreeObserver().removeOnPreDrawListener(this);
192191
mMultiWaveView.resumeAnimations();
@@ -219,7 +218,7 @@ public void show(final boolean show, boolean animate) {
219218
public void hide(boolean animate) {
220219
if (mBar != null) {
221220
// This will indirectly cause show(false, ...) to get called
222-
mBar.animateCollapse();
221+
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
223222
} else {
224223
setVisibility(View.INVISIBLE);
225224
}

packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
import com.android.systemui.R;
6060
import com.android.systemui.statusbar.BaseStatusBar;
61+
import com.android.systemui.statusbar.CommandQueue;
6162
import com.android.systemui.statusbar.phone.PhoneStatusBar;
6263
import com.android.systemui.statusbar.tablet.StatusBarPanel;
6364
import com.android.systemui.statusbar.tablet.TabletStatusBar;
@@ -368,7 +369,7 @@ public void hide(boolean animate) {
368369
}
369370
if (mBar != null) {
370371
// This will indirectly cause show(false, ...) to get called
371-
mBar.animateCollapse();
372+
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
372373
}
373374
}
374375

@@ -822,7 +823,7 @@ public boolean onMenuItemClick(MenuItem item) {
822823
if (viewHolder != null) {
823824
final TaskDescription ad = viewHolder.taskDescription;
824825
startApplicationDetailsActivity(ad.packageName);
825-
mBar.animateCollapse();
826+
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
826827
} else {
827828
throw new IllegalStateException("Oops, no tag on view " + selectedView);
828829
}

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private void startApplicationDetailsActivity(String packageName) {
253253
mContext.startActivity(intent);
254254
}
255255

256-
protected View.OnLongClickListener getNotificationLongClicker() {
256+
protected View.OnLongClickListener getNotificationLongClicker() {
257257
return new View.OnLongClickListener() {
258258
@Override
259259
public boolean onLongClick(View v) {
@@ -268,7 +268,7 @@ public boolean onLongClick(View v) {
268268
public boolean onMenuItemClick(MenuItem item) {
269269
if (item.getItemId() == R.id.notification_inspect_item) {
270270
startApplicationDetailsActivity(packageNameF);
271-
animateCollapse();
271+
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
272272
} else {
273273
return false;
274274
}
@@ -618,7 +618,7 @@ public void onClick(View v) {
618618
}
619619

620620
// close the shade if it was open
621-
animateCollapse();
621+
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
622622
visibilityChanged(false);
623623

624624
// If this click was on the intruder alert, hide that instead

packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ public class CommandQueue extends IStatusBar.Stub {
6666

6767
private static final int MSG_SET_NAVIGATION_ICON_HINTS = 14 << MSG_SHIFT;
6868

69+
public static final int FLAG_EXCLUDE_NONE = 0;
70+
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
71+
public static final int FLAG_EXCLUDE_RECENTS_PANEL = 1 << 1;
72+
public static final int FLAG_EXCLUDE_NOTIFICATION_PANEL = 1 << 2;
73+
public static final int FLAG_EXCLUDE_INPUT_METHODS_PANEL = 1 << 3;
74+
public static final int FLAG_EXCLUDE_COMPAT_MODE_PANEL = 1 << 4;
75+
6976
private StatusBarIconList mList;
7077
private Callbacks mCallbacks;
7178
private Handler mHandler = new H();
@@ -88,7 +95,7 @@ public void updateIcon(String slot, int index, int viewIndex,
8895
public void removeNotification(IBinder key);
8996
public void disable(int state);
9097
public void animateExpand();
91-
public void animateCollapse();
98+
public void animateCollapse(int flags);
9299
public void setSystemUiVisibility(int vis, int mask);
93100
public void topAppWindowChanged(boolean visible);
94101
public void setImeWindowStatus(IBinder token, int vis, int backDisposition);
@@ -161,9 +168,13 @@ public void animateExpand() {
161168
}
162169

163170
public void animateCollapse() {
171+
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
172+
}
173+
174+
public void animateCollapse(int flags) {
164175
synchronized (mList) {
165176
mHandler.removeMessages(MSG_SET_VISIBILITY);
166-
mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_COLLAPSE, 0, null).sendToTarget();
177+
mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_COLLAPSE, flags, null).sendToTarget();
167178
}
168179
}
169180

@@ -277,7 +288,7 @@ public void handleMessage(Message msg) {
277288
if (msg.arg1 == OP_EXPAND) {
278289
mCallbacks.animateExpand();
279290
} else {
280-
mCallbacks.animateCollapse();
291+
mCallbacks.animateCollapse(msg.arg2);
281292
}
282293
break;
283294
case MSG_SET_SYSTEMUI_VISIBILITY:

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import com.android.systemui.statusbar.BaseStatusBar;
7777
import com.android.systemui.statusbar.NotificationData;
7878
import com.android.systemui.statusbar.NotificationData.Entry;
79+
import com.android.systemui.statusbar.CommandQueue;
7980
import com.android.systemui.statusbar.RotationToggle;
8081
import com.android.systemui.statusbar.SignalClusterView;
8182
import com.android.systemui.statusbar.StatusBarIconView;
@@ -529,16 +530,29 @@ public void onClick(View v) {
529530
}
530531
};
531532

533+
private int mShowSearchHoldoff = 0;
534+
private Runnable mShowSearchPanel = new Runnable() {
535+
public void run() {
536+
showSearchPanel();
537+
}
538+
};
539+
532540
View.OnTouchListener mHomeSearchActionListener = new View.OnTouchListener() {
533541
public boolean onTouch(View v, MotionEvent event) {
534542
switch(event.getAction()) {
535-
case MotionEvent.ACTION_DOWN:
536-
if (!shouldDisableNavbarGestures()) {
537-
showSearchPanel();
538-
}
539-
break;
540-
}
541-
return false;
543+
case MotionEvent.ACTION_DOWN:
544+
if (!shouldDisableNavbarGestures()) {
545+
mHandler.removeCallbacks(mShowSearchPanel);
546+
mHandler.postDelayed(mShowSearchPanel, mShowSearchHoldoff);
547+
}
548+
break;
549+
550+
case MotionEvent.ACTION_UP:
551+
case MotionEvent.ACTION_CANCEL:
552+
mHandler.removeCallbacks(mShowSearchPanel);
553+
break;
554+
}
555+
return false;
542556
}
543557
};
544558

@@ -733,6 +747,8 @@ public void removeNotification(IBinder key) {
733747
@Override
734748
protected void onConfigurationChanged(Configuration newConfig) {
735749
updateRecentsPanel();
750+
mShowSearchHoldoff = mContext.getResources().getInteger(
751+
R.integer.config_show_search_delay);
736752
}
737753

738754
private void loadNotificationShade() {
@@ -1057,29 +1073,33 @@ public void animateExpand() {
10571073
}
10581074

10591075
public void animateCollapse() {
1060-
animateCollapse(false);
1076+
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
10611077
}
10621078

1063-
public void animateCollapse(boolean excludeRecents) {
1064-
animateCollapse(excludeRecents, 1.0f);
1079+
public void animateCollapse(int flags) {
1080+
animateCollapse(flags, 1.0f);
10651081
}
10661082

1067-
public void animateCollapse(boolean excludeRecents, float velocityMultiplier) {
1083+
public void animateCollapse(int flags, float velocityMultiplier) {
10681084
if (SPEW) {
10691085
Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded
10701086
+ " mExpandedVisible=" + mExpandedVisible
10711087
+ " mExpanded=" + mExpanded
10721088
+ " mAnimating=" + mAnimating
10731089
+ " mAnimY=" + mAnimY
1074-
+ " mAnimVel=" + mAnimVel);
1090+
+ " mAnimVel=" + mAnimVel
1091+
+ " flags=" + flags);
10751092
}
10761093

1077-
if (!excludeRecents) {
1094+
if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) {
10781095
mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL);
10791096
mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
10801097
}
1081-
mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL);
1082-
mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL);
1098+
1099+
if ((flags & CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL) == 0) {
1100+
mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL);
1101+
mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL);
1102+
}
10831103

10841104
if (!mExpandedVisible) {
10851105
return;
@@ -1941,7 +1961,7 @@ public void onClick(View v) {
19411961
}
19421962
}
19431963
if (snapshot.isEmpty()) {
1944-
animateCollapse(false);
1964+
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
19451965
return;
19461966
}
19471967
new Thread(new Runnable() {
@@ -1989,7 +2009,7 @@ public void run() {
19892009
mHandler.postDelayed(new Runnable() {
19902010
@Override
19912011
public void run() {
1992-
animateCollapse(false);
2012+
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
19932013
}
19942014
}, totalDelay + 225);
19952015
}
@@ -2016,14 +2036,14 @@ public void onReceive(Context context, Intent intent) {
20162036
String action = intent.getAction();
20172037
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
20182038
|| Intent.ACTION_SCREEN_OFF.equals(action)) {
2019-
boolean excludeRecents = false;
2039+
int flags = CommandQueue.FLAG_EXCLUDE_NONE;
20202040
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
20212041
String reason = intent.getStringExtra("reason");
2022-
if (reason != null) {
2023-
excludeRecents = reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS);
2042+
if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
2043+
flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL;
20242044
}
20252045
}
2026-
animateCollapse(excludeRecents);
2046+
animateCollapse(flags);
20272047
}
20282048
else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
20292049
updateResources();

0 commit comments

Comments
 (0)