private void loadSettings() {
    mPreferences = Preferences.getPreferences(getActivity());
    mAutoAdvance = (ListPreference) findPreference(PREFERENCE_KEY_AUTO_ADVANCE);
    mAutoAdvance.setValueIndex(mPreferences.getAutoAdvanceDirection());
    mAutoAdvance.setOnPreferenceChangeListener(this);

    mTextZoom = (ListPreference) findPreference(PREFERENCE_KEY_TEXT_ZOOM);
    if (mTextZoom != null) {
      mTextZoom.setValueIndex(mPreferences.getTextZoom());
      mTextZoom.setOnPreferenceChangeListener(this);
    }

    final CheckBoxPreference convListIcon =
        (CheckBoxPreference) findPreference(PREFERENCE_KEY_CONV_LIST_ICON);
    if (convListIcon != null) {
      final boolean showSenderImage = mMailPrefs.getShowSenderImages();
      convListIcon.setChecked(showSenderImage);
      convListIcon.setOnPreferenceChangeListener(this);
    }

    mConfirmDelete = (CheckBoxPreference) findPreference(PREFERENCE_KEY_CONFIRM_DELETE);
    mConfirmSend = (CheckBoxPreference) findPreference(PREFERENCE_KEY_CONFIRM_SEND);
    mSwipeDelete =
        (CheckBoxPreference) findPreference(MailPrefs.PreferenceKeys.CONVERSATION_LIST_SWIPE);
    mSwipeDelete.setChecked(mMailPrefs.getIsConversationListSwipeEnabled());

    final CheckBoxPreference replyAllPreference =
        (CheckBoxPreference) findPreference(MailPrefs.PreferenceKeys.DEFAULT_REPLY_ALL);
    replyAllPreference.setChecked(mMailPrefs.getDefaultReplyAll());
    replyAllPreference.setOnPreferenceChangeListener(this);

    reloadDynamicSummaries();
  }
  /** Loads the default values if we have them if not then blank it all out */
  private void loadDefaultValues() {
    try {
      mNotification.setChecked(pNotify.notify_active);
      mLed.setChecked(pNotify.led_active);
      mRinger.setChecked(pNotify.ringer_active);
      mVibrate.setChecked(pNotify.vibrate_active);
      mRingtone.setRingtone(Uri.parse(pNotify.ringtone));
      mRingVolume.setVolume(pNotify.ringer_vol);

      if (mNotifyIcon.findIndexOfValue(pNotify.notify_icon) > -1)
        mNotifyIcon.setValueIndex(mNotifyIcon.findIndexOfValue(pNotify.notify_icon));

      if (mLedPattern.findIndexOfValue(pNotify.led_pat) > -1)
        mLedPattern.setValueIndex(mLedPattern.findIndexOfValue(pNotify.led_pat));

      if (mLedColor.findIndexOfValue(pNotify.led_color) > -1)
        mLedColor.setValueIndex(mLedColor.findIndexOfValue(pNotify.led_color));

      if (mVibratePattern.findIndexOfValue(pNotify.vibrate_pat) > -1)
        mVibratePattern.setValueIndex(mVibratePattern.findIndexOfValue(pNotify.vibrate_pat));

    } catch (NullPointerException e) {
      if (Log.LOGV) Log.e(TAG + "Null pointer exception " + e.getLocalizedMessage().toString());
    } catch (RuntimeException e) {

    }
  }
  private void updateGlowTimesSummary() {
    int resId;
    String combinedTime =
        Settings.System.getString(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_DURATION[1])
            + "|"
            + Settings.System.getString(
                mContentRes, Settings.System.NAVIGATION_BAR_GLOW_DURATION[0]);

    String[] glowArray = getResources().getStringArray(R.array.glow_times_values);

    if (glowArray[0].equals(combinedTime)) {
      resId = R.string.glow_times_off;
      mGlowTimes.setValueIndex(0);
    } else if (glowArray[1].equals(combinedTime)) {
      resId = R.string.glow_times_superquick;
      mGlowTimes.setValueIndex(1);
    } else if (glowArray[2].equals(combinedTime)) {
      resId = R.string.glow_times_quick;
      mGlowTimes.setValueIndex(2);
    } else {
      resId = R.string.glow_times_normal;
      mGlowTimes.setValueIndex(3);
    }
    mGlowTimes.setSummary(getResources().getString(resId));
  }
 @Override
 public void setValueIndex(final int index) {
   super.setValueIndex(index);
   if (mEntryIcons != null && updateIcon) {
     setIcon(mEntryIcons[index]);
   }
 }
Esempio n. 5
0
  @Override
  public void onResume() {
    super.onResume();

    // Manually initialize the preference views that require massaging. Prefs that require
    // massaging include:
    //  1. a prefs UI control that does not map 1:1 to storage
    //  2. a pref that must obtain its initial value from migrated storage, and for which we
    //     don't want to always persist a migrated value
    final int autoAdvanceModeIndex =
        prefValueToWidgetIndex(
            AUTO_ADVANCE_VALUES, mMailPrefs.getAutoAdvanceMode(), AutoAdvance.DEFAULT);
    mAutoAdvance.setValueIndex(autoAdvanceModeIndex);

    final String removalAction = mMailPrefs.getRemovalAction(supportsArchive());
    updateListSwipeTitle(removalAction);

    listenForPreferenceChange(
        PreferenceKeys.REMOVAL_ACTION,
        PreferenceKeys.CONVERSATION_LIST_SWIPE,
        PreferenceKeys.SHOW_SENDER_IMAGES,
        PreferenceKeys.DEFAULT_REPLY_ALL,
        PreferenceKeys.CONVERSATION_OVERVIEW_MODE,
        AUTO_ADVANCE_WIDGET,
        PreferenceKeys.CONFIRM_DELETE,
        PreferenceKeys.CONFIRM_ARCHIVE,
        PreferenceKeys.CONFIRM_SEND);
  }
 private void restoreSettingsDefault() {
   if (mPrefs != null) {
     mBandPreference.setValueIndex(0);
     if (mRxMode) {
       mAudioPreference.setValueIndex(0);
       if (FMRadio.RECORDING_ENABLE) {
         mRecordDurPreference.setValueIndex(0);
       }
       mAfPref.setChecked(false);
       FmSharedPreferences.SetDefaults();
     } else {
       FmSharedPreferences.setCountry(FmSharedPreferences.REGIONAL_BAND_NORTH_AMERICA);
     }
     mPrefs.Save();
   }
 }
 private void updateAppProcessLimitOptions() {
   try {
     int limit = ActivityManagerNative.getDefault().getProcessLimit();
     CharSequence[] values = mAppProcessLimit.getEntryValues();
     for (int i = 0; i < values.length; i++) {
       int val = Integer.parseInt(values[i].toString());
       if (val >= limit) {
         mAppProcessLimit.setValueIndex(i);
         mAppProcessLimit.setSummary(mAppProcessLimit.getEntries()[i]);
         return;
       }
     }
     mAppProcessLimit.setValueIndex(0);
     mAppProcessLimit.setSummary(mAppProcessLimit.getEntries()[0]);
   } catch (RemoteException e) {
   }
 }
  private void updateOpenGLTracesOptions() {
    String value = SystemProperties.get(OPENGL_TRACES_PROPERTY);
    if (value == null) {
      value = "";
    }

    CharSequence[] values = mOpenGLTraces.getEntryValues();
    for (int i = 0; i < values.length; i++) {
      if (value.contentEquals(values[i])) {
        mOpenGLTraces.setValueIndex(i);
        mOpenGLTraces.setSummary(mOpenGLTraces.getEntries()[i]);
        return;
      }
    }
    mOpenGLTraces.setValueIndex(0);
    mOpenGLTraces.setSummary(mOpenGLTraces.getEntries()[0]);
  }
 private void updateAnimationScaleValue(int which, ListPreference pref) {
   try {
     float scale = mWindowManager.getAnimationScale(which);
     CharSequence[] values = pref.getEntryValues();
     for (int i = 0; i < values.length; i++) {
       float val = Float.parseFloat(values[i].toString());
       if (scale <= val) {
         pref.setValueIndex(i);
         pref.setSummary(pref.getEntries()[i]);
         return;
       }
     }
     pref.setValueIndex(values.length - 1);
     pref.setSummary(pref.getEntries()[0]);
   } catch (RemoteException e) {
   }
 }
