Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 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; |
Aida Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 20 | import android.os.PersistableBundle; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 21 | import android.preference.CheckBoxPreference; |
| 22 | import android.preference.Preference; |
| 23 | import android.preference.PreferenceActivity; |
| 24 | import android.preference.PreferenceScreen; |
Aida Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 25 | import android.telephony.CarrierConfigManager; |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 26 | import android.view.MenuItem; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 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 | |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 35 | private static final String CALL_FORWARDING_KEY = "call_forwarding_key"; |
Aida Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 36 | private static final String CALL_BARRING_KEY = "call_barring_key"; |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 37 | private static final String ADDITIONAL_GSM_SETTINGS_KEY = "additional_gsm_call_settings_key"; |
| 38 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 39 | @Override |
| 40 | protected void onCreate(Bundle icicle) { |
| 41 | super.onCreate(icicle); |
| 42 | |
| 43 | addPreferencesFromResource(R.xml.gsm_umts_call_options); |
| 44 | |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 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) { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 51 | //disable the entire screen |
| 52 | getPreferenceScreen().setEnabled(false); |
| 53 | } |
| 54 | } |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 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)); |
Aida Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 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 | } |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 87 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 88 | } |