Skip to content

Commit

Permalink
Play Source
Browse files Browse the repository at this point in the history
* Properly configure OkHttpClient.
  • Loading branch information
rumboalla committed Apr 4, 2024
1 parent bf00403 commit 74b1557
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
36 changes: 19 additions & 17 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,37 @@ android {

dependencies {

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.activity:activity-compose:1.8.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
implementation("androidx.compose.material3:material3:1.2.1")
implementation("androidx.compose.ui:ui:1.6.4")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.navigation:navigation-compose:2.7.7")
implementation("androidx.navigation:navigation-runtime-ktx:2.7.7")
implementation("androidx.tv:tv-foundation:1.0.0-alpha10")
implementation("androidx.compose.material3:material3:1.2.1")
implementation("androidx.work:work-runtime-ktx:2.9.0")
implementation("io.insert-koin:koin-android:3.4.2")
implementation("io.insert-koin:koin-androidx-compose:3.4.2")
implementation("com.squareup.retrofit2:retrofit:2.10.0")
implementation("com.squareup.retrofit2:converter-gson:2.10.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
implementation("com.google.code.gson:gson:2.10.1")
implementation("io.coil-kt:coil-compose:2.4.0")
implementation("com.github.rumboalla.KryptoPrefs:kryptoprefs:0.4.3")
implementation("com.github.rumboalla.KryptoPrefs:kryptoprefs-gson:0.4.3")
implementation("org.jsoup:jsoup:1.16.1")
implementation("com.github.rumboalla.KryptoPrefs:kryptoprefs:0.4.3")
implementation("com.github.topjohnwu.libsu:core:5.2.1")
implementation("io.github.g00fy2:versioncompare:1.5.0")
implementation("com.gitlab.AuroraOSS:gplayapi:3.2.10")
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
implementation("com.squareup.retrofit2:converter-gson:2.11.0")
implementation("com.squareup.retrofit2:retrofit:2.11.0")
implementation("io.coil-kt:coil-compose:2.6.0")
implementation("io.github.g00fy2:versioncompare:1.5.0")
implementation("io.insert-koin:koin-android:3.5.3")
implementation("io.insert-koin:koin-androidx-compose:3.5.3")
implementation("org.jsoup:jsoup:1.16.1")

testImplementation("junit:junit:4.13.2")

androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.4")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test.ext:junit:1.1.5")

debugImplementation("androidx.compose.ui:ui-tooling:1.6.4")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.4")
debugImplementation("androidx.compose.ui:ui-tooling:1.6.4")

}
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/apkupdater/di/MainModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ val mainModule = module {

single { InstallLog() }

single { PlayHttpClient() }
single { PlayHttpClient(get()) }

viewModel { MainViewModel(get(), get()) }

Expand Down
11 changes: 7 additions & 4 deletions app/src/main/kotlin/com/apkupdater/util/play/PlayHttpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.aurora.gplayapi.data.models.PlayResponse
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import okhttp3.Cache
import okhttp3.Credentials
import okhttp3.Headers.Companion.toHeaders
import okhttp3.HttpUrl
Expand All @@ -21,7 +22,9 @@ import java.net.Proxy
import java.util.concurrent.TimeUnit


class PlayHttpClient : IProxyHttpClient {
class PlayHttpClient(
cache: Cache
) : IProxyHttpClient {

companion object {
private const val POST = "POST"
Expand All @@ -30,14 +33,15 @@ class PlayHttpClient : IProxyHttpClient {

private val _responseCode = MutableStateFlow(100)
override val responseCode: StateFlow<Int> get() = _responseCode.asStateFlow()
private var okHttpClient = OkHttpClient()
private val okHttpClientBuilder = OkHttpClient().newBuilder()
.connectTimeout(25, TimeUnit.SECONDS)
.readTimeout(25, TimeUnit.SECONDS)
.writeTimeout(25, TimeUnit.SECONDS)
.retryOnConnectionFailure(true)
.followRedirects(true)
.followSslRedirects(true)
.cache(cache)
private var okHttpClient = okHttpClientBuilder.build()

override fun setProxy(proxyInfo: ProxyInfo): PlayHttpClient {
val proxy = Proxy(
Expand All @@ -62,8 +66,7 @@ class PlayHttpClient : IProxyHttpClient {
}
}

okHttpClientBuilder.proxy(proxy)
okHttpClient = okHttpClientBuilder.build()
okHttpClient = okHttpClientBuilder.proxy(proxy).build()
return this
}

Expand Down

0 comments on commit 74b1557

Please sign in to comment.