Esempio n. 10
0
 /** Create the "Show Note Letters" preference */
 private void createShowLetterPrefs(PreferenceScreen root) {
   showNoteLetters = new ListPreference(this);
   showNoteLetters.setOnPreferenceChangeListener(this);
   showNoteLetters.setTitle(R.string.show_note_letters);
   showNoteLetters.setEntries(R.array.show_note_letter_entries);
   showNoteLetters.setEntryValues(R.array.show_note_letter_values);
   showNoteLetters.setValueIndex(options.showNoteLetters);
   showNoteLetters.setSummary(showNoteLetters.getEntry());
   root.addPreference(showNoteLetters);
 }
  private void updateOverlayDisplayDevicesOptions() {
    String value =
        Settings.Global.getString(
            getActivity().getContentResolver(), Settings.Global.OVERLAY_DISPLAY_DEVICES);
    if (value == null) {
      value = "";
    }

    CharSequence[] values = mOverlayDisplayDevices.getEntryValues();
    for (int i = 0; i < values.length; i++) {
      if (value.contentEquals(values[i])) {
        mOverlayDisplayDevices.setValueIndex(i);
        mOverlayDisplayDevices.setSummary(mOverlayDisplayDevices.getEntries()[i]);
        return;
      }
    }
    mOverlayDisplayDevices.setValueIndex(0);
    mOverlayDisplayDevices.setSummary(mOverlayDisplayDevices.getEntries()[0]);
  }
Esempio n. 12
0
 /** Create the "Key Signature" preference */
 private void createKeySignaturePrefs(PreferenceScreen root) {
   key = new ListPreference(this);
   key.setOnPreferenceChangeListener(this);
   key.setTitle(R.string.key_signature);
   key.setEntries(R.array.key_signature_entries);
   key.setEntryValues(R.array.key_signature_values);
   key.setValueIndex(options.key + 1);
   key.setSummary(key.getEntry());
   root.addPreference(key);
 }
Esempio n. 13
0
 /** Create the "Transpose Notes" preference. The values range from 12, 11, 10, .. -10, -11, -12 */
 private void createTransposePrefs(PreferenceScreen root) {
   int transposeIndex = 12 - options.transpose;
   transpose = new ListPreference(this);
   transpose.setOnPreferenceChangeListener(this);
   transpose.setTitle(R.string.transpose);
   transpose.setEntries(R.array.transpose_entries);
   transpose.setEntryValues(R.array.transpose_values);
   transpose.setValueIndex(transposeIndex);
   transpose.setSummary(transpose.getEntry());
   root.addPreference(transpose);
 }
Esempio n. 14
0
 /**
  * Create the "Combine Notes Within Interval" preference. Notes within N milliseconds are combined
  * into a single chord, even though their start times may be slightly different.
  */
 private void createCombineIntervalPrefs(PreferenceScreen root) {
   int selected = options.combineInterval / 20 - 1;
   combineInterval = new ListPreference(this);
   combineInterval.setOnPreferenceChangeListener(this);
   combineInterval.setTitle(R.string.combine_interval);
   combineInterval.setEntries(R.array.combine_interval_entries);
   combineInterval.setEntryValues(R.array.combine_interval_values);
   combineInterval.setValueIndex(selected);
   combineInterval.setSummary(combineInterval.getEntry());
   root.addPreference(combineInterval);
 }
Esempio n. 15
0
 /*
  * M: update ipv4&ipv6 setting preference
  */
 private void updateIpv6Preference() {
   if (mTetherIpv6 != null) {
     mTetherIpv6.setEnabled(
         !mUsbTether.isChecked() && !mBluetoothTether.isChecked() && !mWifiTether.isChecked());
     ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
     if (cm != null) {
       int ipv6Value = cm.getTetheringIpv6Enable() ? 1 : 0;
       mTetherIpv6.setValueIndex(ipv6Value);
       mTetherIpv6.setSummary(
           getResources().getStringArray(R.array.tethered_ipv6_entries)[ipv6Value]);
     }
   }
 }
Esempio n. 16
0
  /**
   * Create the "Play Measures in a Loop" preference.
   *
   * <p>Note that we display the measure numbers starting at 1, but the actual
   * playMeasuresInLoopStart field starts at 0.
   */
  private void createPlayMeasuresInLoopPrefs(PreferenceScreen root) {
    String[] values = new String[options.lastMeasure + 1];
    for (int measure = 0; measure < values.length; measure++) {
      values[measure] = "" + (measure + 1);
    }

    PreferenceCategory playLoopTitle = new PreferenceCategory(this);
    playLoopTitle.setTitle(R.string.play_measures_in_loop_title);
    root.addPreference(playLoopTitle);

    showMeasures = new CheckBoxPreference(this);
    showMeasures.setTitle(R.string.show_measures);
    showMeasures.setChecked(options.showMeasures);
    root.addPreference(showMeasures);

    playMeasuresInLoop = new CheckBoxPreference(this);
    playMeasuresInLoop.setTitle(R.string.play_measures_in_loop);
    playMeasuresInLoop.setChecked(options.playMeasuresInLoop);
    root.addPreference(playMeasuresInLoop);

    loopStart = new ListPreference(this);
    loopStart.setOnPreferenceChangeListener(this);
    loopStart.setTitle(R.string.play_measures_in_loop_start);
    loopStart.setEntries(values);
    loopStart.setEntryValues(values);
    loopStart.setValueIndex(options.playMeasuresInLoopStart);
    loopStart.setSummary(loopStart.getEntry());
    root.addPreference(loopStart);

    loopEnd = new ListPreference(this);
    loopEnd.setOnPreferenceChangeListener(this);
    loopEnd.setTitle(R.string.play_measures_in_loop_end);
    loopEnd.setEntries(values);
    loopEnd.setEntryValues(values);
    loopEnd.setValueIndex(options.playMeasuresInLoopEnd);
    loopEnd.setSummary(loopEnd.getEntry());
    root.addPreference(loopEnd);
  }
