Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab066931 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Split sources, partial inflation, third-party support.

This change splits HardCodedSources into separate classes
so they could borrow helpers from fallback.  This also
finishes up FallbackSource so it handles all new types
supported by ContactsContract.  The view inflaters now
handle showing all types, even if not supported as a choice
during edit.  This approach also allows us to partially
inflate sources, speeding up view and FastTrack.  Fixes
http://b/2116999 and http://b/2126675 and makes progress
towards fixing http://b/2134623

This change also fixes on-phone contacts, meaning we
always have fallback sources, fixing http://b/2119637 and
http://b/2123401

Repurpose code from StyleManager for Sources inflation of
third-party data sources, fixing http://b/2126691

Fix FastTrack chicklet bug so we uncheck when switching
between tabs.  Since all types are in framework, we borrow
those strings here, and also clean up our descriptions for
translation.
parent f2ba281f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
     limitations under the License.
-->

<com.android.contacts.ui.CheckableImageView 
<com.android.contacts.ui.widget.CheckableImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="59dip"
    android:layout_height="52dip"
+179 −125
Original line number Diff line number Diff line
@@ -887,48 +887,26 @@
    <!-- Toast indicating that sharing a contact has failed. -->
    <string name="share_error">This contact cannot be shared.</string>



<!-- TODO: add comments to each of these strings to prepare for translation -->
    <!-- Header that expands to list all name types when editing a structured name of a contact -->
    <string name="nameLabelsGroup">Name</string>
    <!-- Header that expands to list all nickname types when editing a nickname of a contact -->
    <string name="nicknameLabelsGroup">Nickname</string>
    <!-- Header that expands to list all organization types when editing an organization of a contact -->
    <string name="organizationLabelsGroup">Organization</string>
    <!-- Header that expands to list all website types when editing a website of a contact -->
    <string name="websiteLabelsGroup">Website</string>

<string name="type_home">Home</string>
<string name="type_mobile">Mobile</string>
<string name="type_work">Work</string>
<string name="type_fax_work">Work Fax</string>
<string name="type_fax_home">Home Fax</string>
<string name="type_pager">Pager</string>
<string name="type_other">Other</string>
<string name="type_custom">Custom</string>

<!-- Single-character overlays on shortcut icons -->
    <!-- Single-character overlay for home phone numbers when creating desktop shortcuts -->
    <string name="type_short_home">H</string>
    <!-- Single-character overlay for mobile phone numbers when creating desktop shortcuts -->
    <string name="type_short_mobile">M</string>
    <!-- Single-character overlay for work phone numbers when creating desktop shortcuts -->
    <string name="type_short_work">W</string>
    <!-- Single-character overlay for pager phone numbers when creating desktop shortcuts -->
    <string name="type_short_pager">P</string>
    <!-- Single-character overlay for other phone numbers when creating desktop shortcuts -->
    <string name="type_short_other">O</string>

<!-- exchange specific -->
<string name="type_home_2">Home 2</string>
<string name="type_work_2">Work 2</string>
<string name="type_car">Car</string>
<string name="type_company_main">Company Main</string>
<string name="type_mms">MMS</string>
<string name="type_radio">Radio</string>
<string name="type_assistant">Assistant</string>

<string name="type_im_aim">AIM</string>
<string name="type_im_msn">Windows Live</string>
<string name="type_im_yahoo">Yahoo</string>
<string name="type_im_skype">Skype</string>
<string name="type_im_qq">QQ</string>
<string name="type_im_google_talk">Google Talk</string>
<string name="type_im_icq">ICQ</string>
<string name="type_im_jabber">Jabber</string>

    <!-- Shown as the header title over a collapsible section that, by default, hides
         secondary contact detail edit fields, such as birthday. -->
    <string name="edit_secondary_collapse">Secondary details</string>
@@ -957,89 +935,165 @@
         user to give a specific name to describe this address. -->
    <string name="label_email_display_name">Display name</string>

    <!-- Action string for calling a custom phone number -->
    <string name="call_custom">Call <xliff:g id="custom">%s</xliff:g></string>
    <!-- Action string for calling a home phone number -->
    <string name="call_home">Call home</string>
    <!-- Action string for calling a mobile phone number -->
    <string name="call_mobile">Call mobile</string>
    <!-- Action string for calling a work phone number -->
    <string name="call_work">Call work</string>
    <!-- Action string for calling a work fax phone number -->
    <string name="call_fax_work">Call work fax</string>
    <!-- Action string for calling a home fax phone number -->
    <string name="call_fax_home">Call home fax</string>
    <!-- Action string for calling a pager phone number -->
    <string name="call_pager">Call pager</string>
    <!-- Action string for calling an other phone number -->
    <string name="call_other">Call other</string>
