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

Commit 18b4a2e3 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Add "Call with a note" action.

- Adding call with a note action to the call log.  Capability lookup is
cached.
- Moved getLookupKeyFromUri to ContactsCommon.
- Added some extra required values in CallLogListItemViewHolder so that
the call subject dialog is able to build the correct contact photo.

Bug: 22685114
Change-Id: I6665c55137eef7db3ff7ac12d70d823937e8c28b
parent 7803a759
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -104,6 +104,20 @@

    </LinearLayout>

    <LinearLayout
        android:id="@+id/call_with_note_action"
        style="@style/CallLogActionStyle">

        <ImageView
            style="@style/CallLogActionIconStyle"
            android:src="@drawable/ic_call_note_white_24dp" />

        <TextView
            style="@style/CallLogActionTextStyle"
            android:text="@string/call_with_a_note" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/details_action"
        style="@style/CallLogActionStyle">
+2 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.CallUtil;
import com.android.contacts.common.util.UriUtils;
import com.android.dialer.calllog.CallDetailHistoryAdapter;
import com.android.dialer.calllog.CallLogAsyncTaskUtil.CallLogAsyncTaskListener;
import com.android.dialer.calllog.CallLogAsyncTaskUtil;
@@ -162,7 +163,7 @@ public class CallDetailActivity extends Activity
                    new CallDetailHistoryAdapter(mContext, mInflater, mCallTypeHelper, details));

            String lookupKey = contactUri == null ? null
                    : ContactInfoHelper.getLookupKeyFromUri(contactUri);
                    : UriUtils.getLookupKeyFromUri(contactUri);

            final boolean isBusiness = mContactInfoHelper.isBusiness(firstDetails.sourceType);

+7 −2
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.support.v7.widget.RecyclerView;
import android.os.Bundle;
import android.os.Trace;
@@ -526,13 +528,16 @@ public class CallLogAdapter extends GroupingListAdapter
        views.rowId = c.getLong(CallLogQuery.ID);
        // Store values used when the actions ViewStub is inflated on expansion.
        views.number = number;
        views.displayNumber = details.displayNumber;
        views.numberPresentation = numberPresentation;
        views.callType = c.getInt(CallLogQuery.CALL_TYPE);
        views.accountHandle = accountHandle;
        views.voicemailUri = c.getString(CallLogQuery.VOICEMAIL_URI);
        // Stash away the Ids of the calls so that we can support deleting a row in the call log.
        views.callIds = getCallIds(c, count);

        views.isBusiness = mContactInfoHelper.isBusiness(info.sourceType);
        views.numberType = (String) Phone.getTypeLabel(mContext.getResources(), details.numberType,
                details.numberLabel);
        // Default case: an item in the call log.
        views.primaryActionView.setVisibility(View.VISIBLE);

@@ -563,7 +568,7 @@ public class CallLogAdapter extends GroupingListAdapter
            nameForDefaultImage = info.name;
        }
        views.setPhoto(info.photoId, info.photoUri, info.lookupUri, nameForDefaultImage,
                isVoicemailNumber, mContactInfoHelper.isBusiness(info.sourceType));
                isVoicemailNumber, views.isBusiness);

        mCallLogListItemHelper.setPhoneCallDetails(views, details);
    }