Esempio n. 17
0
  /** Create the "Time Signature" preference */
  private void createTimeSignaturePrefs(PreferenceScreen root) {
    String[] values = {"Default", "3/4", "4/4"};
    int selected = 0;
    if (options.time != null && options.time.getNumerator() == 3) selected = 1;
    else if (options.time != null && options.time.getNumerator() == 4) selected = 2;

    time = new ListPreference(this);
    time.setOnPreferenceChangeListener(this);
    time.setTitle(R.string.time_signature);
    time.setEntries(values);
    time.setEntryValues(values);
    time.setValueIndex(selected);
    time.setSummary(time.getEntry());
    root.addPreference(time);
  }
  public void readFontSizePreference(ListPreference pref) {
    try {
      mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
    } catch (RemoteException e) {
      Log.w(TAG, "Unable to retrieve font size");
    }

    // mark the appropriate item in the preferences list
    int index = floatToIndex(mCurConfig.fontScale);
    pref.setValueIndex(index);

    // report the current size in the summary text
    final Resources res = getResources();
    String[] fontSizeNames = res.getStringArray(R.array.entries_font_size);
    pref.setSummary(String.format(res.getString(R.string.summary_font_size), fontSizeNames[index]));
  }
Esempio n. 19
0
  private void setAllCbConfigButtons(int[] configArray) {
    // These buttons are in a well defined sequence. If you want to change it,
    // be sure to map the buttons to their corresponding slot in the configArray !
    mButtonEmergencyBroadcast.setChecked(configArray[1] != 0);
    // subtract 1, because the values are handled in an array which starts with 0 and not with 1
    mListLanguage.setValueIndex(CellBroadcastSmsConfig.getConfigDataLanguage() - 1);
    mButtonAdministrative.setChecked(configArray[2] != 0);
    mButtonMaintenance.setChecked(configArray[3] != 0);
    mButtonLocalWeather.setChecked(configArray[20] != 0);
    mButtonAtr.setChecked(configArray[21] != 0);
    mButtonLafs.setChecked(configArray[22] != 0);
    mButtonRestaurants.setChecked(configArray[23] != 0);
    mButtonLodgings.setChecked(configArray[24] != 0);
    mButtonRetailDirectory.setChecked(configArray[25] != 0);
    mButtonAdvertisements.setChecked(configArray[26] != 0);
    mButtonStockQuotes.setChecked(configArray[27] != 0);
    mButtonEo.setChecked(configArray[28] != 0);
    mButtonMhh.setChecked(configArray[29] != 0);
    mButtonTechnologyNews.setChecked(configArray[30] != 0);
    mButtonMultiCategory.setChecked(configArray[31] != 0);

    mButtonLocal1.setChecked(configArray[4] != 0);
    mButtonRegional1.setChecked(configArray[5] != 0);
    mButtonNational1.setChecked(configArray[6] != 0);
    mButtonInternational1.setChecked(configArray[7] != 0);

    mButtonLocal2.setChecked(configArray[8] != 0);
    mButtonRegional2.setChecked(configArray[9] != 0);
    mButtonNational2.setChecked(configArray[10] != 0);
    mButtonInternational2.setChecked(configArray[11] != 0);

    mButtonLocal3.setChecked(configArray[12] != 0);
    mButtonRegional3.setChecked(configArray[13] != 0);
    mButtonNational3.setChecked(configArray[14] != 0);
    mButtonInternational3.setChecked(configArray[15] != 0);

    mButtonLocal4.setChecked(configArray[16] != 0);
    mButtonRegional4.setChecked(configArray[17] != 0);
    mButtonNational4.setChecked(configArray[18] != 0);
    mButtonInternational4.setChecked(configArray[19] != 0);
  }
Esempio n. 20
0
    private void refresh() {
      final ListPreference autoSilencePref = (ListPreference) findPreference(KEY_AUTO_SILENCE);
      String delay = autoSilencePref.getValue();
      updateAutoSnoozeSummary(autoSilencePref, delay);
      autoSilencePref.setOnPreferenceChangeListener(this);

      final ListPreference clockStylePref = (ListPreference) findPreference(KEY_CLOCK_STYLE);
      clockStylePref.setSummary(clockStylePref.getEntry());
      clockStylePref.setOnPreferenceChangeListener(this);

      final Preference autoHomeClockPref = findPreference(KEY_AUTO_HOME_CLOCK);
      final boolean autoHomeClockEnabled = ((CheckBoxPreference) autoHomeClockPref).isChecked();
      autoHomeClockPref.setOnPreferenceChangeListener(this);

      final ListPreference homeTimezonePref = (ListPreference) findPreference(KEY_HOME_TZ);
      homeTimezonePref.setEnabled(autoHomeClockEnabled);
      homeTimezonePref.setSummary(homeTimezonePref.getEntry());
      homeTimezonePref.setOnPreferenceChangeListener(this);

      final ListPreference volumeButtonsPref = (ListPreference) findPreference(KEY_VOLUME_BUTTONS);
      volumeButtonsPref.setSummary(volumeButtonsPref.getEntry());
      volumeButtonsPref.setOnPreferenceChangeListener(this);

      final Preference volumePref = findPreference(KEY_ALARM_VOLUME);
      volumePref.setOnPreferenceClickListener(this);

      final SnoozeLengthDialog snoozePref = (SnoozeLengthDialog) findPreference(KEY_ALARM_SNOOZE);
      snoozePref.setSummary();

      final ListPreference weekStartPref = (ListPreference) findPreference(KEY_WEEK_START);
      // Set the default value programmatically
      final String value = weekStartPref.getValue();
      final int idx =
          weekStartPref.findIndexOfValue(
              value == null ? String.valueOf(Utils.DEFAULT_WEEK_START) : value);
      weekStartPref.setValueIndex(idx);
      weekStartPref.setSummary(weekStartPref.getEntries()[idx]);
      weekStartPref.setOnPreferenceChangeListener(this);
    }
Esempio n. 21
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    listPreference = (ListPreference) findPreference(PREF_KEY_NOTIFICATION_FREQUENCY_TOGGLE);
    prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
    boolean isDaily = prefs.getBoolean(AlarmsUtility.PREF_ALARM_DAILY, false);

    // Set the default or previously selected value
    listPreference.setSummary(
        getString(R.string.text_configured)
            + (isDaily ? getString(R.string.text_daily) : getString(R.string.text_weekly)));
    listPreference.setValueIndex(isDaily ? 1 : 0);

    listPreference.setEnabled(
        ((CheckBoxPreference) findPreference(PREF_KEY_NOTIFICATION_TOGGLE)).isChecked());

    getPreferenceManager().setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
    getPreferenceScreen()
        .getSharedPreferences()
        .registerOnSharedPreferenceChangeListener(mSharePrefListener);
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   // Load the preferences from an XML resource
   addPreferencesFromResource(R.xml.preferences);
   final ListPreference listPreference =
       (ListPreference) findPreference(getString(R.string.progressBar_pref_key));
   if (listPreference.getValue() == null) {
     // to ensure we don't get a null value
     // set first value by default
     listPreference.setValueIndex(Integer.parseInt(getString(R.string.progressBar_pref_defValue)));
   }
   listPreference.setSummary(
       listPreference.getEntries()[Integer.parseInt(listPreference.getValue())].toString());
   listPreference.setOnPreferenceChangeListener(
       new Preference.OnPreferenceChangeListener() {
         @Override
         public boolean onPreferenceChange(Preference preference, Object newValue) {
           preference.setSummary(
               listPreference.getEntries()[Integer.parseInt(newValue.toString())]);
           return true;
         }
       });
 }
