// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final String NUMBER_OF_QUESTIONS_KEY = "numberOfQuestions";
// 
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final String PREFS_NAME = "MyPrefsFile";
// 
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final String TEST_NAME_KEY = "testName";
// 
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final String TEST_MODE_KEY = "testMode";
// 
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final int TEST_RESULTS_RESULT = 0;


import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import static android.content.Context.MODE_PRIVATE;
import static com.aepronunciation.ipa.MainActivity.NUMBER_OF_QUESTIONS_KEY;
import static com.aepronunciation.ipa.MainActivity.PREFS_NAME;
import static com.aepronunciation.ipa.MainActivity.TEST_NAME_KEY;
import static com.aepronunciation.ipa.MainActivity.TEST_MODE_KEY;
import static com.aepronunciation.ipa.MainActivity.TEST_RESULTS_RESULT;
            name = getString(R.string.test_default_name);
        }

        // Number of questions
        String questions = spinner.getSelectedItem().toString();

        // Test mode
        String testModeString;
        if (rbSingle.isChecked()) {
            testModeString = SoundMode.Single.getPersistentMemoryString();
        } else {
            testModeString = SoundMode.Double.getPersistentMemoryString();
        }

        // Save to preferences
        if (getActivity() != null) {
            SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
            SharedPreferences.Editor editor = settings.edit();
            editor.putString(NUMBER_OF_QUESTIONS_KEY, questions);
            editor.putString(TEST_MODE_KEY, testModeString);
            editor.putString(TEST_NAME_KEY, name);
            editor.apply();
        }


        // Start test activity
        Intent intent = new Intent(getActivity(), TestActivity.class);
        intent.putExtra(TEST_NAME_KEY, name);
        intent.putExtra(TEST_MODE_KEY, testModeString);
        intent.putExtra(NUMBER_OF_QUESTIONS_KEY, Integer.parseInt(questions));
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final String NUMBER_OF_QUESTIONS_KEY = "numberOfQuestions";
// 
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final String PREFS_NAME = "MyPrefsFile";
// 
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final String TEST_NAME_KEY = "testName";
// 
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final String TEST_MODE_KEY = "testMode";
// 
// Path: app/src/main/java/com/aepronunciation/ipa/MainActivity.java
// public static final int TEST_RESULTS_RESULT = 0;


// Path: app/src/main/java/com/aepronunciation/ipa/TestFragment.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import static android.content.Context.MODE_PRIVATE;
import static com.aepronunciation.ipa.MainActivity.NUMBER_OF_QUESTIONS_KEY;
import static com.aepronunciation.ipa.MainActivity.PREFS_NAME;
import static com.aepronunciation.ipa.MainActivity.TEST_NAME_KEY;
import static com.aepronunciation.ipa.MainActivity.TEST_MODE_KEY;
import static com.aepronunciation.ipa.MainActivity.TEST_RESULTS_RESULT;

            name = getString(R.string.test_default_name);
        }

        // Number of questions
        String questions = spinner.getSelectedItem().toString();

        // Test mode
        String testModeString;
        if (rbSingle.isChecked()) {
            testModeString = SoundMode.Single.getPersistentMemoryString();
        } else {
            testModeString = SoundMode.Double.getPersistentMemoryString();
        }

        // Save to preferences
        if (getActivity() != null) {
            SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
            SharedPreferences.Editor editor = settings.edit();
            editor.putString(NUMBER_OF_QUESTIONS_KEY, questions);
            editor.putString(TEST_MODE_KEY, testModeString);
            editor.putString(TEST_NAME_KEY, name);
            editor.apply();
        }


        // Start test activity
        Intent intent = new Intent(getActivity(), TestActivity.class);
        intent.putExtra(TEST_NAME_KEY, name);
        intent.putExtra(TEST_MODE_KEY, testModeString);
        intent.putExtra(NUMBER_OF_QUESTIONS_KEY, Integer.parseInt(questions));
        getActivity().startActivityForResult(intent, TEST_RESULTS_RESULT);