Merge "People: Action bar tab refactoring"
diff --git a/res/layout/contact_tile_starred_secondary_target.xml b/res/layout/contact_tile_starred_secondary_target.xml
new file mode 100644
index 0000000..a8ae00f
--- /dev/null
+++ b/res/layout/contact_tile_starred_secondary_target.xml
@@ -0,0 +1,56 @@
+<?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.ContactTileSecondaryTargetView"
+ style="@style/ContactTileStarred" >
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <ImageView
+ android:id="@+id/contact_tile_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop" />
+
+ <View
+ android:id="@+id/contact_tile_background"
+ style="@style/ContactTileStarredTextBackground" />
+
+ <LinearLayout
+ android:orientation="horizontal"
+ style="@style/ContactTileStarredText">
+
+ <TextView
+ android:id="@+id/contact_tile_name"
+ style="@style/ContactTileStarredText"
+ android:layout_width="0dip"
+ android:layout_weight="2" />
+
+ <ImageButton
+ android:id="@+id/contact_tile_secondary_button"
+ android:src="@drawable/ic_tab_unselected_contacts"
+ android:layout_height="match_parent"
+ android:layout_width="0dip"
+ android:layout_weight="1" />
+
+ </LinearLayout>
+
+ </RelativeLayout>
+
+</view>
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index 0fa745d..3af9821 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -338,7 +338,6 @@
} else if (fragment instanceof PhoneNumberPickerFragment) {
mSearchFragment = (PhoneNumberPickerFragment) fragment;
mSearchFragment.setOnPhoneNumberPickerActionListener(mPhoneNumberPickerActionListener);
- mSearchFragment.setNameHighlightingEnabled(true);
mSearchFragment.setQuickContactEnabled(true);
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
if (mInSearchUi) {
diff --git a/src/com/android/contacts/list/ContactTileAdapter.java b/src/com/android/contacts/list/ContactTileAdapter.java
index 20c639e..360c7a3 100644
--- a/src/com/android/contacts/list/ContactTileAdapter.java
+++ b/src/com/android/contacts/list/ContactTileAdapter.java
@@ -294,6 +294,7 @@
switch (itemViewType) {
case ViewTypes.STARRED:
+ case ViewTypes.STARRED_WITH_SECONDARY_ACTION:
if (contactTileRowView == null) {
// Creating new row if needed
contactTileRowView = new ContactTileRow(mContext, layoutResId, true);
@@ -336,6 +337,8 @@
}
case ViewTypes.FREQUENT:
return R.layout.contact_tile_frequent;
+ case ViewTypes.STARRED_WITH_SECONDARY_ACTION:
+ return R.layout.contact_tile_starred_secondary_target;
default:
throw new IllegalArgumentException("Received unrecognized viewType " + viewType);
}
@@ -358,7 +361,7 @@
switch (mDisplayType) {
case STREQUENT:
if (position < mDividerRowIndex) {
- return ViewTypes.STARRED;
+ return ViewTypes.STARRED_WITH_SECONDARY_ACTION;
} else if (position == mDividerRowIndex) {
return ViewTypes.DIVIDER;
} else {
@@ -405,7 +408,13 @@
if (getChildCount() <= tileIndex) {
if (mIsContactTileSquare) {
- contactTile = (ContactTileStarredView) inflate(mContext, mLayoutResId, null);
+ if (mDisplayType == DisplayType.STREQUENT) {
+ contactTile = (ContactTileSecondaryTargetView)
+ inflate(mContext, mLayoutResId, null);
+ } else {
+ contactTile =
+ (ContactTileStarredView) inflate(mContext, mLayoutResId, null);
+ }
} else {
contactTile = (ContactTileView) inflate(mContext, mLayoutResId, null);
}
@@ -437,10 +446,11 @@
}
private static class ViewTypes {
- public static final int COUNT = 3;
+ public static final int COUNT = 4;
public static final int STARRED = 0;
public static final int DIVIDER = 1;
public static final int FREQUENT = 2;
+ public static final int STARRED_WITH_SECONDARY_ACTION = 3;
}
public interface Listener {
diff --git a/src/com/android/contacts/list/ContactTileSecondaryTargetView.java b/src/com/android/contacts/list/ContactTileSecondaryTargetView.java
new file mode 100644
index 0000000..862e23d
--- /dev/null
+++ b/src/com/android/contacts/list/ContactTileSecondaryTargetView.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package com.android.contacts.list;
+
+import com.android.contacts.R;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ImageButton;
+
+/**
+ * A {@link ContactTileSecondaryTargetView} displays the contact's picture overlayed with their name
+ * in a perfect square like the {@link ContactTileStarredView}. However it adds in an additional
+ * touch target for a secondary action.
+ */
+public class ContactTileSecondaryTargetView extends ContactTileStarredView
+ implements OnClickListener {
+
+ private final static String TAG = ContactTileSecondaryTargetView.class.getSimpleName();
+
+ private ImageButton mSecondaryButton;
+
+ public ContactTileSecondaryTargetView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mSecondaryButton = (ImageButton) findViewById(R.id.contact_tile_secondary_button);
+ mSecondaryButton.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ getContext().startActivity(new Intent(Intent.ACTION_VIEW, getLookupUri()));
+ }
+}