Esempio n. 23
0
  public boolean onPreferenceChange(Preference preference, Object value) {
    String key = preference.getKey();
    Xlog.d(TAG, "onPreferenceChange key=" + key);
    if (TETHERED_IPV6.equals(key)) {
      /// M: save value to provider @{
      ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      int ipv6Value = Integer.parseInt(String.valueOf(value));
      if (cm != null) {
        cm.setTetheringIpv6Enable(ipv6Value == 1);
      }
      mTetherIpv6.setValueIndex(ipv6Value);
      mTetherIpv6.setSummary(
          getResources().getStringArray(R.array.tethered_ipv6_entries)[ipv6Value]);
      /// @}
    } else if (USB_TETHERING_TYPE.equals(key)) {
      int index = Integer.parseInt(((String) value));
      System.putInt(getContentResolver(), System.USB_TETHERING_TYPE, index);
      mUsbTetherType.setSummary(
          getResources().getStringArray(R.array.usb_tether_type_entries)[index]);

      Xlog.d(TAG, "onPreferenceChange USB_TETHERING_TYPE value = " + index);
    }
    return true;
  }
Esempio n. 24
0
  private PreferenceScreen createPreferenceHierarchy() {
    int index = 0;
    if (mPrefs == null) {
      return null;
    }
    // Root
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);

    // Band/Country
    String[] summaryBandItems = getResources().getStringArray(R.array.regional_band_summary);
    mBandPreference = new ListPreference(this);
    mBandPreference.setEntries(R.array.regional_band_entries);
    mBandPreference.setEntryValues(R.array.regional_band_values);
    mBandPreference.setDialogTitle(R.string.sel_band_menu);
    mBandPreference.setKey(REGIONAL_BAND_KEY);
    mBandPreference.setTitle(R.string.regional_band);
    index = FmSharedPreferences.getCountry();
    Log.d(LOGTAG, "createPreferenceHierarchy: Country: " + index);
    // Get the preference and list the value.
    if ((index < 0) || (index >= summaryBandItems.length)) {
      index = 0;
    }
    Log.d(LOGTAG, "createPreferenceHierarchy: CountrySummary: " + summaryBandItems[index]);
    mBandPreference.setSummary(summaryBandItems[index]);
    mBandPreference.setValueIndex(index);
    root.addPreference(mBandPreference);

    if (mRxMode) {
      // Audio Output (Stereo or Mono)
      String[] summaryAudioModeItems = getResources().getStringArray(R.array.ster_mon_entries);
      mAudioPreference = new ListPreference(this);
      mAudioPreference.setEntries(R.array.ster_mon_entries);
      mAudioPreference.setEntryValues(R.array.ster_mon_values);
      mAudioPreference.setDialogTitle(R.string.sel_audio_output);
      mAudioPreference.setKey(AUDIO_OUTPUT_KEY);
      mAudioPreference.setTitle(R.string.aud_output_mode);
      boolean audiomode = FmSharedPreferences.getAudioOutputMode();
      if (audiomode) {
        index = 0;
      } else {
        index = 1;
      }
      Log.d(LOGTAG, "createPreferenceHierarchy: audiomode: " + audiomode);
      mAudioPreference.setSummary(summaryAudioModeItems[index]);
      mAudioPreference.setValueIndex(index);
      root.addPreference(mAudioPreference);

      // AF Auto Enable (Checkbox)
      mAfPref = new CheckBoxPreference(this);
      mAfPref.setKey(AUTO_AF);
      mAfPref.setTitle(R.string.auto_select_af);
      mAfPref.setSummaryOn(R.string.auto_select_af_enabled);
      mAfPref.setSummaryOff(R.string.auto_select_af_disabled);
      boolean bAFAutoSwitch = FmSharedPreferences.getAutoAFSwitch();
      Log.d(LOGTAG, "createPreferenceHierarchy: bAFAutoSwitch: " + bAFAutoSwitch);
      mAfPref.setChecked(bAFAutoSwitch);
      root.addPreference(mAfPref);

      if (FMRadio.RECORDING_ENABLE) {
        String[] summaryRecordItems =
            getResources().getStringArray(R.array.record_durations_entries);
        mRecordDurPreference = new ListPreference(this);
        mRecordDurPreference.setEntries(R.array.record_durations_entries);
        mRecordDurPreference.setEntryValues(R.array.record_duration_values);
        mRecordDurPreference.setDialogTitle(R.string.sel_rec_dur);
        mRecordDurPreference.setKey(RECORD_DURATION_KEY);
        mRecordDurPreference.setTitle(R.string.record_dur);
        index = FmSharedPreferences.getRecordDuration();
        Log.d(LOGTAG, "createPreferenceHierarchy: recordDuration: " + index);
        // Get the preference and list the value.
        if ((index < 0) || (index >= summaryRecordItems.length)) {
          index = 0;
        }
        Log.d(
            LOGTAG,
            "createPreferenceHierarchy: recordDurationSummary: " + summaryRecordItems[index]);
        mRecordDurPreference.setSummary(summaryRecordItems[index]);
        mRecordDurPreference.setValueIndex(index);
        root.addPreference(mRecordDurPreference);
      }
    }

    mBluetoothBehaviour = new ListPreference(this);
    mBluetoothBehaviour.setEntries(R.array.bt_exit_behaviour_entries);
    mBluetoothBehaviour.setEntryValues(R.array.bt_exit_behaviour_values);
    mBluetoothBehaviour.setDialogTitle(R.string.pref_bt_behaviour_on_exit_dialog_title);
    mBluetoothBehaviour.setKey(BT_EXIT_BEHAVIOUR);
    mBluetoothBehaviour.setTitle(R.string.pref_bt_behaviour_on_exit_title);
    mBluetoothBehaviour.setSummary(R.string.pref_bt_behaviour_on_exit_summary);
    root.addPreference(mBluetoothBehaviour);

    mRemoveHeadset = new CheckBoxPreference(this);
    mRemoveHeadset.setKey(HEADSET_DC_BEHAVIOUR);
    mRemoveHeadset.setTitle(R.string.pref_headset_behaviour_title);
    mRemoveHeadset.setSummary(R.string.pref_headset_behaviour_summary);
    mRemoveHeadset.setChecked(FmSharedPreferences.getHeadsetDcBehaviour());
    root.addPreference(mRemoveHeadset);

    mRestoreDefaultPreference = new Preference(this);
    mRestoreDefaultPreference.setTitle(R.string.settings_revert_defaults_title);
    mRestoreDefaultPreference.setKey(RESTORE_FACTORY_DEFAULT);
    mRestoreDefaultPreference.setSummary(R.string.settings_revert_defaults_summary);
    mRestoreDefaultPreference.setOnPreferenceClickListener(this);
    root.addPreference(mRestoreDefaultPreference);

    // Add a new category
    PreferenceCategory prefCat = new PreferenceCategory(this);
    prefCat.setTitle(R.string.about_title);
    root.addPreference(prefCat);

    mAboutPreference = new Preference(this);
    mAboutPreference.setTitle(R.string.about_title);
    mAboutPreference.setKey(ABOUT_KEY);
    mAboutPreference.setSummary(R.string.about_summary);
    mAboutPreference.setOnPreferenceClickListener(this);
    root.addPreference(mAboutPreference);

    return root;
  }
