use of org.thoughtcrime.securesms.database.StickerDatabase.StickerPackRecordReader in project Signal-Android by WhisperSystems.
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.StickerDatabase.StickerPackRecordReader in project Signal-Android by WhisperSystems.
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));
}
use of org.thoughtcrime.securesms.database.StickerDatabase.StickerPackRecordReader 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.StickerDatabase.StickerPackRecordReader 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