1 /* 2 * Copyright (C) 2011 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.calendar.selectcalendars; 18 19 import android.app.ActionBar; 20 import android.app.FragmentTransaction; 21 import android.content.Intent; 22 import android.os.Bundle; 23 import android.view.Menu; 24 import android.view.MenuItem; 25 import android.view.View; 26 27 import com.android.calendar.AbstractCalendarActivity; 28 import com.android.calendar.R; 29 import com.android.calendar.Utils; 30 31 public class SelectVisibleCalendarsActivity extends AbstractCalendarActivity { 32 private SelectVisibleCalendarsFragment mFragment; 33 34 @Override 35 protected void onCreate(Bundle icicle) { 36 super.onCreate(icicle); 37 38 setContentView(R.layout.simple_frame_layout); 39 40 mFragment = (SelectVisibleCalendarsFragment) getFragmentManager().findFragmentById( 41 R.id.main_frame); 42 43 if (mFragment == null) { 44 mFragment = new SelectVisibleCalendarsFragment(R.layout.calendar_sync_item); 45 46 FragmentTransaction ft = getFragmentManager().beginTransaction(); 47 ft.replace(R.id.main_frame, mFragment); 48 ft.show(mFragment); 49 ft.commit(); 50 } 51 } 52 53 // Needs to be in proguard whitelist 54 // Specified as listener via android:onClick in a layout xml 55 public void handleSelectSyncedCalendarsClicked(View v) { 56 Intent intent = new Intent(Intent.ACTION_VIEW); 57 intent.setClass(this, SelectSyncedCalendarsMultiAccountActivity.class); 58 intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); 59 startActivity(intent); 60 } 61 62 @Override 63 public boolean onCreateOptionsMenu(Menu menu) { 64 getActionBar() 65 .setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); 66 return true; 67 } 68 69 @Override 70 public boolean onOptionsItemSelected(MenuItem item) { 71 switch (item.getItemId()) { 72 case android.R.id.home: 73 Utils.returnToCalendarHome(this); 74 return true; 75 } 76 return super.onOptionsItemSelected(item); 77 } 78 } 79