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

Commit 624ddc3c authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Include Google Talk presence, even when missing Im rows.

When inserting Google Talk presence updates, we match on
both Im and Email rows.  This change adds presence "dots"
to individual Im rows, and creates in-memory Im rows when
Email entries have presence.

This loads status details through a second query and holds
back building UI until both queries finish.  This change
also generalizes logic for building Im intents borrowed
from FastTrack code.

This change also fixes a regression that was dropping third-
party data rows.  The second-query approach above allows us
to remove a large chunk of code that was using old API.

Fixes http://b/2161796
parent d40d7f06
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -41,11 +41,11 @@
            android:layout_alignParentRight="true">

            <ImageView android:id="@+id/presence"
                android:layout_width="32dip"
                android:layout_height="32dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dip"
                android:layout_marginRight="5dip"

                android:padding="7dip"
                android:layout_gravity="center_vertical"
                android:scaleType="centerInside"
            />
+3 −3
Original line number Diff line number Diff line
@@ -41,11 +41,11 @@
            android:layout_alignParentRight="true">

            <ImageView android:id="@+id/presence"
                android:layout_width="32dip"
                android:layout_height="32dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dip"
                android:layout_marginRight="5dip"

                android:padding="7dip"
                android:layout_gravity="center_vertical"
                android:scaleType="centerInside"
            />
+14 −5
Original line number Diff line number Diff line
@@ -63,21 +63,30 @@
                android:paddingLeft="3dip"
                android:src="@drawable/ic_default_number"
            />

        </LinearLayout>

        <TextView
            android:id="@+id/footer"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:visibility="gone" />

    </LinearLayout>

    <ImageView android:id="@+id/presence_icon"
        android:layout_width="32dip"
        android:layout_height="32dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dip"
        android:gravity="center"
        android:scaleType="centerInside"
    />

    <ImageView android:id="@+id/action_icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_width="30dip"
        android:layout_height="30dip"
        android:layout_marginLeft="14dip"
        android:layout_marginRight="14dip"
        android:gravity="center"
+3 −2
Original line number Diff line number Diff line
@@ -35,10 +35,11 @@
    <View android:id="@+id/divider"
        android:layout_width="1px"
        android:layout_height="fill_parent"
        android:layout_marginTop="5dip"
        android:layout_marginBottom="5dip"
        android:layout_toLeftOf="@id/call_icon"
        android:layout_marginLeft="11dip"

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

    <ImageView android:id="@+id/call_type_icon"
+26 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.contacts;

import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
@@ -222,6 +223,31 @@ public class ContactsUtils {
        return null;
    }

    /**
     * Build {@link Intent} to launch an action for the given {@link Im} or
     * {@link Email} row. Returns null when missing protocol or data.
     */
    public static Intent buildImIntent(ContentValues values) {
        final boolean isEmail = Email.CONTENT_ITEM_TYPE.equals(values.getAsString(Data.MIMETYPE));
        final int protocol = isEmail ? Im.PROTOCOL_GOOGLE_TALK : values.getAsInteger(Im.PROTOCOL);

        String host = values.getAsString(Im.CUSTOM_PROTOCOL);
        String data = values.getAsString(isEmail ? Email.DATA : Im.DATA);
        if (protocol != Im.PROTOCOL_CUSTOM) {
            // Try bringing in a well-known host for specific protocols
            host = ContactsUtils.lookupProviderNameFromId(protocol);
        }

        if (!TextUtils.isEmpty(host) && !TextUtils.isEmpty(data)) {
            final String authority = host.toLowerCase();
            final Uri imUri = new Uri.Builder().scheme(Constants.SCHEME_IMTO).authority(
                    authority).appendPath(data).build();
            return new Intent(Intent.ACTION_SENDTO, imUri);
        } else {
            return null;
        }
    }

    public static Intent getPhotoPickIntent() {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
        intent.setType("image/*");
Loading