use of org.thoughtcrime.securesms.wallpaper.ChatWallpaper in project Signal-Android by signalapp.
the class WallpaperCropRepository method setWallPaper.
@WorkerThread
@NonNull
ChatWallpaper setWallPaper(byte[] bytes) throws IOException {
try (InputStream inputStream = new ByteArrayInputStream(bytes)) {
ChatWallpaper wallpaper = WallpaperStorage.save(context, inputStream, "webp");
if (recipientId != null) {
Log.i(TAG, "Setting image wallpaper for " + recipientId);
SignalDatabase.recipients().setWallpaper(recipientId, wallpaper);
} else {
Log.i(TAG, "Setting image wallpaper for default");
SignalStore.wallpaper().setWallpaper(context, wallpaper);
}
return wallpaper;
}
}
use of org.thoughtcrime.securesms.wallpaper.ChatWallpaper in project Signal-Android by WhisperSystems.
the class WallpaperCropViewModel method render.
void render(@NonNull Context context, @NonNull EditorModel model, @NonNull Point size, @NonNull AsynchronousCallback.WorkerThread<ChatWallpaper, Error> callback) {
SignalExecutors.BOUNDED.execute(() -> {
Bitmap bitmap = model.render(context, size);
try {
ChatWallpaper chatWallpaper = repository.setWallPaper(BitmapUtil.toWebPByteArray(bitmap));
callback.onComplete(chatWallpaper);
} catch (IOException e) {
Log.w(TAG, e);
callback.onError(Error.SAVING);
} finally {
bitmap.recycle();
}
});
}
use of org.thoughtcrime.securesms.wallpaper.ChatWallpaper in project Signal-Android by signalapp.
the class WallpaperCropViewModel method render.
void render(@NonNull Context context, @NonNull EditorModel model, @NonNull Point size, @NonNull AsynchronousCallback.WorkerThread<ChatWallpaper, Error> callback) {
SignalExecutors.BOUNDED.execute(() -> {
Bitmap bitmap = model.render(context, size);
try {
ChatWallpaper chatWallpaper = repository.setWallPaper(BitmapUtil.toWebPByteArray(bitmap));
callback.onComplete(chatWallpaper);
} catch (IOException e) {
Log.w(TAG, e);
callback.onError(Error.SAVING);
} finally {
bitmap.recycle();
}
});
}
Aggregations