From d0c8da65af3b67ba551a220ca40be31f644dfed6 Mon Sep 17 00:00:00 2001 From: Chiao Cheng Date: Wed, 5 Dec 2012 12:06:58 -0800 Subject: Major resource move and clean-up. Moving resources from Contacts to ContactsCommon and Dialer as necessary to remove dialer dependencies on contacts app. Bug: 6993891 Change-Id: I5ff17028cb675694809cdc08e5ee80c444ee8666 --- res/color/secondary_text_color.xml | 22 ++++++ res/drawable-hdpi/ic_add_contact_holo_dark.png | Bin 0 -> 1641 bytes res/drawable-hdpi/ic_text_holo_dark.png | Bin 0 -> 668 bytes res/drawable-hdpi/list_activated_holo.9.png | Bin 0 -> 154 bytes res/drawable-hdpi/list_background_holo.9.png | Bin 0 -> 224 bytes res/drawable-hdpi/list_focused_holo.9.png | Bin 0 -> 235 bytes res/drawable-hdpi/list_title_holo.9.png | Bin 0 -> 267 bytes res/drawable-mdpi/ic_add_contact_holo_dark.png | Bin 0 -> 1160 bytes res/drawable-mdpi/ic_text_holo_dark.png | Bin 0 -> 580 bytes res/drawable-mdpi/list_activated_holo.9.png | Bin 0 -> 151 bytes res/drawable-mdpi/list_background_holo.9.png | Bin 0 -> 188 bytes res/drawable-mdpi/list_focused_holo.9.png | Bin 0 -> 235 bytes res/drawable-mdpi/list_title_holo.9.png | Bin 0 -> 199 bytes .../list_activated_holo.9.png | Bin 0 -> 1659 bytes .../list_activated_holo.9.png | Bin 0 -> 1005 bytes .../list_activated_holo.9.png | Bin 0 -> 2478 bytes res/drawable-xhdpi/ic_add_contact_holo_dark.png | Bin 0 -> 2283 bytes res/drawable-xhdpi/ic_text_holo_dark.png | Bin 0 -> 749 bytes res/drawable-xhdpi/list_activated_holo.9.png | Bin 0 -> 158 bytes res/drawable-xhdpi/list_background_holo.9.png | Bin 0 -> 245 bytes res/drawable-xhdpi/list_focused_holo.9.png | Bin 0 -> 235 bytes res/drawable-xhdpi/list_title_holo.9.png | Bin 0 -> 267 bytes res/drawable/ic_tab_all.xml | 20 +++++ res/drawable/list_item_activated_background.xml | 20 +++++ res/layout/contact_tile_frequent.xml | 4 +- res/layout/contact_tile_frequent_phone.xml | 4 +- res/layout/contact_tile_phone_starred.xml | 4 +- res/layout/contact_tile_starred.xml | 4 +- res/layout/contact_tile_starred_quick_contact.xml | 4 +- res/values-land/integers.xml | 19 +++++ res/values-sw580dp-land/integers.xml | 19 +++++ res/values-sw580dp/dimens.xml | 1 + res/values-sw580dp/integers.xml | 19 +++++ res/values-sw680dp-land/integers.xml | 19 +++++ res/values-sw680dp/integers.xml | 19 +++++ res/values/attrs.xml | 9 +++ res/values/dimens.xml | 7 ++ res/values/integers.xml | 22 ++++++ res/values/strings.xml | 44 +++++++++++ res/values/styles.xml | 9 +++ .../common/list/ContactTileFrequentView.java | 40 ++++++++++ .../common/list/ContactTilePhoneFrequentView.java | 81 +++++++++++++++++++++ .../common/list/ContactTilePhoneStarredView.java | 64 ++++++++++++++++ .../common/list/ContactTileStarredView.java | 41 +++++++++++ src/com/android/contacts/common/util/ViewUtil.java | 42 +++++++++++ .../common/widget/LayoutSuppressingImageView.java | 39 ++++++++++ .../widget/LayoutSuppressingQuickContactBadge.java | 39 ++++++++++ 47 files changed, 605 insertions(+), 10 deletions(-) create mode 100644 res/color/secondary_text_color.xml create mode 100644 res/drawable-hdpi/ic_add_contact_holo_dark.png create mode 100644 res/drawable-hdpi/ic_text_holo_dark.png create mode 100644 res/drawable-hdpi/list_activated_holo.9.png create mode 100644 res/drawable-hdpi/list_background_holo.9.png create mode 100644 res/drawable-hdpi/list_focused_holo.9.png create mode 100644 res/drawable-hdpi/list_title_holo.9.png create mode 100644 res/drawable-mdpi/ic_add_contact_holo_dark.png create mode 100644 res/drawable-mdpi/ic_text_holo_dark.png create mode 100644 res/drawable-mdpi/list_activated_holo.9.png create mode 100644 res/drawable-mdpi/list_background_holo.9.png create mode 100644 res/drawable-mdpi/list_focused_holo.9.png create mode 100644 res/drawable-mdpi/list_title_holo.9.png create mode 100644 res/drawable-sw580dp-hdpi/list_activated_holo.9.png create mode 100644 res/drawable-sw580dp-mdpi/list_activated_holo.9.png create mode 100644 res/drawable-sw580dp-xhdpi/list_activated_holo.9.png create mode 100644 res/drawable-xhdpi/ic_add_contact_holo_dark.png create mode 100644 res/drawable-xhdpi/ic_text_holo_dark.png create mode 100644 res/drawable-xhdpi/list_activated_holo.9.png create mode 100644 res/drawable-xhdpi/list_background_holo.9.png create mode 100644 res/drawable-xhdpi/list_focused_holo.9.png create mode 100644 res/drawable-xhdpi/list_title_holo.9.png create mode 100644 res/drawable/ic_tab_all.xml create mode 100644 res/drawable/list_item_activated_background.xml create mode 100644 res/values-land/integers.xml create mode 100644 res/values-sw580dp-land/integers.xml create mode 100644 res/values-sw580dp/integers.xml create mode 100644 res/values-sw680dp-land/integers.xml create mode 100644 res/values-sw680dp/integers.xml create mode 100644 res/values/integers.xml create mode 100644 src/com/android/contacts/common/list/ContactTileFrequentView.java create mode 100644 src/com/android/contacts/common/list/ContactTilePhoneFrequentView.java create mode 100644 src/com/android/contacts/common/list/ContactTilePhoneStarredView.java create mode 100644 src/com/android/contacts/common/list/ContactTileStarredView.java create mode 100644 src/com/android/contacts/common/util/ViewUtil.java create mode 100644 src/com/android/contacts/common/widget/LayoutSuppressingImageView.java create mode 100644 src/com/android/contacts/common/widget/LayoutSuppressingQuickContactBadge.java diff --git a/res/color/secondary_text_color.xml b/res/color/secondary_text_color.xml new file mode 100644 index 00000000..1c624587 --- /dev/null +++ b/res/color/secondary_text_color.xml @@ -0,0 +1,22 @@ + + + + + + + + + diff --git a/res/drawable-hdpi/ic_add_contact_holo_dark.png b/res/drawable-hdpi/ic_add_contact_holo_dark.png new file mode 100644 index 00000000..88ff33b3 Binary files /dev/null and b/res/drawable-hdpi/ic_add_contact_holo_dark.png differ diff --git a/res/drawable-hdpi/ic_text_holo_dark.png b/res/drawable-hdpi/ic_text_holo_dark.png new file mode 100644 index 00000000..6d21e42c Binary files /dev/null and b/res/drawable-hdpi/ic_text_holo_dark.png differ diff --git a/res/drawable-hdpi/list_activated_holo.9.png b/res/drawable-hdpi/list_activated_holo.9.png new file mode 100644 index 00000000..4ea7afa0 Binary files /dev/null and b/res/drawable-hdpi/list_activated_holo.9.png differ diff --git a/res/drawable-hdpi/list_background_holo.9.png b/res/drawable-hdpi/list_background_holo.9.png new file mode 100644 index 00000000..cddf9be7 Binary files /dev/null and b/res/drawable-hdpi/list_background_holo.9.png differ diff --git a/res/drawable-hdpi/list_focused_holo.9.png b/res/drawable-hdpi/list_focused_holo.9.png new file mode 100644 index 00000000..86578be4 Binary files /dev/null and b/res/drawable-hdpi/list_focused_holo.9.png differ diff --git a/res/drawable-hdpi/list_title_holo.9.png b/res/drawable-hdpi/list_title_holo.9.png new file mode 100644 index 00000000..ae937176 Binary files /dev/null and b/res/drawable-hdpi/list_title_holo.9.png differ diff --git a/res/drawable-mdpi/ic_add_contact_holo_dark.png b/res/drawable-mdpi/ic_add_contact_holo_dark.png new file mode 100644 index 00000000..867f494b Binary files /dev/null and b/res/drawable-mdpi/ic_add_contact_holo_dark.png differ diff --git a/res/drawable-mdpi/ic_text_holo_dark.png b/res/drawable-mdpi/ic_text_holo_dark.png new file mode 100644 index 00000000..80b95eec Binary files /dev/null and b/res/drawable-mdpi/ic_text_holo_dark.png differ diff --git a/res/drawable-mdpi/list_activated_holo.9.png b/res/drawable-mdpi/list_activated_holo.9.png new file mode 100644 index 00000000..3bf8e036 Binary files /dev/null and b/res/drawable-mdpi/list_activated_holo.9.png differ diff --git a/res/drawable-mdpi/list_background_holo.9.png b/res/drawable-mdpi/list_background_holo.9.png new file mode 100644 index 00000000..7d5d66de Binary files /dev/null and b/res/drawable-mdpi/list_background_holo.9.png differ diff --git a/res/drawable-mdpi/list_focused_holo.9.png b/res/drawable-mdpi/list_focused_holo.9.png new file mode 100644 index 00000000..86578be4 Binary files /dev/null and b/res/drawable-mdpi/list_focused_holo.9.png differ diff --git a/res/drawable-mdpi/list_title_holo.9.png b/res/drawable-mdpi/list_title_holo.9.png new file mode 100644 index 00000000..64bd6912 Binary files /dev/null and b/res/drawable-mdpi/list_title_holo.9.png differ diff --git a/res/drawable-sw580dp-hdpi/list_activated_holo.9.png b/res/drawable-sw580dp-hdpi/list_activated_holo.9.png new file mode 100644 index 00000000..046b24a9 Binary files /dev/null and b/res/drawable-sw580dp-hdpi/list_activated_holo.9.png differ diff --git a/res/drawable-sw580dp-mdpi/list_activated_holo.9.png b/res/drawable-sw580dp-mdpi/list_activated_holo.9.png new file mode 100644 index 00000000..1ff33737 Binary files /dev/null and b/res/drawable-sw580dp-mdpi/list_activated_holo.9.png differ diff --git a/res/drawable-sw580dp-xhdpi/list_activated_holo.9.png b/res/drawable-sw580dp-xhdpi/list_activated_holo.9.png new file mode 100644 index 00000000..2eb7c7eb Binary files /dev/null and b/res/drawable-sw580dp-xhdpi/list_activated_holo.9.png differ diff --git a/res/drawable-xhdpi/ic_add_contact_holo_dark.png b/res/drawable-xhdpi/ic_add_contact_holo_dark.png new file mode 100644 index 00000000..72988823 Binary files /dev/null and b/res/drawable-xhdpi/ic_add_contact_holo_dark.png differ diff --git a/res/drawable-xhdpi/ic_text_holo_dark.png b/res/drawable-xhdpi/ic_text_holo_dark.png new file mode 100644 index 00000000..e80a0423 Binary files /dev/null and b/res/drawable-xhdpi/ic_text_holo_dark.png differ diff --git a/res/drawable-xhdpi/list_activated_holo.9.png b/res/drawable-xhdpi/list_activated_holo.9.png new file mode 100644 index 00000000..eda10e61 Binary files /dev/null and b/res/drawable-xhdpi/list_activated_holo.9.png differ diff --git a/res/drawable-xhdpi/list_background_holo.9.png b/res/drawable-xhdpi/list_background_holo.9.png new file mode 100644 index 00000000..b6527254 Binary files /dev/null and b/res/drawable-xhdpi/list_background_holo.9.png differ diff --git a/res/drawable-xhdpi/list_focused_holo.9.png b/res/drawable-xhdpi/list_focused_holo.9.png new file mode 100644 index 00000000..86578be4 Binary files /dev/null and b/res/drawable-xhdpi/list_focused_holo.9.png differ diff --git a/res/drawable-xhdpi/list_title_holo.9.png b/res/drawable-xhdpi/list_title_holo.9.png new file mode 100644 index 00000000..f4f00ca0 Binary files /dev/null and b/res/drawable-xhdpi/list_title_holo.9.png differ diff --git a/res/drawable/ic_tab_all.xml b/res/drawable/ic_tab_all.xml new file mode 100644 index 00000000..97c4443e --- /dev/null +++ b/res/drawable/ic_tab_all.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/res/drawable/list_item_activated_background.xml b/res/drawable/list_item_activated_background.xml new file mode 100644 index 00000000..a58577eb --- /dev/null +++ b/res/drawable/list_item_activated_background.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/res/layout/contact_tile_frequent.xml b/res/layout/contact_tile_frequent.xml index 9219f56a..494fd3d8 100644 --- a/res/layout/contact_tile_frequent.xml +++ b/res/layout/contact_tile_frequent.xml @@ -15,7 +15,7 @@ --> @@ -24,7 +24,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - @@ -27,7 +27,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - + class="com.android.contacts.common.list.ContactTilePhoneStarredView" > - + class="com.android.contacts.common.list.ContactTileStarredView" > - + class="com.android.contacts.common.list.ContactTileStarredView" > - + + + 4 + diff --git a/res/values-sw580dp-land/integers.xml b/res/values-sw580dp-land/integers.xml new file mode 100644 index 00000000..03f5ed75 --- /dev/null +++ b/res/values-sw580dp-land/integers.xml @@ -0,0 +1,19 @@ + + + + 3 + diff --git a/res/values-sw580dp/dimens.xml b/res/values-sw580dp/dimens.xml index 277c0297..0a149e75 100644 --- a/res/values-sw580dp/dimens.xml +++ b/res/values-sw580dp/dimens.xml @@ -24,4 +24,5 @@ @dimen/list_visible_scrollbar_padding 24dip + 16dip diff --git a/res/values-sw580dp/integers.xml b/res/values-sw580dp/integers.xml new file mode 100644 index 00000000..03f5ed75 --- /dev/null +++ b/res/values-sw580dp/integers.xml @@ -0,0 +1,19 @@ + + + + 3 + diff --git a/res/values-sw680dp-land/integers.xml b/res/values-sw680dp-land/integers.xml new file mode 100644 index 00000000..44d1d5a8 --- /dev/null +++ b/res/values-sw680dp-land/integers.xml @@ -0,0 +1,19 @@ + + + + 4 + diff --git a/res/values-sw680dp/integers.xml b/res/values-sw680dp/integers.xml new file mode 100644 index 00000000..3e47757a --- /dev/null +++ b/res/values-sw680dp/integers.xml @@ -0,0 +1,19 @@ + + + + 2 + diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 745ceb19..9e8c08d8 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -51,4 +51,13 @@ + + + + + + + + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 5fd33903..2c49c2ed 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -86,4 +86,11 @@ 32dip + + + 48dip + + + 64dip + 8dip diff --git a/res/values/integers.xml b/res/values/integers.xml new file mode 100644 index 00000000..73e9aee9 --- /dev/null +++ b/res/values/integers.xml @@ -0,0 +1,22 @@ + + + + + + + 2 + diff --git a/res/values/strings.xml b/res/values/strings.xml index befa813c..cc2aad68 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -661,4 +661,48 @@ a ren't members of any other group. [CHAR LIMIT=25] --> This contact can\'t be shared. + + Search + + + Contacts to display + + + Contacts to display + + + Define custom view + + + Find contacts + + + Favorites + + + No contacts. + + + No visible contacts. + + + No favorites. + + + No contacts in %s + + + Clear frequents + + + Accounts + + + Import/export + diff --git a/res/values/styles.xml b/res/values/styles.xml index 7a43243b..77831b24 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -54,4 +54,13 @@ background and text color. See also android:style/Widget.Holo.TextView.ListSepar match_parent match_parent + + diff --git a/src/com/android/contacts/common/list/ContactTileFrequentView.java b/src/com/android/contacts/common/list/ContactTileFrequentView.java new file mode 100644 index 00000000..a1ee1815 --- /dev/null +++ b/src/com/android/contacts/common/list/ContactTileFrequentView.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 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. + */ +package com.android.contacts.common.list; + +import android.content.Context; +import android.util.AttributeSet; + +import com.android.contacts.common.util.ViewUtil; + +/** + * A {@link com.android.contacts.common.list.ContactTileView} that is used for most frequently contacted in the People app + */ +public class ContactTileFrequentView extends ContactTileView { + public ContactTileFrequentView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected boolean isDarkTheme() { + return false; + } + + @Override + protected int getApproximateImageSize() { + return ViewUtil.getConstantPreLayoutWidth(getQuickContact()); + } +} diff --git a/src/com/android/contacts/common/list/ContactTilePhoneFrequentView.java b/src/com/android/contacts/common/list/ContactTilePhoneFrequentView.java new file mode 100644 index 00000000..2e5f04cb --- /dev/null +++ b/src/com/android/contacts/common/list/ContactTilePhoneFrequentView.java @@ -0,0 +1,81 @@ +/* + * 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.common.list; + +import android.content.Context; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.View; + +import com.android.contacts.common.MoreContactUtils; +import com.android.contacts.common.list.ContactTileAdapter.ContactEntry; +import com.android.contacts.common.util.ViewUtil; + +/** + * A dark version of the {@link com.android.contacts.common.list.ContactTileView} that is used in Dialtacts + * for frequently called contacts. Slightly different behavior from superclass... + * when you tap it, you want to call the frequently-called number for the + * contact, even if that is not the default number for that contact. + */ +public class ContactTilePhoneFrequentView extends ContactTileView { + private String mPhoneNumberString; + + public ContactTilePhoneFrequentView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected boolean isDarkTheme() { + return true; + } + + @Override + protected int getApproximateImageSize() { + return ViewUtil.getConstantPreLayoutWidth(getQuickContact()); + } + + @Override + public void loadFromContact(ContactEntry entry) { + super.loadFromContact(entry); + mPhoneNumberString = null; // ... in case we're reusing the view + if (entry != null) { + // Grab the phone-number to call directly... see {@link onClick()} + mPhoneNumberString = entry.phoneNumber; + } + } + + @Override + protected OnClickListener createClickListener() { + return new OnClickListener() { + @Override + public void onClick(View v) { + if (mListener == null) return; + if (TextUtils.isEmpty(mPhoneNumberString)) { + // Copy "superclass" implementation + mListener.onContactSelected(getLookupUri(), MoreContactUtils + .getTargetRectFromView( + mContext, ContactTilePhoneFrequentView.this)); + } else { + // When you tap a frequently-called contact, you want to + // call them at the number that you usually talk to them + // at (i.e. the one displayed in the UI), regardless of + // whether that's their default number. + mListener.onCallNumberDirectly(mPhoneNumberString); + } + } + }; + } +} diff --git a/src/com/android/contacts/common/list/ContactTilePhoneStarredView.java b/src/com/android/contacts/common/list/ContactTilePhoneStarredView.java new file mode 100644 index 00000000..c3020ebe --- /dev/null +++ b/src/com/android/contacts/common/list/ContactTilePhoneStarredView.java @@ -0,0 +1,64 @@ +/* + * 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.common.list; + +import android.content.Context; +import android.content.Intent; +import android.util.AttributeSet; +import android.view.View; +import android.widget.ImageButton; + +import com.android.contacts.common.R; + +/** + * Displays the contact's picture overlayed with their name + * in a perfect square. It also has an additional touch target for a secondary action. + */ +public class ContactTilePhoneStarredView extends ContactTileView { + private ImageButton mSecondaryButton; + + public ContactTilePhoneStarredView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + mSecondaryButton = (ImageButton) findViewById(R.id.contact_tile_secondary_button); + mSecondaryButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Intent.ACTION_VIEW, getLookupUri()); + // Secondary target will be visible only from phone's favorite screen, then + // we want to launch it as a separate People task. + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + getContext().startActivity(intent); + } + }); + } + + @Override + protected boolean isDarkTheme() { + return true; + } + + @Override + protected int getApproximateImageSize() { + // The picture is the full size of the tile (minus some padding, but we can be generous) + return mListener.getApproximateTileWidth(); + } +} diff --git a/src/com/android/contacts/common/list/ContactTileStarredView.java b/src/com/android/contacts/common/list/ContactTileStarredView.java new file mode 100644 index 00000000..67c7a8da --- /dev/null +++ b/src/com/android/contacts/common/list/ContactTileStarredView.java @@ -0,0 +1,41 @@ +/* + * 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.common.list; + +import android.content.Context; +import android.util.AttributeSet; + +/** + * A {@link ContactTileStarredView} displays the contact's picture overlayed with their name + * in a square. The actual dimensions are set by + * {@link com.android.contacts.common.list.ContactTileAdapter.ContactTileRow}. + */ +public class ContactTileStarredView extends ContactTileView { + public ContactTileStarredView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected boolean isDarkTheme() { + return false; + } + + @Override + protected int getApproximateImageSize() { + // The picture is the full size of the tile (minus some padding, but we can be generous) + return mListener.getApproximateTileWidth(); + } +} diff --git a/src/com/android/contacts/common/util/ViewUtil.java b/src/com/android/contacts/common/util/ViewUtil.java new file mode 100644 index 00000000..190075a2 --- /dev/null +++ b/src/com/android/contacts/common/util/ViewUtil.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 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. + */ + +package com.android.contacts.common.util; + +import android.view.View; +import android.view.ViewGroup; + +/** + * Provides static functions to work with views + */ +public class ViewUtil { + private ViewUtil() {} + + /** + * Returns the width as specified in the LayoutParams + * @throws IllegalStateException Thrown if the view's width is unknown before a layout pass + * s + */ + public static int getConstantPreLayoutWidth(View view) { + // We haven't been layed out yet, so get the size from the LayoutParams + final ViewGroup.LayoutParams p = view.getLayoutParams(); + if (p.width < 0) { + throw new IllegalStateException("Expecting view's width to be a constant rather " + + "than a result of the layout pass"); + } + return p.width; + } +} diff --git a/src/com/android/contacts/common/widget/LayoutSuppressingImageView.java b/src/com/android/contacts/common/widget/LayoutSuppressingImageView.java new file mode 100644 index 00000000..abcf7860 --- /dev/null +++ b/src/com/android/contacts/common/widget/LayoutSuppressingImageView.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 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. + */ + +package com.android.contacts.common.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ImageView; + +/** + * Custom {@link ImageView} that improves layouting performance. + * + * This improves the performance by not passing requestLayout() to its parent, taking advantage + * of knowing that image size won't change once set. + */ +public class LayoutSuppressingImageView extends ImageView { + + public LayoutSuppressingImageView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void requestLayout() { + forceLayout(); + } +} diff --git a/src/com/android/contacts/common/widget/LayoutSuppressingQuickContactBadge.java b/src/com/android/contacts/common/widget/LayoutSuppressingQuickContactBadge.java new file mode 100644 index 00000000..1f48f5d2 --- /dev/null +++ b/src/com/android/contacts/common/widget/LayoutSuppressingQuickContactBadge.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 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. + */ + +package com.android.contacts.common.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.QuickContactBadge; + +/** + * Custom {@link QuickContactBadge} that improves layouting performance. + * + * This improves the performance by not passing requestLayout() to its parent, taking advantage + * of knowing that image size won't change once set. + */ +public class LayoutSuppressingQuickContactBadge extends QuickContactBadge { + + public LayoutSuppressingQuickContactBadge(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void requestLayout() { + forceLayout(); + } +} -- cgit v1.2.3