Skip to content

Commit 1686ad9

Browse files
Jim MillerAndroid (Google) Code Review
authored andcommitted
Merge "Fix 6299832: Improvements to navbar's "swipe to search""
2 parents 9ca10c8 + 3b29187 commit 1686ad9

File tree

4 files changed

+141
-10
lines changed

4 files changed

+141
-10
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/* apps/common/assets/default/default/skins/StatusBar.xml
4+
**
5+
** Copyright 2012, The Android Open Source Project
6+
**
7+
** Licensed under the Apache License, Version 2.0 (the "License");
8+
** you may not use this file except in compliance with the License.
9+
** You may obtain a copy of the License at
10+
**
11+
** http://www.apache.org/licenses/LICENSE-2.0
12+
**
13+
** Unless required by applicable law or agreed to in writing, software
14+
** distributed under the License is distributed on an "AS IS" BASIS,
15+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
** See the License for the specific language governing permissions and
17+
** limitations under the License.
18+
*/
19+
-->
20+
21+
<com.android.systemui.SearchPanelView
22+
xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android"
23+
xmlns:android="http://schemas.android.com/apk/res/android"
24+
android:id="@+id/search_panel_container"
25+
android:layout_height="wrap_content"
26+
android:layout_width="match_parent"
27+
android:paddingBottom="0dip">
28+
29+
<RelativeLayout
30+
android:id="@+id/search_bg_protect"
31+
android:layout_width="match_parent"
32+
android:layout_height="wrap_content"
33+
android:layout_marginBottom="0dip">
34+
35+
<RelativeLayout
36+
android:id="@+id/search_panel_container"
37+
android:layout_width="wrap_content"
38+
android:layout_height="230dip"
39+
android:layout_alignParentBottom="true"
40+
android:layout_alignParentLeft="true">
41+
42+
<com.android.internal.widget.multiwaveview.MultiWaveView
43+
android:id="@+id/multi_wave_view"
44+
android:orientation="horizontal"
45+
android:layout_width="wrap_content"
46+
android:layout_height="match_parent"
47+
android:layout_alignParentBottom="true"
48+
android:background="@drawable/navbar_search_bg_scrim"
49+
50+
prvandroid:targetDrawables="@array/navbar_search_targets"
51+
prvandroid:targetDescriptions="@array/navbar_search_target_descriptions"
52+
prvandroid:directionDescriptions="@array/navbar_search_direction_descriptions"
53+
prvandroid:handleDrawable="@drawable/navbar_search_handle"
54+
prvandroid:waveDrawable="@drawable/navbar_search_outerring"
55+
prvandroid:outerRadius="@dimen/navbar_search_target_placement_radius"
56+
prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
57+
prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
58+
prvandroid:horizontalOffset="0dip"
59+
prvandroid:verticalOffset="60dip"
60+
prvandroid:feedbackCount="0"
61+
prvandroid:vibrationDuration="0"
62+
prvandroid:alwaysTrackFinger="true"/>
63+
64+
</RelativeLayout>
65+
66+
</RelativeLayout>
67+
68+
</com.android.systemui.SearchPanelView>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/* //device/apps/common/assets/res/any/colors.xml
4+
**
5+
** Copyright 2012, The Android Open Source Project
6+
**
7+
** Licensed under the Apache License, Version 2.0 (the "License");
8+
** you may not use this file except in compliance with the License.
9+
** You may obtain a copy of the License at
10+
**
11+
** http://www.apache.org/licenses/LICENSE-2.0
12+
**
13+
** Unless required by applicable law or agreed to in writing, software
14+
** distributed under the License is distributed on an "AS IS" BASIS,
15+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
** See the License for the specific language governing permissions and
17+
** limitations under the License.
18+
*/
19+
-->
20+
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
21+
22+
<array name="navbar_search_targets">
23+
<item>@null</item>
24+
<item>@*android:drawable/ic_lockscreen_search</item>
25+
<item>@null</item>
26+
<item>@null</item>
27+
</array>
28+
29+
<array name="navbar_search_target_descriptions">
30+
<item>@null</item>
31+
<item>@*android:string/description_target_search</item>
32+
<item>@null</item>
33+
<item>@null</item>
34+
</array>
35+
36+
<array name="navbar_search_direction_descriptions">
37+
<item>@null</item>
38+
<item>@*android:string/description_direction_left</item>
39+
<item>@null</item>
40+
<item>@null</item>
41+
</array>
42+
43+
</resources>

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

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818

