blob: 76f08926c396c8cac64cbbb33f29e4f9000f67c1 [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
21import android.app.Activity;
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070022import android.app.Dialog;
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070023import android.content.DialogInterface;
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070024import android.content.DialogInterface.OnDismissListener;
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070025import android.content.Intent;
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070026import android.net.Uri;
27import android.os.Bundle;
28import android.provider.ContactsContract.Contacts;
29
30/**
31 * An interstitial activity used when the user selects a QSB search suggestion using
32 * a call button.
33 */
34public class CallContactActivity extends Activity implements OnDismissListener {
35
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070036 private PhoneNumberInteraction mPhoneNumberInteraction;
37
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070038 @Override
39 protected void onCreate(Bundle savedInstanceState) {
40 super.onCreate(savedInstanceState);
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070041 mPhoneNumberInteraction = new PhoneNumberInteraction(this, false, this);
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070042
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070043 Uri contactUri = getIntent().getData();
44 if (contactUri == null) {
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070045 finish();
46 }
47
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070048 // If we are being invoked with a saved state, rely on Activity to restore it
49 if (savedInstanceState != null) {
50 return;
51 }
52
53 if (Contacts.CONTENT_ITEM_TYPE.equals(getContentResolver().getType(contactUri))) {
54 mPhoneNumberInteraction.startInteraction(contactUri);
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070055 } else {
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070056 startActivity(new Intent(Intent.ACTION_CALL_PRIVILEGED, contactUri));
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070057 finish();
58 }
59 }
60
61 public void onDismiss(DialogInterface dialog) {
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070062 if (!isChangingConfigurations()) {
63 finish();
64 }
65 }
66
67 @Override
68 protected Dialog onCreateDialog(int id, Bundle args) {
69 return mPhoneNumberInteraction.onCreateDialog(id, args);
70 }
71
72 @Override
73 protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {
74 mPhoneNumberInteraction.onPrepareDialog(id, dialog, args);
Dmitri Plotnikov884e3932010-05-13 19:13:51 -070075 }
76}