// Path: 10000sentencesapp/src/main/java/info/puzz/a10000sentences/Preferences.java
// public final class Preferences {
//     public static final String USE_TTS = "use_tts";
//     public static final String MAX_REPEAT = "max_repeat";
//     public static final String MIN_CORRECT_WORDS = "min_correct_words";
// 
//     public static boolean isUseTTS(Context context) {
//         return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(USE_TTS, true);
//     }
// 
//     public static int getMaxRepeat(Context context) {
//         int dflt = 10;
//         int repeat = NumberUtils.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString(MAX_REPEAT, String.valueOf(dflt)), dflt);
//         if (repeat < 1) {
//             return 3;
//         }
//         return repeat;
//     }
// 
//     public static int getMinCorrectWords(Context context) {
//         int dflt = 90;
//         int mcw = NumberUtils.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString(MIN_CORRECT_WORDS, String.valueOf(dflt)), dflt);
//         if (mcw < 0) {
//             return 0;
//         }
//         if (mcw > 100) {
//             return 100;
//         }
//         return mcw;
//     }
// }
// 
// Path: 10000sentencesapp/src/main/java/info/puzz/a10000sentences/models/Language.java
// @Table(name = "language")
// public class Language extends Model {
//     @Column(name = "language_id", index = true, unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
//     public String languageId;
// 
//     @Column(name = "family")
//     public String family;
// 
//     @Column(name = "name")
//     public String name;
// 
//     @Column(name = "native_name")
//     public String nativeName;
// 
//     @Column(name = "rtl")
//     boolean rightToLeft;
// 
//     public String formatNativeName(String delimiter) {
//         String[] parts;
//         if (nativeName.contains(",")) {
//             parts = StringUtils.capitalize(nativeName.split(",")[0]).split("\\s+");
//         } else {
//             parts = StringUtils.capitalize(nativeName).split("\\s+");
//         }
//         return StringUtils.join(parts, delimiter);
//     }
// 
//     public String formatNameAndNativeName() {
//         if (StringUtils.equals(name, nativeName)) {
//             return name;
//         }
//         return name + " / " + nativeName;
//     }
// 
//     public String getLanguageId() {
//         return languageId;
//     }
// 
//     public Language setLanguageId(String languageId) {
//         this.languageId = languageId;
//         return this;
//     }
// 
//     public String getFamily() {
//         return family;
//     }
// 
//     public Language setFamily(String family) {
//         this.family = family;
//         return this;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public Language setName(String name) {
//         this.name = name;
//         return this;
//     }
// 
//     public String getNativeName() {
//         return nativeName;
//     }
// 
//     public Language setNativeName(String nativeName) {
//         this.nativeName = nativeName;
//         return this;
//     }
// 
//     public boolean isRightToLeft() {
//         return rightToLeft;
//     }
// 
//     public Language setRightToLeft(boolean rightToLeft) {
//         this.rightToLeft = rightToLeft;
//         return this;
//     }
// }


import android.content.Context;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.widget.Toast;
import org.apache.commons.lang3.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import info.puzz.a10000sentences.Preferences;
import info.puzz.a10000sentences.R;
import info.puzz.a10000sentences.models.Language;
import lombok.Getter;
package info.puzz.a10000sentences.utils;





public class Speech {

    private static final String TAG = Speech.class.getSimpleName();

    private TextToSpeech tts;

    private final Context context;
    private final Locale locale;
    private final boolean languageFound;
    private final boolean enabled;

    private final Set<Integer> toastMessagesShown = new HashSet<>();

    @Getter
    private boolean initialized = false;

    public Speech(Context context, Language language) {
        this.context = context;
        this.locale = findLocale(language);
        this.languageFound = locale != null;
// Path: 10000sentencesapp/src/main/java/info/puzz/a10000sentences/Preferences.java
// public final class Preferences {
//     public static final String USE_TTS = "use_tts";
//     public static final String MAX_REPEAT = "max_repeat";
//     public static final String MIN_CORRECT_WORDS = "min_correct_words";
// 
//     public static boolean isUseTTS(Context context) {
//         return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(USE_TTS, true);
//     }
// 
//     public static int getMaxRepeat(Context context) {
//         int dflt = 10;
//         int repeat = NumberUtils.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString(MAX_REPEAT, String.valueOf(dflt)), dflt);
//         if (repeat < 1) {
//             return 3;
//         }
//         return repeat;
//     }
// 
//     public static int getMinCorrectWords(Context context) {
//         int dflt = 90;
//         int mcw = NumberUtils.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString(MIN_CORRECT_WORDS, String.valueOf(dflt)), dflt);
//         if (mcw < 0) {
//             return 0;
//         }
//         if (mcw > 100) {
//             return 100;
//         }
//         return mcw;
//     }
// }
// 
// Path: 10000sentencesapp/src/main/java/info/puzz/a10000sentences/models/Language.java
// @Table(name = "language")
// public class Language extends Model {
//     @Column(name = "language_id", index = true, unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
//     public String languageId;
// 
//     @Column(name = "family")
//     public String family;
// 
//     @Column(name = "name")
//     public String name;
// 
//     @Column(name = "native_name")
//     public String nativeName;
// 
//     @Column(name = "rtl")
//     boolean rightToLeft;
// 
//     public String formatNativeName(String delimiter) {
//         String[] parts;
//         if (nativeName.contains(",")) {
//             parts = StringUtils.capitalize(nativeName.split(",")[0]).split("\\s+");
//         } else {
//             parts = StringUtils.capitalize(nativeName).split("\\s+");
//         }
//         return StringUtils.join(parts, delimiter);
//     }
// 
//     public String formatNameAndNativeName() {
//         if (StringUtils.equals(name, nativeName)) {
//             return name;
//         }
//         return name + " / " + nativeName;
//     }
// 
//     public String getLanguageId() {
//         return languageId;
//     }
// 
//     public Language setLanguageId(String languageId) {
//         this.languageId = languageId;
//         return this;
//     }
// 
//     public String getFamily() {
//         return family;
//     }
// 
//     public Language setFamily(String family) {
//         this.family = family;
//         return this;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public Language setName(String name) {
//         this.name = name;
//         return this;
//     }
// 
//     public String getNativeName() {
//         return nativeName;
//     }
// 
//     public Language setNativeName(String nativeName) {
//         this.nativeName = nativeName;
//         return this;
//     }
// 
//     public boolean isRightToLeft() {
//         return rightToLeft;
//     }
// 
//     public Language setRightToLeft(boolean rightToLeft) {
//         this.rightToLeft = rightToLeft;
//         return this;
//     }
// }


// Path: 10000sentencesapp/src/main/java/info/puzz/a10000sentences/utils/Speech.java
import android.content.Context;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.widget.Toast;
import org.apache.commons.lang3.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import info.puzz.a10000sentences.Preferences;
import info.puzz.a10000sentences.R;
import info.puzz.a10000sentences.models.Language;
import lombok.Getter;

package info.puzz.a10000sentences.utils;





public class Speech {

    private static final String TAG = Speech.class.getSimpleName();

    private TextToSpeech tts;

    private final Context context;
    private final Locale locale;
    private final boolean languageFound;
    private final boolean enabled;

    private final Set<Integer> toastMessagesShown = new HashSet<>();

    @Getter
    private boolean initialized = false;

    public Speech(Context context, Language language) {
        this.context = context;
        this.locale = findLocale(language);
        this.languageFound = locale != null;
        this.enabled = Preferences.isUseTTS(context);