package com.github.helltar.anpaside.activities;

import static com.github.helltar.anpaside.Consts.RCODE_SETTINGS;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

import com.github.helltar.anpaside.R;
import com.github.helltar.anpaside.editor.EditorConfig;

public class SettingsActivity extends AppCompatActivity {

    private final EditorConfig editorConfig = new EditorConfig(this);

    private EditText edtFontSize;
    private CheckBox cbHighlighter;
    private CheckBox cbWordwrap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);

        edtFontSize = findViewById(R.id.edtEditorFontSize);
        cbHighlighter = findViewById(R.id.cbHighlighter);
        cbWordwrap = findViewById(R.id.cbWordwrap);

        edtFontSize.setText(String.valueOf(editorConfig.getFontSize()));
        cbHighlighter.setChecked(editorConfig.getHighlighterEnabled());
        cbWordwrap.setChecked(!editorConfig.getWordwrapEnabled());
    }

    public void onBtnSaveClick(View v) {
        Intent data = new Intent();

        data.putExtra(editorConfig.FONT_SIZE, Integer.parseInt(edtFontSize.getText().toString()));
        data.putExtra(editorConfig.HIGHLIGHTER_ENABLED, cbHighlighter.isChecked());
        data.putExtra(editorConfig.WORDWRAP, !cbWordwrap.isChecked());

        setResult(RCODE_SETTINGS, data);

        finish();
    }
}
@@ -1283,45 +1283,22 @@
     
-data.putExtra(editorConfig.FONT_SIZE,
+int fontSize =
  Int
@@ -1344,16 +1344,201 @@
 tring())
+;%0A%0A        if (fontSize %3C 4) %7B%0A            fontSize = 4;%0A        %7D else if (fontSize %3E 64) %7B%0A            fontSize = 64;%0A        %7D%0A%0A        data.putExtra(editorConfig.FONT_SIZE, fontSize
 );%0A     

check fontSize before saving