Home | History | Annotate | Download | only in contacts
      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 
     19 import com.android.contacts.interactions.PhoneNumberInteraction;
     20 
     21 import android.content.DialogInterface;
     22 import android.content.DialogInterface.OnDismissListener;
     23 import android.net.Uri;
     24 import android.os.Bundle;
     25 import android.provider.ContactsContract.Contacts;
     26 
     27 /**
     28  * An interstitial activity used when the user selects a QSB search suggestion using
     29  * a call button.
     30  */
     31 public class CallContactActivity extends ContactsActivity implements OnDismissListener {
     32 
     33     @Override
     34     protected void onCreate(Bundle savedInstanceState) {
     35         super.onCreate(savedInstanceState);
     36 
     37         Uri contactUri = getIntent().getData();
     38         if (contactUri == null) {
     39             finish();
     40         }
     41 
     42         // If this method is being invoked with a saved state, rely on Activity
     43         // to restore it
     44         if (savedInstanceState != null) {
     45             return;
     46         }
     47 
     48         if (Contacts.CONTENT_ITEM_TYPE.equals(getContentResolver().getType(contactUri))) {
     49             PhoneNumberInteraction.startInteractionForPhoneCall(this, contactUri);
     50         } else {
     51             startActivity(ContactsUtils.getCallIntent(contactUri));
     52             finish();
     53         }
     54     }
     55 
     56     @Override
     57     public void onDismiss(DialogInterface dialog) {
     58         if (!isChangingConfigurations()) {
     59             finish();
     60         }
     61     }
     62 }
     63