1919
import android.animation.Animator;
2020
import android.animation.LayoutTransition;
21+
import android.app.SearchManager;
2122
import android.content.ActivityNotFoundException;
23+
import android.content.ComponentName;
2224
import android.content.Context;
2325
import android.content.Intent;
2426
import android.speech.RecognizerIntent;
2527
import android.util.AttributeSet;
2628
import android.util.Log;
29+
import android.util.Slog;
2730
import android.view.MotionEvent;
2831
import android.view.View;
2932
import android.view.ViewGroup;
@@ -49,7 +52,7 @@ public class SearchPanelView extends FrameLayout implements
4952
private boolean mShowing;
5053
private View mSearchTargetsContainer;
5154
private MultiWaveView mMultiWaveView;
52-
55+
private SearchManager mSearchManager;
5356

5457
public SearchPanelView(Context context, AttributeSet attrs) {
5558
this(context, attrs, 0);
@@ -58,6 +61,14 @@ public SearchPanelView(Context context, AttributeSet attrs) {
5861
public SearchPanelView(Context context, AttributeSet attrs, int defStyle) {
5962
super(context, attrs, defStyle);
6063
mContext = context;
64+
mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
65+
if (mSearchManager == null) {
66+
Slog.w(TAG, "Search manager not available");
67+
}
68+
}
69+
70+
public boolean isSearchAvailable() {
71+
return mSearchManager != null && mSearchManager.getGlobalSearchActivity() != null;
6172
}
6273

6374
final MultiWaveView.OnTriggerListener mMultiWaveViewListener
@@ -79,18 +90,27 @@ public void onTrigger(View v, int target) {
7990
final int resId = mMultiWaveView.getResourceIdForTarget(target);
8091
switch (resId) {
8192
case com.android.internal.R.drawable.ic_lockscreen_search:
82-
Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
83-
intent.setFlags(
84-
Intent.FLAG_ACTIVITY_NEW_TASK
85-
| Intent.FLAG_ACTIVITY_SINGLE_TOP
86-
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
93+
startGlobalSearch();
94+
break;
95+
}
96+
mBar.hideSearchPanel();
97+
}
98+
99+
private void startGlobalSearch() {
100+
if (mSearchManager != null) {
101+
ComponentName globalSearchActivity = mSearchManager.getGlobalSearchActivity();
102+
if (globalSearchActivity != null) {
103+
Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
104+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
105+
intent.setComponent(globalSearchActivity);
87106
try {
88107
mContext.startActivity(intent);
89108
} catch (ActivityNotFoundException e) {
90-
Log.w(TAG, "Application not found for action " + intent.getAction());
109+
Slog.w(TAG, "Application not found for action " + intent.getAction());
91110
}
92-
mBar.hideSearchPanel();
93-
break;
111+
} else {
112+
Slog.w(TAG, "No global search activity");
113+
}
94114
}
95115
}
96116
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public void handleMessage(Message m) {
396396
break;
397397
case MSG_OPEN_SEARCH_PANEL:
398398
if (DEBUG) Slog.d(TAG, "opening search panel");
399-
if (mSearchPanelView != null) {
399+
if (mSearchPanelView != null && mSearchPanelView.isSearchAvailable()) {
400400
mSearchPanelView.show(true, true);
401401
}
402402
break;

0 commit comments

Comments
 (0)