mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Rewrite the AppDependencies system.
This commit is contained in:
committed by
Cody Henthorne
parent
a0131bf39b
commit
b6a4e1f145
@@ -43,7 +43,7 @@ import androidx.media3.ui.PlayerView;
|
||||
|
||||
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.mediapreview.MediaPreviewPlayerControlView;
|
||||
import org.thoughtcrime.securesms.mms.VideoSlide;
|
||||
|
||||
@@ -149,7 +149,7 @@ public class VideoPlayer extends FrameLayout {
|
||||
|
||||
public void setVideoSource(@NonNull VideoSlide videoSource, boolean autoplay, String poolTag, long clipStartMs, long clipEndMs) {
|
||||
if (exoPlayer == null) {
|
||||
exoPlayer = ApplicationDependencies.getExoPlayerPool().require(poolTag);
|
||||
exoPlayer = AppDependencies.getExoPlayerPool().require(poolTag);
|
||||
exoPlayer.addListener(exoPlayerListener);
|
||||
exoPlayer.addListener(playerListener);
|
||||
exoView.setPlayer(exoPlayer);
|
||||
@@ -263,7 +263,7 @@ public class VideoPlayer extends FrameLayout {
|
||||
exoPlayer.removeListener(playerListener);
|
||||
exoPlayer.removeListener(exoPlayerListener);
|
||||
|
||||
ApplicationDependencies.getExoPlayerPool().pool(exoPlayer);
|
||||
AppDependencies.getExoPlayerPool().pool(exoPlayer);
|
||||
this.exoPlayer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import androidx.media3.datasource.DataSource;
|
||||
import androidx.media3.datasource.DataSpec;
|
||||
import androidx.media3.datasource.TransferListener;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.net.ChunkedDataFetcher;
|
||||
|
||||
import java.io.EOFException;
|
||||
@@ -63,8 +63,8 @@ class ChunkedDataSource implements DataSource {
|
||||
// Exoplayer sometimes interrupts the thread
|
||||
}
|
||||
|
||||
Context context = ApplicationDependencies.getApplication();
|
||||
GiphyMp4Cache cache = ApplicationDependencies.getGiphyMp4Cache();
|
||||
Context context = AppDependencies.getApplication();
|
||||
GiphyMp4Cache cache = AppDependencies.getGiphyMp4Cache();
|
||||
|
||||
cacheEntry = cache.read(context, dataSpec.uri);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import androidx.media3.exoplayer.mediacodec.MediaCodecUtil
|
||||
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
|
||||
import androidx.media3.exoplayer.source.MediaSource
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.net.ContentProxySelector
|
||||
import org.thoughtcrime.securesms.util.AppForegroundObserver
|
||||
import org.thoughtcrime.securesms.util.DeviceProperties
|
||||
@@ -23,12 +23,12 @@ import kotlin.time.Duration.Companion.seconds
|
||||
@OptIn(markerClass = [UnstableApi::class])
|
||||
class SimpleExoPlayerPool(context: Context) : ExoPlayerPool<ExoPlayer>(MAXIMUM_RESERVED_PLAYERS) {
|
||||
private val context: Context = context.applicationContext
|
||||
private val okHttpClient = ApplicationDependencies.getOkHttpClient().newBuilder().proxySelector(ContentProxySelector()).build()
|
||||
private val dataSourceFactory: DataSource.Factory = SignalDataSource.Factory(ApplicationDependencies.getApplication(), okHttpClient, null)
|
||||
private val okHttpClient = AppDependencies.okHttpClient.newBuilder().proxySelector(ContentProxySelector()).build()
|
||||
private val dataSourceFactory: DataSource.Factory = SignalDataSource.Factory(AppDependencies.application, okHttpClient, null)
|
||||
private val mediaSourceFactory: MediaSource.Factory = DefaultMediaSourceFactory(dataSourceFactory)
|
||||
|
||||
init {
|
||||
ApplicationDependencies.getAppForegroundObserver().addListener(this)
|
||||
AppDependencies.appForegroundObserver.addListener(this)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ class SimpleExoPlayerPool(context: Context) : ExoPlayerPool<ExoPlayer>(MAXIMUM_R
|
||||
return maxInstances
|
||||
}
|
||||
|
||||
return if (DeviceProperties.isLowMemoryDevice(ApplicationDependencies.getApplication())) {
|
||||
return if (DeviceProperties.isLowMemoryDevice(AppDependencies.application)) {
|
||||
MAXIMUM_SUPPORTED_PLAYBACK_PRE_23_LOW_MEM
|
||||
} else {
|
||||
MAXIMUM_SUPPORTED_PLAYBACK_PRE_23
|
||||
|
||||
Reference in New Issue
Block a user