En_seAres3Main_java.txt

(121 KB) Pobierz
package com.yarre.en_seares3;



import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.app.Activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.os.SystemClock;
import android.speech.tts.TextToSpeech;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Chronometer;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.lang.*;


public class MainActivity extends AppCompatActivity {
    public static final String EXTRA_D = "Empty";
    private Chronometer chronometer;
    private long pauseOffset;
    private boolean running;
    private String ex_data;
    private String Translate0 = "";
    private String Translate1 = "";
    private String ans0_orgM;
    private String rec_at;
    private String ans0_orgRest;
    private String quest_ansGaps = "Try again!???Empty!";
    private String AnsRep1 = "";
    private TextToSpeech mTTS;
    private Button mButtonSpeak;
    private SeekBar mSeekBarPitch;
    private SeekBar mSeekBarSpeed;
    private EditText mSpeakText;
    private int db1 = 1;
    private int A_act = 3;
    private int nr_rec = -1;
    private int nr_arr_poc = -1;
    private int var_search = 1;
    private int exeGood = 0;
    private int exeAll = 0;
    private Boolean mKey = true;
    private Boolean mFont = false;
    private Boolean repeat2 = false;
    private CheckBox mspeakCheckbox, mDelCheckbox, mAnsCheckboxRep, mGapsCheckbox, del_rep_Checkbox, trans_to_des_Checkbox, addAnsCheckbox, InteralData;
    public static final String SHARED_PREFS ="sharedPrefs";
    public static final String SPLANG = "text";
    String[] ver_verb={"Nothing", "' ' <= Num", "' ' >=Num<= ","' ' ==Num"};
    String[] sentences, exercise2;



    public String[] diff3 = new String[]{
            "??????????Si??nte como en casa!?????Si??nte como en casa!???Przetlumacz na hiszpanski.???Make yourself at home! / Czuj sie jak w domu! (Uzyj czasownika sentirse)??? ??? ??? ??? ",
            "???Si, ???Si, tambi??n hay algo para t??.???Si, tambi??n hay algo para t??.???Po wysluchanie nagrania uzupelnij zdanie.??? ???Yes, there is also something for you.??? ??? ??? ",

    };

    public String[] diff4 = new String[]{




            "??????????Si??ntete como en casa!?????Si??ntete como en casa!???translate???Make yourself at home!??? ???Czuj sie jak w domu!??? ??? "
    };


    EditText idDB, qSpaces, quest, repeat_nrs, repeat_nrs1;
    TextView hint, answ, desc1, trans0, info13, allQ, allQG, allQPer, pockF, beginP, recPoce;
    Button CheckBtn, RepeatBtn, GoBtn, GoCheckBtn, search2, button_Del_Poc, button_Del_Poc1, btn_add_sign, btn_skip, btnExtAdd, btnExtAdd_trans0, btnExtUpdate, btnCp_Poc;
    Button Btn_One;
    RadioGroup radioGroup, activeRadioGroup;
    RadioButton radioButton;


    @SuppressLint("SetTextI18n")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        RelativeLayout layout = findViewById(R.id.Layout_bot);
        RelativeLayout layout1 = findViewById(R.id.info_low);
        Spinner spinner1 = findViewById(R.id.spinner1);
        idDB = findViewById(R.id.idDB);
        qSpaces = findViewById(R.id.qSpaces);
        quest = findViewById(R.id.quest);
        answ = findViewById(R.id.answ);
        hint = findViewById(R.id.hint);
        desc1 = findViewById(R.id.desc1);
        trans0 = findViewById(R.id.trans0);

        InteralData = findViewById(R.id.InteralData);
        CheckBtn = findViewById(R.id.CheckBtn);
        GoBtn = findViewById(R.id.GoBtn);
        search2 = findViewById(R.id.search2);
        button_Del_Poc = findViewById(R.id.button_Del_Poc);
        button_Del_Poc1 = findViewById(R.id.button_Del_Poc1);
        btn_add_sign = findViewById(R.id.btn_add_sign);
        btn_skip = findViewById(R.id.btn_skip);
        btnExtAdd = findViewById(R.id.btnExtAdd);
        btnExtAdd_trans0 = findViewById(R.id.btnExtAdd_trans0);
        btnExtUpdate = findViewById(R.id.btnExtUpdate);
        btnCp_Poc = findViewById(R.id.btnCp_Poc);
        Btn_One = findViewById(R.id.Btn_One);
        RepeatBtn = findViewById(R.id.RepeatBtn);
        GoCheckBtn = findViewById(R.id.GoCheckBtn);
        del_rep_Checkbox = findViewById(R.id.del_rep_Checkbox);
        trans_to_des_Checkbox = findViewById(R.id.trans_to_des_Checkbox);