+42 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.dialer.calllog;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.content.Intent;
@@ -29,18 +30,16 @@ import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.widget.QuickContactBadge;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.contacts.common.CallUtil;
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
import com.android.contacts.common.dialog.CallSubjectDialog;
import com.android.contacts.common.testing.NeededForTesting;
import com.android.contacts.common.util.UriUtils;
import com.android.dialer.R;
import com.android.dialer.calllog.CallLogAsyncTaskUtil;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.PhoneNumberUtil;
import com.android.dialer.voicemail.VoicemailPlaybackPresenter;
@@ -80,6 +79,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
    public View addToExistingContactButtonView;
    public View sendMessageView;
    public View detailsButtonView;
    public View callWithNoteButtonView;

    /**
     * The row Id for the first call associated with the call log entry.  Used as a key for the
@@ -99,12 +99,22 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
     */
    public String number;

    /**
     * The formatted phone number to display.
     */
    public String displayNumber;

    /**
     * The phone number presentation for the current call log entry.  Cached here as the call back
     * intent is set only when the actions ViewStub is inflated.
     */
    public int numberPresentation;

    /**
     * The type of the phone number (e.g. main, work, etc).
     */
    public String numberType;

    /**
     * The type of call for the current call log entry.  Cached here as the call back
     * intent is set only when the actions ViewStub is inflated.
@@ -130,6 +140,11 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
     */
    public CharSequence nameOrNumber;

    /**
     * Whether this row is for a business or not.
     */
    public boolean isBusiness;

    /**
     * The contact info for the contact displayed in this list item.
     */
@@ -245,6 +260,9 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder

            detailsButtonView = actionsView.findViewById(R.id.details_action);
            detailsButtonView.setOnClickListener(this);

            callWithNoteButtonView = actionsView.findViewById(R.id.call_with_note_action);
            callWithNoteButtonView.setOnClickListener(this);
        }

        bindActionButtons();
@@ -349,6 +367,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
        sendMessageView.setTag(IntentProvider.getSendSmsIntentProvider(number));

        mCallLogListItemHelper.setActionContentDescriptions(this);

        boolean supportsCallSubject =
                mTelecomCallLogCache.doesAccountSupportCallSubject(accountHandle);
        boolean isVoicemailNumber =
                mTelecomCallLogCache.isVoicemailNumber(accountHandle, number);
        callWithNoteButtonView.setVisibility(
                supportsCallSubject && !isVoicemailNumber ? View.VISIBLE : View.GONE);
    }

    /**
@@ -403,7 +428,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder

        String lookupKey = null;
        if (contactUri != null) {
            lookupKey = ContactInfoHelper.getLookupKeyFromUri(contactUri);
            lookupKey = UriUtils.getLookupKeyFromUri(contactUri);
        }

        DefaultImageRequest request = new DefaultImageRequest(
@@ -423,6 +448,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
        if (view.getId() == R.id.primary_action_button && !TextUtils.isEmpty(voicemailUri)) {
            mVoicemailPrimaryActionButtonClicked = true;
            mExpandCollapseListener.onClick(primaryActionView);
        } else if (view.getId() == R.id.call_with_note_action) {
            CallSubjectDialog.start(
                    (Activity) mContext,
                    info.photoId,
                    info.photoUri,
                    info.lookupUri,
                    (String) nameOrNumber /* top line of contact view in call subject dialog */,
                    isBusiness,
                    number, /* callable number used for ACTION_CALL intent */
                    TextUtils.isEmpty(info.name) ? null : displayNumber, /* second line of contact
                                                                           view in dialog. */
                    numberType, /* phone number type (e.g. mobile) in second line of contact view */
                    accountHandle);
        } else {
            final IntentProvider intentProvider = (IntentProvider) view.getTag();
            if (intentProvider != null) {
+0 −18
Original line number Diff line number Diff line
@@ -393,24 +393,6 @@ public class ContactInfoHelper {
        }
    }

    /**
     * Parses the given URI to determine the original lookup key of the contact.
     */
    public static String getLookupKeyFromUri(Uri lookupUri) {
        // Would be nice to be able to persist the lookup key somehow to avoid having to parse
        // the uri entirely just to retrieve the lookup key, but every uri is already parsed
        // once anyway to check if it is an encoded JSON uri, so this has negligible effect
        // on performance.
        if (lookupUri != null && !UriUtils.isEncodedContactUri(lookupUri)) {
            final List<String> segments = lookupUri.getPathSegments();
            // This returns the third path segment of the uri, where the lookup key is located.
            // See {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}.
            return (segments.size() < 3) ? null : Uri.encode(segments.get(2));
        } else {
            return null;
        }
    }

    /**
     * Returns the contact information stored in an entry of the call log.
     *
Loading