Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.contacts; |
| 18 | |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 19 | import com.android.contacts.interactions.PhoneNumberInteraction; |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 20 | |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 21 | import android.app.Dialog; |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 22 | import android.content.DialogInterface; |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 23 | import android.content.DialogInterface.OnDismissListener; |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 24 | import android.content.Intent; |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 25 | import android.net.Uri; |
| 26 | import android.os.Bundle; |
| 27 | import 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 Plotnikov | 6f667b5 | 2011-01-09 12:53:13 -0800 | [diff] [blame] | 33 | public class CallContactActivity extends ContactsActivity implements OnDismissListener { |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 34 | |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 35 | private PhoneNumberInteraction mPhoneNumberInteraction; |
| 36 | |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 37 | @Override |
| 38 | protected void onCreate(Bundle savedInstanceState) { |
| 39 | super.onCreate(savedInstanceState); |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 40 | mPhoneNumberInteraction = new PhoneNumberInteraction(this, false, this); |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 41 | |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 42 | Uri contactUri = getIntent().getData(); |
| 43 | if (contactUri == null) { |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 44 | finish(); |
| 45 | } |
| 46 | |
John Evans | 06feeb5 | 2011-02-24 16:14:54 -0800 | [diff] [blame] | 47 | // If this method is being invoked with a saved state, rely on Activity |
| 48 | // to restore it |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 49 | if (savedInstanceState != null) { |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | if (Contacts.CONTENT_ITEM_TYPE.equals(getContentResolver().getType(contactUri))) { |
| 54 | mPhoneNumberInteraction.startInteraction(contactUri); |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 55 | } else { |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 56 | startActivity(new Intent(Intent.ACTION_CALL_PRIVILEGED, contactUri)); |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 57 | finish(); |
| 58 | } |
| 59 | } |
| 60 | |
John Evans | 06feeb5 | 2011-02-24 16:14:54 -0800 | [diff] [blame] | 61 | @Override |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 62 | public void onDismiss(DialogInterface dialog) { |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 63 | if (!isChangingConfigurations()) { |
| 64 | finish(); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | protected Dialog onCreateDialog(int id, Bundle args) { |
| 70 | return mPhoneNumberInteraction.onCreateDialog(id, args); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | protected void onPrepareDialog(int id, Dialog dialog, Bundle args) { |
| 75 | mPhoneNumberInteraction.onPrepareDialog(id, dialog, args); |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 76 | } |
| 77 | } |