# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

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

# 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

# =============================================================================
# Capacitor Plugin Protection Rules
# =============================================================================

# Keep Capacitor Plugin annotations & your plugin facade
-keep class com.getcapacitor.** { *; }
-keep @com.getcapacitor.annotation.CapacitorPlugin class * { *; }
-keepclassmembers class ** {
  @com.getcapacitor.annotation.PluginMethod *;
}

# Keep DailyNotification plugin classes
-keep class com.timesafari.dailynotification.** { *; }

# Keep plugin method names and signatures
-keepclassmembers class com.timesafari.dailynotification.DailyNotificationPlugin {
  public *;
}

# Keep all plugin manager classes
-keep class com.timesafari.dailynotification.*Manager { *; }
-keep class com.timesafari.dailynotification.*Storage { *; }
-keep class com.timesafari.dailynotification.*Receiver { *; }

# Keep Room database classes
-keep class com.timesafari.dailynotification.storage.** { *; }
-keep class com.timesafari.dailynotification.database.** { *; }

# Keep error handling classes
-keep class com.timesafari.dailynotification.*Error* { *; }
-keep class com.timesafari.dailynotification.*Exception* { *; }

# Keep JWT and ETag managers
-keep class com.timesafari.dailynotification.*JWT* { *; }
-keep class com.timesafari.dailynotification.*ETag* { *; }

# Keep performance and optimization classes
-keep class com.timesafari.dailynotification.*Performance* { *; }
-keep class com.timesafari.dailynotification.*Optimizer* { *; }

# Keep rolling window and TTL classes
-keep class com.timesafari.dailynotification.*Rolling* { *; }
-keep class com.timesafari.dailynotification.*TTL* { *; }

# Keep exact alarm and reboot recovery classes
-keep class com.timesafari.dailynotification.*Exact* { *; }
-keep class com.timesafari.dailynotification.*Reboot* { *; }
-keep class com.timesafari.dailynotification.*Recovery* { *; }

# Keep enhanced fetcher classes
-keep class com.timesafari.dailynotification.*Enhanced* { *; }
-keep class com.timesafari.dailynotification.*Fetcher* { *; }

# Keep migration classes
-keep class com.timesafari.dailynotification.*Migration* { *; }

# Keep channel manager
-keep class com.timesafari.dailynotification.ChannelManager { *; }

# Keep permission manager
-keep class com.timesafari.dailynotification.PermissionManager { *; }

# Keep scheduler classes
-keep class com.timesafari.dailynotification.*Scheduler* { *; }

# =============================================================================
# Android System Classes
# =============================================================================

# Keep Android system classes used by the plugin
-keep class android.app.AlarmManager { *; }
-keep class android.app.NotificationManager { *; }
-keep class android.app.NotificationChannel { *; }
-keep class android.app.PendingIntent { *; }
-keep class androidx.work.WorkManager { *; }
-keep class androidx.core.app.NotificationCompat { *; }

# Keep broadcast receiver classes
-keep class android.content.BroadcastReceiver { *; }
-keep class android.content.Intent { *; }

# =============================================================================
# Room Database Protection
# =============================================================================

# Keep Room database classes
-keep class androidx.room.** { *; }
-keep class * extends androidx.room.RoomDatabase { *; }
-keep @androidx.room.Entity class * { *; }
-keep @androidx.room.Dao class * { *; }

# Keep Room database migrations
-keep class * extends androidx.room.migration.Migration { *; }

# =============================================================================
# Gson Protection (if used)
# =============================================================================

# Keep Gson classes if used for JSON serialization
-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 { *; }

# =============================================================================
# Debugging and Development
# =============================================================================

# Keep debug information for development builds
-keepattributes SourceFile,LineNumberTable
-keepattributes Signature
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes EnclosingMethod

# Keep generic signatures for reflection
-keepattributes Signature

# Keep annotations
-keepattributes *Annotation*

# =============================================================================
# Network and Security
# =============================================================================

# Keep network-related classes
-keep class java.net.** { *; }
-keep class javax.net.ssl.** { *; }

# Keep security-related classes
-keep class java.security.** { *; }
-keep class javax.crypto.** { *; }
