| package com.android.phone; |
| |
| import android.app.ActionBar; |
| import android.content.Intent; |
| import android.os.Bundle; |
| import android.preference.Preference; |
| import android.preference.PreferenceScreen; |
| import android.util.Log; |
| import android.view.MenuItem; |
| |
| import java.util.ArrayList; |
| |
| public class GsmUmtsAdditionalCallOptions extends |
| TimeConsumingPreferenceActivity { |
| private static final String LOG_TAG = "GsmUmtsAdditionalCallOptions"; |
| private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2); |
| |
| private static final String BUTTON_CLIR_KEY = "button_clir_key"; |
| private static final String BUTTON_CW_KEY = "button_cw_key"; |
| |
| private CLIRListPreference mCLIRButton; |
| private CallWaitingCheckBoxPreference mCWButton; |
| |
| private final ArrayList<Preference> mPreferences = new ArrayList<Preference>(); |
| private int mInitIndex= 0; |
| |
| @Override |
| protected void onCreate(Bundle icicle) { |
| super.onCreate(icicle); |
| |
| addPreferencesFromResource(R.xml.gsm_umts_additional_options); |
| |
| PreferenceScreen prefSet = getPreferenceScreen(); |
| mCLIRButton = (CLIRListPreference) prefSet.findPreference(BUTTON_CLIR_KEY); |
| mCWButton = (CallWaitingCheckBoxPreference) prefSet.findPreference(BUTTON_CW_KEY); |
| |
| mPreferences.add(mCLIRButton); |
| mPreferences.add(mCWButton); |
| |
| if (icicle == null) { |
| if (DBG) Log.d(LOG_TAG, "start to init "); |
| mCLIRButton.init(this, false); |
| } else { |
| if (DBG) Log.d(LOG_TAG, "restore stored states"); |
| mInitIndex = mPreferences.size(); |
| mCLIRButton.init(this, true); |
| mCWButton.init(this, true); |
| int[] clirArray = icicle.getIntArray(mCLIRButton.getKey()); |
| if (clirArray != null) { |
| if (DBG) Log.d(LOG_TAG, "onCreate: clirArray[0]=" |
| + clirArray[0] + ", clirArray[1]=" + clirArray[1]); |
| mCLIRButton.handleGetCLIRResult(clirArray); |
| } else { |
| mCLIRButton.init(this, false); |
| } |
| } |
| |
| ActionBar actionBar = getActionBar(); |
| if (actionBar != null) { |
| // android.R.id.home will be triggered in onOptionsItemSelected() |
| actionBar.setDisplayHomeAsUpEnabled(true); |
| } |
| } |
| |
| @Override |
| protected void onSaveInstanceState(Bundle outState) { |
| super.onSaveInstanceState(outState); |
| |
| if (mCLIRButton.clirArray != null) { |
| outState.putIntArray(mCLIRButton.getKey(), mCLIRButton.clirArray); |
| } |
| } |
| |
| @Override |
| public void onFinished(Preference preference, boolean reading) { |
| if (mInitIndex < mPreferences.size()-1 && !isFinishing()) { |
| mInitIndex++; |
| Preference pref = mPreferences.get(mInitIndex); |
| if (pref instanceof CallWaitingCheckBoxPreference) { |
| ((CallWaitingCheckBoxPreference) pref).init(this, false); |
| } |
| } |
| super.onFinished(preference, reading); |
| } |
| |
| @Override |
| public boolean onOptionsItemSelected(MenuItem item) { |
| final int itemId = item.getItemId(); |
| if (itemId == android.R.id.home) { // See ActionBar#setDisplayHomeAsUpEnabled() |
| CallFeaturesSetting.goUpToTopLevelSetting(this); |
| return true; |
| } |
| return super.onOptionsItemSelected(item); |
| } |
| } |