mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Add a cache for GIFs.
This commit is contained in:
committed by
Cody Henthorne
parent
8e020c05f6
commit
c84de8fa60
@@ -39,6 +39,7 @@ import org.thoughtcrime.securesms.util.EarlyMessageCache;
|
||||
import org.thoughtcrime.securesms.util.FrameRateTracker;
|
||||
import org.thoughtcrime.securesms.util.Hex;
|
||||
import org.thoughtcrime.securesms.util.IasKeyStore;
|
||||
import org.thoughtcrime.securesms.video.exo.GiphyMp4Cache;
|
||||
import org.whispersystems.signalservice.api.KeyBackupService;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
@@ -98,6 +99,7 @@ public class ApplicationDependencies {
|
||||
private static volatile TextSecureSessionStore sessionStore;
|
||||
private static volatile TextSecurePreKeyStore preKeyStore;
|
||||
private static volatile SignalSenderKeyStore senderKeyStore;
|
||||
private static volatile GiphyMp4Cache giphyMp4Cache;
|
||||
|
||||
@MainThread
|
||||
public static void init(@NonNull Application application, @NonNull Provider provider) {
|
||||
@@ -551,6 +553,17 @@ public class ApplicationDependencies {
|
||||
return senderKeyStore;
|
||||
}
|
||||
|
||||
public static @NonNull GiphyMp4Cache getGiphyMp4Cache() {
|
||||
if (giphyMp4Cache == null) {
|
||||
synchronized (LOCK) {
|
||||
if (giphyMp4Cache == null) {
|
||||
giphyMp4Cache = provider.provideGiphyMp4Cache();
|
||||
}
|
||||
}
|
||||
}
|
||||
return giphyMp4Cache;
|
||||
}
|
||||
|
||||
public interface Provider {
|
||||
@NonNull GroupsV2Operations provideGroupsV2Operations();
|
||||
@NonNull SignalServiceAccountManager provideSignalServiceAccountManager();
|
||||
@@ -583,5 +596,6 @@ public class ApplicationDependencies {
|
||||
@NonNull TextSecureSessionStore provideSessionStore();
|
||||
@NonNull TextSecurePreKeyStore providePreKeyStore();
|
||||
@NonNull SignalSenderKeyStore provideSenderKeyStore();
|
||||
@NonNull GiphyMp4Cache provideGiphyMp4Cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ import org.thoughtcrime.securesms.util.EarlyMessageCache;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.FrameRateTracker;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.state.SignalProtocolStore;
|
||||
import org.thoughtcrime.securesms.video.exo.GiphyMp4Cache;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
@@ -284,6 +284,11 @@ public class ApplicationDependencyProvider implements ApplicationDependencies.Pr
|
||||
return new SignalSenderKeyStore(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull GiphyMp4Cache provideGiphyMp4Cache() {
|
||||
return new GiphyMp4Cache(ByteUnit.MEGABYTES.toBytes(16));
|
||||
}
|
||||
|
||||
private @NonNull WebSocketFactory provideWebSocketFactory(@NonNull SignalWebSocketHealthMonitor healthMonitor) {
|
||||
return new WebSocketFactory() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user