Merge "Fix 6398209: SearchPanel gesture improvements" into jb-dev

This commit is contained in:
Jim Miller
2012-05-30 09:26:37 -07:00
committed by Android (Google) Code Review
8 changed files with 117 additions and 55 deletions

View File

@@ -519,6 +519,10 @@ public class MultiWaveView extends View {
// Inform listener of any active targets. Typically only one will be active.
deactivateHandle(RETURN_TO_HOME_DURATION, RETURN_TO_HOME_DELAY, 0.0f, mResetListener);
dispatchTriggerEvent(activeTarget);
if (!mAlwaysTrackFinger) {
// Force ring and targets to finish animation to final expanded state
mTargetAnimations.stop();
}
} else {
// Animate handle back to the center based on current state.
deactivateHandle(HIDE_ANIMATION_DURATION, HIDE_ANIMATION_DELAY, 1.0f,
@@ -542,7 +546,6 @@ public class MultiWaveView extends View {
mTargetDrawables.get(i).setAlpha(0.0f);
}
}
mOuterRing.setAlpha(0.0f);
}
private void hideTargets(boolean animate, boolean expanded) {
@@ -809,7 +812,6 @@ public class MultiWaveView extends View {
switchToState(STATE_START, eventX, eventY);
if (!trySwitchToFirstTouchState(eventX, eventY)) {
mDragging = false;
mTargetAnimations.cancel();
ping();
}
}

View File

@@ -57,6 +57,9 @@
<!-- Show rotation lock button in phone-style notification panel. -->
<bool name="config_showRotationLock">true</bool>
<!-- Amount of time to hold off before showing the search panel when the user presses home -->
<integer name="config_show_search_delay">200</integer>
<!-- Vibration duration for MultiWaveView used in SearchPanelView -->
<integer translatable="false" name="config_vibration_duration">20</integer>
</resources>

View File

@@ -16,9 +16,7 @@
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;
@@ -40,6 +38,7 @@ import com.android.internal.widget.multiwaveview.MultiWaveView.OnTriggerListener
import com.android.systemui.R;
import com.android.systemui.recent.StatusBarTouchProxy;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.tablet.StatusBarPanel;
import com.android.systemui.statusbar.tablet.TabletStatusBar;
@@ -49,7 +48,7 @@ public class SearchPanelView extends FrameLayout implements
private static final int SEARCH_PANEL_HOLD_DURATION = 500;
static final String TAG = "SearchPanelView";
static final boolean DEBUG = TabletStatusBar.DEBUG || PhoneStatusBar.DEBUG || false;
private Context mContext;
private final Context mContext;
private BaseStatusBar mBar;
private StatusBarTouchProxy mStatusBarTouchProxy;
@@ -106,7 +105,7 @@ public class SearchPanelView extends FrameLayout implements
private void startAssistActivity() {
// Close Recent Apps if needed
mBar.animateCollapse();
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
// Launch Assist
Intent intent = getAssistIntent();
try {
@@ -160,7 +159,7 @@ public class SearchPanelView extends FrameLayout implements
protected void onFinishInflate() {
super.onFinishInflate();
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mSearchTargetsContainer = (ViewGroup) findViewById(R.id.search_panel_container);
mSearchTargetsContainer = findViewById(R.id.search_panel_container);
mStatusBarTouchProxy = (StatusBarTouchProxy) findViewById(R.id.status_bar_touch_proxy);
// TODO: fetch views
mMultiWaveView = (MultiWaveView) findViewById(R.id.multi_wave_view);
@@ -186,7 +185,7 @@ public class SearchPanelView extends FrameLayout implements
}
}
private OnPreDrawListener mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
private final OnPreDrawListener mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
mMultiWaveView.resumeAnimations();
@@ -219,7 +218,7 @@ public class SearchPanelView extends FrameLayout implements
public void hide(boolean animate) {
if (mBar != null) {
// This will indirectly cause show(false, ...) to get called
mBar.animateCollapse();
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
} else {
setVisibility(View.INVISIBLE);
}

View File

@@ -58,6 +58,7 @@ import android.widget.TextView;
import com.android.systemui.R;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.tablet.StatusBarPanel;
import com.android.systemui.statusbar.tablet.TabletStatusBar;
@@ -368,7 +369,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
}
if (mBar != null) {
// This will indirectly cause show(false, ...) to get called
mBar.animateCollapse();
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
}
}
@@ -822,7 +823,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
if (viewHolder != null) {
final TaskDescription ad = viewHolder.taskDescription;
startApplicationDetailsActivity(ad.packageName);
mBar.animateCollapse();
mBar.animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
} else {
throw new IllegalStateException("Oops, no tag on view " + selectedView);
}

View File

@@ -253,7 +253,7 @@ public abstract class BaseStatusBar extends SystemUI implements
mContext.startActivity(intent);
}
protected View.OnLongClickListener getNotificationLongClicker() {
protected View.OnLongClickListener getNotificationLongClicker() {
return new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
@@ -268,7 +268,7 @@ public abstract class BaseStatusBar extends SystemUI implements
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.notification_inspect_item) {
startApplicationDetailsActivity(packageNameF);
animateCollapse();
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
} else {
return false;
}
@@ -618,7 +618,7 @@ public abstract class BaseStatusBar extends SystemUI implements
}
// close the shade if it was open
animateCollapse();
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
visibilityChanged(false);
// If this click was on the intruder alert, hide that instead