Esempio n. 25
0
  public void fillLayout(final SipProfile account) {
    bindFields();

    accountDisplayName.setText(account.display_name);
    accountAccId.setText(account.acc_id);
    accountRegUri.setText(account.reg_uri);
    accountRealm.setText(account.realm);
    accountUserName.setText(account.username);
    accountData.setText(account.data);

    {
      String scheme = account.scheme;
      if (scheme != null && !scheme.equals("")) {
        accountScheme.setValue(scheme);
      } else {
        accountScheme.setValue(SipProfile.CRED_SCHEME_DIGEST);
      }
    }
    {
      int ctype = account.datatype;
      if (ctype == SipProfile.CRED_DATA_PLAIN_PASSWD) {
        accountDataType.setValueIndex(0);
      } else if (ctype == SipProfile.CRED_DATA_DIGEST) {
        accountDataType.setValueIndex(1);
      }
      // DISABLED SINCE NOT SUPPORTED YET
      /*
      else if (ctype ==SipProfile.CRED_CRED_DATA_EXT_AKA) {
      	accountDataType.setValueIndex(2);
      } */ else {
        accountDataType.setValueIndex(0);
      }
    }
    accountInitAuth.setChecked(account.initial_auth);
    accountAuthAlgo.setText(account.auth_algo);

    accountTransport.setValue(account.transport.toString());
    if (!TextUtils.isEmpty(account.default_uri_scheme)) {
      accountDefaultUriScheme.setValue(account.default_uri_scheme);
    }
    accountPublishEnabled.setChecked((account.publish_enabled == 1));
    accountRegTimeout.setText(Long.toString(account.reg_timeout));
    accountRegDelayRefresh.setText(Long.toString(account.reg_delay_before_refresh));

    accountForceContact.setText(account.force_contact);
    accountAllowContactRewrite.setChecked(account.allow_contact_rewrite);
    accountAllowViaRewrite.setChecked(account.allow_via_rewrite);
    accountContactRewriteMethod.setValue(Integer.toString(account.contact_rewrite_method));
    if (account.proxies != null) {
      accountProxy.setText(TextUtils.join(SipProfile.PROXIES_SEPARATOR, account.proxies));
    } else {
      accountProxy.setText("");
    }
    Log.d(THIS_FILE, "use srtp : " + account.use_srtp);
    accountUseSrtp.setValueIndex(account.use_srtp + 1);
    accountUseZrtp.setValueIndex(account.use_zrtp + 1);

    useRfc5626.setChecked(account.use_rfc5626);
    rfc5626_instanceId.setText(account.rfc5626_instance_id);
    rfc5626_regId.setText(account.rfc5626_reg_id);

    rtpEnableQos.setValue(Integer.toString(account.rtp_enable_qos));
    rtpQosDscp.setText(Integer.toString(account.rtp_qos_dscp));
    rtpPort.setText(Integer.toString(account.rtp_port));
    rtpBoundAddr.setText(account.rtp_bound_addr);
    rtpPublicAddr.setText(account.rtp_public_addr);

    vidInAutoShow.setValue(Integer.toString(account.vid_in_auto_show));
    vidOutAutoTransmit.setValue(Integer.toString(account.vid_out_auto_transmit));

    accountVm.setText(account.vm_nbr);
    mwiEnabled.setChecked(account.mwi_enabled);
    tryCleanRegisters.setChecked(account.try_clean_registers != 0);

    sipStunUse.setValue(Integer.toString(account.sip_stun_use));
    mediaStunUse.setValue(Integer.toString(account.media_stun_use));
    iceCfgUse.setChecked(account.ice_cfg_use == 1);
    iceCfgEnable.setChecked(account.ice_cfg_enable == 1);
    turnCfgUse.setChecked(account.turn_cfg_use == 1);
    turnCfgEnable.setChecked(account.turn_cfg_enable == 1);
    turnCfgServer.setText(account.turn_cfg_server);
    turnCfgUser.setText(account.turn_cfg_user);
    turnCfgPassword.setText(account.turn_cfg_password);

    ipv6MediaEnable.setChecked(account.ipv6_media_use == 1);
  }
