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

This commit is contained in:
Beqa Gozalishvili
2022-11-02 14:57:52 +04:00
parent 94e0024bf4
commit d3ae703e60
4 changed files with 23 additions and 9 deletions
@@ -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();