use of org.thoughtcrime.securesms.wallpaper.ChatWallpaper in project Signal-Android by WhisperSystems.
the class WallpaperValues method setWallpaper.
public void setWallpaper(@NonNull Context context, @Nullable ChatWallpaper wallpaper) {
Wallpaper currentWallpaper = getCurrentWallpaper();
Uri currentUri = null;
if (currentWallpaper != null && currentWallpaper.hasFile()) {
currentUri = Uri.parse(currentWallpaper.getFile().getUri());
}
if (wallpaper != null) {
putBlob(KEY_WALLPAPER, wallpaper.serialize().toByteArray());
} else {
getStore().beginWrite().remove(KEY_WALLPAPER).apply();
}
if (currentUri != null) {
WallpaperStorage.onWallpaperDeselected(context, currentUri);
}
}
use of org.thoughtcrime.securesms.wallpaper.ChatWallpaper in project Signal-Android by WhisperSystems.
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 WallpaperCropActivity method setWallpaper.
private void setWallpaper() {
EditorModel model = imageEditor.getModel();
Point size = new Point(imageEditor.getWidth(), imageEditor.getHeight());
AlertDialog dialog = SimpleProgressDialog.show(this);
viewModel.render(this, model, size, new AsynchronousCallback.MainThread<ChatWallpaper, WallpaperCropViewModel.Error>() {
@Override
public void onComplete(@Nullable ChatWallpaper result) {
dialog.dismiss();
setResult(RESULT_OK, new Intent().putExtra(ChatWallpaperPreviewActivity.EXTRA_CHAT_WALLPAPER, result));
finish();
}
@Override
public void onError(@Nullable WallpaperCropViewModel.Error error) {
dialog.dismiss();
Toast.makeText(WallpaperCropActivity.this, R.string.WallpaperCropActivity__error_setting_wallpaper, Toast.LENGTH_SHORT).show();
}
}.toWorkerCallback());
}
use of org.thoughtcrime.securesms.wallpaper.ChatWallpaper in project Signal-Android by signalapp.
the class WallpaperValues method setWallpaper.
public void setWallpaper(@NonNull Context context, @Nullable ChatWallpaper wallpaper) {
Wallpaper currentWallpaper = getCurrentWallpaper();
Uri currentUri = null;
if (currentWallpaper != null && currentWallpaper.hasFile()) {
currentUri = Uri.parse(currentWallpaper.getFile().getUri());
}
if (wallpaper != null) {
putBlob(KEY_WALLPAPER, wallpaper.serialize().toByteArray());
} else {
getStore().beginWrite().remove(KEY_WALLPAPER).apply();
}
if (currentUri != null) {
WallpaperStorage.onWallpaperDeselected(context, currentUri);
}
}
use of org.thoughtcrime.securesms.wallpaper.ChatWallpaper in project Signal-Android by signalapp.
the class WallpaperCropActivity method setWallpaper.
private void setWallpaper() {
EditorModel model = imageEditor.getModel();
Point size = new Point(imageEditor.getWidth(), imageEditor.getHeight());
AlertDialog dialog = SimpleProgressDialog.show(this);
viewModel.render(this, model, size, new AsynchronousCallback.MainThread<ChatWallpaper, WallpaperCropViewModel.Error>() {
@Override
public void onComplete(@Nullable ChatWallpaper result) {
dialog.dismiss();
setResult(RESULT_OK, new Intent().putExtra(ChatWallpaperPreviewActivity.EXTRA_CHAT_WALLPAPER, result));
finish();
}
@Override
public void onError(@Nullable WallpaperCropViewModel.Error error) {
dialog.dismiss();
Toast.makeText(WallpaperCropActivity.this, R.string.WallpaperCropActivity__error_setting_wallpaper, Toast.LENGTH_SHORT).show();
}
}.toWorkerCallback());
}
Aggregations