Browse Source

Android: fix crash when opening settings on pre-7 devices

master
Beqa Gozalishvili 2 years ago
parent
commit
d3ae703e60

+ 5
- 3
android/src/com/reecedunn/espeak/TtsSettingsActivity.java View File

protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);


PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setStorageDeviceProtected ();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setStorageDeviceProtected ();
}
// Migrate old eyes-free settings to the new settings: // Migrate old eyes-free settings to the new settings:


storageContext = EspeakApp.getStorageContext(); storageContext = EspeakApp.getStorageContext();

+ 6
- 2
android/src/com/reecedunn/espeak/preference/SeekBarPreference.java View File

import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.DialogPreference; import android.preference.DialogPreference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.AttributeSet; import android.util.AttributeSet;
String text = Integer.toString(mProgress); String text = Integer.toString(mProgress);
callChangeListener(text); callChangeListener(text);
if (shouldCommit()) { if (shouldCommit()) {
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setStorageDeviceProtected ();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setStorageDeviceProtected ();
}
SharedPreferences.Editor editor = getEditor(); SharedPreferences.Editor editor = getEditor();
editor.putString(getKey(), text); editor.putString(getKey(), text);
editor.commit(); editor.commit();

+ 6
- 2
android/src/com/reecedunn/espeak/preference/SpeakPunctuationPreference.java View File

import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.DialogPreference; import android.preference.DialogPreference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Editable; import android.text.Editable;
onDataChanged(level, characters); onDataChanged(level, characters);


if (shouldCommit()) { if (shouldCommit()) {
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setStorageDeviceProtected();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setStorageDeviceProtected ();
}
SharedPreferences.Editor editor = getEditor(); SharedPreferences.Editor editor = getEditor();
if (editor != null) { if (editor != null) {
editor.putString(VoiceSettings.PREF_PUNCTUATION_CHARACTERS, characters); editor.putString(VoiceSettings.PREF_PUNCTUATION_CHARACTERS, characters);

+ 6
- 2
android/src/com/reecedunn/espeak/preference/VoiceVariantPreference.java View File

import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.DialogPreference; import android.preference.DialogPreference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.AttributeSet; import android.util.AttributeSet;
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
onDataChanged(); onDataChanged();
if (shouldCommit()) { if (shouldCommit()) {
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setStorageDeviceProtected();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setStorageDeviceProtected ();
}
SharedPreferences.Editor editor = getEditor(); SharedPreferences.Editor editor = getEditor();
if (editor != null) { if (editor != null) {
VoiceVariant variant = variants[mCategoryIndex][mVariantIndex].getVariant(); VoiceVariant variant = variants[mCategoryIndex][mVariantIndex].getVariant();

Loading…
Cancel
Save