2 * Copyright (C) 2009 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.contacts.ui;
19 import com.android.contacts.StickyTabs;
21 import android.app.Activity;
22 import android.content.ContentUris;
23 import android.content.Intent;
24 import android.graphics.Rect;
25 import android.net.Uri;
26 import android.os.Bundle;
27 import android.provider.ContactsContract.QuickContact;
28 import android.provider.ContactsContract.RawContacts;
29 import android.util.Log;
32 * Stub translucent activity that just shows {@link QuickContactWindow} floating
33 * above the caller. This temporary hack should eventually be replaced with
34 * direct framework support.
36 public final class QuickContactActivity extends Activity implements
37 QuickContactWindow.OnDismissListener {
38 private static final String TAG = "QuickContactActivity";
40 static final boolean LOGV = false;
41 static final boolean FORCE_CREATE = false;
43 private QuickContactWindow mQuickContact;
46 protected void onCreate(Bundle icicle) {
47 super.onCreate(icicle);
48 if (LOGV) Log.d(TAG, "onCreate");
50 this.onNewIntent(getIntent());
54 public void onNewIntent(Intent intent) {
55 super.onNewIntent(intent);
56 if (LOGV) Log.d(TAG, "onNewIntent");
58 if (QuickContactWindow.TRACE_LAUNCH) {
59 android.os.Debug.startMethodTracing(QuickContactWindow.TRACE_TAG);
62 if (mQuickContact == null || FORCE_CREATE) {
63 if (LOGV) Log.d(TAG, "Preparing window");
64 mQuickContact = new QuickContactWindow(this, this);
66 mQuickContact.setLastSelectedContactsAppTab(StickyTabs.getTab(intent));
68 // Use our local window token for now
69 Uri lookupUri = intent.getData();
70 // Check to see whether it comes from the old version.
71 if (android.provider.Contacts.AUTHORITY.equals(lookupUri.getAuthority())) {
72 final long rawContactId = ContentUris.parseId(lookupUri);
73 lookupUri = RawContacts.getContactLookupUri(getContentResolver(),
74 ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId));
76 final Bundle extras = intent.getExtras();
78 // Read requested parameters for displaying
79 final Rect target = intent.getSourceBounds();
80 final int mode = extras.getInt(QuickContact.EXTRA_MODE, QuickContact.MODE_MEDIUM);
81 final String[] excludeMimes = extras.getStringArray(QuickContact.EXTRA_EXCLUDE_MIMES);
83 mQuickContact.show(lookupUri, target, mode, excludeMimes);
88 public void onBackPressed() {
89 if (LOGV) Log.w(TAG, "Unexpected back captured by stub activity");
94 protected void onPause() {
96 if (LOGV) Log.d(TAG, "onPause");
98 // Dismiss any dialog when pausing
99 mQuickContact.dismiss();
103 protected void onDestroy() {
105 if (LOGV) Log.d(TAG, "onDestroy");
109 public void onDismiss(QuickContactWindow dialog) {
110 if (LOGV) Log.d(TAG, "onDismiss");
112 if (isTaskRoot() && !FORCE_CREATE) {
113 // Instead of stopping, simply push this to the back of the stack.
114 // This is only done when running at the top of the stack;
115 // otherwise, we have been launched by someone else so need to
116 // allow the user to go back to the caller.
117 moveTaskToBack(false);