<string name="call_custom">Call <xliff:g id="custom">%s</xliff:g></string>

<!-- exchange specific -->
<string name="call_home_2">Call home 2</string>
<string name="call_work_2">Call work 2</string>
    <!-- Action string for calling a callback number -->
    <string name="call_callback">Call callback</string>
    <!-- Action string for calling a car phone number -->
    <string name="call_car">Call car</string>
    <!-- Action string for calling a company main phone number -->
    <string name="call_company_main">Call company main</string>
<string name="call_mms">Call MMS</string>
    <!-- Action string for calling a ISDN phone number -->
    <string name="call_isdn">Call ISDN</string>
    <!-- Action string for calling a main phone number -->
    <string name="call_main">Call main</string>
    <!-- Action string for calling an other fax phone number -->
    <string name="call_other_fax">Call other fax</string>
    <!-- Action string for calling a radio phone number -->
    <string name="call_radio">Call radio</string>
    <!-- Action string for calling a Telex phone number -->
    <string name="call_telex">Call telex</string>
    <!-- Action string for calling a TTY/TDD phone number -->
    <string name="call_tty_tdd">Call TTY/TDD</string>
    <!-- Action string for calling a work mobile phone number -->
    <string name="call_work_mobile">Call work mobile</string>
    <!-- Action string for calling a work pager phone number -->
    <string name="call_work_pager">Call work pager</string>
    <!-- Action string for calling an assistant phone number -->
    <string name="call_assistant">Call <xliff:g id="assistant">%s</xliff:g></string>
    <!-- Action string for calling a MMS phone number -->
    <string name="call_mms">Call MMS</string>





    <!-- Action string for sending an SMS to a custom phone number -->
    <string name="sms_custom">Text <xliff:g id="custom">%s</xliff:g></string>
    <!-- Action string for sending an SMS to a home phone number -->
    <string name="sms_home">Text home</string>
    <!-- Action string for sending an SMS to a mobile phone number -->
    <string name="sms_mobile">Text mobile</string>
    <!-- Action string for sending an SMS to a work phone number -->
    <string name="sms_work">Text work</string>
    <!-- Action string for sending an SMS to a work fax phone number -->
    <string name="sms_fax_work">Text work fax</string>
    <!-- Action string for sending an SMS to a home fax phone number -->
    <string name="sms_fax_home">Text home fax</string>
    <!-- Action string for sending an SMS to a pager phone number -->
    <string name="sms_pager">Text pager</string>
    <!-- Action string for sending an SMS to an other phone number -->
    <string name="sms_other">Text other</string>
<string name="sms_custom">Text <xliff:g id="custom">%s</xliff:g></string>

<!-- exchange specific -->
<string name="sms_home_2">Text home 2</string>
<string name="sms_work_2">Text work 2</string>
    <!-- Action string for sending an SMS to a callback number -->
    <string name="sms_callback">Text callback</string>
    <!-- Action string for sending an SMS to a car phone number -->
    <string name="sms_car">Text car</string>
    <!-- Action string for sending an SMS to a company main phone number -->
    <string name="sms_company_main">Text company main</string>
