wallpapers hooks: fix (maybe)

- close outputstream > release dedicated memory
- delete temp file on exit
- improved check"compress" for null
This commit is contained in:
Erik Kiznov
2022-08-26 23:12:48 +05:00
parent d9f03a5d0e
commit f96baa58ac
@@ -73,8 +73,10 @@ public class WallpapersHooks {
inputStream.close();
File outPutFile = File.createTempFile("wallpaper_temp","image");
outPutFile.deleteOnExit();
FileOutputStream outputStream = new FileOutputStream(outPutFile);
selectedBitmap.compress(Bitmap.CompressFormat.PNG, 85 , outputStream);
outputStream.close();
return outPutFile;
} catch (Exception e) {
@@ -93,16 +95,20 @@ public class WallpapersHooks {
}
public static String getWallpaperUrl() {
if (getWallpaperFile().exists() && eligibleWallpaperFile(getWallpaperFile()))
if (compress(getWallpaperFile()) == null) {
var file = getWallpaperFile();
if (file.exists() && eligibleWallpaperFile(file)) {
var compressed = compress(file);
if (compressed == null) {
return "default";
} else if (getBoolValue("compresswp", true)){
return compress(getWallpaperFile()).getAbsolutePath();
} else if (getBoolValue("compresswp", true) && compressed != null) {
return compressed.getAbsolutePath();
} else {
return getWallpaperFile().getAbsolutePath();
return file.getAbsolutePath();
}
else
return "default";
}
return "default";
}
public static Drawable getWallpaper() {