diff options
Diffstat (limited to 'src')
7 files changed, 6 insertions, 294 deletions
diff --git a/src/com/android/dialer/DeepLinkIntegrationManager.java b/src/com/android/dialer/DeepLinkIntegrationManager.java deleted file mode 100644 index 052d6ef8d..000000000 --- a/src/com/android/dialer/DeepLinkIntegrationManager.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.dialer; - -import android.net.Uri; -import android.provider.CallLog; -import android.content.Context; - -import com.cyanogen.ambient.common.api.AmbientApiClient; -import com.cyanogen.ambient.common.api.PendingResult; -import com.cyanogen.ambient.common.api.ResultCallback; -import com.cyanogen.ambient.common.ConnectionResult; -import com.cyanogen.ambient.deeplink.DeepLink; -import com.cyanogen.ambient.deeplink.DeepLinkApi; -import com.cyanogen.ambient.deeplink.DeepLinkServices; -import com.cyanogen.ambient.deeplink.linkcontent.DeepLinkContentType; - -import java.util.List; - -public class DeepLinkIntegrationManager { - - public static DeepLinkIntegrationManager getInstance() { - if (sInstance == null) { - sInstance = new DeepLinkIntegrationManager(); - } - return sInstance; - } - - private static DeepLinkIntegrationManager sInstance; - private AmbientApiClient mAmbientApiClient; - private DeepLinkApi mApi; - private boolean mConnected = false; - - public void setUp(Context ctx) { - mApi = (DeepLinkApi) DeepLinkServices.API; - mAmbientApiClient = new AmbientApiClient.Builder(ctx).addApi(DeepLinkServices.API).build(); - - mAmbientApiClient.registerConnectionFailedListener( - new AmbientApiClient.OnConnectionFailedListener() { - @Override - public void onConnectionFailed(ConnectionResult connectionResult) { - mConnected = false; - } - }); - - mAmbientApiClient.registerDisconnectionListener( - new AmbientApiClient.OnDisconnectionListener() { - @Override - public void onDisconnection() { - mConnected = false; - } - }); - - mAmbientApiClient.registerConnectionCallbacks(new AmbientApiClient.ConnectionCallbacks() { - @Override - public void onConnected(android.os.Bundle bundle) { - mConnected = true; - } - - @Override - public void onConnectionSuspended(int i) { - mConnected = false; - } - }); - mAmbientApiClient.connect(); - } - - public void getPreferredLinksFor( - ResultCallback<DeepLink.DeepLinkResultList> callback, - DeepLinkContentType category, - Uri uri) { - if (mConnected) { - PendingResult<DeepLink.DeepLinkResultList> - result = mApi.getPreferredLinksForSingleItem(mAmbientApiClient, category, uri); - result.setResultCallback(callback); - } - } - - public void getPreferredLinksForList( - ResultCallback<DeepLink.DeepLinkResultList> callback, - DeepLinkContentType category, - List<Uri> uris) { - if (mConnected) { - PendingResult<DeepLink.DeepLinkResultList> - result = mApi.getPreferredLinksForList(mAmbientApiClient, category, uris); - result.setResultCallback(callback); - } - } - - /** - * Generate a uri which will identify the call for a given number and timestamp - * - * @param number - the phone number dialed - * @param time - the time the call occured - * @return Uri identifying the call. - */ - public static Uri generateCallUri(String number, long time) { - return Uri.parse(CallLog.AUTHORITY + "." + number + "." + time); - } -} diff --git a/src/com/android/dialer/DialerApplication.java b/src/com/android/dialer/DialerApplication.java index 9db00771a..3e762632a 100644 --- a/src/com/android/dialer/DialerApplication.java +++ b/src/com/android/dialer/DialerApplication.java @@ -45,7 +45,6 @@ public class DialerApplication extends Application { Trace.endSection(); CallMethodHelper.init(this); - DeepLinkIntegrationManager.getInstance().setUp(this); MetricsHelper.init(this); Trace.endSection(); } diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 1b7c10449..d3f314e90 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -56,7 +56,6 @@ import com.android.dialer.util.DialerUtils; import com.android.dialer.util.PhoneNumberUtil; import com.android.dialer.voicemail.VoicemailPlaybackPresenter; -import com.cyanogen.ambient.deeplink.DeepLink; import com.google.common.annotations.VisibleForTesting; import java.util.HashMap; @@ -543,23 +542,13 @@ public class CallLogAdapter extends GroupingListAdapter 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. - DeepLink dl = getDeepLink(position); - views.mDeepLink = dl; - - if (dl != null) { - views.mDeepLink = dl; - views.phoneCallDetailsViews.noteIconView.setVisibility(View.VISIBLE); - views.phoneCallDetailsViews.noteIconView.setImageDrawable(dl.getDrawableIcon(mContext)); - } else { - views.phoneCallDetailsViews.noteIconView.setVisibility(View.GONE); - } String component = c.getString(CallLogQuery.PLUGIN_PACKAGE_NAME); if (!TextUtils.isEmpty(component)) { views.inCallComponentName = ComponentName.unflattenFromString(component); } else { views.inCallComponentName = null; } + // Check if the day group has changed and display a header if necessary. int currentGroup = getDayGroupForCall(views.rowId); int previousGroup = getPreviousDayGroup(c); diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 708dcf85c..b36bf9bfb 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -57,7 +57,6 @@ import com.android.dialer.voicemail.VoicemailPlaybackLayout; import com.android.phone.common.incall.CallMethodHelper; import com.android.phone.common.incall.CallMethodInfo; -import com.cyanogen.ambient.deeplink.DeepLink; import com.cyanogen.ambient.incall.extension.OriginCodes; import com.cyanogen.lookup.phonenumber.provider.LookupProviderImpl; @@ -87,8 +86,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public final ImageView primaryActionButtonView; /** DialerQuickContact */ public final DialerQuickContact dialerQuickContact; - /** DeepLink to be used when a link icon is clicked. */ - public DeepLink mDeepLink; /** The view containing call log item actions. Null until the ViewStub is inflated. */ public View actionsView; @@ -96,7 +93,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public VoicemailPlaybackLayout voicemailPlaybackView; public View callButtonView; public View videoCallButtonView; - public View viewNoteButton; public View createNewContactButtonView; public View addToExistingContactButtonView; public View sendMessageView; @@ -298,9 +294,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder createNewContactButtonView = actionsView.findViewById(R.id.create_new_contact_action); createNewContactButtonView.setOnClickListener(this); - viewNoteButton = actionsView.findViewById(R.id.view_note_action); - viewNoteButton.setOnClickListener(this); - addToExistingContactButtonView = actionsView.findViewById(R.id.add_to_existing_contact_action); addToExistingContactButtonView.setOnClickListener(this); @@ -391,13 +384,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder callButtonView.setVisibility(View.GONE); } - if (mDeepLink != null) { - ImageView icon = (ImageView) viewNoteButton.findViewById(R.id.view_note_action_icon); - icon.setImageDrawable(mDeepLink.getDrawableIcon(mContext)); - viewNoteButton.setVisibility(View.VISIBLE); - } else { - viewNoteButton.setVisibility(View.GONE); - } // If one of the calls had video capabilities, show the video call button. if (mTelecomCallLogCache.isVideoEnabled() && canPlaceCallToNumber && phoneCallDetailsViews.callTypeIcons.isVideoShown() || @@ -572,8 +558,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder view in dialog. */ numberType, /* phone number type (e.g. mobile) in second line of contact view */ accountHandle); - } else if (view.getId() == R.id.view_note_action) { - mContext.startActivity(mDeepLink.createViewIntent()); } else { final Object tag = view.getTag(); if (tag instanceof String && inCallComponentName != null) { diff --git a/src/com/android/dialer/calllog/GroupingListAdapter.java b/src/com/android/dialer/calllog/GroupingListAdapter.java index 0864be4de..8d3ab4545 100644 --- a/src/com/android/dialer/calllog/GroupingListAdapter.java +++ b/src/com/android/dialer/calllog/GroupingListAdapter.java @@ -20,7 +20,6 @@ import android.content.Context; import android.database.ContentObserver; import android.database.Cursor; import android.database.DataSetObserver; -import android.net.Uri; import android.os.Handler; import android.support.v7.widget.RecyclerView; import android.util.Log; @@ -30,14 +29,6 @@ import android.view.ViewGroup; import android.widget.BaseAdapter; import com.android.contacts.common.testing.NeededForTesting; -import com.android.dialer.DeepLinkIntegrationManager; -import com.cyanogen.ambient.common.api.ResultCallback; -import com.cyanogen.ambient.deeplink.DeepLink; -import com.cyanogen.ambient.deeplink.applicationtype.DeepLinkApplicationType; -import com.cyanogen.ambient.deeplink.linkcontent.DeepLinkContentType; - -import java.util.ArrayList; -import java.util.List; /** * Maintains a list that groups adjacent items sharing the same value of a "group-by" field. @@ -86,13 +77,6 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { private int mGroupCount; /** - * Count of the DeepLinks we should display in the list; - */ - private int mDeepLinkCount; - private DeepLink[] mDeepLinks; - private SparseIntArray mDeepLinkCache = new SparseIntArray(); - - /** * Information about where these groups are located in the list, how large they are * and whether they are expanded. */ @@ -152,8 +136,6 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { mLastCachedGroup = -1; mPositionMetadata.listPosition = -1; mPositionCache.clear(); - mDeepLinkCount = 0; - mDeepLinkCache.clear(); } public void changeCursor(Cursor cursor) { @@ -169,7 +151,6 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { mCursor = cursor; resetCache(); findGroups(); - findDeepLinks(); if (cursor != null) { cursor.registerContentObserver(mChangeObserver); @@ -179,121 +160,6 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { } } - /** - * Iterates over all of the views in the adapter, determines which calls or groups of calls - * should be considered for potential DeepLinking. Calls the API for each of these groups to - * determine which DeepLink to display. - */ - private void findDeepLinks() { - mDeepLinks = new DeepLink[GROUP_METADATA_ARRAY_INITIAL_SIZE]; - - if (mCursor == null) { - return; - } - - for (int i = 0; i < getItemCount(); i++) { - askForDeepLink(i, buildCallUris(i)); - } - } - - /** - * Query the DeepLink API for a specific DeepLink against a specific set of Uris - * @param position - view position in the adapter that this DeepLink is associated with. - * @param uris - the set of call uris which we are querying aginst - */ - private void askForDeepLink(final int position, List<Uri> uris) { - if (uris == null || uris.size() <= 0) { - return; - } - - DeepLinkIntegrationManager.getInstance().getPreferredLinksForList( - new ResultCallback<DeepLink.DeepLinkResultList>() { - @Override - public void onResult(DeepLink.DeepLinkResultList result) { - List<DeepLink> links = result.getResults(); - for(DeepLink link: links) { - // we only want to display this deeplink if its a note, and if its - // for content that was previously saved to the application in question. - if(link != null && link.getApplicationType() == DeepLinkApplicationType.NOTE && - link.getAlreadyHasContent()) { - addDeepLink(position, link); - break; - } - } - } - }, DeepLinkContentType.CALL, uris); - } - - /** - * For a given view in the adapter figure out what phone number it is for, collect all the - * call times and generate Uri's for each call in the view. - * @param position - the position in views that we're checking - * @return a list of uri's representing the call or group of calls to check for DeepLinking. - */ - private List<Uri> buildCallUris(int position) { - List<Uri> uris = null; - obtainPositionMetadata(mPositionMetadata, position); - Cursor c = (Cursor) getItem(position); - if (c != null) { - String number = mCursor.getString(CallLogQuery.NUMBER); - uris = new ArrayList<Uri>(); - Uri toUse; - long[] callTimes = getCallTimes(mCursor, mPositionMetadata.childCount); - for (int i = 0; i < callTimes.length; i++) { - toUse = DeepLinkIntegrationManager.generateCallUri(number, callTimes[i]); - uris.add(toUse); - } - } - return uris; - } - - /** - * Returns call times for the given number of items in the cursor - */ - private long[] getCallTimes(Cursor cursor, int count) { - int position = cursor.getPosition(); - long[] callTimes = new long[count]; - for (int index = 0; index < count; ++index) { - callTimes[index] = cursor.getLong(CallLogQuery.DATE); - cursor.moveToNext(); - } - cursor.moveToPosition(position); - return callTimes; - } - - /** - * Add a DeepLink to our deep link cache. - * {@link #addGroups} method. - */ - protected void addDeepLink(int position, DeepLink deepLink) { - if (mDeepLinkCount >= mDeepLinks.length) { - int newSize = idealLongArraySize( - mDeepLinks.length + GROUP_METADATA_ARRAY_INCREMENT); - DeepLink[] array = new DeepLink[newSize]; - System.arraycopy(mDeepLinks, 0, array, 0, mDeepLinkCount); - mDeepLinks = array; - } - mDeepLinks[mDeepLinkCount] = deepLink; - obtainPositionMetadata(mPositionMetadata, position); - mDeepLinkCache.put(position, mDeepLinkCount); - mDeepLinkCount++; - notifyItemChanged(position); - } - - /** - * Get the DeepLink associated with the given position in the views. If no DeepLink is - * associated with this position returns null. - * @param position the position in the views to check for deeplinks - * @return the DeepLink for this position or null. - */ - protected DeepLink getDeepLink(int position) { - DeepLink deepLink = null; - if(mDeepLinkCache.get(position, -1) >= 0) { - deepLink = mDeepLinks[mDeepLinkCache.get(position)]; - } - return deepLink; - } - @NeededForTesting public Cursor getCursor() { return mCursor; diff --git a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java index 986805db1..df5fe0606 100644 --- a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java +++ b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java @@ -132,12 +132,9 @@ public class PhoneCallDetailsHelper { } else { nameText = details.name; } - views.nameWrapper.setVisibility(View.VISIBLE); + views.nameView.setText(nameText); - views.nameView.setVisibility(View.VISIBLE); - if(views.noteIconView.getDrawable() == null) { - views.noteIconView.setVisibility(View.GONE); - } + if (isVoicemail && !TextUtils.isEmpty(details.transcription)) { views.voicemailTranscriptionView.setText(details.transcription); views.voicemailTranscriptionView.setVisibility(View.VISIBLE); diff --git a/src/com/android/dialer/calllog/PhoneCallDetailsViews.java b/src/com/android/dialer/calllog/PhoneCallDetailsViews.java index d8b654411..94f4411b0 100644 --- a/src/com/android/dialer/calllog/PhoneCallDetailsViews.java +++ b/src/com/android/dialer/calllog/PhoneCallDetailsViews.java @@ -27,8 +27,6 @@ import com.android.dialer.R; * Encapsulates the views that are used to display the details of a phone call in the call log. */ public final class PhoneCallDetailsViews { - public final View nameWrapper; - public final ImageView noteIconView; public final TextView nameView; public final View callTypeView; public final CallTypeIconsView callTypeIcons; @@ -36,11 +34,9 @@ public final class PhoneCallDetailsViews { public final TextView voicemailTranscriptionView; public final TextView callAccountLabel; - private PhoneCallDetailsViews(View nameAndNote, ImageView noteIconView, TextView nameView, - View callTypeView, CallTypeIconsView callTypeIcons, TextView callLocationAndDate, + private PhoneCallDetailsViews(TextView nameView, View callTypeView, + CallTypeIconsView callTypeIcons, TextView callLocationAndDate, TextView voicemailTranscriptionView, TextView callAccountLabel) { - this.nameWrapper = nameAndNote; - this.noteIconView = noteIconView; this.nameView = nameView; this.callTypeView = callTypeView; this.callTypeIcons = callTypeIcons; @@ -57,10 +53,7 @@ public final class PhoneCallDetailsViews { * {@code R.id.call_types}. */ public static PhoneCallDetailsViews fromView(View view) { - return new PhoneCallDetailsViews( - view.findViewById(R.id.nameWrapper), - (ImageView) view.findViewById(R.id.contactHasNotesIcon), - (TextView) view.findViewById(R.id.name), + return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name), view.findViewById(R.id.call_type), (CallTypeIconsView) view.findViewById(R.id.call_type_icons), (TextView) view.findViewById(R.id.call_location_and_date), @@ -70,8 +63,6 @@ public final class PhoneCallDetailsViews { public static PhoneCallDetailsViews createForTest(Context context) { return new PhoneCallDetailsViews( - new View(context), - new ImageView(context), new TextView(context), new View(context), new CallTypeIconsView(context), |
