Tell the Launcher not to animate QuickContact
Bug:6408369
Change-Id: I68c1330f81dbfd2d3eb60be8431f2460e185f2f5
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a9c781a..33da473 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -418,6 +418,10 @@
</intent-filter>
</activity>
+ <receiver
+ android:name=".quickcontact.QuickContactBroadcastReceiver"
+ android:exported="false" />
+
<activity-alias android:name="ContactShortcut"
android:targetActivity=".activities.ContactSelectionActivity"
android:label="@string/shortcutContact"
diff --git a/src/com/android/contacts/list/ShortcutIntentBuilder.java b/src/com/android/contacts/list/ShortcutIntentBuilder.java
index 074d7ec..753ba02 100644
--- a/src/com/android/contacts/list/ShortcutIntentBuilder.java
+++ b/src/com/android/contacts/list/ShortcutIntentBuilder.java
@@ -86,6 +86,13 @@
private final int mBorderColor;
/**
+ * This is a hidden API of the launcher in JellyBean that allows us to disable the animation
+ * that it would usually do, because it interferes with our own animation for QuickContact
+ */
+ public static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION =
+ "com.android.launcher.intent.extra.shortcut.INGORE_LAUNCH_ANIMATION";
+
+ /**
* Listener interface.
*/
public interface OnShortcutIntentCreatedListener {
@@ -245,9 +252,7 @@
byte[] bitmapData) {
Bitmap bitmap = getPhotoBitmap(bitmapData);
- Intent shortcutIntent;
- // This is a simple shortcut to view a contact.
- shortcutIntent = new Intent(ContactsContract.QuickContact.ACTION_QUICK_CONTACT);
+ Intent shortcutIntent = new Intent(ContactsContract.QuickContact.ACTION_QUICK_CONTACT);
// When starting from the launcher, start in a new, cleared task.
// CLEAR_WHEN_TASK_RESET cannot reset the root of a task, so we
@@ -255,6 +260,9 @@
// finish itself when launching other detail activities.
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ // Tell the launcher to not do its animation, because we are doing our own
+ shortcutIntent.putExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION, true);
+
shortcutIntent.setData(contactUri);
shortcutIntent.putExtra(ContactsContract.QuickContact.EXTRA_MODE,
ContactsContract.QuickContact.MODE_LARGE);
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 11f3da1..b656969 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -214,9 +214,9 @@
mLookupUri = Preconditions.checkNotNull(lookupUri, "missing lookupUri");
// Read requested parameters for displaying
- final Rect targetScreen = intent.getSourceBounds();
- Preconditions.checkNotNull(targetScreen, "missing targetScreen");
- mFloatingLayout.setChildTargetScreen(targetScreen);
+ final Rect sourceBounds = intent.getSourceBounds();
+ Preconditions.checkNotNull(sourceBounds, "missing sourceBounds");
+ mFloatingLayout.setChildTargetScreen(sourceBounds);
mExcludeMimes = intent.getStringArrayExtra(QuickContact.EXTRA_EXCLUDE_MIMES);
diff --git a/src/com/android/contacts/quickcontact/QuickContactBroadcastReceiver.java b/src/com/android/contacts/quickcontact/QuickContactBroadcastReceiver.java
new file mode 100644
index 0000000..e0850d7
--- /dev/null
+++ b/src/com/android/contacts/quickcontact/QuickContactBroadcastReceiver.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 The Android Open Source 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.contacts.quickcontact;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.provider.ContactsContract.QuickContact;
+
+/**
+ * Broadcast receiver for invoking QuickContact using the widget. The purpose of this pass-through
+ * intent receiver is to disable the animation that RemoveViews typically do, which interfere
+ * with our own animation
+ */
+public class QuickContactBroadcastReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final Uri dataUri = intent.getData();
+ final Intent newIntent = new Intent(QuickContact.ACTION_QUICK_CONTACT);
+ newIntent.setSourceBounds(intent.getSourceBounds());
+ newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ newIntent.setData(dataUri);
+ context.startActivity(newIntent);
+ }
+}
diff --git a/src/com/android/contacts/socialwidget/SocialWidgetProvider.java b/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
index 38dac60..d858e73 100644
--- a/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
+++ b/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
@@ -18,8 +18,10 @@
import com.android.contacts.ContactLoader;
import com.android.contacts.R;
+import com.android.contacts.list.ShortcutIntentBuilder;
import com.android.contacts.model.AccountType;
import com.android.contacts.model.AccountTypeManager;
+import com.android.contacts.quickcontact.QuickContactBroadcastReceiver;
import com.android.contacts.util.ContactBadgeUtil;
import com.android.contacts.util.HtmlUtils;
import com.android.contacts.util.StreamItemEntry;
@@ -27,6 +29,7 @@
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
+import android.content.ComponentName;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
@@ -145,20 +148,10 @@
// TODO: Rotate between all the stream items?
- // OnClick launch QuickContact
- final Intent intent = new Intent(QuickContact.ACTION_QUICK_CONTACT);
-
- // When starting from the launcher, start in a new, cleared task.
- // CLEAR_WHEN_TASK_RESET cannot reset the root of a task, so we
- // clear the whole thing preemptively here since QuickContactActivity will
- // finish itself when launching other detail activities.
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
-
+ final Intent intent = new Intent(context, QuickContactBroadcastReceiver.class);
intent.setData(contactData.getLookupUri());
- intent.putExtra(QuickContact.EXTRA_MODE, QuickContact.MODE_SMALL);
-
- final PendingIntent pendingIntent = PendingIntent.getActivity(context,
- 0, intent, 0);
+ final PendingIntent pendingIntent = PendingIntent.getBroadcast(
+ context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.border, pendingIntent);
setDisplayNameAndSnippet(context, views, contactData.getDisplayName(),