Skip to content

Commit 1ad5b5a

Browse files
authored
Merge pull request #200 from usetrmnl/fix/issue-199-enable-r8-minification
feat: Enable R8 minification and resource shrinking (#199)
2 parents 691bf93 + 08375a8 commit 1ad5b5a

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ android {
8181
buildConfigField("Boolean", "USE_FAKE_API", "false")
8282

8383
// Enables code shrinking, obfuscation, and optimization
84-
isMinifyEnabled = false
84+
// See https://github.com/usetrmnl/trmnl-android/issues/199
85+
isMinifyEnabled = true
8586

8687
// Enables resource shrinking, which is performed by the Android Gradle plugin.
87-
isShrinkResources = false
88+
// See https://github.com/usetrmnl/trmnl-android/issues/199
89+
isShrinkResources = true
8890

8991
proguardFiles(
9092
getDefaultProguardFile("proguard-android-optimize.txt"),

app/src/main/java/ink/trmnl/android/di/NetworkModule.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.squareup.moshi.Moshi
1010
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
1111
import dagger.Module
1212
import dagger.Provides
13+
import ink.trmnl.android.BuildConfig
1314
import ink.trmnl.android.network.TrmnlApiService
1415
import okhttp3.Cache
1516
import okhttp3.OkHttpClient
@@ -30,11 +31,6 @@ object NetworkModule {
3031
fun provideOkHttpClient(
3132
@ApplicationContext context: Context,
3233
): OkHttpClient {
33-
val loggingInterceptor =
34-
HttpLoggingInterceptor().apply {
35-
level = HttpLoggingInterceptor.Level.BODY
36-
}
37-
3834
// Create cache directory
3935
val cacheDir = File(context.cacheDir, "http_cache")
4036
val cache = Cache(cacheDir, CACHE_SIZE)
@@ -59,8 +55,16 @@ object NetworkModule {
5955
.header("User-Agent", userAgent)
6056
.build()
6157
chain.proceed(request)
62-
}.addInterceptor(loggingInterceptor)
63-
.cache(cache)
58+
}.apply {
59+
// Only add logging interceptor in debug builds
60+
if (BuildConfig.DEBUG) {
61+
addInterceptor(
62+
HttpLoggingInterceptor().apply {
63+
level = HttpLoggingInterceptor.Level.BODY
64+
},
65+
)
66+
}
67+
}.cache(cache)
6468
.connectTimeout(30, TimeUnit.SECONDS)
6569
.readTimeout(30, TimeUnit.SECONDS)
6670
.writeTimeout(30, TimeUnit.SECONDS)

0 commit comments

Comments
 (0)