From eef5bfbdb1247794ac55d0685d4c8dac09616ad3 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Wed, 9 Sep 2020 16:45:43 +0200 Subject: [PATCH] remove older migration code --- .../connect/ApplicationDcContext.java | 42 +------------------ .../thoughtcrime/securesms/util/Prefs.java | 1 - 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/src/org/thoughtcrime/securesms/connect/ApplicationDcContext.java b/src/org/thoughtcrime/securesms/connect/ApplicationDcContext.java index 2cd4dd2eb..cbee741a8 100644 --- a/src/org/thoughtcrime/securesms/connect/ApplicationDcContext.java +++ b/src/org/thoughtcrime/securesms/connect/ApplicationDcContext.java @@ -59,46 +59,8 @@ public class ApplicationDcContext extends DcContext { super("Android "+BuildConfig.VERSION_NAME, AccountManager.getInstance().getSelectedAccount(context).getAbsolutePath()); this.context = context; - // migration, can be removed after some versions (added 5/2020) - // (this will convert only for one account, but that is fine, multi-account is experimental anyway) - try { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - if(sharedPreferences.contains("pref_compression")) { - if (sharedPreferences.getString("pref_compression", "0").equals("1")) { - setConfigInt(DcHelper.CONFIG_MEDIA_QUALITY, DC_MEDIA_QUALITY_WORSE); - } - sharedPreferences.edit().remove("pref_compression").apply(); - } - } - catch(Exception e) { - Log.e(TAG, "cannot migrate pref_compression"); - } - // /migration - - // migration, can be removed after some versions (added 5/2020) - try { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - Set keys = sharedPreferences.getAll().keySet(); - for (String key : keys) { - if (key.startsWith(Prefs.CHAT_MUTED_UNTIL)) { - int id = Integer.parseInt(key.substring(Prefs.CHAT_MUTED_UNTIL.length())); - long mutedUntil = Prefs.getLongPreference(context, key, 0); - long remainingSeconds = (mutedUntil - System.currentTimeMillis()) / 1000; - if (remainingSeconds > 0) { - setChatMuteDuration(id, remainingSeconds); - Log.i(TAG, "Migrating sharedPref mutedUntil "+mutedUntil+" to duration "+remainingSeconds); - } else { - Log.i(TAG, "Not migrating sharedPref mutedUntil "+mutedUntil+" to duration "+remainingSeconds+"because it's negative"); - } - sharedPreferences.edit().remove(key).apply(); - } - } - } - catch(Exception e) { - Log.e(TAG, "cannot migrate mutedUntil"); - e.printStackTrace(); - } - // /migration + // if ui-based migrations are needed, this is a good place + // (see eg. https://github.com/deltachat/deltachat-android/pull/1618 for an example) new Thread(() -> { DcEventEmitter emitter = getEventEmitter(); diff --git a/src/org/thoughtcrime/securesms/util/Prefs.java b/src/org/thoughtcrime/securesms/util/Prefs.java index a76582dee..b679976f0 100644 --- a/src/org/thoughtcrime/securesms/util/Prefs.java +++ b/src/org/thoughtcrime/securesms/util/Prefs.java @@ -42,7 +42,6 @@ public class Prefs { private static final String CHAT_VIBRATE = "pref_chat_vibrate_"; // followed by chat-id private static final String NOTIFICATION_PREF = "pref_key_enable_notifications"; public static final String LED_COLOR_PREF = "pref_led_color"; - public static final String CHAT_MUTED_UNTIL = "pref_chat_muted_until_"; // followed by chat-id private static final String CHAT_RINGTONE = "pref_chat_ringtone_"; // followed by chat-id public static final String SCREEN_LOCK_TIMEOUT_INTERVAL_PREF = "pref_timeout_interval"; public static final String SCREEN_LOCK_TIMEOUT_PREF = "pref_timeout_passphrase";