Home | History | Annotate | Download | only in phone
      1 /*
      2  * Copyright (C) 2006 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.CheckBoxPreference;
     22 import android.preference.Preference;
     23 import android.preference.PreferenceActivity;
     24 import android.preference.PreferenceScreen;
     25 import android.telephony.CarrierConfigManager;
     26 import android.view.MenuItem;
     27 
     28 import com.android.internal.telephony.Phone;
     29 import com.android.internal.telephony.PhoneConstants;
     30 
     31 public class GsmUmtsCallOptions extends PreferenceActivity {
     32     private static final String LOG_TAG = "GsmUmtsCallOptions";
     33     private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
     34 
     35     private static final String CALL_FORWARDING_KEY = "call_forwarding_key";
     36     private static final String CALL_BARRING_KEY = "call_barring_key";
     37     private static final String ADDITIONAL_GSM_SETTINGS_KEY = "additional_gsm_call_settings_key";
     38 
     39     @Override
     40     protected void onCreate(Bundle icicle) {
     41         super.onCreate(icicle);
     42 
     43         addPreferencesFromResource(R.xml.gsm_umts_call_options);
     44 
     45         SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent());
     46         subInfoHelper.setActionBarTitle(
     47                 getActionBar(), getResources(), R.string.labelGsmMore_with_label);
     48         init(getPreferenceScreen(), subInfoHelper);
     49 
     50         if (subInfoHelper.getPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
     51             //disable the entire screen
     52             getPreferenceScreen().setEnabled(false);
     53         }
     54     }
     55 
     56     @Override
     57     public boolean onOptionsItemSelected(MenuItem item) {
     58         final int itemId = item.getItemId();
     59         if (itemId == android.R.id.home) {
     60             onBackPressed();
     61             return true;
     62         }
     63         return super.onOptionsItemSelected(item);
     64     }
     65 
     66     public static void init(PreferenceScreen prefScreen, SubscriptionInfoHelper subInfoHelper) {
     67         Preference callForwardingPref = prefScreen.findPreference(CALL_FORWARDING_KEY);
     68         callForwardingPref.setIntent(subInfoHelper.getIntent(GsmUmtsCallForwardOptions.class));
     69 
     70         Preference additionalGsmSettingsPref =
     71                 prefScreen.findPreference(ADDITIONAL_GSM_SETTINGS_KEY);
     72         additionalGsmSettingsPref.setIntent(
     73                 subInfoHelper.getIntent(GsmUmtsAdditionalCallOptions.class));
     74 
     75         Preference callBarringPref = prefScreen.findPreference(CALL_BARRING_KEY);
     76         PersistableBundle b = null;
     77         if (subInfoHelper.hasSubId()) {
     78             b = PhoneGlobals.getInstance().getCarrierConfigForSubId(subInfoHelper.getSubId());
     79         } else {
     80             b = PhoneGlobals.getInstance().getCarrierConfig();
     81         }
     82         if (b != null && b.getBoolean(CarrierConfigManager.KEY_CALL_BARRING_VISIBILITY_BOOL)) {
     83             callBarringPref.setIntent(subInfoHelper.getIntent(GsmUmtsCallBarringOptions.class));
     84         } else {
     85             prefScreen.removePreference(callBarringPref);
     86         }
     87     }
     88 }
     89