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

Commit c7ab59e2 authored by Evan Millar's avatar Evan Millar
Browse files
-Also fixes problems with the call button divider not disappearing when
the call button was gone.

-Also populates the typeList for the "fallback" source, for phone,
email, and postal DataKinds. The type lists are the unions of the focus
and exchange typeLists.

Change-Id: Idd68760d852e4accdcf3043007253e122bd5534b
parent 3b1a3550
Loading
Loading
Loading
Loading
+25 −24
Original line number Diff line number Diff line
@@ -22,12 +22,9 @@
    android:layout_height="wrap_content"
    android:orientation="vertical"
>
    <TextView android:id="@+id/header"
        style="?android:attr/listSeparatorTextViewStyle"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:background="#444444"
        android:gravity="center_horizontal"
    <include
        android:id="@+id/header"
        layout="@layout/list_separator"
    />

    <View android:id="@+id/list_divider"
@@ -97,27 +94,31 @@
            android:textAppearance="?android:attr/textAppearanceLarge"
        />

        <LinearLayout android:id="@+id/call_view"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:orientation="horizontal"
            android:layout_marginLeft="11dip"
            android:layout_alignParentRight="true">

            <View android:id="@+id/divider"
                android:layout_width="1dip"
                android:layout_height="fill_parent"
                android:background="@drawable/divider_vertical_dark"
            />

            <ImageView android:id="@+id/call_button"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:paddingLeft="14dip"
                android:paddingRight="14dip"
            android:layout_alignParentRight="true"
                android:layout_centerVertical="true"

                android:gravity="center"
                android:src="@android:drawable/sym_action_call"
                android:background="@android:drawable/list_selector_background"
            />

        <View android:id="@+id/divider"
            android:layout_width="1dip"
            android:layout_height="fill_parent"
            android:layout_toLeftOf="@id/call_button"
            android:layout_marginLeft="11dip"

            android:background="@drawable/divider_vertical_dark"
        />
        </LinearLayout>

    </RelativeLayout>
</LinearLayout>
+24 −21
Original line number Diff line number Diff line
@@ -101,27 +101,30 @@
            android:textAppearance="?android:attr/textAppearanceLarge"
        />

        <LinearLayout android:id="@+id/call_view"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:orientation="horizontal"
            android:layout_marginLeft="11dip"
            android:layout_alignParentRight="true">

            <View android:id="@+id/divider"
                android:layout_width="1dip"
                android:layout_height="fill_parent"
                android:background="@drawable/divider_vertical_dark"
            />

            <ImageView android:id="@+id/call_button"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:paddingLeft="14dip"
                android:paddingRight="14dip"
            android:layout_alignParentRight="true"
                android:layout_centerVertical="true"

                android:gravity="center"
                android:src="@android:drawable/sym_action_call"
                android:background="@android:drawable/list_selector_background"
            />

        <View android:id="@+id/divider"
            android:layout_width="1dip"
            android:layout_height="fill_parent"
            android:layout_toLeftOf="@id/call_button"
            android:layout_marginLeft="11dip"

            android:background="@drawable/divider_vertical_dark"
        />

        </LinearLayout>
    </RelativeLayout>
</LinearLayout>
+57 −26
Original line number Diff line number Diff line
@@ -16,6 +16,11 @@

package com.android.contacts;

import com.android.contacts.model.ContactsSource;
import com.android.contacts.model.EntityModifier;
import com.android.contacts.model.Sources;
import com.android.contacts.model.ContactsSource.DataKind;
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;
@@ -92,6 +97,7 @@ import android.widget.ArrayAdapter;
import android.widget.FasttrackBadgeWidget;
import android.widget.Filter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ResourceCursorAdapter;
import android.widget.SectionIndexer;
@@ -1792,7 +1798,8 @@ public final class ContactsListActivity extends ListActivity implements
        public TextView header;
        public View divider;
        public TextView nameView;
        public ImageView callView;
        public View callView;
        public ImageView callButton;
        public CharArrayBuffer nameBuffer = new CharArrayBuffer(128);
        public TextView labelView;
        public CharArrayBuffer labelBuffer = new CharArrayBuffer(128);
@@ -1819,7 +1826,7 @@ public final class ContactsListActivity extends ListActivity implements
        private String mAlphabet;
        private boolean mLoading = true;
        private CharSequence mUnknownNameText;
        private CharSequence[] mLocalizedLabels;
        private SparseArray<Integer> mLocalizedLabels;
        private boolean mDisplayPhotos = false;
        private boolean mDisplayCallButton = false;
        private boolean mDisplayAdditionalData = true;
