blob: 38e890d4de237c98d55f5f7c7e010fc63c102905 [file] [log] [blame]
Dmitri Plotnikov884e3932010-05-13 19:13:51 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17package com.android.contacts;
18
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070019import com.android.contacts.interactions.PhoneNumberInteraction;
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070020
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070021import android.app.Dialog;
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070022import android.content.DialogInterface;
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070023import android.content.DialogInterface.OnDismissListener;
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070024import android.content.Intent;
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070025import android.net.Uri;
26import android.os.Bundle;
27import android.provider.ContactsContract.Contacts;
28
29/**
30 * An interstitial activity used when the user selects a QSB search suggestion using
31 * a call button.
32 */
Dmitri Plotnikov6f667b52011-01-09 12:53:13 -080033public class CallContactActivity extends ContactsActivity implements OnDismissListener {
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070034
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070035 private PhoneNumberInteraction mPhoneNumberInteraction;
36
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070037 @Override
38 protected void onCreate(Bundle savedInstanceState) {
39 super.onCreate(savedInstanceState);
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070040 mPhoneNumberInteraction = new PhoneNumberInteraction(this, false, this);
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070041
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070042 Uri contactUri = getIntent().getData();
43 if (contactUri == null) {
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070044 finish();
45 }
46
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070047 // If we are being invoked with a saved state, rely on Activity to restore it
48 if (savedInstanceState != null) {
49 return;
50 }
51
52 if (Contacts.CONTENT_ITEM_TYPE.equals(getContentResolver().getType(contactUri))) {
53 mPhoneNumberInteraction.startInteraction(contactUri);
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070054 } else {
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070055 startActivity(new Intent(Intent.ACTION_CALL_PRIVILEGED, contactUri));
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070056 finish();
57 }
58 }
59
60 public void onDismiss(DialogInterface dialog) {
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070061 if (!isChangingConfigurations()) {
62 finish();
63 }
64 }
65
66 @Override
67 protected Dialog onCreateDialog(int id, Bundle args) {
68 return mPhoneNumberInteraction.onCreateDialog(id, args);
69 }
70
71 @Override
72 protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {
73 mPhoneNumberInteraction.onPrepareDialog(id, dialog, args);
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070074 }
75}