1 /* 2 * Copyright (C) 2015 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.messaging.ui; 17 18 import android.app.Fragment; 19 import android.net.Uri; 20 import android.os.Bundle; 21 import android.view.MenuItem; 22 23 import com.android.messaging.R; 24 import com.android.messaging.util.Assert; 25 26 /** 27 * An activity that hosts VCardDetailFragment that shows the content of a VCard that contains one 28 * or more contacts. 29 */ 30 public class VCardDetailActivity extends BugleActionBarActivity { 31 @Override onCreate(final Bundle savedInstanceState)32 protected void onCreate(final Bundle savedInstanceState) { 33 super.onCreate(savedInstanceState); 34 setContentView(R.layout.vcard_detail_activity); 35 getSupportActionBar().setDisplayHomeAsUpEnabled(true); 36 } 37 38 @Override onAttachFragment(final Fragment fragment)39 public void onAttachFragment(final Fragment fragment) { 40 if (fragment instanceof VCardDetailFragment) { 41 final Uri vCardUri = 42 getIntent().getParcelableExtra(UIIntents.UI_INTENT_EXTRA_VCARD_URI); 43 Assert.notNull(vCardUri); 44 final VCardDetailFragment vCardDetailFragment = (VCardDetailFragment) fragment; 45 vCardDetailFragment.setVCardUri(vCardUri); 46 } 47 } 48 49 @Override onOptionsItemSelected(final MenuItem item)50 public boolean onOptionsItemSelected(final MenuItem item) { 51 switch (item.getItemId()) { 52 case android.R.id.home: 53 // Treat the home press as back press so that when we go back to 54 // ConversationActivity, it doesn't lose its original intent (conversation id etc.) 55 onBackPressed(); 56 return true; 57 58 default: 59 return super.onOptionsItemSelected(item); 60 } 61 } 62 } 63