use of org.thoughtcrime.securesms.database.model.StickerPackRecord in project Signal-Android by signalapp.
the class StickerManagementRepository method getStickerPacks.
void getStickerPacks(@NonNull Callback<PackResult> callback) {
SignalExecutors.SERIAL.execute(() -> {
List<StickerPackRecord> installedPacks = new ArrayList<>();
List<StickerPackRecord> availablePacks = new ArrayList<>();
List<StickerPackRecord> blessedPacks = new ArrayList<>();
try (StickerPackRecordReader reader = new StickerPackRecordReader(stickerDatabase.getAllStickerPacks())) {
StickerPackRecord record;
while ((record = reader.getNext()) != null) {
if (record.isInstalled()) {
installedPacks.add(record);
} else if (BlessedPacks.contains(record.getPackId())) {
blessedPacks.add(record);
} else {
availablePacks.add(record);
}
}
}
callback.onComplete(new PackResult(installedPacks, availablePacks, blessedPacks));
});
}
use of org.thoughtcrime.securesms.database.model.StickerPackRecord in project Signal-Android by signalapp.
the class StickerPackPreviewRepository method getManifestFromDatabase.
@WorkerThread
private Optional<StickerManifestResult> getManifestFromDatabase(@NonNull String packId) {
StickerPackRecord record = stickerDatabase.getStickerPack(packId);
if (record != null && record.isInstalled()) {
StickerManifest.Sticker cover = toSticker(record.getCover());
List<StickerManifest.Sticker> stickers = getStickersFromDatabase(packId);
StickerManifest manifest = new StickerManifest(record.getPackId(), record.getPackKey(), record.getTitle(), record.getAuthor(), Optional.of(cover), stickers);
return Optional.of(new StickerManifestResult(manifest, record.isInstalled()));
}
return Optional.absent();
}
use of org.thoughtcrime.securesms.database.model.StickerPackRecord in project Signal-Android by signalapp.
the class MultiDeviceStickerPackSyncJob method onRun.
@Override
protected void onRun() throws Exception {
if (!Recipient.self().isRegistered()) {
throw new NotPushRegisteredException();
}
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...");
return;
}
List<StickerPackOperationMessage> operations = new LinkedList<>();
try (StickerPackRecordReader reader = new StickerPackRecordReader(SignalDatabase.stickers().getInstalledStickerPacks())) {
StickerPackRecord pack;
while ((pack = reader.getNext()) != null) {
byte[] packIdBytes = Hex.fromStringCondensed(pack.getPackId());
byte[] packKeyBytes = Hex.fromStringCondensed(pack.getPackKey());
operations.add(new StickerPackOperationMessage(packIdBytes, packKeyBytes, StickerPackOperationMessage.Type.INSTALL));
}
}
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
messageSender.sendSyncMessage(SignalServiceSyncMessage.forStickerPackOperations(operations), UnidentifiedAccessUtil.getAccessForSync(context));
}
Aggregations