mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
be backwards compatible
also fix bug: save custom wallpaper in different file per account
This commit is contained in:
@@ -56,10 +56,19 @@ 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());
|
||||
|
||||
String backgroundImagePath = Prefs.getBackgroundImagePath(this, accountId);
|
||||
backgroundImagePath = Prefs.getBackgroundImagePath(this, accountId);
|
||||
if(backgroundImagePath.isEmpty()){
|
||||
setDefaultLayoutBackgroundImage();
|
||||
}else {
|
||||
@@ -97,7 +106,7 @@ public class ChatBackgroundActivity extends PassphraseRequiredActionBarActivity
|
||||
Thread thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
String destination = context.getFilesDir().getAbsolutePath() + "/background";
|
||||
String destination = context.getFilesDir().getAbsolutePath() + "/background."+ accountId;
|
||||
Prefs.setBackgroundImagePath(context, accountId, destination);
|
||||
scaleAndSaveImage(context, destination);
|
||||
}
|
||||
|
||||
@@ -306,6 +306,14 @@ 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