From 920864daa2beb1ad54385ac5e68f41c49e3b40f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lenclud?= Date: Sat, 30 Sep 2023 14:10:36 +0200 Subject: [PATCH] Disable reading mode when incognito Also disable share, print, and add to home as security feature. Close Slion/Fulguris#369. --- .../browser/lightning/browser/MenuWebPage.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/browser/MenuWebPage.kt b/app/src/main/java/acr/browser/lightning/browser/MenuWebPage.kt index 8ec2053b8..46cdb6555 100644 --- a/app/src/main/java/acr/browser/lightning/browser/MenuWebPage.kt +++ b/app/src/main/java/acr/browser/lightning/browser/MenuWebPage.kt @@ -53,7 +53,6 @@ class MenuWebPage : PopupWindow { val abpUserRules: AbpUserRules var iBinding: MenuWebPageBinding - var iIsIncognito = false constructor(layoutInflater: LayoutInflater, aBinding: MenuWebPageBinding = MenuWebPage.inflate(layoutInflater)) : super(aBinding.root, WRAP_CONTENT, WRAP_CONTENT, true) { @@ -73,17 +72,6 @@ class MenuWebPage : PopupWindow { // See: https://stackoverflow.com/questions/46872634/close-popupwindow-upon-tapping-outside-or-back-button setBackgroundDrawable(ColorDrawable()) - // Hide incognito menu item if we are already incognito - /* - iIsIncognito = (aBinding.root.context as BrowserActivity).isIncognito() - if (iIsIncognito) { - aBinding.menuItemIncognito.isVisible = false - // No sessions in incognito mode - aBinding.menuItemSessions.isVisible = false - } - - */ - //val radius: Float = getResources().getDimension(R.dimen.default_corner_radius) //32dp //iBinding.layoutMenuItems.layoutTransition.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING) @@ -176,6 +164,17 @@ class MenuWebPage : PopupWindow { } } + if ((iBinding.root.context as? BrowserActivity)?.isIncognito() == true) { + // Incognito only works for that activity + // So no reader mode as it starts another activity + // TODO: We could try get reading mode working in incognito by creating another activity which starts in the same process I guess + iBinding.menuItemReaderMode.isVisible = false + // Also hide share and print as security feature when in incognito mode + iBinding.menuItemShare.isVisible = false + iBinding.menuItemPrint.isVisible = false + iBinding.menuItemAddToHome.isVisible = false + } + scrollToStart() }