/** When the 'restore defaults' preference is clicked, restore the default settings */ public boolean onPreferenceClick(Preference preference) { updateOptions(); if (preference == restoreDefaults) { options = defaultOptions.copy(); createView(); } else if (preference == setAllToPiano) { for (int i = 0; i < options.instruments.length; i++) { options.instruments[i] = 0; } createView(); } return true; }
/** 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; }