コード例 #1
0
        public void onClick(View v) {
          // If the user click on these fields, then we assume user has changed some settings.
          settingsChanged = true;

          if (v == colorCheckbox) {
            if (colorCheckbox.isChecked()) {
              colorRow.setVisibility(View.VISIBLE);
            } else {
              colorRow.setVisibility(View.GONE);
              resetToDefaultColors();
            }
          }

          if (v == colorButton) {
            showColorPickerDialog();
          }

          if (v == qTypefaceCheckbox) {
            if (qTypefaceCheckbox.isChecked()) {
              qTypefaceEdit.setVisibility(View.VISIBLE);
            } else {
              qTypefaceEdit.setVisibility(View.GONE);
              setting.setQuestionFont("");
            }
          }

          if (v == aTypefaceCheckbox) {
            if (aTypefaceCheckbox.isChecked()) {
              aTypefaceEdit.setVisibility(View.VISIBLE);
            } else {
              aTypefaceEdit.setVisibility(View.GONE);
              setting.setAnswerFont("");
            }
          }

          if (v == displayInHTMLCheckbox) {
            if (displayInHTMLCheckbox.isChecked()) {
              // Create a AlertDialog for user to select fields display in HTML
              fieldsDisplayedInHTML = setting.getDisplayInHTMLEnum();
              showCardFieldMultipleChoiceAlertDialog(
                  fieldsDisplayedInHTML, R.string.settings_html_display);
            } else {
              fieldsDisplayedInHTML = EnumSet.noneOf(CardField.class);
            }
            if (fieldsDisplayedInHTML.size() == 0) {
              field1Checkbox.setChecked(false);
            }
          }

          if (v == field1Checkbox) {
            if (field1Checkbox.isChecked()) {
              questionFields = setting.getQuestionFieldEnum();
              showCardFieldMultipleChoiceAlertDialog(questionFields, R.string.settings_field1);
            } else {
              questionFields = EnumSet.of(CardField.QUESTION);
            }
            if (questionFields.size() == 0) {
              field1Checkbox.setChecked(false);
            }
          }

          if (v == field2Checkbox) {
            if (field2Checkbox.isChecked()) {
              answerFields = setting.getAnswerFieldEnum();
              showCardFieldMultipleChoiceAlertDialog(answerFields, R.string.settings_field2);
            } else {
              answerFields = EnumSet.of(CardField.ANSWER);
            }
            if (answerFields.size() == 0) {
              field2Checkbox.setChecked(false);
            }
          }
          if (v == qTypefaceEdit) {
            FileBrowserFragment df = new FileBrowserFragment();
            Bundle b = new Bundle();
            b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".ttf");
            b.putString(FileBrowserFragment.EXTRA_DEFAULT_ROOT, AMEnv.DEFAULT_ROOT_PATH);
            b.putBoolean(FileBrowserFragment.EXTRA_DISMISS_ON_SELECT, true);
            df.setArguments(b);
            df.setOnFileClickListener(qTypefaceEditFbListener);
            df.show(getSupportFragmentManager(), "qTypefaceEditFB");
          }

          if (v == aTypefaceEdit) {
            FileBrowserFragment df = new FileBrowserFragment();
            Bundle b = new Bundle();
            b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".ttf");
            b.putString(FileBrowserFragment.EXTRA_DEFAULT_ROOT, AMEnv.DEFAULT_ROOT_PATH);
            b.putBoolean(FileBrowserFragment.EXTRA_DISMISS_ON_SELECT, true);
            df.setArguments(b);
            df.setOnFileClickListener(aTypefaceEditFbListener);
            df.show(getSupportFragmentManager(), "aTypefaceEditFB");
          }
        }
コード例 #2
0
        @Override
        public void run() {
          // Dismiss the progress dialog

          settingDao = dbOpenHelper.getSettingDao();

          setContentView(R.layout.settings_screen);

          questionFontSizeSpinner = (AMSpinner) findViewById(R.id.question_font_size_spinner);

          answerFontSizeSpinner = (AMSpinner) findViewById(R.id.answer_font_size_spinner);

          questionAlignSpinner = (AMSpinner) findViewById(R.id.question_align_spinner);

          answerAlignSpinner = (AMSpinner) findViewById(R.id.answer_align_spinner);

          styleSpinner = (AMSpinner) findViewById(R.id.card_style_spinner);

          qaRatioSpinner = (AMSpinner) findViewById(R.id.ratio_spinner);

          questionLocaleSpinner = (AMSpinner) findViewById(R.id.question_locale_spinner);

          answerLocaleSpinner = (AMSpinner) findViewById(R.id.answer_locale_spinner);

          audioLocationEdit = (EditText) findViewById(R.id.settings_audio_location);

          // If we got no text, we will use the default location.
          if (!Strings.isNullOrEmpty(setting.getQuestionAudio())) {
            audioLocationEdit.setText(setting.getQuestionAudioLocation());
          }

          if (!Strings.isNullOrEmpty(setting.getAnswerAudio())) {
            audioLocationEdit.setText(setting.getAnswerAudioLocation());
          }

          if (Strings.isNullOrEmpty(audioLocationEdit.getText().toString())) {
            audioLocationEdit.setText(AMEnv.DEFAULT_AUDIO_PATH);
          }

          colorCheckbox = (CheckBox) findViewById(R.id.checkbox_customize_color);
          colorCheckbox.setOnClickListener(settingFieldOnClickListener);
          colorRow = (TableRow) findViewById(R.id.color_row);

          colorSpinner = (AMSpinner) findViewById(R.id.color_item_spinner);
          colorButton = (Button) findViewById(R.id.settings_color_button);
          colorButton.setOnClickListener(settingFieldOnClickListener);
          colors = new ArrayList<Integer>(5);
          colors.add(setting.getQuestionTextColor());
          colors.add(setting.getAnswerTextColor());
          colors.add(setting.getQuestionBackgroundColor());
          colors.add(setting.getAnswerBackgroundColor());
          colors.add(setting.getSeparatorColor());

          qTypefaceCheckbox = (CheckBox) findViewById(R.id.checkbox_typeface_question);
          qTypefaceCheckbox.setOnClickListener(settingFieldOnClickListener);
          aTypefaceCheckbox = (CheckBox) findViewById(R.id.checkbox_typeface_answer);
          aTypefaceCheckbox.setOnClickListener(settingFieldOnClickListener);

          qTypefaceEdit = (EditText) findViewById(R.id.edit_typeface_question);
          qTypefaceEdit.setOnClickListener(settingFieldOnClickListener);

          aTypefaceEdit = (EditText) findViewById(R.id.edit_typeface_answer);
          aTypefaceEdit.setOnClickListener(settingFieldOnClickListener);

          displayInHTMLCheckbox = (CheckBox) findViewById(R.id.display_html);
          displayInHTMLCheckbox.setOnClickListener(settingFieldOnClickListener);
          fieldsDisplayedInHTML = setting.getDisplayInHTMLEnum();

          linebreakCheckbox = (CheckBox) findViewById(R.id.linebreak_conversion);
          linebreakCheckbox.setOnClickListener(settingFieldOnClickListener);

          field1Checkbox = (CheckBox) findViewById(R.id.checkbox_field1);
          field1Checkbox.setOnClickListener(settingFieldOnClickListener);
          questionFields = setting.getQuestionFieldEnum();

          field2Checkbox = (CheckBox) findViewById(R.id.checkbox_field2);
          field2Checkbox.setOnClickListener(settingFieldOnClickListener);
          answerFields = setting.getAnswerFieldEnum();

          updateViews();

          setSpinnerListeners();
        }