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

Commit 001310f2 authored by Yorke Lee's avatar Yorke Lee Committed by Android (Google) Code Review
Browse files

Merge "Restore the phone disambiguation dialog" into klp-dev

parents 8ea8569d 43f54390
Loading
Loading
Loading
Loading
+22 −26
Original line number Diff line number Diff line
@@ -37,37 +37,34 @@
            android:scaleType="centerCrop"
            android:focusable="true" />

        <TextView
            android:id="@id/contact_tile_name"
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dip"
            android:layout_marginStart="8dip"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_marginTop="8dip"
            android:layout_toRightOf="@id/contact_tile_quick"
            android:layout_toEndOf="@id/contact_tile_quick"
            android:layout_centerVertical="true"
            android:orientation="vertical">
            <TextView
                android:id="@id/contact_tile_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:singleLine="true"
                android:fadingEdge="horizontal"
                android:fadingEdgeLength="3dip"
                android:ellipsize="marquee"
                android:textAlignment="viewStart" />

            <TextView
                android:id="@+id/contact_tile_phone_type"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
            android:layout_below="@id/contact_tile_name"
            android:layout_toRightOf="@id/contact_tile_quick"
            android:layout_toEndOf="@id/contact_tile_quick"
                android:textSize="12sp"
                android:ellipsize="marquee"
                android:singleLine="true"
            android:textColor="@color/dialtacts_secondary_text_color"
            android:layout_marginLeft="8dip"
            android:layout_marginStart="8dip"
            android:layout_gravity="bottom" />

                android:textColor="@color/dialtacts_secondary_text_color" />
        </LinearLayout>
        <ImageView
            android:id="@+id/contact_favorite_star"
            android:layout_width="wrap_content"
@@ -78,7 +75,6 @@
            android:layout_marginRight="7dip"
            android:layout_marginEnd="7dip"
            android:layout_marginBottom="7dip"
            android:layout_centerVertical="true"
            android:src="@drawable/ic_star_marked_as_fav"
            android:visibility="gone" />

+32 −14
Original line number Diff line number Diff line
@@ -39,10 +39,20 @@
            android:layout_height="match_parent"
            android:background="@drawable/shadow_contact_photo"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="8dp"
            android:paddingRight="@dimen/contact_tile_info_button_height_and_width"
            android:paddingStart="8dp"
            android:paddingEnd="@dimen/contact_tile_info_button_height_and_width"
            android:paddingBottom="4dp"
            android:layout_alignParentBottom="true"
            android:orientation="vertical" >
            <TextView
                android:id="@+id/contact_tile_name"
                android:layout_width="match_parent"
            android:layout_height="@dimen/contact_tile_info_button_height_and_width"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:textColor="@color/contact_tile_name_color"
                android:fontFamily="sans-serif-light"
@@ -51,13 +61,21 @@
                android:fadingEdge="horizontal"
                android:fadingEdgeLength="3dip"
                android:ellipsize="marquee"
            android:layout_alignParentBottom="true"
            android:paddingLeft="8dp"
            android:paddingRight="@dimen/contact_tile_info_button_height_and_width"
            android:paddingStart="8dp"
            android:paddingEnd="@dimen/contact_tile_info_button_height_and_width"
                android:textAlignment="viewStart" />

            <TextView
                android:id="@+id/contact_tile_phone_type"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:textColor="@color/contact_tile_name_color"
                android:fontFamily="sans-serif-light"
                android:singleLine="true"
                android:textSize="12sp"
                android:fadingEdge="horizontal"
                android:fadingEdgeLength="3dip"
                android:ellipsize="marquee"
                android:textAlignment="viewStart" />
        </LinearLayout>
        <View
            android:id="@+id/contact_tile_push_state"
            android:layout_width="match_parent"
+15 −9
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
    private int mPhoneNumberIndex;
    private int mPhoneNumberTypeIndex;
    private int mPhoneNumberLabelIndex;
    private int mIsDefaultNumberIndex;
    protected int mPinnedIndex;
    protected int mContactIdIndex;

@@ -203,6 +204,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
        mPhoneNumberIndex = ContactTileLoaderFactory.PHONE_NUMBER;
        mPhoneNumberTypeIndex = ContactTileLoaderFactory.PHONE_NUMBER_TYPE;
        mPhoneNumberLabelIndex = ContactTileLoaderFactory.PHONE_NUMBER_LABEL;
        mIsDefaultNumberIndex = ContactTileLoaderFactory.IS_DEFAULT_NUMBER;
        mPinnedIndex = ContactTileLoaderFactory.PINNED;
        mContactIdIndex = ContactTileLoaderFactory.CONTACT_ID_FOR_DATA;
    }
@@ -256,11 +258,6 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements

        final LongSparseArray<Object> duplicates = new LongSparseArray<Object>(cursor.getCount());

        // Dummy object that we're inserting into the sparse array as a value so that we can use
        // the sparse array as a set to check for duplicates

        final Object dummy = new Object();

        // Track the length of {@link #mContactEntries} and compare to {@link #TILES_SOFT_LIMIT}.
        int counter = 0;

@@ -277,9 +274,14 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
                id = cursor.getLong(mContactIdIndex);
            }

            if (duplicates.get(id) == null) {
                duplicates.put(id, dummy);
            } else {
            final ContactEntry existing = (ContactEntry) duplicates.get(id);
            if (existing != null) {
                // Check if the existing number is a default number. If not, clear the phone number
                // and label fields so that the disambiguation dialog will show up.
                if (!existing.isDefaultNumber) {
                    existing.phoneLabel = null;
                    existing.phoneNumber = null;
                }
                continue;
            }

@@ -288,6 +290,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
            final int pinned = cursor.getInt(mPinnedIndex);
            final String name = cursor.getString(mNameIndex);
            final boolean isStarred = cursor.getInt(mStarredIndex) > 0;
            final boolean isDefaultNumber = cursor.getInt(mIsDefaultNumberIndex) > 0;

            final ContactEntry contact = new ContactEntry();

@@ -298,8 +301,9 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
            contact.lookupKey = ContentUris.withAppendedId(
                    Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey), id);
            contact.isFavorite = isStarred;
            contact.isDefaultNumber = isDefaultNumber;

            // Set phone number, label and status
            // Set phone number and label
            final int phoneNumberType = cursor.getInt(mPhoneNumberTypeIndex);
            final String phoneNumberCustomLabel = cursor.getString(mPhoneNumberLabelIndex);
            contact.phoneLabel = (String) Phone.getTypeLabel(mResources, phoneNumberType,
@@ -309,6 +313,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
            contact.pinned = pinned;
            mContactEntries.add(contact);

            duplicates.put(id, contact);

            counter++;
        }