        addAnsCheckbox = findViewById(R.id.addAnsCheckbox);

        mButtonSpeak = findViewById(R.id.button_speak);
        mSpeakText = findViewById(R.id.speak_text);
        mSeekBarPitch = findViewById(R.id.seek_bar_pitch);
        mSeekBarSpeed = findViewById(R.id.seek_bar_speed);
        radioGroup = findViewById(R.id.radioGroup);
        activeRadioGroup = findViewById(R.id.activeRadioGroup);
        info13 = findViewById(R.id.info13);
        mspeakCheckbox = findViewById(R.id.speakCheckbox);
        mGapsCheckbox = findViewById(R.id.GapsCheckbox);
        // mspeakCheckbox.setChecked(true);
        mDelCheckbox = findViewById(R.id.DelCheckbox);
        // mDelCheckbox.setChecked(true);
        mAnsCheckboxRep = findViewById(R.id.AnsCheckboxRep);
        chronometer = findViewById(R.id.chronometer);
        allQ = findViewById(R.id.allQ);
        allQG = findViewById(R.id.allQG);
        allQPer = findViewById(R.id.allQPer);
        pockF = findViewById(R.id.pockF);
        beginP = findViewById(R.id.beginP);
        recPoce = findViewById(R.id.recPoce);
        repeat_nrs = findViewById(R.id.repeat_nrs);
        repeat_nrs1 = findViewById(R.id.repeat_nrs1);
        sentences = getResources().getStringArray(R.array.sentences_array);
        exercise2 = getResources().getStringArray(R.array.myexercises_array);
        startChronometer();
        repeat_nrs.setText("25{p10}5:10[0-7]");
        //repeat_nrs.setText("25{+11+ }5:10[0-7]");
        //mspeakCheckbox.setChecked(true);
        BtnRandom();
        //----------------------------------
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, ver_verb);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        spinner1.setAdapter(adapter);

        spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {


            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                // v_verb.setText(String.valueOf(position));
                //add_verb(position);
                //Toast.makeText(parent.getContext(), text, Toast.LENGTH_SHORT).show();
                Toast.makeText(getApplicationContext(), ver_verb[position] +" id >:" + id, Toast.LENGTH_LONG).show();
                if (id == 1) {
                    var_search = 0;
                    //  repeat_nrs.setText("45{+11n+ }5:10[0-7]");
                    if (db1 != 2){
                        mGapsCheckbox.setChecked(true);
                    }
                    //  int id1 = position;
                    //  RadioButton rb = radioGroup.findViewById(R.id.radio_one);
                    //   rb.setChecked(true);

                    search2es();

                }
                if (id == 2) {
                    var_search = 1;
                    // repeat_nrs.setText("45{+11n+ }5:10[0-7]");
                    if (db1 != 2){
                        mGapsCheckbox.setChecked(true);
                    }

                    //  int id1 = position;
                    //    RadioButton rb = radioGroup.findViewById(R.id.radio_one);
                    //    rb.setChecked(true);

                    search2es();

                }
                if (id == 3) {
                    var_search = 2;
                    // repeat_nrs.setText("45{+11n+ }5:10[1-7]");
                    mGapsCheckbox.setChecked(false);
                    //    RadioButton rb = radioGroup.findViewById(R.id.radio_two);
                    //    rb.setChecked(true);

                    search2es();

                }

            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        //----------------------------------------------------------
        layout.setOnClickListener(v -> {
            if (mKey) {
                //    InputMethodManager inputMethodManager = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                //    inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);

                InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
                mKey = false;
            } else {
                InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
//Hide:
                //  imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0...
Zgłoś jeśli naruszono regulamin