<string name="sms_mms">Text MMS</string>
    <!-- Action string for sending an SMS to a ISDN phone number -->
    <string name="sms_isdn">Text ISDN</string>
    <!-- Action string for sending an SMS to a main phone number -->
    <string name="sms_main">Text main</string>
    <!-- Action string for sending an SMS to an other fax phone number -->
    <string name="sms_other_fax">Text other fax</string>
    <!-- Action string for sending an SMS to a radio phone number -->
    <string name="sms_radio">Text radio</string>
    <!-- Action string for sending an SMS to a Telex phone number -->
    <string name="sms_telex">Text telex</string>
    <!-- Action string for sending an SMS to a TTY/TDD phone number -->
    <string name="sms_tty_tdd">Text TTY/TDD</string>
    <!-- Action string for sending an SMS to a work mobile phone number -->
    <string name="sms_work_mobile">Text work mobile</string>
    <!-- Action string for sending an SMS to a work pager phone number -->
    <string name="sms_work_pager">Text work pager</string>
    <!-- Action string for sending an SMS to an assistant phone number -->
    <string name="sms_assistant">Text <xliff:g id="assistant">%s</xliff:g></string>
    <!-- Action string for sending an SMS to a MMS phone number -->
    <string name="sms_mms">Text MMS</string>



    <!-- Action string for sending an email to a home email address -->
    <string name="email_home">Email home</string>
    <!-- Action string for sending an email to a mobile email address -->
    <string name="email_mobile">Email mobile</string>
    <!-- Action string for sending an email to a work email address -->
    <string name="email_work">Email work</string>
    <!-- Action string for sending an email to an other email address -->
    <string name="email_other">Email other</string>
    <!-- Action string for sending an email to a custom email address -->
    <string name="email_custom">Email <xliff:g id="custom">%s</xliff:g></string>

    <!-- Generic action string for sending an email -->
    <string name="email">Email</string>



    <!-- Action string for viewing a home postal address -->
    <string name="map_home">View home address</string>
    <!-- Action string for viewing a work postal address -->
    <string name="map_work">View work address</string>
    <!-- Action string for viewing an other postal address -->
    <string name="map_other">View other address</string>
    <!-- Action string for viewing a custom postal address -->
    <string name="map_custom">View <xliff:g id="custom">%s</xliff:g> address</string>

    <!-- Action string for starting an IM chat with the AIM protocol -->
    <string name="chat_aim">Chat using AIM</string>
    <!-- Action string for starting an IM chat with the MSN or Windows Live protocol -->
    <string name="chat_msn">Chat using Windows Live</string>
    <!-- Action string for starting an IM chat with the Yahoo protocol -->
    <string name="chat_yahoo">Chat using Yahoo</string>
    <!-- Action string for starting an IM chat with the Skype protocol -->
    <string name="chat_skype">Chat using Skype</string>
    <!-- Action string for starting an IM chat with the QQ protocol -->
    <string name="chat_qq">Chat using QQ</string>
    <!-- Action string for starting an IM chat with the Google Talk protocol -->
    <string name="chat_gtalk">Chat using Google Talk</string>
    <!-- Action string for starting an IM chat with the ICQ protocol -->
    <string name="chat_icq">Chat using ICQ</string>
    <!-- Action string for starting an IM chat with the Jabber protocol -->
    <string name="chat_jabber">Chat using Jabber</string>
<string name="chat_other">Chat</string>

    <!-- Generic action string for starting an IM chat -->
    <string name="chat">Chat</string>

    <!-- Field title for the street of a structured postal address of a contact -->
    <string name="postal_street">Street</string>
    <!-- Field title for the PO box of a structured postal address of a contact -->
    <string name="postal_pobox">PO box</string>
    <!-- Field title for the neighborhood of a structured postal address of a contact -->
    <string name="postal_neighborhood">Neighborhood</string>
    <!-- Field title for the city of a structured postal address of a contact -->
    <string name="postal_city">City</string>
    <!-- Field title for the region, or state, of a structured postal address of a contact -->
    <string name="postal_region">State</string>
    <!-- Field title for the postal code of a structured postal address of a contact -->
    <string name="postal_postcode">ZIP code</string>
    <!-- Field title for the country of a structured postal address of a contact -->
    <string name="postal_country">Country</string>


    <!-- Field title for the given name of a contact -->
    <string name="name_given">Given name</string>
    <!-- Field title for the family name of a contact -->
    <string name="name_family">Family name</string>
    <!-- Field title for the prefix name of a contact -->
    <string name="name_prefix">Name prefix</string>
    <!-- Field title for the middle name of a contact -->
    <string name="name_middle">Middle name</string>
    <!-- Field title for the suffix name of a contact -->
    <string name="name_suffix">Name suffix</string>
    <!-- Field title for the phonetic given name of a contact -->
    <string name="name_phonetic_given">Phonetic given name</string>
    <!-- Field title for the phonetic middle name of a contact -->
    <string name="name_phonetic_middle">Phonetic middle name</string>
    <!-- Field title for the phonetic family name of a contact -->
    <string name="name_phonetic_family">Phonetic family name</string>



</resources>
+8 −40
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.contacts.model.ContactsSource.EditType;
import com.android.contacts.ui.DisplayGroupsActivity;
import com.android.contacts.ui.DisplayGroupsActivity.Prefs;
import com.android.contacts.util.Constants;
import com.google.android.collect.Lists;

import android.accounts.Account;
import android.app.Activity;
@@ -1945,7 +1946,6 @@ public final class ContactsListActivity extends ListActivity implements
        private String mAlphabet;
        private boolean mLoading = true;
        private CharSequence mUnknownNameText;
        private SparseArray<Integer> mLocalizedLabels;
        private boolean mDisplayPhotos = false;
        private boolean mDisplayCallButton = false;
        private boolean mDisplayAdditionalData = true;
