mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Rewrite the AppDependencies system.
This commit is contained in:
committed by
Cody Henthorne
parent
a0131bf39b
commit
b6a4e1f145
@@ -9,7 +9,7 @@ import androidx.annotation.Nullable;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.paging.PagedDataSource;
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.giph.model.GiphyImage;
|
||||
import org.thoughtcrime.securesms.giph.model.GiphyResponse;
|
||||
import org.thoughtcrime.securesms.net.ContentProxySelector;
|
||||
@@ -50,7 +50,7 @@ final class GiphyMp4PagedDataSource implements PagedDataSource<String, GiphyImag
|
||||
|
||||
GiphyMp4PagedDataSource(@Nullable String searchQuery) {
|
||||
this.searchString = Optional.ofNullable(searchQuery).map(String::trim).orElse("");
|
||||
this.client = ApplicationDependencies.getOkHttpClient().newBuilder().proxySelector(new ContentProxySelector()).build();
|
||||
this.client = AppDependencies.getOkHttpClient().newBuilder().proxySelector(new ContentProxySelector()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.thoughtcrime.securesms.giph.mp4;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.util.DeviceProperties;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -13,7 +13,7 @@ public final class GiphyMp4PlaybackPolicy {
|
||||
private GiphyMp4PlaybackPolicy() { }
|
||||
|
||||
public static boolean autoplay() {
|
||||
return !DeviceProperties.isLowMemoryDevice(ApplicationDependencies.getApplication());
|
||||
return !DeviceProperties.isLowMemoryDevice(AppDependencies.getApplication());
|
||||
}
|
||||
|
||||
public static int maxRepeatsOfSinglePlayback() {
|
||||
@@ -25,10 +25,10 @@ public final class GiphyMp4PlaybackPolicy {
|
||||
}
|
||||
|
||||
public static int maxSimultaneousPlaybackInSearchResults() {
|
||||
return ApplicationDependencies.getExoPlayerPool().getPoolStats().getMaxUnreserved();
|
||||
return AppDependencies.getExoPlayerPool().getPoolStats().getMaxUnreserved();
|
||||
}
|
||||
|
||||
public static int maxSimultaneousPlaybackInConversation() {
|
||||
return ApplicationDependencies.getExoPlayerPool().getPoolStats().getMaxUnreserved() / 3;
|
||||
return AppDependencies.getExoPlayerPool().getPoolStats().getMaxUnreserved() / 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import androidx.media3.ui.AspectRatioFrameLayout;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.util.Projection;
|
||||
import org.thoughtcrime.securesms.video.exo.ExoPlayerKt;
|
||||
|
||||
@@ -58,7 +58,7 @@ public final class GiphyMp4ProjectionPlayerHolder implements Player.Listener, De
|
||||
this.policyEnforcer = policyEnforcer;
|
||||
|
||||
if (player.getExoPlayer() == null) {
|
||||
ExoPlayer fromPool = ApplicationDependencies.getExoPlayerPool().get(TAG);
|
||||
ExoPlayer fromPool = AppDependencies.getExoPlayerPool().get(TAG);
|
||||
|
||||
if (fromPool == null) {
|
||||
Log.i(TAG, "Could not get exoplayer from pool.");
|
||||
@@ -84,7 +84,7 @@ public final class GiphyMp4ProjectionPlayerHolder implements Player.Listener, De
|
||||
player.stop();
|
||||
player.setExoPlayer(null);
|
||||
exoPlayer.removeListener(this);
|
||||
ApplicationDependencies.getExoPlayerPool().pool(exoPlayer);
|
||||
AppDependencies.getExoPlayerPool().pool(exoPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public final class GiphyMp4ProjectionPlayerHolder implements Player.Listener, De
|
||||
@Override
|
||||
public void onResume(@NonNull LifecycleOwner owner) {
|
||||
if (mediaItem != null) {
|
||||
ExoPlayer fromPool = ApplicationDependencies.getExoPlayerPool().get(TAG);
|
||||
ExoPlayer fromPool = AppDependencies.getExoPlayerPool().get(TAG);
|
||||
if (fromPool != null) {
|
||||
ExoPlayerKt.configureForGifPlayback(fromPool);
|
||||
fromPool.addListener(this);
|
||||
@@ -163,7 +163,7 @@ public final class GiphyMp4ProjectionPlayerHolder implements Player.Listener, De
|
||||
player.getExoPlayer().stop();
|
||||
player.getExoPlayer().clearMediaItems();
|
||||
player.getExoPlayer().removeListener(this);
|
||||
ApplicationDependencies.getExoPlayerPool().pool(player.getExoPlayer());
|
||||
AppDependencies.getExoPlayerPool().pool(player.getExoPlayer());
|
||||
player.setExoPlayer(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import androidx.annotation.WorkerThread;
|
||||
import androidx.core.util.Consumer;
|
||||
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.giph.model.GiphyImage;
|
||||
import org.thoughtcrime.securesms.net.ContentProxySelector;
|
||||
import org.thoughtcrime.securesms.net.StandardUserAgentInterceptor;
|
||||
@@ -69,7 +69,7 @@ final class GiphyMp4Repository {
|
||||
return BlobProvider.getInstance()
|
||||
.forData(response.body().byteStream(), response.body().contentLength())
|
||||
.withMimeType(mime)
|
||||
.createForSingleSessionOnDisk(ApplicationDependencies.getApplication());
|
||||
.createForSingleSessionOnDisk(AppDependencies.getApplication());
|
||||
} else {
|
||||
throw new IOException("Unexpected response code: " + response.code());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user