Skip to content

Commit c247d90

Browse files
committed
Add @keep annotations and update ProGuard rules
Added @keep annotations to WebUIView and its event posting methods to prevent them from being removed or obfuscated by ProGuard. Updated proguard-rules.pro to include -dontobfuscate for easier debugging and to ensure reflection-based code works as expected.
1 parent f07f35c commit c247d90

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

app/proguard-rules.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
-verbose
22
-optimizationpasses 5
33

4+
-dontobfuscate
5+
46
-dontwarn org.conscrypt.**
57
-dontwarn kotlinx.serialization.**
68

@@ -48,7 +50,6 @@
4850
-dontwarn javax.lang.model.util.Types
4951
-dontwarn javax.tools.Diagnostic$Kind
5052

51-
5253
# MMRL:webui reflection
5354
-keep class com.dergoogler.mmrl.platform.model.ModId { *; }
5455
-keep class com.dergoogler.mmrl.webui.interfaces.** { *; }

webui/src/main/kotlin/com/dergoogler/mmrl/webui/view/WebUIView.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.view.ViewGroup.LayoutParams
99
import android.webkit.WebMessage
1010
import android.webkit.WebView
1111
import android.widget.FrameLayout
12+
import androidx.annotation.Keep
1213
import androidx.annotation.UiThread
1314
import androidx.compose.ui.graphics.toArgb
1415
import androidx.core.graphics.drawable.toDrawable
@@ -50,6 +51,7 @@ import kotlin.text.replace
5051
* @property interfaces A set of JavaScript interface names that have been added to this WebView.
5152
* @property console A [WXConsole] implementation for logging messages from the WebView.
5253
*/
54+
@Keep
5355
@SuppressLint("ViewConstructor")
5456
open class WebUIView(
5557
protected val options: WebUIOptions,
@@ -159,6 +161,7 @@ open class WebUIView(
159161
*
160162
* @param type The type of the event.
161163
*/
164+
@Keep
162165
fun postWXEvent(type: WXEvent) =
163166
postWXEvent<WXEvent, Nothing>(type, null)
164167

@@ -167,6 +170,7 @@ open class WebUIView(
167170
*
168171
* @param type The type of the event.
169172
*/
173+
@Keep
170174
fun postWXEvent(type: String) =
171175
postWXEvent<String, Nothing>(type, null)
172176

@@ -177,6 +181,7 @@ open class WebUIView(
177181
* @param data The data to be sent with the event.
178182
* @param D The type of the data.
179183
*/
184+
@Keep
180185
fun <D : Any?> postWXEvent(type: WXEvent, data: D?) =
181186
postWXEvent<WXEvent, D>(type, data)
182187

@@ -187,6 +192,7 @@ open class WebUIView(
187192
* @param data The data to be sent with the event.
188193
* @param D The type of the data.
189194
*/
195+
@Keep
190196
fun <D : Any?> postWXEvent(type: String, data: D?) =
191197
postWXEvent<String, D>(type, data)
192198

@@ -199,6 +205,7 @@ open class WebUIView(
199205
* @param T The type of the event type.
200206
* @param D The type of the data.
201207
*/
208+
@Keep
202209
fun <T, D : Any?> postWXEvent(type: T, data: D?) =
203210
postWXEvent<T, D?>(WXEventHandler<T, D?>(type, data))
204211

@@ -213,6 +220,7 @@ open class WebUIView(
213220
* @param T The type of the event type.
214221
* @param D The type of the data.
215222
*/
223+
@Keep
216224
fun <T, D : Any?> postWXEvent(event: WXEventHandler<T, D?>) {
217225
val activity = context.findActivity()
218226
if (activity == null) {

0 commit comments

Comments
 (0)