diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-04-14 20:30:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-04-14 20:30:35 +0000 |
commit | 42fd6617649dc6bdd9df6f36fc00cdef716a5002 (patch) | |
tree | dfd8a05a0d871d72d1cd59eb8b66cc37b6f6af51 | |
parent | a16cb24e5b5690af55597ad5c8540a7c90ae146a (diff) | |
parent | 476856e35551612a71a33c0f797d09dc73569f2f (diff) | |
download | platform_packages_apps_Car_Dialer-42fd6617649dc6bdd9df6f36fc00cdef716a5002.tar.gz platform_packages_apps_Car_Dialer-42fd6617649dc6bdd9df6f36fc00cdef716a5002.tar.bz2 platform_packages_apps_Car_Dialer-42fd6617649dc6bdd9df6f36fc00cdef716a5002.zip |
Merge "More search in dialer."
-rw-r--r-- | res/layout/contact_detail_name_image.xml | 62 | ||||
-rw-r--r-- | res/layout/contact_details.xml | 25 | ||||
-rw-r--r-- | res/layout/contact_details_number.xml | 38 | ||||
-rw-r--r-- | res/layout/no_hfp.xml | 47 | ||||
-rw-r--r-- | res/layout/strequents_fragment.xml | 8 | ||||
-rw-r--r-- | res/values/dimens.xml | 3 | ||||
-rw-r--r-- | res/values/strings.xml | 5 | ||||
-rw-r--r-- | res/values/styles.xml | 6 | ||||
-rw-r--r-- | src/com/android/car/dialer/ContactDetailsFragment.java | 300 | ||||
-rw-r--r-- | src/com/android/car/dialer/StrequentsFragment.java | 16 | ||||
-rw-r--r-- | src/com/android/car/dialer/TelecomActivity.java | 34 |
11 files changed, 491 insertions, 53 deletions
diff --git a/res/layout/contact_detail_name_image.xml b/res/layout/contact_detail_name_image.xml new file mode 100644 index 00000000..dc82d58d --- /dev/null +++ b/res/layout/contact_detail_name_image.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2017 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. +--> +<!-- This FrameLayout is used to center the inner layout. --> +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="@dimen/call_log_card_overlap" + android:focusable="true"> + + <!-- Wraps everything in a card --> + <com.android.car.stream.ui.StreamCardView + android:id="@+id/card" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:backgroundTint="@color/car_grey_200" + android:backgroundTintMode="multiply" + android:layout_gravity="center"> + + <!-- Used to provide common margins and also allow for the textview to set its right margin + to the width of the image to allow it to ellipsize. + --> + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginLeft="@dimen/stream_card_keyline_1" + android:layout_marginRight="@dimen/stream_card_keyline_1" + android:layout_marginTop="@dimen/contact_detail_vertical_margin" + android:layout_marginBottom="@dimen/contact_detail_vertical_margin"> + + <TextView + android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom|left" + android:layout_marginRight="@dimen/contact_detail_image_size" + android:singleLine="true" + android:ellipsize="end" + style="@style/CarHeadline1" /> + + <ImageView + android:id="@+id/right_icon" + android:layout_width="@dimen/contact_detail_image_size" + android:layout_height="@dimen/contact_detail_image_size" + android:background="@drawable/avatar_rounded_bg" + android:layout_gravity="right" /> + </FrameLayout> + </com.android.car.stream.ui.StreamCardView> +</FrameLayout> diff --git a/res/layout/contact_details.xml b/res/layout/contact_details.xml new file mode 100644 index 00000000..6d05b3b5 --- /dev/null +++ b/res/layout/contact_details.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2017 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. +--> +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/telecom_display_scrim" + android:clickable="true" + android:clipChildren="false"> + + <include layout="@layout/paged_list" /> +</FrameLayout> diff --git a/res/layout/contact_details_number.xml b/res/layout/contact_details_number.xml new file mode 100644 index 00000000..928d789e --- /dev/null +++ b/res/layout/contact_details_number.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 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. +--> +<!-- This FrameLayout is used to center the inner layout. --> +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="@dimen/call_log_card_overlap" + android:focusable="true"> + + <com.android.car.stream.ui.StreamCardView + android:id="@+id/card" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center"> + + <include layout="@layout/car_list_item_2" /> + <View + android:layout_width="match_parent" + android:layout_height="@dimen/car_divider_height" + android:background="@color/car_list_divider" + android:layout_gravity="bottom" + android:layout_marginLeft="@dimen/stream_card_keyline_2" /> + </com.android.car.stream.ui.StreamCardView> +</FrameLayout> diff --git a/res/layout/no_hfp.xml b/res/layout/no_hfp.xml index 1d453f18..2a7909ac 100644 --- a/res/layout/no_hfp.xml +++ b/res/layout/no_hfp.xml @@ -13,38 +13,25 @@ See the License for the specific language governing permissions and limitations under the License. --> -<FrameLayout +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="@color/telecom_display_scrim"> - <FrameLayout - android:background="@color/telecom_display_scrim" - android:layout_width="match_parent" - android:layout_height="match_parent" /> + <ImageView + android:id="@+id/error_icon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:src="@drawable/car_ic_bluetooth_disable_large" /> - <LinearLayout + <TextView + android:id="@+id/error_string" android:layout_width="@dimen/apps_max_content_width" - android:layout_height="match_parent" - android:layout_gravity="center_horizontal" - android:gravity="center_horizontal" - android:layout_marginTop="@dimen/lens_header_height" - android:orientation="vertical" > - <ImageView - android:id="@+id/error_icon" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="144dp" - android:src="@drawable/car_ic_bluetooth_disable_large" /> - <TextView - android:id="@+id/error_string" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="132dp" - android:layout_marginTop="32dp" - android:layout_marginRight="132dp" - android:text="@string/no_hfp" - style="@style/CarBody2.Light" - android:maxLines="3" /> - </LinearLayout> -</FrameLayout> + android:layout_height="wrap_content" + android:layout_below="@id/error_icon" + android:layout_centerHorizontal="true" + android:text="@string/no_hfp" + style="@style/NoHfpText"/> +</RelativeLayout> diff --git a/res/layout/strequents_fragment.xml b/res/layout/strequents_fragment.xml index ce534381..3fffea38 100644 --- a/res/layout/strequents_fragment.xml +++ b/res/layout/strequents_fragment.xml @@ -17,12 +17,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@color/telecom_display_scrim" android:clipChildren="false" > - <FrameLayout - android:background="@color/telecom_display_scrim" - android:layout_width="match_parent" - android:layout_height="match_parent" /> - - <include layout="@layout/paged_list" /> + <include layout="@layout/paged_list" /> </FrameLayout> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 8aa4937c..f306f89a 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -67,4 +67,7 @@ <dimen name="call_log_icon_size">@dimen/car_list_item_icon_size</dimen> <dimen name="icon_container_height">@dimen/car_list_item_icon_size</dimen> + + <dimen name="contact_detail_image_size">@dimen/in_call_small_contact_photo_size</dimen> + <dimen name="contact_detail_vertical_margin">16dp</dimen> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 108e08a2..21ac1b59 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -105,4 +105,9 @@ <string name="search_title">Search contacts</string> <string name="search_hint">Enter the name of a contact</string> + <string name="type_home">Home</string> + <string name="type_work">Work</string> + <string name="type_mobile">Mobile</string> + <string name="type_other">Other</string> + </resources> diff --git a/res/values/styles.xml b/res/values/styles.xml index f4aaafc2..5866d20e 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -38,4 +38,10 @@ <item name="android:textSize">@dimen/keyboard_key_letter_height</item> <item name="android:textColor">@color/car_headline1</item> </style> + + <style name="NoHfpText" parent="CarBody2.Light"> + <item name="android:textColor">@color/car_body1_light</item> + <item name="android:gravity">center</item> + <item name="android:maxLines">3</item> + </style> </resources> diff --git a/src/com/android/car/dialer/ContactDetailsFragment.java b/src/com/android/car/dialer/ContactDetailsFragment.java new file mode 100644 index 00000000..825857ac --- /dev/null +++ b/src/com/android/car/dialer/ContactDetailsFragment.java @@ -0,0 +1,300 @@ +/* + * Copyright (C) 2017 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. + */ +package com.android.car.dialer; + +import android.database.Cursor; +import android.graphics.Canvas; +import android.net.Uri; +import android.os.Bundle; +import android.provider.ContactsContract; +import android.support.v4.app.Fragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.support.v7.widget.RecyclerView; +import android.util.Log; +import android.util.Pair; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.android.car.dialer.telecom.TelecomUtils; +import com.android.car.view.PagedListView; + +import java.util.ArrayList; +import java.util.List; + +/** + * A fragment that shows the name of the contact, the photo and all listed phone numbers. It is + * primarily used to respond to the results of search queries but supplying it with the content:// + * uri of a contact should work too. + */ +public class ContactDetailsFragment extends Fragment + implements LoaderManager.LoaderCallbacks<Cursor> { + private static final String TAG = "ContactDetailsFragment"; + private static final int DETAILS_QUERY_ID = 31415; + private static final int PHONE_QUERY_ID = 42; + private static final String KEY_URI = "uri"; + + private static final String[] CONTACT_DETAILS_PROJECTION = { + ContactsContract.Contacts._ID, + ContactsContract.Contacts.DISPLAY_NAME, + ContactsContract.Contacts.PHOTO_URI, + ContactsContract.Contacts.HAS_PHONE_NUMBER + }; + + private PagedListView mListView; + + public static ContactDetailsFragment newInstance(Uri uri) { + ContactDetailsFragment fragment = new ContactDetailsFragment(); + Bundle args = new Bundle(); + args.putParcelable(KEY_URI, uri); + fragment.setArguments(args); + return fragment; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.contact_details, container, false); + mListView = v.findViewById(R.id.list_view); + // Disable the default recyclerview decoration. + mListView.setDefaultItemDecoration(new PagedListView.Decoration(getContext()) { + @Override + public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { } + }); + return v; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + getLoaderManager().initLoader(DETAILS_QUERY_ID, null, this); + } + + @Override + public Loader<Cursor> onCreateLoader(int id, Bundle args) { + if (vdebug()) { + Log.d(TAG, "onCreateLoader id=" + id); + } + + if (id != DETAILS_QUERY_ID) { + return null; + } + + Uri contactUri = getArguments().getParcelable(KEY_URI); + return new CursorLoader(getContext(), contactUri, CONTACT_DETAILS_PROJECTION, + null /* selection */, null /* selectionArgs */, null /* sortOrder */); + } + + @Override + public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { + if (vdebug()) { + Log.d(TAG, "onLoadFinished"); + } + + if (cursor.moveToFirst()) { + mListView.setAdapter(new ContactDetailsAdapter(cursor)); + } + } + + @Override + public void onLoaderReset(Loader loader) { } + + private boolean vdebug() { + return Log.isLoggable(TAG, Log.DEBUG); + } + + class ContactDetailViewHolder extends RecyclerView.ViewHolder { + public View card; + public ImageView leftIcon; + public TextView title; + public TextView text; + public ImageView rightIcon; + + private int mViewType; + + public ContactDetailViewHolder(View v) { + super(v); + card = v.findViewById(R.id.card); + leftIcon = v.findViewById(R.id.icon); + title = v.findViewById(R.id.title); + text = v.findViewById(R.id.text); + rightIcon = v.findViewById(R.id.right_icon); + } + } + + class ContactDetailsAdapter extends RecyclerView.Adapter<ContactDetailViewHolder> + implements PagedListView.ItemCap { + + private static final int ID_HEADER = 1; + private static final int ID_CONTENT = 2; + + private final List<ContactDetailViewHolder> mData = new ArrayList<>(); + private final Cursor mCursor; + + private final String mContactName; + private final String mContactPhotoUri; + + private List<Pair<String, String>> mPhoneNumbers = new ArrayList<>(); + + public ContactDetailsAdapter(Cursor cursor) { + super(); + mCursor = cursor; + + int idColIdx = cursor.getColumnIndex(ContactsContract.Contacts._ID); + String contactId = cursor.getString(idColIdx); + int nameColIdx = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); + mContactName = cursor.getString(nameColIdx); + int photoColIdx = cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_URI); + mContactPhotoUri = cursor.getString(photoColIdx); + int hasPhoneColIdx = cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER); + boolean hasPhoneNumber = Integer.parseInt(cursor.getString(hasPhoneColIdx)) > 0; + + if (!hasPhoneNumber) { + return; + } + + // Fetch the phone number from the contacts db using another loader. + getLoaderManager().initLoader(PHONE_QUERY_ID, null, + new LoaderManager.LoaderCallbacks<Cursor>() { + @Override + public Loader<Cursor> onCreateLoader(int id, Bundle args) { + return new CursorLoader(getContext(), + ContactsContract.CommonDataKinds.Phone.CONTENT_URI, + null, /* All columns **/ + ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", + new String[] { contactId }, + null /* sortOrder */); + } + + public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { + while (cursor.moveToNext()) { + int typeColIdx = cursor.getColumnIndex( + ContactsContract.CommonDataKinds.Phone.TYPE); + int type = cursor.getInt(typeColIdx); + int numberColIdx = cursor.getColumnIndex( + ContactsContract.CommonDataKinds.Phone.NUMBER); + String number = cursor.getString(numberColIdx); + String numberType; + switch (type) { + case ContactsContract.CommonDataKinds.Phone.TYPE_HOME: + numberType = getString(R.string.type_home); + break; + case ContactsContract.CommonDataKinds.Phone.TYPE_WORK: + numberType = getString(R.string.type_work); + break; + case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE: + numberType = getString(R.string.type_mobile); + break; + default: + numberType = getString(R.string.type_other); + } + mPhoneNumbers.add(new Pair<>(numberType, + TelecomUtils.getFormattedNumber(getContext(), number))); + notifyItemInserted(mPhoneNumbers.size()); + } + notifyDataSetChanged(); + } + + public void onLoaderReset(Loader loader) { } + }); + } + + /** + * Appropriately sets the background for the View that is being bound. This method will + * allow for rounded corners on either the top or bottom of a card. + */ + private void setBackground(ContactDetailViewHolder viewHolder) { + int itemCount = getItemCount(); + int adapterPosition = viewHolder.getAdapterPosition(); + + if (itemCount == 1) { + // Only element - all corners are rounded + viewHolder.card.setBackgroundResource( + R.drawable.car_card_rounded_top_bottom_background); + } else if (adapterPosition == 0) { + // First element gets rounded top + viewHolder.card.setBackgroundResource(R.drawable.car_card_rounded_top_background); + } else if (adapterPosition == itemCount - 1) { + // Last one has a rounded bottom + viewHolder.card.setBackgroundResource( + R.drawable.car_card_rounded_bottom_background); + } else { + // Middle have no rounded corners + viewHolder.card.setBackgroundResource(R.color.car_card); + } + } + + @Override + public int getItemViewType(int position) { + return position == 0 ? ID_HEADER : ID_CONTENT; + } + + @Override + public void setMaxItems(int maxItems) { + // Ignore. + } + + @Override + public int getItemCount() { + return mPhoneNumbers.size() + 1; // +1 for the header row. + } + + public ContactDetailViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + int layoutResId; + switch (viewType) { + case ID_HEADER: + layoutResId = R.layout.contact_detail_name_image; + break; + case ID_CONTENT: + layoutResId = R.layout.contact_details_number; + break; + default: + Log.e(TAG, "Unknown view type " + viewType); + return null; + } + + View view = LayoutInflater.from(parent.getContext()).inflate(layoutResId, null); + return new ContactDetailViewHolder(view); + } + + public void onBindViewHolder(ContactDetailViewHolder viewHolder, int position) { + switch (viewHolder.getItemViewType()) { + case ID_HEADER: + viewHolder.title.setText(mContactName); + if (!mPhoneNumbers.isEmpty()) { + String firstNumber = mPhoneNumbers.get(0).second; + TelecomUtils.setContactBitmapAsync(getContext(), viewHolder.rightIcon, + mContactName, firstNumber); + } + break; + case ID_CONTENT: + Pair<String, String> data = mPhoneNumbers.get(position - 1); + viewHolder.title.setText(data.first); + viewHolder.text.setText(data.second); + viewHolder.leftIcon.setImageResource(R.drawable.ic_phone); + break; + default: + Log.e(TAG, "Unknown view type " + viewHolder.getItemViewType()); + return; + } + setBackground(viewHolder); + } + } +} diff --git a/src/com/android/car/dialer/StrequentsFragment.java b/src/com/android/car/dialer/StrequentsFragment.java index 4e5e5ac1..87bb668e 100644 --- a/src/com/android/car/dialer/StrequentsFragment.java +++ b/src/com/android/car/dialer/StrequentsFragment.java @@ -19,7 +19,6 @@ import android.content.ContentResolver; import android.content.Context; import android.content.CursorLoader; import android.content.Loader; -import android.content.res.Configuration; import android.database.ContentObserver; import android.database.Cursor; import android.graphics.Canvas; @@ -132,9 +131,6 @@ public class StrequentsFragment extends Fragment { }); mListView.setMaxPages(maxPages); mListView.setAdapter(mAdapter); - if (getResources().getConfiguration().navigation == Configuration.NAVIGATION_WHEEL) { - mAdapter.setFocusChangeListener(mFocusListener); - } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "setItemAnimator"); @@ -208,18 +204,6 @@ public class StrequentsFragment extends Fragment { } } - private final View.OnFocusChangeListener mFocusListener = new View.OnFocusChangeListener() { - @Override - public void onFocusChange(View v, boolean hasFocus) { - // You can only invalidate decorations when RecyclerView is not in the process - // of laying out or scrolling. - if (!mListView.getRecyclerView().isInLayout() && - !mListView.getLayoutManager().isSmoothScrolling()) { - mListView.getRecyclerView().invalidateItemDecorations(); - } - } - }; - /** * A {@link ContentResolver} that is responsible for reloading the user's starred and frequent * contacts. diff --git a/src/com/android/car/dialer/TelecomActivity.java b/src/com/android/car/dialer/TelecomActivity.java index a23c0631..499f6f16 100644 --- a/src/com/android/car/dialer/TelecomActivity.java +++ b/src/com/android/car/dialer/TelecomActivity.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.SearchView; @@ -28,6 +29,7 @@ import android.telecom.Call; import android.telephony.PhoneNumberUtils; import android.util.Log; import android.view.Menu; +import android.view.MenuItem; import android.view.MenuInflater; import com.android.car.app.CarDrawerActivity; @@ -40,6 +42,7 @@ import com.android.car.dialer.telecom.UiCallManager.CallListener; import java.util.List; +import static android.provider.Contacts.Intents.SEARCH_SUGGESTION_CLICKED; import static android.support.v7.widget.Toolbar.LayoutParams.MATCH_PARENT; /** @@ -109,7 +112,24 @@ public class TelecomActivity extends CarDrawerActivity implements inflater.inflate(R.menu.options_menu, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); - SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); + MenuItem searchItem = menu.findItem(R.id.search); + searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { + @Override + public boolean onMenuItemActionExpand(MenuItem item) { + return true; + } + + @Override + public boolean onMenuItemActionCollapse(MenuItem item) { + // The back arrow on the search view causes this to trigger. It isn't really a back + // at all so we can't use the back stack and instead we just set the speed dial + // fragment manually. + showSpeedDialFragment(); + return true; + } + }); + + SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT)); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); @@ -225,6 +245,11 @@ public class TelecomActivity extends CarDrawerActivity implements } break; + case SEARCH_SUGGESTION_CLICKED: + Uri contactUri = intent.getData(); + showContactDetailFragment(contactUri); + break; + default: // Do nothing. } @@ -388,6 +413,13 @@ public class TelecomActivity extends CarDrawerActivity implements mCurrentFragment = frag; } + + private void showContactDetailFragment(Uri contactUri) { + ContactDetailsFragment fragment = ContactDetailsFragment.newInstance(contactUri); + setContentFragment(fragment); + mCurrentFragment = fragment; + } + private void setContentFragmentWithSlideAndDelayAnimation(Fragment fragment) { if (vdebug()) { Log.d(TAG, "setContentFragmentWithSlideAndDelayAnimation, fragment: " + fragment); |