# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\YangZhe\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

# 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 *;
#}

-keep class com.yfree.BuildConfig { *; }

-keep class * extends com.yfree.models.YModel{*;}
-keep class * extends com.yfree.utils.YJSDelegate{*;}

-dontwarn com.yfree.models.**
-keep class com.yfree.models.** {*;}

-keep @com.yfree.annotation.YKeep class * {
    *;
}

-dontwarn net.tsz.afinal.**
-keep class net.tsz.afinal.** {*;}

-dontwarn com.sun.crypto.provider.**
-keep class com.sun.crypto.provider.** {*;}

-keep class com.tencent.** {*;}

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

-keepclassmembers class android.support.graphics.drawable.VectorDrawableCompat$* {
   void set*(***);
   *** get*();
}

-ignorewarnings
-dontpreverify
-dontoptimize
-optimizationpasses 5
-renamesourcefileattribute SourceFile
-keepattributes *Annotation*,Signature,EnclosingMethod,InnerClasses,SourceFile,LineNumberTable
-keep class * implements java.io.Serializable {
    public static final long serialVersionUID;
}

# ==================== 基础保留规则 ====================
# 保留自定义View、四大组件、Application等不被混淆
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.view.View
-keep public class * extends android.preference.Preference

# 保留support/v7包下的构造方法
-keepclassmembers class * extends android.support.v7.** {
    <init>(...);
}

# ==================== 反射相关保留 ====================
# 保留被反射使用的类、方法、字段
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

# 保留R文件中的资源ID
-keep class **.R$* {
    *;
}

# ==================== 序列化相关 ====================
# 保留Serializable实现类的全部内容（避免序列化失败）
-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();
}

# 保留Parcelable实现类
-keep class * implements android.os.Parcelable {
    public static final android.os.Parcelable$Creator *;
}

# ==================== 注解保留 ====================
-keepattributes *Annotation*
-keepclasseswithmembers class * {
    @androidx.annotation.Keep <methods>;
}
-keep @androidx.annotation.Keep class * {*;}

# ==================== 枚举保留 ====================
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# ==================== Native方法保留 ====================
-keepclasseswithmembernames class * {
    native <methods>;
}

# ==================== 常见第三方库规则 ====================
# ---- Retrofit (网络请求) ----
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions

# ---- OkHttp (网络请求) ----
-dontwarn okhttp3.**
-keep class okhttp3.** { *; }
-dontwarn okio.**

# ---- Gson (JSON解析) ----
-keep class com.google.gson.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers class * {
    @com.google.gson.annotations.SerializedName <fields>;
}

# ---- Glide (图片加载) ----
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class com.bumptech.glide.** { *; }
-dontwarn com.bumptech.glide.**

# ---- EventBus (事件总线) ----
-keepclassmembers class * {
    @org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }

# ---- GreenDao (数据库) ----
-keep class org.greenrobot.greendao.** { *; }
-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
    public static java.lang.String TABLENAME;
}
-keep class **$Properties

# ---- RxJava / RxAndroid ----
-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
    long producerIndex;
    long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
    rx.internal.util.atomic.LinkedQueueNode producerNode;
}

# ---- 友盟统计 ----
-keepclassmembers class * {
    public <init> (org.json.JSONObject);
}
-keep class com.umeng.** { *; }

# ---- 微信支付 ----
-keep class com.tencent.mm.opensdk.** { *; }

# ---- 支付宝支付 ----
-keep class com.alipay.** { *; }

# ==================== 优化选项 ====================
# 优化代码，允许访问并修改有修饰符的类和类的成员
-allowaccessmodification
# 优化时允许加载并访问类
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
# 优化时允许对方法进行重载
-overloadaggressively

# ==================== 混淆选项 ====================
# 混淆时不会产生形形色色的类名
-dontusemixedcaseclassnames
# 不跳过非公共库的类
-dontskipnonpubliclibraryclasses
# 打印混淆细节
-verbose
# 混淆时应用微调
-dontpreverify

# ==================== 日志保留（调试用，发布时可删除） ====================
-keepattributes SourceFile,LineNumberTable

# 保留内联函数展开所需的所有内部方法
-keepclassmembers,allowoptimization class * {
    *** inlined$***(...);
}

# 保留所有 inline 函数不被优化掉（适用于 R8）
-keep,allowoptimization class * {
    *** inlined$*(...);
}

# 保留 Kotlin reified 运行时支持
-keep,allowoptimization class kotlin.jvm.internal.Intrinsics {
    static *** reifiedOperationMarker(...);
}

# 保留必要的元数据属性
-keepattributes *Annotation*, InnerClasses, Signature, EnclosingMethod

# 保留所有内联函数的内部结构（防止被优化成普通函数）
-keepclassmembers,allowoptimization class ** {
    *** inlined$***(...);
}

# 保留 Kotlin 元数据中的内联信息
-keepattributes *Annotation*, Signature, EnclosingMethod, InnerClasses

# 通用 Kotlin 内联支持规则（来自 Kotlin 官方建议）
-keepclassmembers class ** {
    *** inlined$***(...);
}
-keepclassmembers,allowoptimization class ** {
    *** inlined$***(...);
}
-keep,allowoptimization class kotlin.jvm.internal.Intrinsics {
    static *** reifiedOperationMarker(...);
}

# 保留所有 ViewBinding 子类（不混淆类名）
-keep class * implements androidx.viewbinding.ViewBinding {
    public static *** inflate(...);
}

-keep class kotlin.Metadata
-keep class com.yfree.extensions.** { *; }
-keep class * implements androidx.viewbinding.ViewBinding { *; }