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.phone; 18 19 import android.os.Bundle; 20 import android.os.PersistableBundle; 21 import android.preference.Preference; 22 import android.preference.PreferenceScreen; 23 import android.telephony.CarrierConfigManager; 24 import android.view.MenuItem; 25 26 import com.android.internal.telephony.PhoneConstants; 27 28 public class CdmaCallOptions extends TimeConsumingPreferenceActivity { 29 private static final String LOG_TAG = "CdmaCallOptions"; 30 private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2); 31 32 private static final String BUTTON_VP_KEY = "button_voice_privacy_key"; 33 private static final String CALL_FORWARDING_KEY = "call_forwarding_key"; 34 private static final String CALL_WAITING_KEY = "call_waiting_key"; 35 private CdmaVoicePrivacySwitchPreference mButtonVoicePrivacy; 36 37 @Override onCreate(Bundle icicle)38 protected void onCreate(Bundle icicle) { 39 super.onCreate(icicle); 40 41 addPreferencesFromResource(R.xml.cdma_call_privacy); 42 43 SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent()); 44 subInfoHelper.setActionBarTitle( 45 getActionBar(), getResources(), R.string.labelCdmaMore_with_label); 46 47 mButtonVoicePrivacy = (CdmaVoicePrivacySwitchPreference) findPreference(BUTTON_VP_KEY); 48 mButtonVoicePrivacy.setPhone(subInfoHelper.getPhone()); 49 PersistableBundle carrierConfig; 50 if (subInfoHelper.hasSubId()) { 51 carrierConfig = PhoneGlobals.getInstance().getCarrierConfigForSubId( 52 subInfoHelper.getSubId()); 53 } else { 54 carrierConfig = PhoneGlobals.getInstance().getCarrierConfig(); 55 } 56 if (subInfoHelper.getPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_CDMA 57 || carrierConfig.getBoolean(CarrierConfigManager.KEY_VOICE_PRIVACY_DISABLE_UI_BOOL)) { 58 // disable the entire screen 59 mButtonVoicePrivacy.setEnabled(false); 60 } 61 62 Preference callForwardingPref = getPreferenceScreen().findPreference(CALL_FORWARDING_KEY); 63 callForwardingPref.setIntent(subInfoHelper.getIntent(CdmaCallForwardOptions.class)); 64 65 CdmaCallWaitingPreference callWaitingPref = (CdmaCallWaitingPreference)getPreferenceScreen() 66 .findPreference(CALL_WAITING_KEY); 67 callWaitingPref.init(this, subInfoHelper.getPhone()); 68 } 69 70 @Override onOptionsItemSelected(MenuItem item)71 public boolean onOptionsItemSelected(MenuItem item) { 72 final int itemId = item.getItemId(); 73 if (itemId == android.R.id.home) { 74 onBackPressed(); 75 return true; 76 } 77 return super.onOptionsItemSelected(item); 78 } 79 80 @Override onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)81 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { 82 if (preference.getKey().equals(BUTTON_VP_KEY)) { 83 return true; 84 } 85 return false; 86 } 87 } 88