Ejemplo n.º 1
0
  private void initLayout() {
    FragmentManager manager = getFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    TextView title = (TextView) findViewById(R.id.title);
    int stepId = getIntent().getIntExtra(EXTRA_OOBE_SETTINGS, -1);
    switch (stepId) {
      case ID_DATE_TIME_SETTINGS:
        title.setText(R.string.date_and_time);
        DateTimeSettings dateTimeSettings = new DateTimeSettings();
        transaction.replace(R.id.fragment_container, dateTimeSettings);
        break;
      case ID_SIM_INFO_SETTINGS:
        title.setText(
            mExt.customizeSimDisplayString(getString(R.string.oobe_sim_info_title), SLOT_ALL));
        SimManagement simInfo = new SimManagement();
        transaction.replace(R.id.fragment_container, simInfo);
        break;
      case ID_DEFAULT_SIM_SETTINGS:
        title.setText(
            mExt.customizeSimDisplayString(getString(R.string.oobe_default_sim_title), SLOT_ALL));
        SimManagement defaultSim = new SimManagement();
        transaction.replace(R.id.fragment_container, defaultSim);
        break;
      case ID_WIFI_SETTINGS:
        title.setText(R.string.wifi_setup_wizard_title);
        WifiSettings wifiSettings = new WifiSettings();
        transaction.replace(R.id.fragment_container, wifiSettings);
        break;
      case ID_ZONE_PICKER:
        title.setText(R.string.date_time_set_timezone);
        ZonePicker zonePicker = new ZonePicker();
        transaction.replace(R.id.fragment_container, zonePicker);
        mNeedAnim = true;
        break;
      case ID_SIM_INFO_EDITOR:
        title.setText(
            mExt.customizeSimDisplayString(getString(R.string.gemini_sim_info_title), SLOT_ALL));
        SimInfoEditor simInfoEditor = new SimInfoEditor();
        transaction.replace(R.id.fragment_container, simInfoEditor);
        mNeedAnim = true;
        break;
      default:
        break;
    }
    transaction.commit();

    Button backBtn = (Button) findViewById(R.id.panel_button_back);
    backBtn.setOnClickListener(mBackListener);
    Button nextBtn = (Button) findViewById(R.id.panel_button_next);
    nextBtn.setOnClickListener(mNextListener);

    int totalStep = getIntent().getIntExtra(OOBE_BASIC_STEP_TOTAL, 1);
    int stepIndex = getIntent().getIntExtra(OOBE_BASIC_STEP_INDEX, 0);
    LinearLayout progressBar = (LinearLayout) findViewById(R.id.progressbar_layout);
    for (int i = 0; i < totalStep; i++) {
      ImageView child = (ImageView) progressBar.getChildAt(i);
      if (i == stepIndex - 1) {
        child.setImageResource(R.drawable.progress_radio_on);
      }
      child.setVisibility(View.VISIBLE);
    }
  }
Ejemplo n.º 2
0
  private void fillList(int simId) {
    String where = getFillListQuery();
    Xlog.e(TAG, "fillList where: " + where);

    if (mUri == null) {
      Xlog.e(TAG, "fillList, mUri null !");
      finish();
      return;
    }
    Cursor cursor =
        getContentResolver()
            .query(
                mUri, new String[] {"_id", "name", "apn", "type", "sourcetype"}, where, null, null);

    PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
    apnList.removeAll();

    ArrayList<Preference> mmsApnList = new ArrayList<Preference>();

    boolean keySetChecked = false;

    mSelectedKey = getSelectedApnKey();
    Xlog.d(TAG, "fillList : mSelectedKey = " + mSelectedKey);

    cursor.moveToFirst();

    while (!cursor.isAfterLast()) {
      String type = cursor.getString(TYPES_INDEX);

      if (mIsTetherApn && !TETHER_TYPE.equals(type)) {
        cursor.moveToNext();
        continue;
      }

      String name = cursor.getString(NAME_INDEX);
      String apn = cursor.getString(APN_INDEX);
      String key = cursor.getString(ID_INDEX);

      int sourcetype = cursor.getInt(SOURCE_TYPE_INDEX);

      if ("cmmail".equals(apn) && sourcetype == 0) {
        cursor.moveToNext();
        continue;
      }
      if (RCSE_TYPE.equals(type) && mRcseExt != null) {
        if (!mRcseExt.isRcseOnlyApnEnabled()) {
          cursor.moveToNext();
          Xlog.d(TAG, "Vodafone not matched");
          continue;
        } else {
          Xlog.d(TAG, "Vodafone matched");
        }
      }

      ApnPreference pref = new ApnPreference(this);

      pref.setSimId(simId); // set pre sim id info to the ApnEditor
      pref.setKey(key);
      pref.setTitle(name);
      pref.setSummary(apn);
      pref.setPersistent(false);
      pref.setSourceType(sourcetype);
      pref.setOnPreferenceChangeListener(this);

      boolean isEditable = mExt.isAllowEditPresetApn(type, apn, mNumeric);
      pref.setApnEditable((sourcetype != 0) || isEditable);

      // All tether apn will be selectable for otthers , mms will not be selectable.
      boolean selectable = true;
      if (TETHER_TYPE.equals(type)) {
        selectable = mIsTetherApn;
      } else {
        selectable = !"mms".equals(type);
      }
      pref.setSelectable(selectable);

      if (selectable) {
        if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
          pref.setChecked();
          keySetChecked = true;
          Xlog.d(TAG, "apn key: " + key + " set.");
        }
        apnList.addPreference(pref);
        Xlog.i(TAG, "key:  " + key + " added!");
      } else {
        mmsApnList.add(pref);
      }
      cursor.moveToNext();
    }
    cursor.close();

    mSelectableApnCount = apnList.getPreferenceCount();
    // if no key selected, choose the 1st one.
    if (!keySetChecked && mSelectableApnCount > 0) {
      int[] sourceTypeArray = new int[mSelectableApnCount];
      for (int i = 0; i < mSelectableApnCount; i++) {
        sourceTypeArray[i] = ((ApnPreference) apnList.getPreference(i)).getSourceType();
      }
      ApnPreference apnPref =
          (ApnPreference) mExt.getApnPref(apnList, mSelectableApnCount, sourceTypeArray);
      if (apnPref != null) {
        setSelectedApnKey(apnPref.getKey());
        apnPref.setChecked();
        Xlog.i(TAG, "Key does not match.Set key: " + apnPref.getKey() + ".");
      }
    }

    if (!mIsTetherApn) {
      for (Preference preference : mmsApnList) {
        apnList.addPreference(preference);
      }
    }
    getPreferenceScreen().setEnabled(getScreenEnableState());
  }