From ff1025e27a70eaedd573329e32c2b907942f851d Mon Sep 17 00:00:00 2001 From: Erica Chang Date: Tue, 26 Apr 2016 22:11:41 -0700 Subject: [2/2] Contacts : fixed InCall plugin PendingIntent after refactor -Addressed contact card not reflecting InCall plugin status/auth state change -Added error Snackbar message in case invite and directory search PendingIntents are null CD-550,CD-588 Change-Id: I2ba66a98d13f982fe13563439afd5f785ab0f16c --- Android.mk | 7 +++-- res/values/cm_strings.xml | 1 + .../android/contacts/incall/InCallPluginInfo.java | 3 -- .../android/contacts/incall/InCallPluginUtils.java | 6 ++++ .../list/PluginContactBrowseListFragment.java | 2 +- .../quickcontact/QuickContactActivity.java | 35 +++++++++++++++------- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Android.mk b/Android.mk index 7d623408d..5ac8d24b1 100644 --- a/Android.mk +++ b/Android.mk @@ -14,20 +14,23 @@ res_dirs := res $(contacts_common_dir)/res $(phone_common_dir)/res LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs)) LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs)) \ - frameworks/support/v7/cardview/res + frameworks/support/v7/cardview/res \ + external/uicommon/res LOCAL_AAPT_FLAGS := \ --auto-add-overlay \ --extra-packages com.android.contacts.common \ --extra-packages com.android.phone.common \ --extra-packages android.support.v7.cardview \ - --extra-packages com.cyanogen.ambient + --extra-packages com.cyanogen.ambient \ + --extra-packages com.cyngn.uicommon LOCAL_JAVA_LIBRARIES := telephony-common voip-common ims-common LOCAL_FULL_LIBS_MANIFEST_FILES := $(LOCAL_PATH)/AndroidManifest_cm.xml LOCAL_STATIC_JAVA_LIBRARIES := \ com.android.vcard \ android-common \ + uicommon \ guava \ android-support-v13 \ android-support-v7-cardview \ diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 2c6a9badf..491ee5809 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -78,4 +78,5 @@ INVITE %1$s name %s cannot make this call + Unable to complete this action. Try again later. diff --git a/src/com/android/contacts/incall/InCallPluginInfo.java b/src/com/android/contacts/incall/InCallPluginInfo.java index cca5c0048..98cfd3cd2 100644 --- a/src/com/android/contacts/incall/InCallPluginInfo.java +++ b/src/com/android/contacts/incall/InCallPluginInfo.java @@ -58,8 +58,6 @@ public class InCallPluginInfo implements Parcelable { mCallMethodInfo.mStatus = in.readInt(); mCallMethodInfo.mDefaultDirectorySearchIntent = in.readParcelable(PendingIntent.class .getClassLoader()); - mCallMethodInfo.mDirectorySearchIntent = - in.readParcelable(PendingIntent.class.getClassLoader()); mCallMethodInfo.mLoginIntent = in.readParcelable(PendingIntent.class.getClassLoader()); mCallMethodInfo.mName = in.readString(); mCallMethodInfo.mBrandIconId = in.readInt(); @@ -78,7 +76,6 @@ public class InCallPluginInfo implements Parcelable { dest.writeInt(mCallMethodInfo.mIsAuthenticated ? 1 : 0); dest.writeInt(mCallMethodInfo.mStatus); dest.writeParcelable(mCallMethodInfo.mDefaultDirectorySearchIntent, flags); - dest.writeParcelable(mCallMethodInfo.mDirectorySearchIntent, flags); dest.writeParcelable(mCallMethodInfo.mLoginIntent, flags); dest.writeString(mCallMethodInfo.mName); dest.writeInt(mCallMethodInfo.mBrandIconId); diff --git a/src/com/android/contacts/incall/InCallPluginUtils.java b/src/com/android/contacts/incall/InCallPluginUtils.java index 0c0ef9702..7d90f4fe5 100644 --- a/src/com/android/contacts/incall/InCallPluginUtils.java +++ b/src/com/android/contacts/incall/InCallPluginUtils.java @@ -28,6 +28,7 @@ import android.net.Uri; import android.provider.ContactsContract; import android.text.TextUtils; import android.util.Log; +import android.view.View; import com.android.contacts.common.ContactPresenceIconUtil; import com.android.contacts.common.ContactStatusUtil; @@ -41,6 +42,7 @@ import com.android.phone.common.incall.ContactsDataSubscription; import com.android.phone.common.incall.utils.CallMethodFilters; import com.cyanogen.ambient.incall.extension.InCallContactInfo; +import com.cyngn.uicommon.view.Snackbar; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -205,4 +207,8 @@ public class InCallPluginUtils { phoneNumber, lookupUri); } + + public static void displayPendingIntentError(View parentView, String msg) { + Snackbar.make(parentView, msg, Snackbar.LENGTH_SHORT).show(); + } } diff --git a/src/com/android/contacts/list/PluginContactBrowseListFragment.java b/src/com/android/contacts/list/PluginContactBrowseListFragment.java index 09060f251..eb313d588 100644 --- a/src/com/android/contacts/list/PluginContactBrowseListFragment.java +++ b/src/com/android/contacts/list/PluginContactBrowseListFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * 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. diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java index b3a2e60e0..2a39b5437 100644 --- a/src/com/android/contacts/quickcontact/QuickContactActivity.java +++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java @@ -174,6 +174,7 @@ import com.android.contacts.widget.MultiShrinkScroller.MultiShrinkScrollerListen import com.android.contacts.widget.QuickContactImageView; import com.android.phone.common.incall.ContactsDataSubscription; import com.android.phone.common.incall.CallMethodInfo; +import com.android.phone.common.incall.ContactsPendingIntents; import com.android.phone.common.incall.utils.CallMethodFilters; import com.android.phone.common.incall.utils.CallMethodUtils; import com.android.phone.common.incall.utils.MimeTypeUtils; @@ -1508,9 +1509,8 @@ public class QuickContactActivity extends ContactsActivity implements Set pluginMimeExcluded; Set pluginMimeIncluded; if (ContactsDataSubscription.infoReady()) { - mCallMethodMap = (HashMap) - CallMethodFilters.getAllEnabledAndHiddenCallMethods( - ContactsDataSubscription.get(this)); + mCallMethodMap = CallMethodFilters.getAllEnabledAndHiddenCallMethods( + ContactsDataSubscription.get(this)); pluginMimeExcluded = MimeTypeUtils.getAllEnabledVideoImMimeSet( ContactsDataSubscription.get(this)); pluginMimeIncluded = MimeTypeUtils.getAllEnabledVoiceMimeSet( @@ -2475,8 +2475,8 @@ public class QuickContactActivity extends ContactsActivity implements if (DEBUG) Log.d(TAG, "checkAndBindContactData," + withBlockHelper + " " + onlyStartAsyncTask); // Update pending Intents - ContactsDataSubscription.refreshPendingIntents( - InCallPluginUtils.getInCallContactInfo(contact)); + ContactsDataSubscription.get(this).updatePendingIntents( + mIntentMap, InCallPluginUtils.getInCallContactInfo(contact)); if (mIsUpdating.get() && mEntriesAndActionsTask != null && !mEntriesAndActionsTask .isCancelled()) { @@ -3635,8 +3635,11 @@ public class QuickContactActivity extends ContactsActivity implements CallMethodInfo cmiStored = entry.getCallMethodInfo(); CallMethodInfo cmi = ContactsDataSubscription.get(this).getPluginIfExists(cmiStored .mComponent); + ContactsPendingIntents cpi = mIntentMap.get(cmiStored.mComponent); Intent intent = tag.getIntent(); if (cmi == null || intent == null) { + InCallPluginUtils.displayPendingIntentError(mScroller, + getResources().getString(R.string.incall_plugin_intent_error)); return; } try { @@ -3676,6 +3679,9 @@ public class QuickContactActivity extends ContactsActivity implements } else if (intent.getAction().equals(ACTION_INCALL_PLUGIN_LOGIN)) { if (cmi.mLoginIntent != null) { cmi.mLoginIntent.send(); + } else { + InCallPluginUtils.displayPendingIntentError(mScroller, + getResources().getString(R.string.incall_plugin_intent_error)); } InCallMetricsHelper.setValue( this, @@ -3686,13 +3692,19 @@ public class QuickContactActivity extends ContactsActivity implements InCallMetricsHelper.EVENT_ACCEPT, InCallMetricsHelper.generateNudgeId(cmi.mLoginNudgeSubtitle)); } else if (intent.getAction().equals(ACTION_INCALL_PLUGIN_INVITE)) { - if (cmi.mInviteIntent != null) { - cmi.mInviteIntent.send(); + if (cpi != null && cpi.mInviteIntent != null) { + cpi.mInviteIntent.send(); + } else { + InCallPluginUtils.displayPendingIntentError(mScroller, + getResources().getString(R.string.incall_plugin_intent_error)); } InCallMetricsHelper.increaseInviteCount(this, cmi.mComponent.flattenToString()); } else if (intent.getAction().equals(ACTION_INCALL_PLUGIN_DIRECTORY_SEARCH)) { - if (cmi.mDirectorySearchIntent != null) { - cmi.mDirectorySearchIntent.send(); + if (cpi != null && cpi.mDirectorySearchIntent != null) { + cpi.mDirectorySearchIntent.send(); + } else { + InCallPluginUtils.displayPendingIntentError(mScroller, + getResources().getString(R.string.incall_plugin_intent_error)); } } } catch (PendingIntent.CanceledException e) { @@ -3737,7 +3749,8 @@ public class QuickContactActivity extends ContactsActivity implements }; // Global CallMethod map that keeps track of the currently displayed plugins - HashMap mCallMethodMap = new HashMap(); + HashMap mCallMethodMap = new HashMap<>(); + HashMap mIntentMap = new HashMap<>(); private void updatePlugins(HashMap callMethods) { if (DEBUG) Log.d(TAG, "+++updatePlugins"); @@ -3759,7 +3772,7 @@ public class QuickContactActivity extends ContactsActivity implements if (newCmMap.containsKey(cn)) { // Check if update needed CallMethodInfo newCmi = newCmMap.remove(cn); - if (!newCmi.equals(cmi) || newCmi.mIsAuthenticated != cmi.mIsAuthenticated) { + if (newCmi.mIsAuthenticated != cmi.mIsAuthenticated) { updateNeeded = true; } } else { -- cgit v1.2.3