Home | History | Annotate | Download | only in list
      1 /*
      2  * Copyright (C) 2013 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 package com.android.dialer.list;
     17 
     18 import android.app.ActionBar;
     19 import android.app.Fragment;
     20 import android.content.Intent;
     21 import android.net.Uri;
     22 import android.os.Bundle;
     23 import android.text.Spannable;
     24 import android.text.SpannableString;
     25 import android.text.style.TypefaceSpan;
     26 import android.util.Log;
     27 
     28 import com.android.contacts.common.CallUtil;
     29 import com.android.contacts.common.activity.TransactionSafeActivity;
     30 import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
     31 import com.android.dialer.DialtactsActivity;
     32 import com.android.dialer.R;
     33 import com.android.dialer.interactions.PhoneNumberInteraction;
     34 
     35 public class AllContactsActivity extends TransactionSafeActivity {
     36     private static final String TAG = AllContactsActivity.class.getSimpleName();
     37 
     38     private AllContactsFragment mAllContactsFragment;
     39 
     40     // Same behavior as {@link DialtactsActivity}
     41     private final OnPhoneNumberPickerActionListener mPhoneNumberPickerActionListener =
     42             new OnPhoneNumberPickerActionListener() {
     43                 @Override
     44                 public void onPickPhoneNumberAction(Uri dataUri) {
     45                     // Specify call-origin so that users will see the previous tab instead of
     46                     // CallLog screen (search UI will be automatically exited).
     47                     PhoneNumberInteraction.startInteractionForPhoneCall(
     48                         AllContactsActivity.this, dataUri, null);
     49                 }
     50 
     51                 @Override
     52                 public void onCallNumberDirectly(String phoneNumber) {
     53                 final Intent intent = CallUtil.getCallIntent(phoneNumber, null);
     54                     startActivity(intent);
     55                 }
     56 
     57                 @Override
     58                 public void onShortcutIntentCreated(Intent intent) {
     59                     Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring.");
     60                 }
     61 
     62                 @Override
     63                 public void onHomeInActionBarSelected() {
     64                     // {@link PhoneNumberPickerFragment handles onClick on the home button
     65                     // and performs the callback here. This means we don't have to handle it
     66                     // ourself in the activity.
     67                     final Intent intent = new Intent(AllContactsActivity.this,
     68                             DialtactsActivity.class);
     69                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
     70                     startActivity(intent);
     71                 }
     72     };
     73 
     74     @Override
     75     protected void onCreate(Bundle savedInstanceState) {
     76         super.onCreate(savedInstanceState);
     77 
     78         final ActionBar actionBar = getActionBar();
     79         actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
     80         actionBar.setDisplayShowHomeEnabled(true);
     81         actionBar.setDisplayHomeAsUpEnabled(true);
     82         actionBar.setDisplayShowTitleEnabled(true);
     83 
     84         setContentView(R.layout.all_contacts_activity);
     85     }
     86 
     87     @Override
     88     public void onAttachFragment(Fragment fragment) {
     89         if (fragment instanceof AllContactsFragment) {
     90             mAllContactsFragment = (AllContactsFragment) fragment;
     91             mAllContactsFragment.setOnPhoneNumberPickerActionListener(
     92                     mPhoneNumberPickerActionListener);
     93         }
     94     }
     95 }
     96