Reset pre-1.6.6 custom sound preferences

This is required because newer versions of the application use the
preference value differently. Custom sounds are now copied to the
application's data folder, rather than being referenced externally.
This commit is contained in:
Trevor Slocum 2023-04-01 14:45:41 -07:00
parent df5b24076a
commit 8f5db6906a
3 changed files with 24 additions and 2 deletions

View File

@ -1,4 +1,5 @@
1.6.7:
- Reset pre-1.6.6 custom sound preferences to accommodate storage permission changes
- Fix PendingIntents missing FLAG_MUTABLE on Android 13+
- Fix selecting custom sounds on Android 13+

View File

@ -258,7 +258,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
editDuration
.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(android.widget.TextView v,
public boolean onEditorAction(TextView v,
int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
RelativeLayout layEditDuration = findViewById(R.id.layEditDuration);

View File

@ -1265,6 +1265,27 @@ public class MeditationAssistant extends Application {
// Do nothing
}
// Upgrade custom sound preferences.
String[] soundPrefs = {"start", "interval", "finish", "bell"};
for (String prefKey : soundPrefs) {
try {
// Check for custom sound.
String soundPref = getPrefs().getString("pref_meditation_sound_" + prefKey, "");
if (!soundPref.equals("custom")) {
continue;
}
// Check for legacy custom sound path.
String customSound = getPrefs().getString("pref_meditation_sound_" + prefKey + "_custom", "");
if (customSound.contains("/")) {
// Reset to default sound.
getPrefs().edit().putString("pref_meditation_sound_" + prefKey, "").putString("pref_meditation_sound_" + prefKey + "_custom", "").apply();
}
} catch (Exception e) {
// Do nothing.
}
}
db = DatabaseHandler.getInstance(getApplicationContext());
setDailyReminder(getApplicationContext());
@ -2654,7 +2675,7 @@ public class MeditationAssistant extends Application {
}
public static boolean hasPermission(Context context, String permission) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
return true;
}
return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;