summaryrefslogtreecommitdiffstats
path: root/src/com/android/dialer/list/SmartDialNumberListAdapter.java
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2013-06-26 18:24:32 -0700
committerYorke Lee <yorkelee@google.com>2013-07-16 12:28:32 -0700
commitdfb2eee7d98f8540fd1614db66bb03e8e1f3a26a (patch)
treea33447c38bbfa4a055e78c909176dde351b419d9 /src/com/android/dialer/list/SmartDialNumberListAdapter.java
parent6b049128c51b90e17ae14856d98130a22d3a5433 (diff)
downloadandroid_packages_apps_Dialer-dfb2eee7d98f8540fd1614db66bb03e8e1f3a26a.tar.gz
android_packages_apps_Dialer-dfb2eee7d98f8540fd1614db66bb03e8e1f3a26a.tar.bz2
android_packages_apps_Dialer-dfb2eee7d98f8540fd1614db66bb03e8e1f3a26a.zip
Initial commit of all new dialer activities, layouts and styles
As far as possible, this change does not modify any behavior/look of the existing dialer. All modifications to classes/layouts/style attributes that would affect functionality of the old dialer are instead done in separate new files. Added new versions of all activities, fragments, layouts, menus and resources that have been rewritten or modified. The activities do not have intent filters yet in order to not interfere with the existing dialer. Added some new values in colors/styles/dimens for the newly added layouts. Added NewCallLogActivity to separate the CallLogFragment from DialtactsActivity. All call log and voicemail entries are now presented in a separate (New)CallLogActivity. IntentProvider.getCallDetailIntent now takes a cursor instead of an adapter for more flexibility. Add OnListFragmentScrolledListener interface for DialtactsActivity to receive callback when one of its children fragment is scrolled. Added slide in and slide out animations for DialpadFragment. Add slide up and hide animations for search view All menu options now show up in a PopupMenu in NewPhoneFavoriteFragment. Added call log adapter into NewPhoneFavoriteMergedAdapter. Rewrote layout of DialpadFragment to show up as a fragment partially overlaying the screen. Removed some unused code in DialpadFragment (smart dialing, menu handling) Add fragments and adapters for SmartDial. - Update Dialer database to support highlight masking and record contact data Uri, as well as photo uri - Add a fragment and adapter for smart dialing - Add SmartDialCursorLoader to load SmartDial results. - Typing in the dialpad now returns smart dialing results instead of regular search results QuickContactTiles for all sub-adapters of PhoneFavoriteMergedAdapter now use light theme instead of the the default dark theme. Removed all redundant call log filter and contacts to display filter code Moved Dialer specific UI list-related classes to the Dialer package Change-Id: I34885813e4fa79b69e29ac870a87a56d6f08a5e7
Diffstat (limited to 'src/com/android/dialer/list/SmartDialNumberListAdapter.java')
-rw-r--r--src/com/android/dialer/list/SmartDialNumberListAdapter.java114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/com/android/dialer/list/SmartDialNumberListAdapter.java b/src/com/android/dialer/list/SmartDialNumberListAdapter.java
new file mode 100644
index 000000000..0413c4ee5
--- /dev/null
+++ b/src/com/android/dialer/list/SmartDialNumberListAdapter.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2013 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.dialer.list;
+
+import android.content.ContentUris;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Callable;
+import android.telephony.PhoneNumberUtils;
+import android.util.Log;
+
+import com.android.contacts.common.list.ContactListItemView;
+import com.android.contacts.common.list.PhoneNumberListAdapter;
+import com.android.dialer.dialpad.SmartDialCursorLoader;
+import com.android.dialer.dialpad.SmartDialCursorLoader.SmartDialPhoneQuery;
+import com.android.dialer.dialpad.SmartDialNameMatcher;
+import com.android.dialer.dialpad.SmartDialPrefix;
+import com.android.dialer.dialpad.SmartDialMatchPosition;
+
+import java.util.ArrayList;
+
+/**
+ * List adapter to display the SmartDial search results.
+ */
+public class SmartDialNumberListAdapter extends PhoneNumberListAdapter{
+
+ private static final String TAG = SmartDialNumberListAdapter.class.getSimpleName();
+ private static final boolean DEBUG = false;
+
+ private SmartDialNameMatcher mNameMatcher;
+
+ public SmartDialNumberListAdapter(Context context) {
+ super(context);
+ if (DEBUG) {
+ Log.v(TAG, "Constructing List Adapter");
+ }
+ }
+
+ /**
+ * Sets query for the SmartDialCursorLoader.
+ */
+ public void configureLoader(SmartDialCursorLoader loader) {
+ if (DEBUG) {
+ Log.v(TAG, "Congifugure Loader with query" + getQueryString());
+ }
+
+ if (getQueryString() == null) {
+ mNameMatcher = new SmartDialNameMatcher("", SmartDialPrefix.getMap());
+ loader.configureQuery("");
+ } else {
+ loader.configureQuery(getQueryString());
+ mNameMatcher = new SmartDialNameMatcher(PhoneNumberUtils.normalizeNumber(
+ getQueryString()), SmartDialPrefix.getMap());
+ }
+ }
+
+ /**
+ * Sets highlight options for a List item in the SmartDial search results.
+ * @param view ContactListItemView where the result will be displayed.
+ * @param cursor Object containing information of the associated List item.
+ */
+ @Override
+ protected void setHighlight(ContactListItemView view, Cursor cursor) {
+ view.clearHighlightSequences();
+
+ if (mNameMatcher.matches(cursor.getString(SmartDialPhoneQuery.SMARTDIAL_DISPLAY_NAME))) {
+ final ArrayList<SmartDialMatchPosition> nameMatches = mNameMatcher.getMatchPositions();
+ for (SmartDialMatchPosition match:nameMatches) {
+ view.addNameHighlightSequence(match.start, match.end);
+ if (DEBUG) {
+ Log.v(TAG, cursor.getString(SmartDialPhoneQuery.SMARTDIAL_DISPLAY_NAME) + " " +
+ mNameMatcher.getQuery() + " " + String.valueOf(match.start));
+ }
+ }
+ }
+
+ final SmartDialMatchPosition numberMatch = mNameMatcher.matchesNumber(cursor.getString(
+ SmartDialPhoneQuery.SMARTDIAL_NUMBER));
+ if (numberMatch != null) {
+ view.addNumberHighlightSequence(numberMatch.start, numberMatch.end);
+ }
+ }
+
+ /**
+ * Gets Uri for the list item at the given position.
+ * @param position Location of the data of interest.
+ * @return Data Uri of the entry.
+ */
+ public Uri getDataUri(int position) {
+ Cursor cursor = ((Cursor)getItem(position));
+ if (cursor != null) {
+ long id = cursor.getLong(SmartDialPhoneQuery.SMARTDIAL_ID);
+ return ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, id);
+ } else {
+ Log.w(TAG, "Cursor was null in getDataUri() call. Returning null instead.");
+ return null;
+ }
+ }
+}