mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
move migration to ApplicationContext
This commit is contained in:
@@ -43,6 +43,7 @@ import org.thoughtcrime.securesms.notifications.NotificationCenter;
|
||||
import org.thoughtcrime.securesms.util.AndroidSignalProtocolLogger;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.SignalProtocolLoggerProvider;
|
||||
|
||||
import java.io.File;
|
||||
@@ -127,6 +128,15 @@ public class ApplicationContext extends MultiDexApplication {
|
||||
|
||||
rpc.start();
|
||||
|
||||
// [Migration 04/10/23] Chat Background: migrate old custom background
|
||||
String backgroundImagePath = Prefs.getStringPreference(this, "pref_chat_background", "");
|
||||
if (!backgroundImagePath.isEmpty()) {
|
||||
for (int accId : dcAccounts.getAll()) {
|
||||
Prefs.setBackgroundImagePath(this, accId, backgroundImagePath);
|
||||
}
|
||||
Prefs.setStringPreference(this, "pref_chat_background", "");
|
||||
}
|
||||
|
||||
// set translations before starting I/O to avoid sending untranslated MDNs (issue #2288)
|
||||
DcHelper.setStockTranslations(this);
|
||||
|
||||
|
||||
@@ -56,19 +56,10 @@ public class ChatBackgroundActivity extends PassphraseRequiredActionBarActivity
|
||||
preview = findViewById(R.id.preview);
|
||||
accountId = DcHelper.getContext(getApplicationContext()).getAccountId();
|
||||
|
||||
// try to be backwards compatible so users don't lose already set background
|
||||
String backgroundImagePath = Prefs.getBackgroundImagePathLegacy(this);
|
||||
if (!backgroundImagePath.isEmpty()) {
|
||||
for (int accId : DcHelper.getAccounts(getApplicationContext()).getAll()) {
|
||||
Prefs.setBackgroundImagePath(this, accId, backgroundImagePath);
|
||||
}
|
||||
Prefs.setBackgroundImagePathLegacy(this, "");
|
||||
}
|
||||
|
||||
defaultButton.setOnClickListener(new DefaultClickListener());
|
||||
galleryButton.setOnClickListener(new GalleryClickListener());
|
||||
|
||||
backgroundImagePath = Prefs.getBackgroundImagePath(this, accountId);
|
||||
String backgroundImagePath = Prefs.getBackgroundImagePath(this, accountId);
|
||||
if(backgroundImagePath.isEmpty()){
|
||||
setDefaultLayoutBackgroundImage();
|
||||
}else {
|
||||
|
||||
@@ -306,14 +306,6 @@ public class Prefs {
|
||||
|
||||
// misc.
|
||||
|
||||
public static String getBackgroundImagePathLegacy(Context context) {
|
||||
return getStringPreference(context, BACKGROUND_PREF, "");
|
||||
}
|
||||
|
||||
public static void setBackgroundImagePathLegacy(Context context, String path) {
|
||||
setStringPreference(context, BACKGROUND_PREF, path);
|
||||
}
|
||||
|
||||
public static String getBackgroundImagePath(Context context, int accountId) {
|
||||
return getStringPreference(context, BACKGROUND_PREF+accountId, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user