View File

@@ -66,6 +66,13 @@ public class CommandQueue extends IStatusBar.Stub {
private static final int MSG_SET_NAVIGATION_ICON_HINTS = 14 << MSG_SHIFT;
public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
public static final int FLAG_EXCLUDE_RECENTS_PANEL = 1 << 1;
public static final int FLAG_EXCLUDE_NOTIFICATION_PANEL = 1 << 2;
public static final int FLAG_EXCLUDE_INPUT_METHODS_PANEL = 1 << 3;
public static final int FLAG_EXCLUDE_COMPAT_MODE_PANEL = 1 << 4;
private StatusBarIconList mList;
private Callbacks mCallbacks;
private Handler mHandler = new H();
@@ -88,7 +95,7 @@ public class CommandQueue extends IStatusBar.Stub {
public void removeNotification(IBinder key);
public void disable(int state);
public void animateExpand();
public void animateCollapse();
public void animateCollapse(int flags);
public void setSystemUiVisibility(int vis, int mask);
public void topAppWindowChanged(boolean visible);
public void setImeWindowStatus(IBinder token, int vis, int backDisposition);
@@ -161,9 +168,13 @@ public class CommandQueue extends IStatusBar.Stub {
}
public void animateCollapse() {
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
}
public void animateCollapse(int flags) {
synchronized (mList) {
mHandler.removeMessages(MSG_SET_VISIBILITY);
mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_COLLAPSE, 0, null).sendToTarget();
mHandler.obtainMessage(MSG_SET_VISIBILITY, OP_COLLAPSE, flags, null).sendToTarget();
}
}
@@ -277,7 +288,7 @@ public class CommandQueue extends IStatusBar.Stub {
if (msg.arg1 == OP_EXPAND) {
mCallbacks.animateExpand();
} else {
mCallbacks.animateCollapse();
mCallbacks.animateCollapse(msg.arg2);
}
break;
case MSG_SET_SYSTEMUI_VISIBILITY:

View File

@@ -76,6 +76,7 @@ import com.android.systemui.recent.RecentTasksLoader;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.RotationToggle;
import com.android.systemui.statusbar.SignalClusterView;
import com.android.systemui.statusbar.StatusBarIconView;
@@ -529,16 +530,29 @@ public class PhoneStatusBar extends BaseStatusBar {
}
};
private int mShowSearchHoldoff = 0;
private Runnable mShowSearchPanel = new Runnable() {
public void run() {
showSearchPanel();
}
};
View.OnTouchListener mHomeSearchActionListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (!shouldDisableNavbarGestures()) {
showSearchPanel();
}
break;
}
return false;
case MotionEvent.ACTION_DOWN:
if (!shouldDisableNavbarGestures()) {
mHandler.removeCallbacks(mShowSearchPanel);
mHandler.postDelayed(mShowSearchPanel, mShowSearchHoldoff);
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mHandler.removeCallbacks(mShowSearchPanel);
break;
}
return false;
}
};
@@ -733,6 +747,8 @@ public class PhoneStatusBar extends BaseStatusBar {
@Override
protected void onConfigurationChanged(Configuration newConfig) {
updateRecentsPanel();
mShowSearchHoldoff = mContext.getResources().getInteger(
R.integer.config_show_search_delay);
}
private void loadNotificationShade() {
@@ -1057,29 +1073,33 @@ public class PhoneStatusBar extends BaseStatusBar {
}
public void animateCollapse() {
animateCollapse(false);
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
}
public void animateCollapse(boolean excludeRecents) {
animateCollapse(excludeRecents, 1.0f);
public void animateCollapse(int flags) {
animateCollapse(flags, 1.0f);
}
public void animateCollapse(boolean excludeRecents, float velocityMultiplier) {
public void animateCollapse(int flags, float velocityMultiplier) {
if (SPEW) {
Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded
+ " mExpandedVisible=" + mExpandedVisible
+ " mExpanded=" + mExpanded
+ " mAnimating=" + mAnimating
+ " mAnimY=" + mAnimY
+ " mAnimVel=" + mAnimVel);
+ " mAnimVel=" + mAnimVel
+ " flags=" + flags);
}
if (!excludeRecents) {
if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) {
mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
}
mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL);
if ((flags & CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL) == 0) {
mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL);
}
if (!mExpandedVisible) {
return;
@@ -1941,7 +1961,7 @@ public class PhoneStatusBar extends BaseStatusBar {
}
}
if (snapshot.isEmpty()) {
animateCollapse(false);
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
return;
}
new Thread(new Runnable() {
@@ -1989,7 +2009,7 @@ public class PhoneStatusBar extends BaseStatusBar {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
animateCollapse(false);
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
}
}, totalDelay + 225);
}
@@ -2016,14 +2036,14 @@ public class PhoneStatusBar extends BaseStatusBar {
String action = intent.getAction();
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
|| Intent.ACTION_SCREEN_OFF.equals(action)) {
boolean excludeRecents = false;
int flags = CommandQueue.FLAG_EXCLUDE_NONE;
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
String reason = intent.getStringExtra("reason");
if (reason != null) {
excludeRecents = reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS);
if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL;
}
}
animateCollapse(excludeRecents);
animateCollapse(flags);
}
else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
updateResources();

