Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1686ad93 authored by Jim Miller's avatar Jim Miller Committed by Android (Google) Code Review
Browse files

Merge "Fix 6299832: Improvements to navbar's "swipe to search""

parents 9ca10c8c 3b291870
Loading
Loading
Loading
Loading
+68 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/* apps/common/assets/default/default/skins/StatusBar.xml
**
** Copyright 2012, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

<com.android.systemui.SearchPanelView
    xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/search_panel_container"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:paddingBottom="0dip">

    <RelativeLayout
        android:id="@+id/search_bg_protect"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="0dip">

        <RelativeLayout
            android:id="@+id/search_panel_container"
            android:layout_width="wrap_content"
            android:layout_height="230dip"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true">

            <com.android.internal.widget.multiwaveview.MultiWaveView
                android:id="@+id/multi_wave_view"
                android:orientation="horizontal"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_alignParentBottom="true"
                android:background="@drawable/navbar_search_bg_scrim"

                prvandroid:targetDrawables="@array/navbar_search_targets"
                prvandroid:targetDescriptions="@array/navbar_search_target_descriptions"
                prvandroid:directionDescriptions="@array/navbar_search_direction_descriptions"
                prvandroid:handleDrawable="@drawable/navbar_search_handle"
                prvandroid:waveDrawable="@drawable/navbar_search_outerring"
                prvandroid:outerRadius="@dimen/navbar_search_target_placement_radius"
                prvandroid:snapMargin="@dimen/navbar_search_snap_margin"
                prvandroid:hitRadius="@dimen/navbar_search_hit_radius"
                prvandroid:horizontalOffset="0dip"
                prvandroid:verticalOffset="60dip"
                prvandroid:feedbackCount="0"
                prvandroid:vibrationDuration="0"
                prvandroid:alwaysTrackFinger="true"/>

        </RelativeLayout>

    </RelativeLayout>

</com.android.systemui.SearchPanelView>
+43 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/any/colors.xml
**
** Copyright 2012, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

    <array name="navbar_search_targets">
        <item>@null</item>
        <item>@*android:drawable/ic_lockscreen_search</item>
        <item>@null</item>
        <item>@null</item>
    </array>

    <array name="navbar_search_target_descriptions">
        <item>@null</item>
        <item>@*android:string/description_target_search</item>
        <item>@null</item>
        <item>@null</item>
    </array>

    <array name="navbar_search_direction_descriptions">
        <item>@null</item>
        <item>@*android:string/description_direction_left</item>
        <item>@null</item>
        <item>@null</item>
    </array>

</resources>
+29 −9
Original line number Diff line number Diff line
@@ -18,12 +18,15 @@ package com.android.systemui;

import android.animation.Animator;
import android.animation.LayoutTransition;
import android.app.SearchManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.speech.RecognizerIntent;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Slog;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -49,7 +52,7 @@ public class SearchPanelView extends FrameLayout implements
    private boolean mShowing;
    private View mSearchTargetsContainer;
    private MultiWaveView mMultiWaveView;

    private SearchManager mSearchManager;

    public SearchPanelView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
@@ -58,6 +61,14 @@ public class SearchPanelView extends FrameLayout implements
    public SearchPanelView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext = context;
        mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
        if (mSearchManager == null) {
            Slog.w(TAG, "Search manager not available");
        }
    }

    public boolean isSearchAvailable() {
        return mSearchManager != null && mSearchManager.getGlobalSearchActivity() != null;
    }

    final MultiWaveView.OnTriggerListener mMultiWaveViewListener
@@ -79,18 +90,27 @@ public class SearchPanelView extends FrameLayout implements
            final int resId = mMultiWaveView.getResourceIdForTarget(target);
            switch (resId) {
                case com.android.internal.R.drawable.ic_lockscreen_search:
                    Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
                    intent.setFlags(
                            Intent.FLAG_ACTIVITY_NEW_TASK
                            | Intent.FLAG_ACTIVITY_SINGLE_TOP
                            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startGlobalSearch();
                break;
            }
            mBar.hideSearchPanel();
        }

        private void startGlobalSearch() {
            if (mSearchManager != null) {
                ComponentName globalSearchActivity = mSearchManager.getGlobalSearchActivity();
                if (globalSearchActivity != null) {
                    Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.setComponent(globalSearchActivity);
                    try {
                        mContext.startActivity(intent);
                    } catch (ActivityNotFoundException e) {
                        Log.w(TAG, "Application not found for action " + intent.getAction());
                        Slog.w(TAG, "Application not found for action " + intent.getAction());
                    }
                } else {
                    Slog.w(TAG, "No global search activity");
                }
                    mBar.hideSearchPanel();
                break;
            }
        }
    };
+1 −1
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                  break;
             case MSG_OPEN_SEARCH_PANEL:
                 if (DEBUG) Slog.d(TAG, "opening search panel");
                 if (mSearchPanelView != null) {
                 if (mSearchPanelView != null && mSearchPanelView.isSearchAvailable()) {
                     mSearchPanelView.show(true, true);
                 }
                 break;