-keepparameternames
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes Deprecated
-keepattributes SourceFile
-keepattributes LineNumberTable
-keepattributes *Annotation*
-keepattributes EnclosingMethod

# Keep all PSPDFKit/Nutrient classes. We don't want to obfuscate them as it can cause issues if not managed properly.
-keep class com.pspdfkit.** { *; }
-keep class io.nutrient.** { *; }
-dontwarn com.pspdfkit.**
-dontwarn io.nutrient.**
-dontwarn com.pspdfkit.media.MediaGalleryView*
-dontwarn com.pspdfkit.internal.**

# Preserve all .class method names.
-keepclassmembernames class * {
    java.lang.Class class$(java.lang.String);
    java.lang.Class class$(java.lang.String, boolean);
}

# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames,includedescriptorclasses class * {
    native <methods>;
}

# Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers,allowoptimization enum * {
    public static **[] values(); public static ** valueOf(java.lang.String);
}

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Explicitly preseve all parcelation members.
-keepclassmembers class * implements android.os.Parcelable {
    public static final ** CREATOR;
}
-keep class kotlinx.parcelize.** { *; }

# Preseve classes/methods/fields with keep annotation
#noinspection ShrinkerUnresolvedReference
-keep class androidx.annotation.Keep
-keep @androidx.annotation.Keep class * {*;}
-keepclasseswithmembers class * {
    @androidx.annotation.Keep <methods>;
}
-keepclasseswithmembers class * {
    @androidx.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
    @androidx.annotation.Keep <init>(...);
}

# Optional third party libraries. You can safely ignore those warnings.
-dontwarn com.squareup.**
-dontwarn com.facebook.device.yearclass.**
-dontwarn sun.misc.**

# OkHttp is used by Nutrient Instant and needs these lines for proper operation.
-keep class okhttp3.** { *; }
-dontwarn okio.**
-dontwarn okhttp3.**

# Java 8 is used by PSPDFKit. You can safely ignore those warnings produced by lambdas.
-dontwarn java.lang.invoke.**

# Error prone annotations are compile only.
-dontwarn com.google.errorprone.annotations.*

# These names must be present, since PSPDFKit uses them for availability checking of third-party dependencies.
# This list needs to be kept in sync with the list of dependencies inside PSPDFKit.java.
-keep class androidx.palette.graphics.Palette
-keep class androidx.gridlayout.widget.GridLayout
-keep class androidx.cardview.widget.CardView

# Prevent JSON class obfuscation to avoid NoSuchMethodError at runtime
-keep class org.json.** { *; }
