From 9c94305ba54a3d5e3dbeef6ae0b1a7045c9b1cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Sat, 15 Dec 2018 21:29:57 +0100 Subject: [PATCH] Configure code shrinking (#200) --- app/build.gradle | 14 ++--- app/proguard-rules.pro | 53 +++++++++++-------- .../ui/modules/about/AboutFragment.kt | 21 ++++---- app/src/main/res/layout/header_exam.xml | 2 +- .../main/res/layout/header_grade_summary.xml | 2 +- .../res/layout/item_attendance_summary.xml | 2 +- 6 files changed, 54 insertions(+), 40 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8a965c5e6..b4cc74bab 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -44,7 +44,9 @@ android { buildTypes { release { buildConfigField "boolean", "CRASHLYTICS_ENABLED", "true" - minifyEnabled false + minifyEnabled true + useProguard false + shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } @@ -79,7 +81,7 @@ configurations.all { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - implementation('com.github.wulkanowy:api:88e279e') { exclude module: "threetenbp" } + implementation('com.github.wulkanowy:api:afc019d0b7') { exclude module: "threetenbp" } implementation "androidx.legacy:legacy-support-v4:1.0.0" implementation "androidx.appcompat:appcompat:1.0.2" @@ -124,10 +126,10 @@ dependencies { testImplementation "org.mockito:mockito-inline:2.23.4" testImplementation 'org.threeten:threetenbp:1.3.8' - androidTestImplementation 'androidx.test:core:1.0.0' - androidTestImplementation 'androidx.test:runner:1.1.0' - androidTestImplementation 'androidx.test.ext:junit:1.0.0' - androidTestImplementation "org.mockito:mockito-android:2.23.4" + androidTestImplementation 'androidx.test:core:1.1.0' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.ext:junit:1.1.0' + androidTestImplementation 'org.mockito:mockito-android:2.23.4' androidTestImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 34ed4c38c..7dbda6e8b 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,25 +1,36 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in C:\Users\RicomenPL\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html +# Optimizations +-optimizationpasses 5 +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontskipnonpubliclibraryclassmembers +-dontpreverify +-allowaccessmodification +-repackageclasses '' +-verbose -# Add any project specific keep options here: -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} +#Config for anallitycs +-keepattributes *Annotation* +-keepattributes SourceFile,LineNumberTable +-renamesourcefileattribute SourceFile +-keep class com.crashlytics.** {*;} +-keep public class * extends java.lang.Exception +-dontwarn com.crashlytics.** -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile +#Config for OkHttp +-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase +-dontwarn org.codehaus.mojo.animal_sniffer.* +-dontwarn okhttp3.internal.platform.ConscryptPlatform +-dontwarn javax.annotation.** + + +#Config for ReactiveNetwork +-dontwarn com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork +-dontwarn io.reactivex.functions.Function +-dontwarn rx.internal.util.** +-dontwarn sun.misc.Unsafe + +#Confi for API +-keep class io.github.wulkanowy.api.** {*;} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt index b7c57cbce..ddc4e11fa 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt @@ -32,16 +32,17 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView { presenter.onAttachView(this) return Bundle().apply { putSerializable("data", LibsBuilder() - .withAboutAppName(getString(R.string.app_name)) - .withAboutVersionShown(true) - .withAboutIconShown(true) - .withLicenseShown(true) - .withAboutSpecial1(getString(R.string.about_source_code)) - .withAboutSpecial2(getString(R.string.about_feedback)) - .withCheckCachedDetection(false) - .withExcludedLibraries("fastadapter", "AndroidIconics", "gson", - "Jsoup", "Retrofit", "okio", "OkHttp") - .withOnExtraListener { presenter.onExtraSelect(it) }) + .withAboutAppName(getString(R.string.app_name)) + .withAboutVersionShown(true) + .withAboutIconShown(true) + .withLicenseShown(true) + .withAboutSpecial1(getString(R.string.about_source_code)) + .withAboutSpecial2(getString(R.string.about_feedback)) + .withFields(R.string::class.java.fields) + .withCheckCachedDetection(false) + .withExcludedLibraries("fastadapter", "AndroidIconics", "gson", + "Jsoup", "Retrofit", "okio", "OkHttp") + .withOnExtraListener { presenter.onExtraSelect(it) }) }.let { fragmentCompat.onCreateView(inflater.context, inflater, container, savedInstanceState, it) } diff --git a/app/src/main/res/layout/header_exam.xml b/app/src/main/res/layout/header_exam.xml index 7345a4b9f..25faab325 100644 --- a/app/src/main/res/layout/header_exam.xml +++ b/app/src/main/res/layout/header_exam.xml @@ -2,7 +2,7 @@