@@ -1840,24 +1847,24 @@ public final class ContactsListActivity extends ListActivity implements
            mAlphabet = context.getString(com.android.internal.R.string.fast_scroll_alphabet);

            mUnknownNameText = context.getText(android.R.string.unknownName);
            // TODO: use a different method of finding labels
//            switch (mMode) {
//                case MODE_PICK_POSTAL:
//                    mLocalizedLabels = EditContactActivity.getLabelsForMimetype(mContext,
//                            CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE);
//                    mDisplaySectionHeaders = false;
//                    break;
//                case MODE_PICK_PHONE:
//                    mLocalizedLabels = EditContactActivity.getLabelsForMimetype(mContext,
//                            CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
//                    mDisplaySectionHeaders = false;
//                    break;
//                default:
                    mLocalizedLabels = context.getResources().getStringArray(android.R.array.phoneTypes);
//                    EditContactActivity.getLabelsForMimetype(mContext,
//                            CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
//                    break;
//            }
            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;
            }

            // Do not display the second line of text if in a specific SEARCH query mode, usually for
            // matching a specific E-mail or phone number. Any contact details
@@ -1887,6 +1894,29 @@ 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
@@ -2065,9 +2095,10 @@ public final class ContactsListActivity extends ListActivity implements
            cache.header = (TextView) view.findViewById(R.id.header);
            cache.divider = view.findViewById(R.id.list_divider);
            cache.nameView = (TextView) view.findViewById(R.id.name);
            cache.callView = (ImageView) view.findViewById(R.id.call_button);
            if (cache.callView != null) {
                cache.callView.setOnClickListener(ContactsListActivity.this);
            cache.callView = view.findViewById(R.id.call_view);
            cache.callButton = (ImageView) view.findViewById(R.id.call_button);
            if (cache.callButton != null) {
                cache.callButton.setOnClickListener(ContactsListActivity.this);
            }
            cache.labelView = (TextView) view.findViewById(R.id.label);
            cache.dataView = (TextView) view.findViewById(R.id.data);
@@ -2132,7 +2163,7 @@ public final class ContactsListActivity extends ListActivity implements
            if (mDisplayCallButton) {
                int pos = cursor.getPosition();
                cache.callView.setVisibility(View.VISIBLE);
                cache.callView.setTag(pos);
                cache.callButton.setTag(pos);
            } else {
                cache.callView.setVisibility(View.GONE);
            }
@@ -2212,9 +2243,9 @@ public final class ContactsListActivity extends ListActivity implements

                if (type != CommonDataKinds.BaseTypes.TYPE_CUSTOM) {
                    try {
                        labelView.setText(mLocalizedLabels[type - 1]);
                        labelView.setText(mLocalizedLabels.get(type));
                    } catch (ArrayIndexOutOfBoundsException e) {
                        labelView.setText(mLocalizedLabels[defaultType - 1]);
                        labelView.setText(mLocalizedLabels.get(defaultType));
                    }
                } else {
                    cursor.copyStringToBuffer(labelColumnIndex, cache.labelBuffer);
+81 −1
Original line number Diff line number Diff line
@@ -104,6 +104,34 @@ public class HardCodedSources {
            kind.actionAltHeader = new ActionAltInflater(list.resPackageName, kind);
            kind.actionBody = new SimpleInflater(Phone.NUMBER);

            kind.typeColumn = Phone.TYPE;
            kind.typeList = Lists.newArrayList();
            kind.typeList.add(new EditType(Phone.TYPE_HOME, R.string.type_home, R.string.call_home,
                    R.string.sms_home));
            kind.typeList.add(new EditType(Phone.TYPE_MOBILE, R.string.type_mobile,
                    R.string.call_mobile, R.string.sms_mobile));
            kind.typeList.add(new EditType(Phone.TYPE_WORK, R.string.type_work, R.string.call_work,
                    R.string.sms_work));
            kind.typeList.add(new EditType(Phone.TYPE_FAX_WORK, R.string.type_fax_work,
                    R.string.call_fax_work, R.string.sms_fax_work).setSecondary(true));
            kind.typeList.add(new EditType(Phone.TYPE_FAX_HOME, R.string.type_fax_home,
                    R.string.call_fax_home, R.string.sms_fax_home).setSecondary(true));
            kind.typeList.add(new EditType(Phone.TYPE_PAGER, R.string.type_pager,
                    R.string.call_pager, R.string.sms_pager).setSecondary(true));
            kind.typeList.add(new EditType(Phone.TYPE_OTHER, R.string.type_other,
                    R.string.call_other, R.string.sms_other));
            kind.typeList.add(new EditType(Phone.TYPE_CUSTOM, R.string.type_custom,
                    R.string.call_custom, R.string.sms_custom).setSecondary(true).setCustomColumn(
                    Phone.LABEL));
            kind.typeList.add(new EditType(Phone.TYPE_CAR, R.string.type_car, R.string.call_car,
                    R.string.sms_car).setSecondary(true));
            kind.typeList.add(new EditType(Phone.TYPE_COMPANY_MAIN, R.string.type_company_main,
                    R.string.call_company_main, R.string.sms_company_main).setSecondary(true));
            kind.typeList.add(new EditType(Phone.TYPE_MMS, R.string.type_mms, R.string.call_mms,
                    R.string.sms_mms).setSecondary(true));
            kind.typeList.add(new EditType(Phone.TYPE_RADIO, R.string.type_radio, R.string.call_radio,
                    R.string.sms_radio).setSecondary(true));

            kind.fieldList = Lists.newArrayList();
            kind.fieldList.add(new EditField(Phone.NUMBER, R.string.phoneLabelsGroup, FLAGS_PHONE));

@@ -111,13 +139,65 @@ public class HardCodedSources {
        }

        {
            // GOOGLE: EMAIL
            // FALLBACK: POSTAL
            DataKind kind = new DataKind(StructuredPostal.CONTENT_ITEM_TYPE,
                    R.string.postalLabelsGroup, R.drawable.sym_action_map, 25, true);

            kind.actionHeader = new ActionInflater(list.resPackageName, kind);
            // TODO: build body from various structured fields
            kind.actionBody = new SimpleInflater(StructuredPostal.FORMATTED_ADDRESS);

            kind.typeColumn = StructuredPostal.TYPE;
            kind.typeList = Lists.newArrayList();
            kind.typeList.add(new EditType(StructuredPostal.TYPE_HOME, R.string.type_home,
                    R.string.map_home));
            kind.typeList.add(new EditType(StructuredPostal.TYPE_WORK, R.string.type_work,
                    R.string.map_work));
            kind.typeList.add(new EditType(StructuredPostal.TYPE_OTHER, R.string.type_other,
                    R.string.map_other));
            kind.typeList
                    .add(new EditType(StructuredPostal.TYPE_CUSTOM, R.string.type_custom,
                            R.string.map_custom).setSecondary(true).setCustomColumn(
                            StructuredPostal.LABEL));

            kind.fieldList = Lists.newArrayList();
            kind.fieldList.add(new EditField(StructuredPostal.STREET, R.string.postal_street,
                    FLAGS_POSTAL));
            kind.fieldList.add(new EditField(StructuredPostal.POBOX, R.string.postal_pobox,
                    FLAGS_POSTAL, true));
            kind.fieldList.add(new EditField(StructuredPostal.NEIGHBORHOOD,
                    R.string.postal_neighborhood, FLAGS_POSTAL, true));
            kind.fieldList.add(new EditField(StructuredPostal.CITY, R.string.postal_city,
                    FLAGS_POSTAL));
            kind.fieldList.add(new EditField(StructuredPostal.REGION, R.string.postal_region,
                    FLAGS_POSTAL));
            kind.fieldList.add(new EditField(StructuredPostal.POSTCODE, R.string.postal_postcode,
                    FLAGS_POSTAL));
            kind.fieldList.add(new EditField(StructuredPostal.COUNTRY, R.string.postal_country,
                    FLAGS_POSTAL, true));

            list.add(kind);
        }

        {
            // FALLBACK: EMAIL
            DataKind kind = new DataKind(Email.CONTENT_ITEM_TYPE,
                    R.string.emailLabelsGroup, android.R.drawable.sym_action_email, 15, true);

            kind.actionHeader = new ActionInflater(list.resPackageName, kind);
            kind.actionBody = new SimpleInflater(Email.DATA);

            kind.typeColumn = Email.TYPE;
            kind.typeList = Lists.newArrayList();
            kind.typeList
                    .add(new EditType(Email.TYPE_HOME, R.string.type_home, R.string.email_home));
            kind.typeList
                    .add(new EditType(Email.TYPE_WORK, R.string.type_work, R.string.email_work));
            kind.typeList.add(new EditType(Email.TYPE_OTHER, R.string.type_other,
                    R.string.email_other));
            kind.typeList.add(new EditType(Email.TYPE_CUSTOM, R.string.type_custom,
                    R.string.email_home).setSecondary(true).setCustomColumn(Email.LABEL));

            kind.fieldList = Lists.newArrayList();
            kind.fieldList.add(new EditField(Email.DATA, R.string.emailLabelsGroup, FLAGS_EMAIL));