Esempio n. 26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Workaround for bug 4611: http://code.google.com/p/android/issues/detail?id=4611
    if (AnkiDroidApp.SDK_VERSION >= 7 && AnkiDroidApp.SDK_VERSION <= 10) {
      Themes.applyTheme(this, Themes.THEME_ANDROID_DARK);
    }
    super.onCreate(savedInstanceState);

    mCol = AnkiDroidApp.getCol();
    mPrefMan = getPreferenceManager();
    mPrefMan.setSharedPreferencesName(AnkiDroidApp.SHARED_PREFS_NAME);

    addPreferencesFromResource(R.xml.preferences);

    swipeCheckboxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("swipe");
    zoomCheckboxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("zoom");
    keepScreenOnCheckBoxPreference =
        (CheckBoxPreference) getPreferenceScreen().findPreference("keepScreenOn");
    showAnswerCheckBoxPreference =
        (CheckBoxPreference) getPreferenceScreen().findPreference("timeoutAnswer");
    animationsCheckboxPreference =
        (CheckBoxPreference) getPreferenceScreen().findPreference("themeAnimations");
    useBackupPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("useBackup");
    asyncModePreference = (CheckBoxPreference) getPreferenceScreen().findPreference("asyncMode");
    eInkDisplayPreference =
        (CheckBoxPreference) getPreferenceScreen().findPreference("eInkDisplay");
    fadeScrollbars = (CheckBoxPreference) getPreferenceScreen().findPreference("fadeScrollbars");
    //        ListPreference listpref = (ListPreference)
    // getPreferenceScreen().findPreference("theme");
    convertFenText = (CheckBoxPreference) getPreferenceScreen().findPreference("convertFenText");
    fixHebrewText = (CheckBoxPreference) getPreferenceScreen().findPreference("fixHebrewText");
    syncAccount = (Preference) getPreferenceScreen().findPreference("syncAccount");
    showEstimates = (CheckBoxPreference) getPreferenceScreen().findPreference("showEstimates");
    showProgress = (CheckBoxPreference) getPreferenceScreen().findPreference("showProgress");
    learnCutoff = (NumberRangePreference) getPreferenceScreen().findPreference("learnCutoff");
    timeLimit = (NumberRangePreference) getPreferenceScreen().findPreference("timeLimit");
    useCurrent = (ListPreference) getPreferenceScreen().findPreference("useCurrent");
    newSpread = (ListPreference) getPreferenceScreen().findPreference("newSpread");
    dayOffset = (SeekBarPreference) getPreferenceScreen().findPreference("dayOffset");
    //        String theme = listpref.getValue();
    //        animationsCheckboxPreference.setEnabled(theme.equals("2") || theme.equals("3"));
    zoomCheckboxPreference.setEnabled(!swipeCheckboxPreference.isChecked());

    initializeLanguageDialog();
    initializeCustomFontsDialog();

    if (mCol != null) {
      // For collection preferences, we need to fetch the correct values from the collection
      mStartDate = GregorianCalendar.getInstance();
      Timestamp timestamp = new Timestamp(mCol.getCrt() * 1000);
      mStartDate.setTimeInMillis(timestamp.getTime());
      dayOffset.setValue(mStartDate.get(Calendar.HOUR_OF_DAY));
      try {
        JSONObject conf = mCol.getConf();
        learnCutoff.setValue(conf.getInt("collapseTime") / 60);
        timeLimit.setValue(conf.getInt("timeLim") / 60);
        showEstimates.setChecked(conf.getBoolean("estTimes"));
        showProgress.setChecked(conf.getBoolean("dueCounts"));
        newSpread.setValueIndex(conf.getInt("newSpread"));
        useCurrent.setValueIndex(conf.getBoolean("addToCur") ? 0 : 1);
      } catch (JSONException e) {
        throw new RuntimeException();
      } catch (NumberFormatException e) {
        throw new RuntimeException();
      }
    } else {
      // It's possible to open the preferences from the loading screen if no SD card is found.
      // In that case, there will be no collection loaded, so we need to disable the settings
      // that read from and write to the collection.
      dayOffset.setEnabled(false);
      learnCutoff.setEnabled(false);
      timeLimit.setEnabled(false);
      showEstimates.setEnabled(false);
      showProgress.setEnabled(false);
      newSpread.setEnabled(false);
      useCurrent.setEnabled(false);
    }

    for (String key : mShowValueInSummList) {
      updateListPreference(key);
    }
    for (String key : mShowValueInSummSeek) {
      updateSeekBarPreference(key);
    }
    for (String key : mShowValueInSummEditText) {
      updateEditTextPreference(key);
    }
    for (String key : mShowValueInSummNumRange) {
      updateNumberRangePreference(key);
    }

    if (AnkiDroidApp.SDK_VERSION <= 4) {
      fadeScrollbars.setChecked(false);
      fadeScrollbars.setEnabled(false);
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Activity activity = getActivity();
    final ContentResolver resolver = activity.getContentResolver();
    mHardware = CMHardwareManager.getInstance(activity);
    addPreferencesFromResource(R.xml.display_settings);

    PreferenceCategory displayPrefs = (PreferenceCategory) findPreference(KEY_CATEGORY_DISPLAY);

    mDisplayRotationPreference = (PreferenceScreen) findPreference(KEY_DISPLAY_ROTATION);

    mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER);
    if (mScreenSaverPreference != null
        && getResources().getBoolean(com.android.internal.R.bool.config_dreamsSupported) == false) {
      getPreferenceScreen().removePreference(mScreenSaverPreference);
    }

    mScreenTimeoutPreference = (ListPreference) findPreference(KEY_SCREEN_TIMEOUT);
    final long currentTimeout =
        Settings.System.getLong(resolver, SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
    mScreenTimeoutPreference.setValue(String.valueOf(currentTimeout));
    mScreenTimeoutPreference.setOnPreferenceChangeListener(this);
    disableUnusableTimeouts(mScreenTimeoutPreference);
    updateTimeoutPreferenceDescription(currentTimeout);
    updateDisplayRotationPreferenceDescription();

    mLcdDensityPreference = (ListPreference) findPreference(KEY_LCD_DENSITY);
    if (mLcdDensityPreference != null) {
      if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
        displayPrefs.removePreference(mLcdDensityPreference);
      } else {
        int defaultDensity = getDefaultDensity();
        int currentDensity = getCurrentDensity();
        if (currentDensity < 10 || currentDensity >= 1000) {
          // Unsupported value, force default
          currentDensity = defaultDensity;
        }

        int factor = defaultDensity >= 480 ? 40 : 20;
        int minimumDensity = defaultDensity - 4 * factor;
        int currentIndex = -1;
        String[] densityEntries = new String[7];
        String[] densityValues = new String[7];
        for (int idx = 0; idx < 7; ++idx) {
          int val = minimumDensity + factor * idx;
          int valueFormatResId =
              val == defaultDensity
                  ? R.string.lcd_density_default_value_format
                  : R.string.lcd_density_value_format;

          densityEntries[idx] = getString(valueFormatResId, val);
          densityValues[idx] = Integer.toString(val);
          if (currentDensity == val) {
            currentIndex = idx;
          }
        }
        mLcdDensityPreference.setEntries(densityEntries);
        mLcdDensityPreference.setEntryValues(densityValues);
        if (currentIndex != -1) {
          mLcdDensityPreference.setValueIndex(currentIndex);
        }
        mLcdDensityPreference.setOnPreferenceChangeListener(this);
        updateLcdDensityPreferenceDescription(currentDensity);
      }
    }

    mFontSizePref = (FontDialogPreference) findPreference(KEY_FONT_SIZE);
    mFontSizePref.setOnPreferenceChangeListener(this);
    mFontSizePref.setOnPreferenceClickListener(this);

    if (isAutomaticBrightnessAvailable(getResources())) {
      mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
      mAutoBrightnessPreference.setOnPreferenceChangeListener(this);
    } else {
      removePreference(KEY_AUTO_BRIGHTNESS);
    }

    if (isLiftToWakeAvailable(activity)) {
      mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
      mLiftToWakePreference.setOnPreferenceChangeListener(this);
    } else {
      removePreference(KEY_LIFT_TO_WAKE);
    }

    PreferenceCategory advancedPrefs = (PreferenceCategory) findPreference(CATEGORY_ADVANCED);

    mDozeFragement = (PreferenceScreen) findPreference(KEY_DOZE_FRAGMENT);
    if (!Utils.isDozeAvailable(activity)) {
      getPreferenceScreen().removePreference(mDozeFragement);
      mDozeFragement = null;
    }

    mTapToWake = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE);
    if (!mHardware.isSupported(FEATURE_TAP_TO_WAKE)) {
      advancedPrefs.removePreference(mTapToWake);
      mTapToWake = null;
    }

    mProximityWakePreference = (SwitchPreference) findPreference(KEY_PROXIMITY_WAKE);
    boolean proximityCheckOnWake =
        getResources().getBoolean(com.android.internal.R.bool.config_proximityCheckOnWake);
    if (mProximityWakePreference != null && proximityCheckOnWake) {
      mProximityWakePreference.setOnPreferenceChangeListener(this);
    } else {
      if (advancedPrefs != null && mProximityWakePreference != null) {
        advancedPrefs.removePreference(mProximityWakePreference);
        Settings.System.putInt(getContentResolver(), Settings.System.PROXIMITY_ON_WAKE, 0);
      }
    }

    mWakeWhenPluggedOrUnplugged =
        (SwitchPreference) findPreference(KEY_WAKE_WHEN_PLUGGED_OR_UNPLUGGED);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.network_traffic);

    loadResources();

    PreferenceScreen prefSet = getPreferenceScreen();

    mNetTrafficState = (ListPreference) prefSet.findPreference(NETWORK_TRAFFIC_STATE);
    mNetTrafficUnit = (ListPreference) prefSet.findPreference(NETWORK_TRAFFIC_UNIT);
    mNetTrafficPeriod = (ListPreference) prefSet.findPreference(NETWORK_TRAFFIC_PERIOD);

    mNetTrafficAutohide = (SwitchPreference) prefSet.findPreference(NETWORK_TRAFFIC_AUTOHIDE);
    mNetTrafficAutohide.setChecked(
        (Settings.System.getInt(getContentResolver(), Settings.System.NETWORK_TRAFFIC_AUTOHIDE, 0)
            == 1));
    mNetTrafficAutohide.setOnPreferenceChangeListener(this);

    mNetTrafficAutohideThreshold =
        (SeekBarPreference) prefSet.findPreference(NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD);
    int netTrafficAutohideThreshold =
        Settings.System.getInt(
            getContentResolver(), Settings.System.NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD, 10);
    mNetTrafficAutohideThreshold.setValue(netTrafficAutohideThreshold / 1);
    mNetTrafficAutohideThreshold.setOnPreferenceChangeListener(this);

    mNetTrafficColor = (ColorPickerPreference) prefSet.findPreference(NETWORK_TRAFFIC_COLOR);
    mNetTrafficColor.setOnPreferenceChangeListener(this);
    int intColor =
        Settings.System.getInt(
            getContentResolver(), Settings.System.NETWORK_TRAFFIC_COLOR, 0xffffffff);
    String hexColor = String.format("#%08x", (0xffffffff & intColor));
    mNetTrafficColor.setSummary(hexColor);
    mNetTrafficColor.setNewPreviewColor(intColor);

    // TrafficStats will return UNSUPPORTED if the device does not support it.
    if (TrafficStats.getTotalTxBytes() != TrafficStats.UNSUPPORTED
        && TrafficStats.getTotalRxBytes() != TrafficStats.UNSUPPORTED) {
      mNetTrafficVal =
          Settings.System.getInt(getContentResolver(), Settings.System.NETWORK_TRAFFIC_STATE, 0);
      int intIndex = mNetTrafficVal & (MASK_UP + MASK_DOWN);
      intIndex = mNetTrafficState.findIndexOfValue(String.valueOf(intIndex));
      updateNetworkTrafficState(intIndex);

      mNetTrafficState.setValueIndex(intIndex >= 0 ? intIndex : 0);
      mNetTrafficState.setSummary(mNetTrafficState.getEntry());
      mNetTrafficState.setOnPreferenceChangeListener(this);

      mNetTrafficUnit.setValueIndex(getBit(mNetTrafficVal, MASK_UNIT) ? 1 : 0);
      mNetTrafficUnit.setSummary(mNetTrafficUnit.getEntry());
      mNetTrafficUnit.setOnPreferenceChangeListener(this);

      intIndex = (mNetTrafficVal & MASK_PERIOD) >>> 16;
      intIndex = mNetTrafficPeriod.findIndexOfValue(String.valueOf(intIndex));
      mNetTrafficPeriod.setValueIndex(intIndex >= 0 ? intIndex : 1);
      mNetTrafficPeriod.setSummary(mNetTrafficPeriod.getEntry());
      mNetTrafficPeriod.setOnPreferenceChangeListener(this);
    }
  }
 public void updatePreference(String key) {
   // Preference change
   String str;
   if (key.equals(PREF_KEY_LOAD_CANVAS_SIZE)) {
     str = mListPreferenceLoadCanvasSize.getValue();
     if (str == null) {
       mListPreferenceLoadCanvasSize.setValueIndex(1);
       str = mListPreferenceLoadCanvasSize.getValue();
     }
     // Show Selected Text
     int nSelectIndex = Integer.parseInt(str);
     CharSequence[] strings = getResources().getTextArray(R.array.load_canvas_size);
     mListPreferenceLoadCanvasSize.setSummary(strings[nSelectIndex]);
   } else if (key.equals(PREF_KEY_LOAD_CANVAS_HALIGN)) {
     str = mListPreferenceLoadCanvasHAlign.getValue();
     if (str == null) {
       mListPreferenceLoadCanvasHAlign.setValueIndex(0);
       str = mListPreferenceLoadCanvasHAlign.getValue();
     }
     // Show Selected Text
     int nSelectIndex = Integer.parseInt(str);
     CharSequence[] strings = getResources().getTextArray(R.array.load_canvas_halign);
     mListPreferenceLoadCanvasHAlign.setSummary(strings[nSelectIndex]);
   } else if (key.equals(PREF_KEY_LOAD_CANVAS_VALIGN)) {
     str = mListPreferenceLoadCanvasVAlign.getValue();
     if (str == null) {
       mListPreferenceLoadCanvasVAlign.setValueIndex(0);
       str = mListPreferenceLoadCanvasVAlign.getValue();
     }
     // Show Selected Text
     int nSelectIndex = Integer.parseInt(str);
     CharSequence[] strings = getResources().getTextArray(R.array.load_canvas_valign);
     mListPreferenceLoadCanvasVAlign.setSummary(strings[nSelectIndex]);
   } else if (key.equals(PREF_KEY_SAVE_CROP_IMAGE_HORIZONTAL)) {
     if (!mCheckPreferenceSaveCropImageHorizontal.isChecked())
       mCheckPreferenceSaveCropImageHorizontal.setSummaryOff(
           getResources().getString(R.string.save_image_horizontal_crop_off));
     else
       mCheckPreferenceSaveCropImageHorizontal.setSummaryOn(
           getResources().getString(R.string.save_image_horizontal_crop_on));
   } else if (key.equals(PREF_KEY_SAVE_CROP_IMAGE_VERTICAL)) {
     if (!mCheckPreferenceSaveCropImageVertical.isChecked())
       mCheckPreferenceSaveCropImageVertical.setSummaryOff(
           getResources().getString(R.string.save_image_vertical_crop_off));
     else
       mCheckPreferenceSaveCropImageVertical.setSummaryOn(
           getResources().getString(R.string.save_image_vertical_crop_on));
   } else if (key.equals(PREF_KEY_SAVE_CROP_CONTENTS)) {
     if (!mCheckPreferenceSaveCropContents.isChecked())
       mCheckPreferenceSaveCropContents.setSummaryOff(
           getResources().getString(R.string.adjust_saving_contents_by_cropping_off));
     else
       mCheckPreferenceSaveCropContents.setSummaryOn(
           getResources().getString(R.string.adjust_saving_contents_by_cropping_on));
   } else if (key.equals(PREF_KEY_SAVE_IMAGESIZE)) {
     str = mListPreferenceSaveImageSize.getValue();
     if (str == null) {
       mListPreferenceSaveImageSize.setValueIndex(0);
       str = mListPreferenceSaveImageSize.getValue();
     }
     // Show Selected Text
     int nSelectIndex = Integer.parseInt(str);
     CharSequence[] strings = getResources().getTextArray(R.array.save_image_size);
     mListPreferenceSaveImageSize.setSummary(strings[nSelectIndex]);
   } else if (key.equals(PREF_KEY_SAVE_IMAGEQUALITY)) {
     str = mListPreferenceSaveImageQuality.getValue();
     if (str == null) {
       mListPreferenceSaveImageQuality.setValueIndex(0);
       str = mListPreferenceSaveImageQuality.getValue();
     }
     // Show Selected Text
     int nSelectIndex = Integer.parseInt(str);
     CharSequence[] strings = getResources().getTextArray(R.array.save_image_quality);
     mListPreferenceSaveImageQuality.setSummary(strings[nSelectIndex]);
   } else if (key.equals(PREF_KEY_SAVE_ONLYFOREGROUNDIMAGE)) {
     if (!mCheckPreferenceSaveOnlyForegroundImage.isChecked())
       mCheckPreferenceSaveOnlyForegroundImage.setSummaryOff(
           getResources().getString(R.string.save_only_foreground_image_off));
     else
       mCheckPreferenceSaveOnlyForegroundImage.setSummaryOn(
           getResources().getString(R.string.save_only_foreground_image_on));
   } else if (key.equals(PREF_KEY_SAVE_CREATENEWIMAGEFILE)) {
     if (!mCheckPreferenceSaveCreateNewImageFile.isChecked())
       mCheckPreferenceSaveCreateNewImageFile.setSummaryOff(
           getResources().getString(R.string.create_new_image_off));
     else
       mCheckPreferenceSaveCreateNewImageFile.setSummaryOn(
           getResources().getString(R.string.create_new_image_on));
   } else if (key.equals(PREF_KEY_ENCODE_FOREGROUNDIMAGE)) {
     if (!mCheckPreferenceEncodeForegroundImage.isChecked())
       mCheckPreferenceEncodeForegroundImage.setSummaryOff(
           getResources().getString(R.string.encode_foreground_image_off));
     else
       mCheckPreferenceEncodeForegroundImage.setSummaryOn(
           getResources().getString(R.string.encode_foreground_image_on));
   } else if (key.equals(PREF_KEY_ENCODE_THUMBNAILIMAGE)) {
     if (!mCheckPreferenceEncodeThumbnailImage.isChecked())
       mCheckPreferenceEncodeThumbnailImage.setSummaryOff(
           getResources().getString(R.string.encode_thumbnail_image_off));
     else
       mCheckPreferenceEncodeThumbnailImage.setSummaryOn(
           getResources().getString(R.string.encode_thumbnail_image_on));
   } else if (key.equals(PREF_KEY_ENCODE_OBJECTDATA)) {
     if (!mCheckPreferenceEncodeObjectData.isChecked())
       mCheckPreferenceEncodeObjectData.setSummaryOff(
           getResources().getString(R.string.encode_object_data_off));
     else
       mCheckPreferenceEncodeObjectData.setSummaryOn(
           getResources().getString(R.string.encode_object_data_on));
   } else if (key.equals(PREF_KEY_LOAD_DECODE_PRIORITY_FGDATA)) {
     str = mListPreferenceDecodePriorityFGData.getValue();
     if (str == null) {
       mListPreferenceDecodePriorityFGData.setValueIndex(0);
       str = mListPreferenceDecodePriorityFGData.getValue();
     }
     // Show Selected Text
     int nSelectIndex = Integer.parseInt(str);
     CharSequence[] strings = getResources().getTextArray(R.array.decode_priority_fg);
     mListPreferenceDecodePriorityFGData.setSummary(strings[nSelectIndex]);
   } else if (key.equals(PREF_KEY_ENCODE_VIDEOFILEDATA)) {
     if (!mCheckPreferenceEncodeVideoFileData.isChecked())
       mCheckPreferenceEncodeVideoFileData.setSummaryOff(
           getResources().getString(R.string.encode_video_file_data_off));
     else
       mCheckPreferenceEncodeVideoFileData.setSummaryOn(
           getResources().getString(R.string.encode_video_file_data_on));
   }
 }
