예제 #1
0
    @Override
    protected View onCreateDialogView() {
      reload();
      Context context = getContext();
      if (activityRef.get() == null) {
        return null;
      }

      ScrollView view =
          (ScrollView)
              activityRef
                  .get()
                  .getLayoutInflater()
                  .inflate(R.layout.dialog_language_preference, null);

      resetButton = (Button) view.findViewById(R.id.reset_button);
      resetButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              resetValues();
            }
          });

      engineSpinner = (Spinner) view.findViewById(R.id.engine_spinner);
      List<String> engines = Arrays.asList(AbsttsTextToSpeechService.DEFAULT_ENGINES);
      engineSpinner.setAdapter(
          new ArrayAdapter<String>(
              context, android.R.layout.simple_spinner_dropdown_item, engines));
      for (int i = 0; i < engines.size(); i++) {
        if (engines.get(i).equals(prefItem.getValueForEngine())) {
          engineSpinner.setSelection(i);
        }
      }

      enabledCheckBox = (CheckBox) view.findViewById(R.id.enabled_check_box);
      enabledCheckBox.setChecked(prefItem.getValueForEnable());

      volumeSeekBar = (SeekBar) view.findViewById(R.id.volume_seek_bar);
      volumeSeekBar.setProgress((int) (prefItem.getValueForVolume() * 100.f));

      rateSeekBar = (SeekBar) view.findViewById(R.id.rate_seek_bar);
      rateSeekBar.setProgress((int) (prefItem.getValueForSpeechRate() * 10.f));

      pitchSeekBar = (SeekBar) view.findViewById(R.id.pitch_seek_bar);
      pitchSeekBar.setProgress((int) (prefItem.getValueForSpeechRate() * 10.f));

      panSeekBar = (SeekBar) view.findViewById(R.id.pan_seek_bar);
      panSeekBar.setProgress((int) ((prefItem.getValueForPan() + 1.f) * 50.f));

      return view;
    }
예제 #2
0
    @Override
    protected void onDialogClosed(boolean positiveResult) {
      super.onDialogClosed(positiveResult);
      if (!positiveResult) {
        return;
      }

      reload();

      prefItem.setValueForEnable(enabledCheckBox.isChecked());
      prefItem.setValueForEngine((String) engineSpinner.getSelectedItem());
      prefItem.setValueForVolume(volumeSeekBar.getProgress() / 100.f);
      prefItem.setValueForPitch(pitchSeekBar.getProgress() / 10.f);
      prefItem.setValueForSpeechRate(rateSeekBar.getProgress() / 10.f);
      prefItem.setValueForPan((panSeekBar.getProgress() - 50) / 50.f);
      prefItem.commit(getSharedPreferences());

      reload();
    }
예제 #3
0
 @Override
 protected void onAttachedToHierarchy(PreferenceManager preferenceManager) {
   super.onAttachedToHierarchy(preferenceManager);
   prefItem.load(preferenceManager.getSharedPreferences());
   reload();
 }
예제 #4
0
 void reload() {
   String title = prefItem.getTitle();
   setTitle(title);
   setDialogTitle(title);
 }
예제 #5
0
 public LanguagePreference(Activity activity, AttributeSet attrs, String language) {
   super(activity, attrs);
   activityRef = new WeakReference<Activity>(activity);
   prefItem = new LanguagePrefItem(new Locale(language));
   setKey(prefItem.getKey());
 }