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 | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 19 | import android.content.DialogInterface; |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 20 | import android.content.DialogInterface.OnDismissListener; |
| 21 | import android.net.Uri; |
| 22 | import android.os.Bundle; |
| 23 | import android.provider.ContactsContract.Contacts; |
| 24 | |
Chiao Cheng | 3a8df86 | 2012-09-04 16:30:17 -0700 | [diff] [blame] | 25 | import com.android.contacts.common.CallUtil; |
Chiao Cheng | e0b2f1e | 2012-06-12 13:07:56 -0700 | [diff] [blame] | 26 | import com.android.contacts.interactions.PhoneNumberInteraction; |
| 27 | |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 28 | /** |
| 29 | * An interstitial activity used when the user selects a QSB search suggestion using |
| 30 | * a call button. |
| 31 | */ |
Dmitri Plotnikov | 6f667b5 | 2011-01-09 12:53:13 -0800 | [diff] [blame] | 32 | public class CallContactActivity extends ContactsActivity implements OnDismissListener { |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 33 | |
| 34 | @Override |
| 35 | protected void onCreate(Bundle savedInstanceState) { |
| 36 | super.onCreate(savedInstanceState); |
| 37 | |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 38 | Uri contactUri = getIntent().getData(); |
| 39 | if (contactUri == null) { |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 40 | finish(); |
| 41 | } |
| 42 | |
John Evans | 06feeb5 | 2011-02-24 16:14:54 -0800 | [diff] [blame] | 43 | // If this method is being invoked with a saved state, rely on Activity |
| 44 | // to restore it |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 45 | if (savedInstanceState != null) { |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | if (Contacts.CONTENT_ITEM_TYPE.equals(getContentResolver().getType(contactUri))) { |
Daisuke Miyakawa | b1f0e5e | 2011-06-21 17:42:49 -0700 | [diff] [blame] | 50 | PhoneNumberInteraction.startInteractionForPhoneCall(this, contactUri); |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 51 | } else { |
Chiao Cheng | 3a8df86 | 2012-09-04 16:30:17 -0700 | [diff] [blame] | 52 | startActivity(CallUtil.getCallIntent(contactUri)); |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 53 | finish(); |
| 54 | } |
| 55 | } |
| 56 | |
John Evans | 06feeb5 | 2011-02-24 16:14:54 -0800 | [diff] [blame] | 57 | @Override |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 58 | public void onDismiss(DialogInterface dialog) { |
Dmitri Plotnikov | b4e8886 | 2010-06-30 21:24:35 -0700 | [diff] [blame] | 59 | if (!isChangingConfigurations()) { |
| 60 | finish(); |
| 61 | } |
| 62 | } |
Dmitri Plotnikov | 884e393 | 2010-05-13 19:13:51 -0700 | [diff] [blame] | 63 | } |