Esempio n. 30
0
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   if (key.equals(REGIONAL_BAND_KEY)) {
     String[] summaryBandItems = getResources().getStringArray(R.array.regional_band_summary);
     String valueStr = sharedPreferences.getString(key, "");
     int index = 0;
     if (valueStr != null) {
       index = mBandPreference.findIndexOfValue(valueStr);
     }
     if ((index < 0) || (index >= summaryBandItems.length)) {
       index = 0;
       mBandPreference.setValueIndex(0);
     }
     Log.d(LOGTAG, "onSharedPreferenceChanged: Country Change: " + index);
     mBandPreference.setSummary(summaryBandItems[index]);
     FmSharedPreferences.setCountry(index);
     FMRadio.fmConfigure();
   } else {
     if (mRxMode) {
       if (key.equals(AUTO_AF)) {
         boolean bAFAutoSwitch = mAfPref.isChecked();
         Log.d(LOGTAG, "onSharedPreferenceChanged: Auto AF Enable: " + bAFAutoSwitch);
         FmSharedPreferences.setAutoAFSwitch(bAFAutoSwitch);
         FMRadio.fmAutoAFSwitch();
       } else if (key.equals(RECORD_DURATION_KEY)) {
         if (FMRadio.RECORDING_ENABLE) {
           String[] recordItems = getResources().getStringArray(R.array.record_durations_entries);
           String valueStr = mRecordDurPreference.getValue();
           int index = 0;
           if (valueStr != null) {
             index = mRecordDurPreference.findIndexOfValue(valueStr);
           }
           if ((index < 0) || (index >= recordItems.length)) {
             index = 0;
             mRecordDurPreference.setValueIndex(index);
           }
           Log.d(LOGTAG, "onSharedPreferenceChanged: recorddur: " + recordItems[index]);
           mRecordDurPreference.setSummary(recordItems[index]);
           FmSharedPreferences.setRecordDuration(index);
         }
       } else if (key.equals(AUDIO_OUTPUT_KEY)) {
         String[] bandItems = getResources().getStringArray(R.array.ster_mon_entries);
         String valueStr = mAudioPreference.getValue();
         int index = 0;
         if (valueStr != null) {
           index = mAudioPreference.findIndexOfValue(valueStr);
         }
         if (index != 1) {
           if (index != 0) {
             index = 0;
             /* It shud be 0(Stereo) or 1(Mono) */
             mAudioPreference.setValueIndex(index);
           }
         }
         Log.d(LOGTAG, "onSharedPreferenceChanged: audiomode: " + bandItems[index]);
         mAudioPreference.setSummary(bandItems[index]);
         if (index == 0) {
           // Stereo
           FmSharedPreferences.setAudioOutputMode(true);
         } else {
           // Mono
           FmSharedPreferences.setAudioOutputMode(false);
         }
         FMRadio.fmAudioOutputMode();
       } else if (key.equals(BT_EXIT_BEHAVIOUR)) {
         String[] btChoices = getResources().getStringArray(R.array.bt_exit_behaviour_entries);
         String valueStr = mBluetoothBehaviour.getValue();
         Log.d(
             LOGTAG,
             "onSharedPreferenceChanged: BT behaviour: "
                 + btChoices[mBluetoothBehaviour.findIndexOfValue(valueStr)]);
         FmSharedPreferences.setBluetoothExitBehaviour(Integer.parseInt(valueStr));
       } else if (key.equals(HEADSET_DC_BEHAVIOUR)) {
         boolean bRemoveHeadset = mRemoveHeadset.isChecked();
         Log.d(LOGTAG, "onSharedPreferenceChanged: Remove Headset Enable: " + bRemoveHeadset);
         FmSharedPreferences.setHeadsetDcBehaviour(bRemoveHeadset);
       }
     }
   }
   if (mPrefs != null) {
     mPrefs.Save();
   }
 }