From 8ce3a0d38b4862951eb1202b9a7ee4efb367fd7a Mon Sep 17 00:00:00 2001 From: Xor290 Date: Sat, 7 Nov 2026 16:32:48 +0100 Subject: [PATCH] chore: build V2 --- frontend-admin/app.json | 2 +- frontend-admin/plugins/withRecentsLogo.js | 73 ------------------- .../plugins/withRecentsProtection.js | 26 +++++++ 3 files changed, 27 insertions(+), 74 deletions(-) delete mode 100644 frontend-admin/plugins/withRecentsLogo.js create mode 100644 frontend-admin/plugins/withRecentsProtection.js diff --git a/frontend-admin/app.json b/frontend-admin/app.json index a38b560c..ad1fabf6 100644 --- a/frontend-admin/app.json +++ b/frontend-admin/app.json @@ -38,7 +38,7 @@ "expo-font", "expo-location", "expo-updates", - "./plugins/withRecentsLogo", + "./plugins/withRecentsProtection", [ "expo-build-properties", { diff --git a/frontend-admin/plugins/withRecentsLogo.js b/frontend-admin/plugins/withRecentsLogo.js deleted file mode 100644 index 5207f0e3..00000000 --- a/frontend-admin/plugins/withRecentsLogo.js +++ /dev/null @@ -1,73 +0,0 @@ -const { withMainActivity } = require("expo/config-plugins"); - -const IMPORTS = [ - "android.graphics.Color", - "android.view.Gravity", - "android.view.ViewGroup", - "android.widget.FrameLayout", - "android.widget.ImageView", -]; - -const MEMBERS = ` - // Affiche le logo à la place de l'écran dans la vue des apps ouvertes - private var recentsLogoOverlay: FrameLayout? = null - - private fun showRecentsLogo() { - if (recentsLogoOverlay != null) return - val logoSize = (160 * resources.displayMetrics.density).toInt() - val overlay = FrameLayout(this).apply { - setBackgroundColor(Color.BLACK) - addView( - ImageView(this@MainActivity).apply { setImageResource(R.mipmap.ic_launcher) }, - FrameLayout.LayoutParams(logoSize, logoSize, Gravity.CENTER) - ) - } - (window.decorView as ViewGroup).addView( - overlay, - ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) - ) - recentsLogoOverlay = overlay - } - - private fun hideRecentsLogo() { - recentsLogoOverlay?.let { (it.parent as? ViewGroup)?.removeView(it) } - recentsLogoOverlay = null - } - - override fun onUserLeaveHint() { - super.onUserLeaveHint() - showRecentsLogo() - } - - override fun onPause() { - showRecentsLogo() - super.onPause() - } - - override fun onResume() { - super.onResume() - hideRecentsLogo() - } -`; - -module.exports = (config) => - withMainActivity(config, (cfg) => { - let src = cfg.modResults.contents; - if (cfg.modResults.language !== "kt") { - throw new Error("withRecentsLogo: MainActivity Kotlin attendue"); - } - if (src.includes("recentsLogoOverlay")) return cfg; - - const classDecl = /class MainActivity\s*:\s*ReactActivity\(\)\s*\{/; - if (!classDecl.test(src)) { - throw new Error("withRecentsLogo: déclaration MainActivity introuvable"); - } - const missing = IMPORTS.filter((i) => !src.includes(`import ${i}\n`)) - .map((i) => `import ${i}`) - .join("\n"); - src = src.replace(/^(package .+\n)/m, `$1\n${missing}\n`); - src = src.replace(classDecl, (m) => `${m}${MEMBERS}`); - - cfg.modResults.contents = src; - return cfg; - }); diff --git a/frontend-admin/plugins/withRecentsProtection.js b/frontend-admin/plugins/withRecentsProtection.js new file mode 100644 index 00000000..594d06f6 --- /dev/null +++ b/frontend-admin/plugins/withRecentsProtection.js @@ -0,0 +1,26 @@ +const { withMainActivity } = require("expo/config-plugins"); + +const CALL = + "if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) setRecentsScreenshotEnabled(false)"; + +// Masque l'écran dans les apps récentes sans bloquer les captures (Android 13+). +module.exports = (config) => + withMainActivity(config, (cfg) => { + let src = cfg.modResults.contents; + if (cfg.modResults.language !== "kt") { + throw new Error("withRecentsProtection: MainActivity Kotlin attendue"); + } + if (src.includes("setRecentsScreenshotEnabled")) return cfg; + + const superOnCreate = /^(\s*)super\.onCreate\([^)]*\)[ \t]*;?[ \t]*$/m; + if (!superOnCreate.test(src)) { + throw new Error("withRecentsProtection: super.onCreate introuvable"); + } + src = src.replace(superOnCreate, (m, indent) => `${m}\n${indent}${CALL}`); + if (!src.includes("import android.os.Build\n")) { + src = src.replace(/^(package .+\n)/m, `$1\nimport android.os.Build\n`); + } + + cfg.modResults.contents = src; + return cfg; + });