SHOW_OR_CREATE to original behavior, new FastTrack API.
We had been overriding SHOW_OR_CREATE for awhile, but as
part of http://b/2087222 we added a separate API for
triggering FastTrack. This change returns SHOW_OR_CREATE to
its original behavior, and adds support for the new API.
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b1014ad..68e66ba 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -239,11 +239,12 @@
/>
</activity>
+ <!-- Used to select display and sync groups -->
<activity android:name=".ui.DisplayGroupsActivity" android:label="@string/displayGroups" />
<activity
- android:name="ShowOrCreateActivity"
- android:theme="@style/ShowOrCreateTheme">
+ android:name=".ui.ShowOrCreateActivity"
+ android:theme="@style/FullyTranslucent">
<intent-filter>
<action android:name="com.android.contacts.action.SHOW_OR_CREATE_CONTACT" />
@@ -251,11 +252,17 @@
<data android:scheme="mailto" />
<data android:scheme="tel" />
</intent-filter>
+ </activity>
+
+ <!-- Used to show FastTrack window over a translucent activity, which is a
+ temporary hack until we add better framework support. -->
+ <activity
+ android:name=".ui.FastTrackActivity"
+ android:theme="@style/FullyTranslucent">
<intent-filter>
- <action android:name="com.android.contacts.action.SHOW_OR_CREATE_CONTACT" />
+ <action android:name="com.android.contacts.action.FAST_TRACK" />
<category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.cursor.item/person" android:host="contacts" />
<data android:mimeType="vnd.android.cursor.item/contact" android:host="com.android.contacts" />
</intent-filter>
</activity>
@@ -413,6 +420,3 @@
</application>
</manifest>
-
-
-
diff --git a/res/layout-finger/contacts_list_item_photo.xml b/res/layout-finger/contacts_list_item_photo.xml
index 6b17ef6..0330534 100644
--- a/res/layout-finger/contacts_list_item_photo.xml
+++ b/res/layout-finger/contacts_list_item_photo.xml
@@ -55,7 +55,7 @@
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="8dip"
- style="@*android:style/Widget.FasttrackBadgeWidget.WindowLarge" />
+ style="@*android:style/Widget.FasttrackBadgeWidget.WindowMedium" />
/>
<TextView android:id="@+id/label"
diff --git a/res/values/styles.xml b/res/values/styles.xml
index cedd2b7..b656160 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -44,7 +44,7 @@
<item name="android:windowIsFloating">true</item>
</style>
- <style name="ShowOrCreateTheme" parent="android:Theme.Translucent.NoTitleBar">
+ <style name="FullyTranslucent" parent="android:Theme.Translucent.NoTitleBar">
<item name="android:windowContentOverlay">@null</item>
</style>
diff --git a/src/com/android/contacts/ui/FastTrackActivity.java b/src/com/android/contacts/ui/FastTrackActivity.java
new file mode 100644
index 0000000..8fdc40d
--- /dev/null
+++ b/src/com/android/contacts/ui/FastTrackActivity.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2009 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.ui;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Rect;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.ContactsContract.FastTrack;
+
+/**
+ * Stub translucent activity that just shows {@link FastTrackWindow} floating
+ * above the caller. This temporary hack should eventually be replaced with
+ * direct framework support.
+ */
+public final class FastTrackActivity extends Activity implements FastTrackWindow.OnDismissListener {
+ private FastTrackWindow mFastTrack;
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ // Use our local window token for now
+ final Intent intent = getIntent();
+ final Uri lookupUri = intent.getData();
+ final Bundle extras = intent.getExtras();
+
+ // Read requested parameters for displaying
+ final Rect target = (Rect)extras.getParcelable(FastTrack.EXTRA_TARGET_RECT);
+ final int mode = extras.getInt(FastTrack.EXTRA_MODE, FastTrack.MODE_MEDIUM);
+ final String[] excludeMimes = extras.getStringArray(FastTrack.EXTRA_EXCLUDE_MIMES);
+
+ mFastTrack = new FastTrackWindow(this, this);
+ mFastTrack.show(lookupUri, target, mode, excludeMimes);
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ mFastTrack.dismiss();
+ }
+
+ /** {@inheritDoc} */
+ public void onDismiss(FastTrackWindow dialog) {
+ // When dismissed, finish this activity
+ finish();
+ }
+}
diff --git a/src/com/android/contacts/ui/FastTrackWindow.java b/src/com/android/contacts/ui/FastTrackWindow.java
index fd5036d..ba0d912 100644
--- a/src/com/android/contacts/ui/FastTrackWindow.java
+++ b/src/com/android/contacts/ui/FastTrackWindow.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2009 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.
@@ -35,10 +36,9 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.provider.ContactsContract;
-import android.provider.SocialContract;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
+import android.provider.ContactsContract.FastTrack;
import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.Presence;
import android.provider.ContactsContract.RawContacts;
@@ -212,13 +212,13 @@
private View getHeaderView(int mode) {
View header = null;
switch (mode) {
- case Intents.MODE_SMALL:
+ case FastTrack.MODE_SMALL:
header = mWindow.findViewById(R.id.header_small);
break;
- case Intents.MODE_MEDIUM:
+ case FastTrack.MODE_MEDIUM:
header = mWindow.findViewById(R.id.header_medium);
break;
- case Intents.MODE_LARGE:
+ case FastTrack.MODE_LARGE:
header = mWindow.findViewById(R.id.header_large);
break;
}
@@ -390,10 +390,10 @@
*/
private synchronized void considerShowing() {
if (mHasSummary && mHasSocial && mHasActions && !mShowing) {
- if (mMode == Intents.MODE_MEDIUM && !mHasValidSocial) {
+ if (mMode == FastTrack.MODE_MEDIUM && !mHasValidSocial) {
// Missing valid social, swap medium for small header
mHeader.setVisibility(View.GONE);
- mHeader = getHeaderView(Intents.MODE_SMALL);
+ mHeader = getHeaderView(FastTrack.MODE_SMALL);
}
// All queries have returned, pull curtain
diff --git a/src/com/android/contacts/ShowOrCreateActivity.java b/src/com/android/contacts/ui/ShowOrCreateActivity.java
similarity index 78%
rename from src/com/android/contacts/ShowOrCreateActivity.java
rename to src/com/android/contacts/ui/ShowOrCreateActivity.java
index ed8568a..8d3ed01 100755
--- a/src/com/android/contacts/ShowOrCreateActivity.java
+++ b/src/com/android/contacts/ui/ShowOrCreateActivity.java
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-package com.android.contacts;
+package com.android.contacts.ui;
-import com.android.contacts.ui.FastTrackWindow;
+import com.android.contacts.ContactsListActivity;
+import com.android.contacts.R;
import com.android.contacts.util.Constants;
import com.android.contacts.util.NotifyingAsyncQueryHandler;
@@ -28,7 +29,6 @@
import android.content.EntityIterator;
import android.content.Intent;
import android.database.Cursor;
-import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
@@ -47,14 +47,14 @@
* <li>If no matching contacts found, will prompt user with dialog to add to a
* contact, then will use {@link Intent#ACTION_INSERT_OR_EDIT} to let create new
* contact or edit new data into an existing one.
- * <li>If one matching contact found, show the {@link FastTrackWindow}
- * associated with the found contact. Will show translucent over the caller.
+ * <li>If one matching contact found, directly show {@link Intent#ACTION_VIEW}
+ * that specific contact.
* <li>If more than one matching found, show list of matching contacts using
* {@link Intent#ACTION_SEARCH}.
* </ul>
*/
public final class ShowOrCreateActivity extends Activity implements
- NotifyingAsyncQueryHandler.AsyncQueryListener, FastTrackWindow.OnDismissListener {
+ NotifyingAsyncQueryHandler.AsyncQueryListener {
static final String TAG = "ShowOrCreateActivity";
static final boolean LOGD = false;
@@ -66,7 +66,7 @@
RawContacts.CONTACT_ID,
};
- static final int AGGREGATE_ID_INDEX = 0;
+ static final int CONTACT_ID_INDEX = 0;
static final int QUERY_TOKEN = 42;
@@ -76,8 +76,6 @@
private String mCreateDescrip;
private boolean mCreateForce;
- private FastTrackWindow mFastTrack;
-
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -120,7 +118,7 @@
if (Constants.SCHEME_MAILTO.equals(scheme)) {
mCreateExtras.putString(Intents.Insert.EMAIL, ssp);
- Uri uri = Uri.withAppendedPath(Email.CONTENT_FILTER_EMAIL_URI, Uri.encode(ssp));
+ Uri uri = Uri.withAppendedPath(Email.CONTENT_FILTER_URI, Uri.encode(ssp));
mQueryHandler.startQuery(QUERY_TOKEN, null, uri, CONTACTS_PROJECTION, null, null, null);
} else if (Constants.SCHEME_TEL.equals(scheme)) {
@@ -130,9 +128,8 @@
mQueryHandler.startQuery(QUERY_TOKEN, null, uri, PHONES_PROJECTION, null, null, null);
} else {
- // Otherwise assume incoming aggregate Uri
- showFastTrack(data);
-
+ Log.w(TAG, "Invalid intent:" + getIntent());
+ finish();
}
}
@@ -142,40 +139,6 @@
if (mQueryHandler != null) {
mQueryHandler.cancelOperation(QUERY_TOKEN);
}
- if (mFastTrack != null) {
- mFastTrack.dismiss();
- }
- }
-
- /**
- * Show a {@link FastTrackWindow} for the given aggregate at the requested
- * screen location.
- */
- private void showFastTrack(Uri aggUri) {
- // Use our local window token for now
- final Bundle extras = getIntent().getExtras();
-
- Rect targetRect;
- if (extras.containsKey(Intents.EXTRA_TARGET_RECT)) {
- targetRect = (Rect)extras.getParcelable(Intents.EXTRA_TARGET_RECT);
- } else {
- // TODO: this default rect matches gmail messages, and should move over there
- Log.w(TAG, "Using default TARGET_RECT");
- targetRect = new Rect(15, 110, 15+18, 110+18);
- }
-
- // Use requested display mode, defaulting to medium
- final int mode = extras.getInt(Intents.EXTRA_MODE, Intents.MODE_MEDIUM);
- final String[] excludeMimes = extras.getStringArray(Intents.EXTRA_EXCLUDE_MIMES);
-
- mFastTrack = new FastTrackWindow(this, this);
- mFastTrack.show(aggUri, targetRect, mode, excludeMimes);
- }
-
- /** {@inheritDoc} */
- public void onDismiss(FastTrackWindow dialog) {
- // When dismissed, finish this activity
- finish();
}
/** {@inheritDoc} */
@@ -188,21 +151,23 @@
// Count contacts found by query
int count = 0;
- long aggId = -1;
+ long contactId = -1;
try {
count = cursor.getCount();
if (count == 1 && cursor.moveToFirst()) {
// Try reading ID if only one contact returned
- aggId = cursor.getLong(AGGREGATE_ID_INDEX);
+ contactId = cursor.getLong(CONTACT_ID_INDEX);
}
} finally {
cursor.close();
}
- if (count == 1 && aggId != -1) {
- // If we only found one item, show fast-track
- final Uri aggUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, aggId);
- showFastTrack(aggUri);
+ if (count == 1 && contactId != -1) {
+ // If we only found one item, jump right to viewing it
+ final Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
+ final Intent viewIntent = new Intent(Intent.ACTION_VIEW, contactUri);
+ startActivity(viewIntent);
+ finish();
} else if (count > 1) {
// If more than one, show pick list