View File

@@ -67,6 +67,7 @@ import com.android.systemui.R;
import com.android.systemui.recent.RecentTasksLoader;
import com.android.systemui.recent.RecentsPanelView;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.DoNotDisturb;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.SignalClusterView;
@@ -186,16 +187,30 @@ public class TabletStatusBar extends BaseStatusBar implements
private int mNavigationIconHints = 0;
private int mShowSearchHoldoff = 0;
public Context getContext() { return mContext; }
private Runnable mShowSearchPanel = new Runnable() {
public void run() {
showSearchPanel();
}
};
private View.OnTouchListener mHomeSearchActionListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (!shouldDisableNavbarGestures()) {
showSearchPanel();
mHandler.removeCallbacks(mShowSearchPanel);
mHandler.postDelayed(mShowSearchPanel, mShowSearchHoldoff);
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mHandler.removeCallbacks(mShowSearchPanel);
break;
}
return false;
}
@@ -387,6 +402,8 @@ public class TabletStatusBar extends BaseStatusBar implements
WindowManagerImpl.getDefault().updateViewLayout(mNotificationPanel,
mNotificationPanelParams);
mRecentsPanel.updateValuesFromResources();
mShowSearchHoldoff = mContext.getResources().getInteger(
R.integer.config_show_search_delay);
}
protected void loadDimens() {
@@ -1001,22 +1018,31 @@ public class TabletStatusBar extends BaseStatusBar implements
}
public void animateCollapse() {
animateCollapse(false);
animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE);
}
private void animateCollapse(boolean excludeRecents) {
mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PANEL);
if (!excludeRecents) {
public void animateCollapse(int flags) {
if ((flags & CommandQueue.FLAG_EXCLUDE_NOTIFICATION_PANEL) == 0) {
mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PANEL);
}
if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) {
mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
}
mHandler.removeMessages(MSG_CLOSE_INPUT_METHODS_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_INPUT_METHODS_PANEL);
mHandler.removeMessages(MSG_CLOSE_COMPAT_MODE_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_COMPAT_MODE_PANEL);
mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL);
if ((flags & CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL) == 0) {
mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL);
}
if ((flags & CommandQueue.FLAG_EXCLUDE_INPUT_METHODS_PANEL) == 0) {
mHandler.removeMessages(MSG_CLOSE_INPUT_METHODS_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_INPUT_METHODS_PANEL);
}
if ((flags & CommandQueue.FLAG_EXCLUDE_COMPAT_MODE_PANEL) == 0) {
mHandler.removeMessages(MSG_CLOSE_COMPAT_MODE_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_COMPAT_MODE_PANEL);
}
}
@Override // CommandQueue
@@ -1594,11 +1620,11 @@ public class TabletStatusBar extends BaseStatusBar implements
String action = intent.getAction();
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
|| Intent.ACTION_SCREEN_OFF.equals(action)) {
boolean excludeRecents = false;
int flags = CommandQueue.FLAG_EXCLUDE_NONE;
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
String reason = intent.getStringExtra("reason");
if (reason != null) {
excludeRecents = reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS);
if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL;
}
}
if (Intent.ACTION_SCREEN_OFF.equals(action)) {
@@ -1607,9 +1633,9 @@ public class TabletStatusBar extends BaseStatusBar implements
// TODO: hide other things, like the notification tray,
// with no animation as well
mRecentsPanel.show(false, false);
excludeRecents = true;
flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL;
}
animateCollapse(excludeRecents);
animateCollapse(flags);
}
}
};