@@ -1969,19 +1969,13 @@ public final class ContactsListActivity extends ListActivity implements
            switch (mMode) {
                case MODE_LEGACY_PICK_POSTAL:
                case MODE_PICK_POSTAL:
                    mLocalizedLabels = inflateLocalizedLabels(
                            CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE);
                    mDisplaySectionHeaders = false;
                    break;
                case MODE_LEGACY_PICK_PHONE:
                case MODE_PICK_PHONE:
                    mDisplaySectionHeaders = false;
                    mLocalizedLabels = inflateLocalizedLabels(
                            CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
                    break;
                default:
                    mLocalizedLabels = inflateLocalizedLabels(
                            CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
                    break;
            }

@@ -2013,29 +2007,6 @@ public final class ContactsListActivity extends ListActivity implements
            }
        }

        private SparseArray<Integer> inflateLocalizedLabels(String mimetype) {
            SparseArray<Integer> localizedLabels = new SparseArray<Integer>();

            Sources sources = Sources.getInstance(ContactsListActivity.this);

            ContactsSource contactsSource = sources.getInflatedSource(null /*get fallback type*/,
                    ContactsSource.LEVEL_MIMETYPES);
            if (contactsSource == null) {
                return localizedLabels;
            }

            DataKind kind = contactsSource.getKindForMimetype(mimetype);
            if (kind == null) {
                return localizedLabels;
            }

            for (EditType type : kind.typeList) {
                localizedLabels.put(type.rawValue, type.labelRes);
            }

            return localizedLabels;
        }

        private class ImageFetchHandler extends Handler {

            @Override
@@ -2371,18 +2342,15 @@ public final class ContactsListActivity extends ListActivity implements
            // Set the label.
            if (!cursor.isNull(typeColumnIndex)) {
                labelView.setVisibility(View.VISIBLE);
                int type = cursor.getInt(typeColumnIndex);

                if (type != CommonDataKinds.BaseTypes.TYPE_CUSTOM) {
                    try {
                        labelView.setText(mLocalizedLabels.get(type));
                    } catch (ArrayIndexOutOfBoundsException e) {
                        labelView.setText(mLocalizedLabels.get(defaultType));
                    }
                final int type = cursor.getInt(typeColumnIndex);
                final String label = cursor.getString(labelColumnIndex);

                if (mMode == MODE_LEGACY_PICK_POSTAL || mMode == MODE_PICK_POSTAL) {
                    labelView.setText(StructuredPostal.getTypeLabel(context.getResources(), type,
                            label));
                } else {
                    cursor.copyStringToBuffer(labelColumnIndex, cache.labelBuffer);
                    // Don't check size, if it's zero just don't show anything
                    labelView.setText(cache.labelBuffer.data, 0, cache.labelBuffer.sizeCopied);
                    labelView.setText(Phone.getTypeLabel(context.getResources(), type, label));
                }
            } else {
                // There is no label, hide the the view
+1 −11
Original line number Diff line number Diff line
@@ -339,17 +339,7 @@ public class ContactsUtils {
    public static View createTabIndicatorView(ViewGroup parent, ContactsSource source) {
        Drawable icon = null;
        if (source != null) {
            final String packageName = source.resPackageName;
            if (source.iconRes > 0) {
                try {
                    final Context authContext = parent.getContext().
                            createPackageContext(packageName, 0);
                    icon = authContext.getResources().getDrawable(source.iconRes);

                } catch (PackageManager.NameNotFoundException e) {
                    Log.d(TAG, "error getting the Package Context for " + packageName, e);
                }
            }
            icon = source.getDisplayIcon(parent.getContext());
        }
        return createTabIndicatorView(parent, null, icon);
    }
+1 −10
Original line number Diff line number Diff line
@@ -251,16 +251,7 @@ public class SplitAggregateView extends ListView {
            ContactsSource source = mSources.getInflatedSource(info.accountType,
                    ContactsSource.LEVEL_SUMMARY);
            if (source != null) {
                final String packageName = source.resPackageName;
                if (source.iconRes > 0) {
                    try {
                        final Context context = getContext().createPackageContext(packageName, 0);
                        icon = context.getResources().getDrawable(source.iconRes);

                    } catch (PackageManager.NameNotFoundException e) {
                        Log.d(TAG, "error getting the Package Context for " + packageName, e);
                    }
                }
                icon = source.getDisplayIcon(getContext());
            }
            if (icon != null) {
                cache.sourceIcon.setImageDrawable(icon);
Loading