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

@@ -44,9 +44,11 @@ public class TtsSettingsActivity extends PreferenceActivity {
protected void onCreate(Bundle 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:

storageContext = EspeakApp.getStorageContext();

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

@@ -20,6 +20,7 @@ package com.reecedunn.espeak.preference;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.DialogPreference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
@@ -115,8 +116,11 @@ public class SeekBarPreference extends DialogPreference implements SeekBar.OnSee
String text = Integer.toString(mProgress);
callChangeListener(text);
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();
editor.putString(getKey(), text);
editor.commit();

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

@@ -20,6 +20,7 @@ package com.reecedunn.espeak.preference;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.DialogPreference;
import android.preference.PreferenceManager;
import android.text.Editable;
@@ -130,8 +131,11 @@ public class SpeakPunctuationPreference extends DialogPreference {
onDataChanged(level, characters);

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();
if (editor != null) {
editor.putString(VoiceSettings.PREF_PUNCTUATION_CHARACTERS, characters);

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

@@ -21,6 +21,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.DialogPreference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
@@ -330,8 +331,11 @@ public class VoiceVariantPreference extends DialogPreference {
case DialogInterface.BUTTON_POSITIVE:
onDataChanged();
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();
if (editor != null) {
VoiceVariant variant = variants[mCategoryIndex][mVariantIndex].getVariant();

Loading…
Cancel
Save