use of org.thoughtcrime.securesms.components.emoji.EmojiPageModel in project Signal-Android by WhisperSystems.
the class DownloadLatestEmojiDataJob method onRun.
@Override
protected void onRun() throws Exception {
EmojiFiles.Version version = EmojiFiles.Version.readVersion(context);
int localVersion = (version != null) ? version.getVersion() : 0;
int serverVersion = EmojiRemote.getVersion();
String bucket;
if (targetVersion == null) {
ScreenDensity density = ScreenDensity.get(context);
bucket = getDesiredRemoteBucketForDensity(density);
} else {
bucket = targetVersion.getDensity();
}
Log.d(TAG, "LocalVersion: " + localVersion + ", ServerVersion: " + serverVersion + ", Bucket: " + bucket);
if (bucket == null) {
Log.d(TAG, "This device has too low a display density to download remote emoji.");
} else if (localVersion == serverVersion) {
Log.d(TAG, "Already have latest emoji data. Skipping.");
} else if (serverVersion > localVersion) {
Log.d(TAG, "New server data detected. Starting download...");
if (targetVersion == null || targetVersion.getVersion() != serverVersion) {
targetVersion = new EmojiFiles.Version(serverVersion, UUID.randomUUID(), bucket);
}
if (isCanceled()) {
Log.w(TAG, "Job was cancelled prior to downloading json.");
return;
}
EmojiData emojiData = downloadJson(context, targetVersion);
List<String> supportedDensities = emojiData.getDensities();
String format = emojiData.getFormat();
List<String> imagePaths = Stream.of(emojiData.getDataPages()).map(EmojiPageModel::getSpriteUri).map(Uri::getLastPathSegment).toList();
String density = resolveDensity(supportedDensities, targetVersion.getDensity());
targetVersion = new EmojiFiles.Version(targetVersion.getVersion(), targetVersion.getUuid(), density);
if (isCanceled()) {
Log.w(TAG, "Job was cancelled after downloading json.");
return;
}
downloadImages(context, targetVersion, imagePaths, format, this::isCanceled);
if (isCanceled()) {
Log.w(TAG, "Job was cancelled during or after downloading images.");
return;
}
clearOldEmojiData(context, targetVersion);
markComplete(targetVersion);
EmojiSource.refresh();
JumboEmoji.updateCurrentVersion(context);
} else {
Log.d(TAG, "Server has an older version than we do. Skipping.");
}
}
use of org.thoughtcrime.securesms.components.emoji.EmojiPageModel in project Signal-Android by signalapp.
the class DownloadLatestEmojiDataJob method onRun.
@Override
protected void onRun() throws Exception {
EmojiFiles.Version version = EmojiFiles.Version.readVersion(context);
int localVersion = (version != null) ? version.getVersion() : 0;
int serverVersion = EmojiRemote.getVersion();
String bucket;
if (targetVersion == null) {
ScreenDensity density = ScreenDensity.get(context);
bucket = getDesiredRemoteBucketForDensity(density);
} else {
bucket = targetVersion.getDensity();
}
Log.d(TAG, "LocalVersion: " + localVersion + ", ServerVersion: " + serverVersion + ", Bucket: " + bucket);
if (bucket == null) {
Log.d(TAG, "This device has too low a display density to download remote emoji.");
} else if (localVersion == serverVersion) {
Log.d(TAG, "Already have latest emoji data. Skipping.");
} else if (serverVersion > localVersion) {
Log.d(TAG, "New server data detected. Starting download...");
if (targetVersion == null || targetVersion.getVersion() != serverVersion) {
targetVersion = new EmojiFiles.Version(serverVersion, UUID.randomUUID(), bucket);
}
if (isCanceled()) {
Log.w(TAG, "Job was cancelled prior to downloading json.");
return;
}
EmojiData emojiData = downloadJson(context, targetVersion);
List<String> supportedDensities = emojiData.getDensities();
String format = emojiData.getFormat();
List<String> imagePaths = Stream.of(emojiData.getDataPages()).map(EmojiPageModel::getSpriteUri).map(Uri::getLastPathSegment).toList();
String density = resolveDensity(supportedDensities, targetVersion.getDensity());
targetVersion = new EmojiFiles.Version(targetVersion.getVersion(), targetVersion.getUuid(), density);
if (isCanceled()) {
Log.w(TAG, "Job was cancelled after downloading json.");
return;
}
downloadImages(context, targetVersion, imagePaths, format, this::isCanceled);
if (isCanceled()) {
Log.w(TAG, "Job was cancelled during or after downloading images.");
return;
}
clearOldEmojiData(context, targetVersion);
markComplete(targetVersion);
EmojiSource.refresh();
JumboEmoji.updateCurrentVersion(context);
} else {
Log.d(TAG, "Server has an older version than we do. Skipping.");
}
}
Aggregations