Merge "Make search behave correctly"
diff --git a/res/layout/call_log_fragment.xml b/res/layout/call_log_fragment.xml
index 2d0b9b5..ff7dd4b 100644
--- a/res/layout/call_log_fragment.xml
+++ b/res/layout/call_log_fragment.xml
@@ -18,7 +18,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
->
+ android:paddingBottom="?android:attr/actionBarSize">
+
<FrameLayout
android:id="@+id/voicemail_status"
android:layout_width="match_parent"
diff --git a/res/layout/contact_tile_frequent_phone.xml b/res/layout/contact_tile_frequent_phone.xml
new file mode 100644
index 0000000..e0ea0fb
--- /dev/null
+++ b/res/layout/contact_tile_frequent_phone.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+<view
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ class="com.android.contacts.list.ContactTileView"
+ android:focusable="true"
+ android:background="@drawable/list_selector"
+ android:paddingRight="16dip"
+ android:paddingLeft="16dip" >
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <QuickContactBadge
+ android:id="@+id/contact_tile_quick"
+ android:layout_width="64dip"
+ android:layout_height="64dip"
+ android:scaleType="centerCrop"
+ android:layout_alignParentLeft="true" />
+
+ <TextView
+ android:id="@+id/contact_tile_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:layout_marginLeft="8dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:layout_marginTop="8dip"
+ android:layout_toRightOf="@id/contact_tile_quick" />
+
+ <TextView
+ android:id="@+id/contact_tile_phone_number"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="12sp"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:textColor="#cccccc"
+ android:layout_marginLeft="12dip"
+ android:layout_toRightOf="@id/contact_tile_quick"
+ android:layout_below="@id/contact_tile_name" />
+
+ <TextView
+ android:id="@+id/contact_tile_phone_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="12sp"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:textColor="#cccccc"
+ android:layout_marginLeft="12dip"
+ android:layout_alignParentRight="true"
+ android:layout_alignTop="@id/contact_tile_phone_number" />
+
+ </RelativeLayout>
+
+</view>
diff --git a/res/layout/contact_tile_list.xml b/res/layout/contact_tile_list.xml
index c72386e..2047b13 100644
--- a/res/layout/contact_tile_list.xml
+++ b/res/layout/contact_tile_list.xml
@@ -17,7 +17,8 @@
<FrameLayout
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:paddingBottom="?attr/favorites_padding_bottom">
<ListView
android:id="@+id/contact_tile_list"
diff --git a/res/layout/contact_tile_starred_secondary_target.xml b/res/layout/contact_tile_starred_secondary_target.xml
index 5d4e55e..f7b8673 100644
--- a/res/layout/contact_tile_starred_secondary_target.xml
+++ b/res/layout/contact_tile_starred_secondary_target.xml
@@ -35,29 +35,24 @@
android:layout_alignParentBottom="true"
style="@style/ContactTileStarredShadowBox" />
- <LinearLayout
+ <TextView
+ android:id="@+id/contact_tile_name"
android:layout_width="match_parent"
- android:layout_height="48dip"
+ android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:orientation="horizontal" >
+ android:layout_alignParentLeft="true"
+ android:layout_marginLeft="8dip"
+ android:layout_marginBottom="20dip"
+ android:textColor="@android:color/white"
+ stlye="@style/ContactTileStarredName" />
- <TextView
- android:id="@+id/contact_tile_name"
- android:layout_width="0dip"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:gravity="center_vertical"
- android:layout_marginLeft="8dip"
- android:textColor="@android:color/white"
- stlye="@style/ContactTileStarredName" />
-
- <ImageButton
- android:id="@+id/contact_tile_secondary_button"
- android:src="@drawable/ic_tab_unselected_contacts"
- android:layout_height="match_parent"
- android:layout_width="wrap_content" />
-
- </LinearLayout>
+ <ImageButton
+ android:id="@+id/contact_tile_secondary_button"
+ android:src="@drawable/ic_tab_unselected_contacts"
+ android:layout_height="@dimen/contact_tile_shadowbox_height"
+ android:layout_width="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentRight="true" />
</RelativeLayout>
diff --git a/res/layout/dialtacts_activity.xml b/res/layout/dialtacts_activity.xml
index 14fb137..6484d87 100644
--- a/res/layout/dialtacts_activity.xml
+++ b/res/layout/dialtacts_activity.xml
@@ -16,7 +16,8 @@
<FrameLayout 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:layout_marginTop="?android:attr/actionBarSize">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
diff --git a/res/values/styles.xml b/res/values/styles.xml
index f32ae4c..e98175d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
<resources>
- <style name="DialtactsTheme" parent="android:Theme.Holo.SplitActionBarWhenNarrow">
+ <style name="DialtactsTheme"
+ parent="android:Theme.Holo.SolidActionBar.SplitActionBarWhenNarrow">
+ <item name="android:windowActionBarOverlay">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@android:color/black</item>
<item name="activated_background">@drawable/list_item_activated_background</item>
@@ -51,6 +53,8 @@
<item name="call_log_voicemail_status_height">40dip</item>
<item name="call_log_voicemail_status_background_color">#FFFFE0</item>
<item name="call_log_voicemail_status_text_color">#000000</item>
+ <!-- Favorites -->
+ <item name="favorites_padding_bottom">?android:attr/actionBarSize</item>
</style>
<style name="CallDetailActivityTheme" parent="android:Theme.Holo.SplitActionBarWhenNarrow">
@@ -161,6 +165,10 @@
<attr name="call_log_voicemail_status_text_color" format="color" />
</declare-styleable>
+ <declare-styleable name="Favorites">
+ <attr name="favorites_padding_bottom" format="dimension" />
+ </declare-styleable>
+
<style name="PeopleTheme" parent="@android:style/Theme.Holo.Light.SolidActionBar.Inverse.SplitActionBarWhenNarrow">
<item name="android:actionBarStyle">@style/ContactsActionBarStyle</item>
<item name="list_item_height">?android:attr/listPreferredItemHeight</item>
@@ -188,6 +196,8 @@
<item name="list_item_header_underline_height">1px</item>
<item name="list_item_header_underline_color">@color/people_app_theme_color</item>
<item name="contact_filter_popup_width">320dip</item>
+ <!-- Favorites -->
+ <item name="favorites_padding_bottom">0dip</item>
</style>
<style name="ContactsActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
diff --git a/src/com/android/contacts/ContactTileLoaderFactory.java b/src/com/android/contacts/ContactTileLoaderFactory.java
index 41532c2..30bd7e4 100644
--- a/src/com/android/contacts/ContactTileLoaderFactory.java
+++ b/src/com/android/contacts/ContactTileLoaderFactory.java
@@ -21,7 +21,9 @@
import android.content.CursorLoader;
import android.net.Uri;
import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.Contacts.Data;
/**
* Used to create {@link CursorLoader}s to load different groups of {@link ContactTileView}s
@@ -36,14 +38,36 @@
public final static int CONTACT_PRESENCE = 5;
public final static int CONTACT_STATUS = 6;
+ // Only used for StrequentPhoneOnlyLoader
+ public final static int PHONE_NUMBER = 5;
+ public final static int PHONE_NUMBER_TYPE = 6;
+ public final static int PHONE_NUMBER_LABEL = 7;
+
private static final String[] COLUMNS = new String[] {
- Contacts._ID,
- Contacts.DISPLAY_NAME,
- Contacts.STARRED,
- Contacts.PHOTO_URI,
- Contacts.LOOKUP_KEY,
- Contacts.CONTACT_PRESENCE,
- Contacts.CONTACT_STATUS,
+ Contacts._ID, // ..........................................0
+ Contacts.DISPLAY_NAME, // .................................1
+ Contacts.STARRED, // ......................................2
+ Contacts.PHOTO_URI, // ....................................3
+ Contacts.LOOKUP_KEY, // ...................................4
+ Contacts.CONTACT_PRESENCE, // .............................5
+ Contacts.CONTACT_STATUS, // ...............................6
+ };
+
+ /**
+ * Projection used for the {@link Contacts#CONTENT_STREQUENT_URI}
+ * query when {@link ContactsContract#STREQUENT_PHONE_ONLY} flag
+ * is set to true. The main difference is the lack of presence
+ * and status data and the addition of phone number and label.
+ */
+ private static final String[] COLUMNS_PHONE_ONLY = new String[] {
+ Contacts._ID, // ..........................................0
+ Contacts.DISPLAY_NAME, // .................................1
+ Contacts.STARRED, // ......................................2
+ Contacts.PHOTO_URI, // ....................................3
+ Contacts.LOOKUP_KEY, // ...................................4
+ Phone.NUMBER, // ..........................................5
+ Phone.TYPE, // ............................................6
+ Phone.LABEL // ............................................7
};
public static CursorLoader createStrequentLoader(Context context) {
@@ -54,7 +78,7 @@
Uri uri = Contacts.CONTENT_STREQUENT_URI.buildUpon()
.appendQueryParameter(ContactsContract.STREQUENT_PHONE_ONLY, "true").build();
- return new CursorLoader(context, uri, COLUMNS, null, null, null);
+ return new CursorLoader(context, uri, COLUMNS_PHONE_ONLY, null, null, null);
}
public static CursorLoader createStarredLoader(Context context) {
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index 8ca56f8..01212f5 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -122,7 +122,12 @@
}
private class PageChangeListener implements OnPageChangeListener {
- private int mPreviousPosition = -1; // Invalid at first
+ private int mCurrentPosition = -1;
+ /**
+ * Used during page migration, to remember the next position {@link #onPageSelected(int)}
+ * specified.
+ */
+ private int mNextPosition = -1;
@Override
public void onPageScrolled(
@@ -132,34 +137,38 @@
@Override
public void onPageSelected(int position) {
final ActionBar actionBar = getActionBar();
- if (mPreviousPosition == position) {
+ if (mCurrentPosition == position) {
Log.w(TAG, "Previous position and next position became same (" + position + ")");
}
- if (mPreviousPosition >= 0) {
- sendFragmentVisibilityChange(mPreviousPosition, false);
- }
- sendFragmentVisibilityChange(position, true);
-
actionBar.selectTab(actionBar.getTabAt(position));
-
- // Activity#onPrepareOptionsMenu() may not be called when Fragment has it's own
- // options menu. We force this Activity to call it to hide/show bottom bar. Also
- // we don't want to do so when it is unnecessary (buttons may flicker).
- if (mPreviousPosition == TAB_INDEX_DIALER || position == TAB_INDEX_DIALER) {
- // Force this Activity to prepare Menu again.
- invalidateOptionsMenu();
- }
-
- mPreviousPosition = position;
+ mNextPosition = position;
}
public void setCurrentPosition(int position) {
- mPreviousPosition = position;
+ mCurrentPosition = position;
}
@Override
public void onPageScrollStateChanged(int state) {
+ switch (state) {
+ case ViewPager.SCROLL_STATE_IDLE: {
+ if (mCurrentPosition >= 0) {
+ sendFragmentVisibilityChange(mCurrentPosition, false);
+ }
+ if (mNextPosition >= 0) {
+ sendFragmentVisibilityChange(mNextPosition, true);
+ }
+ invalidateOptionsMenu();
+
+ mCurrentPosition = mNextPosition;
+ break;
+ }
+ case ViewPager.SCROLL_STATE_DRAGGING:
+ case ViewPager.SCROLL_STATE_SETTLING:
+ default:
+ break;
+ }
}
}
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index 8f7cfa8..abc9adf 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -989,19 +989,16 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
- inflater.inflate(R.menu.call_log_options, menu);
+ if (mShowOptionsMenu) {
+ inflater.inflate(R.menu.call_log_options, menu);
+ }
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
- menu.findItem(R.id.delete_all).setVisible(mShowOptionsMenu);
- menu.findItem(R.id.show_voicemails_only).setVisible(mShowOptionsMenu);
- final MenuItem callSettingsMenuItem = menu.findItem(R.id.menu_call_settings_call_log);
if (mShowOptionsMenu) {
- callSettingsMenuItem.setVisible(true);
- callSettingsMenuItem.setIntent(DialtactsActivity.getCallSettingsIntent());
- } else {
- callSettingsMenuItem.setVisible(false);
+ menu.findItem(R.id.menu_call_settings_call_log)
+ .setIntent(DialtactsActivity.getCallSettingsIntent());
}
}
diff --git a/src/com/android/contacts/dialpad/DialpadFragment.java b/src/com/android/contacts/dialpad/DialpadFragment.java
index 6acbc85..add6b80 100644
--- a/src/com/android/contacts/dialpad/DialpadFragment.java
+++ b/src/com/android/contacts/dialpad/DialpadFragment.java
@@ -538,10 +538,8 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
-
- // If the hardware doesn't have a hardware menu key, we'll show soft menu button on the
- // right side of digits EditText.
- if (ViewConfiguration.get(getActivity()).hasPermanentMenuKey()) {
+ if (mShowOptionsMenu && ViewConfiguration.get(getActivity()).hasPermanentMenuKey() &&
+ mDialpadChooser != null && mDigits != null) {
inflater.inflate(R.menu.dialpad_options, menu);
}
}
@@ -549,16 +547,9 @@
@Override
public void onPrepareOptionsMenu(Menu menu) {
// Hardware menu key should be available and Views should already be ready.
- if (ViewConfiguration.get(getActivity()).hasPermanentMenuKey() &&
+ if (mShowOptionsMenu && ViewConfiguration.get(getActivity()).hasPermanentMenuKey() &&
mDialpadChooser != null && mDigits != null) {
- if (mShowOptionsMenu) {
- setupMenuItems(menu);
- } else {
- menu.findItem(R.id.menu_call_settings_dialpad).setVisible(false);
- menu.findItem(R.id.menu_add_contacts).setVisible(false);
- menu.findItem(R.id.menu_2s_pause).setVisible(false);
- menu.findItem(R.id.menu_add_wait).setVisible(false);
- }
+ setupMenuItems(menu);
}
}
diff --git a/src/com/android/contacts/list/ContactTileAdapter.java b/src/com/android/contacts/list/ContactTileAdapter.java
index 6150670..53b744d 100644
--- a/src/com/android/contacts/list/ContactTileAdapter.java
+++ b/src/com/android/contacts/list/ContactTileAdapter.java
@@ -19,11 +19,16 @@
import com.android.contacts.ContactTileLoaderFactory;
import com.android.contacts.GroupMemberLoader;
import com.android.contacts.R;
+import com.android.contacts.model.AccountTypeManager;
+import com.android.contacts.model.DataKind;
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.Email;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.view.View;
import android.view.View.OnClickListener;
@@ -62,6 +67,13 @@
private int mPresenceIndex;
private int mStatusIndex;
+ /**
+ * Only valid when {@link DisplayType#STREQUENT_PHONE_ONLY} is true
+ */
+ private int mPhoneNumberIndex;
+ private int mPhoneNumberTypeIndex;
+ private int mPhoneNumberLabelIndex;
+
private boolean mIsQuickContactEnabled = false;
/**
@@ -151,6 +163,10 @@
mStarredIndex = ContactTileLoaderFactory.STARRED;
mPresenceIndex = ContactTileLoaderFactory.CONTACT_PRESENCE;
mStatusIndex = ContactTileLoaderFactory.CONTACT_STATUS;
+
+ mPhoneNumberIndex = ContactTileLoaderFactory.PHONE_NUMBER;
+ mPhoneNumberTypeIndex = ContactTileLoaderFactory.PHONE_NUMBER_TYPE;
+ mPhoneNumberLabelIndex = ContactTileLoaderFactory.PHONE_NUMBER_LABEL;
}
}
@@ -168,7 +184,7 @@
/**
* Iterates over the {@link Cursor}
* Returns position of the first NON Starred Contact
- * Returns -1 if not {@link DisplayType#}
+ * Returns -1 if not {@link DisplayType#STREQUENT} or {@link DisplayType#STREQUENT_PHONE_ONLY}
*/
private int getDividerPosition(Cursor cursor) {
if (cursor == null || cursor.isClosed() || (mDisplayType != DisplayType.STREQUENT
@@ -204,6 +220,17 @@
Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey), id);
contact.presence = cursor.isNull(mPresenceIndex) ? null : cursor.getInt(mPresenceIndex);
+ if (mDisplayType == DisplayType.STREQUENT_PHONE_ONLY) {
+ int phoneNumberType = cursor.getInt(mPhoneNumberTypeIndex);
+ String phoneNumberCustomLabel = cursor.getString(mPhoneNumberLabelIndex);
+ contact.phoneLabel = (String) Phone.getTypeLabel(mContext.getResources(),
+ phoneNumberType, phoneNumberCustomLabel);
+ contact.phoneNumber = cursor.getString(mPhoneNumberIndex);
+ } else {
+ contact.status = cursor.getString(mStatusIndex);
+ contact.presence = cursor.isNull(mPresenceIndex) ? null : cursor.getInt(mPresenceIndex);
+ }
+
return contact;
}
@@ -345,7 +372,8 @@
return mIsQuickContactEnabled ?
R.layout.contact_tile_starred_quick_contact : R.layout.contact_tile_starred;
case ViewTypes.FREQUENT:
- return R.layout.contact_tile_frequent;
+ return mDisplayType == DisplayType.STREQUENT_PHONE_ONLY ?
+ R.layout.contact_tile_frequent_phone : R.layout.contact_tile_frequent;
case ViewTypes.STARRED_WITH_SECONDARY_ACTION:
return R.layout.contact_tile_starred_secondary_target;
default:
@@ -466,6 +494,8 @@
public static class ContactEntry {
public String name;
public String status;
+ public String phoneLabel;
+ public String phoneNumber;
public Uri photoUri;
public Uri lookupKey;
public Integer presence;
diff --git a/src/com/android/contacts/list/ContactTileView.java b/src/com/android/contacts/list/ContactTileView.java
index 6374c23..3839573 100644
--- a/src/com/android/contacts/list/ContactTileView.java
+++ b/src/com/android/contacts/list/ContactTileView.java
@@ -21,9 +21,8 @@
import com.android.contacts.list.ContactTileAdapter.ContactEntry;
import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.provider.ContactsContract.StatusUpdates;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -32,9 +31,6 @@
import android.widget.QuickContactBadge;
import android.widget.TextView;
-import android.provider.ContactsContract.StatusUpdates;
-
-
/**
* A ContactTile displays the contact's picture overlayed with their name
*/
@@ -47,6 +43,8 @@
private QuickContactBadge mQuickContact;
private TextView mName;
private TextView mStatus;
+ private TextView mPhoneLabel;
+ private TextView mPhoneNumber;
private ContactPhotoManager mPhotoManager = null;
public ContactTileView(Context context, AttributeSet attrs) {
@@ -63,6 +61,8 @@
mPhoto = (ImageView) findViewById(R.id.contact_tile_image);
mPresence = (ImageView) findViewById(R.id.contact_tile_presence);
mStatus = (TextView) findViewById(R.id.contact_tile_status);
+ mPhoneLabel = (TextView) findViewById(R.id.contact_tile_phone_type);
+ mPhoneNumber = (TextView) findViewById(R.id.contact_tile_phone_number);
}
public void setPhotoManager(ContactPhotoManager photoManager) {
@@ -97,6 +97,15 @@
mStatus.setText(statusText);
}
+ if (mPhoneLabel != null) {
+ mPhoneLabel.setText(entry.phoneLabel);
+ }
+
+ if (mPhoneNumber != null) {
+ // TODO: Format number correctly
+ mPhoneNumber.setText(entry.phoneNumber);
+ }
+
if (mQuickContact != null) {
mQuickContact.assignContactUri(mLookupUri);
mQuickContact.setImageBitmap(null);
diff --git a/tests/src/com/android/contacts/ContactLoaderTest.java b/tests/src/com/android/contacts/ContactLoaderTest.java
index 1d3fb20..3d0ddb4 100644
--- a/tests/src/com/android/contacts/ContactLoaderTest.java
+++ b/tests/src/com/android/contacts/ContactLoaderTest.java
@@ -297,6 +297,9 @@
Data.STATUS_LABEL, Data.STATUS_TIMESTAMP,
Contacts.PHOTO_URI,
+
+ Contacts.SEND_TO_VOICEMAIL,
+ Contacts.CUSTOM_RINGTONE,
})
.withSortOrder(Contacts.Entity.RAW_CONTACT_ID)
.returnRow(
@@ -330,7 +333,10 @@
"Having dinner", "mockPkg3", 0,
20, 0,
- "content:some.photo.uri"
+ "content:some.photo.uri",
+
+ 0,
+ null
);
}