Esempio n. 1
0
 /**
  * For each list dialog, we display the value selected in the "summary" text. When a new value is
  * selected from the list dialog, update the summary to the selected entry.
  */
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   ListPreference list = (ListPreference) preference;
   int index = list.findIndexOfValue((String) newValue);
   CharSequence entry = list.getEntries()[index];
   preference.setSummary(entry);
   return true;
 }
  /**
   * onSharedPreferenceChanged not needed in my code, but still in case i have one listpreference,
   * its takes the selected entry to create the summary (planned when/if i add background images to
   * the buttons...
   */
  @Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPref, String key) {
    Preference pref = findPreference(key);
    // Log.d(TAG, "preference change for " + key + " " + pref.getTitle());

    // pref.getTitle();
    if (pref instanceof ListPreference) {
      ListPreference listPref = (ListPreference) pref;
      pref.setSummary(listPref.getEntry());
    } else pref.setSummary(sharedPref.getString(key, key));

    // MainActivity mainAct = (MainActivity) getContext();
    // if(mainAct != null) mainAct.onSharedPreferenceChanged(sharedPref,key);
  }
Esempio n. 3
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. 4
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);
 }
Esempio n. 5
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. 6
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. 7
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);
  }
Esempio n. 8
0
  /** Update the MidiOptions based on the preferences selected. */
  private void updateOptions() {
    for (int i = 0; i < options.tracks.length; i++) {
      options.tracks[i] = selectTracks[i].isChecked();
    }
    for (int i = 0; i < options.mute.length; i++) {
      options.mute[i] = muteTracks[i].isChecked();
    }
    for (int i = 0; i < options.tracks.length; i++) {
      ListPreference entry = selectInstruments[i];
      options.instruments[i] = entry.findIndexOfValue(entry.getValue());
    }
    options.scrollVert = scrollVertically.isChecked();
    options.showPiano = showPiano.isChecked();
    options.showLyrics = showLyrics.isChecked();
    if (twoStaffs != null) options.twoStaffs = twoStaffs.isChecked();
    else options.twoStaffs = false;

    options.showNoteLetters = Integer.parseInt(showNoteLetters.getValue());
    options.transpose = Integer.parseInt(transpose.getValue());
    options.key = Integer.parseInt(key.getValue());
    if (time.getValue().equals("Default")) {
      options.time = null;
    } else if (time.getValue().equals("3/4")) {
      options.time =
          new TimeSignature(3, 4, options.defaultTime.getQuarter(), options.defaultTime.getTempo());
    } else if (time.getValue().equals("4/4")) {
      options.time =
          new TimeSignature(4, 4, options.defaultTime.getQuarter(), options.defaultTime.getTempo());
    }
    options.combineInterval = Integer.parseInt(combineInterval.getValue());
    options.shade1Color = shade1Color.getColor();
    options.shade2Color = shade2Color.getColor();
    options.showMeasures = showMeasures.isChecked();
    options.playMeasuresInLoop = playMeasuresInLoop.isChecked();
    options.playMeasuresInLoopStart = Integer.parseInt(loopStart.getValue()) - 1;
    options.playMeasuresInLoopEnd = Integer.parseInt(loopEnd.getValue()) - 1;
  }
Esempio n. 9
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);
  }