For #11903: Enforce private theme in custom tabs
parent
b1a8c0f483
commit
ed334788e8
|
@ -511,11 +511,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun updateThemeForSession(session: Session) {
|
||||
val sessionMode = BrowsingMode.fromBoolean(session.private)
|
||||
browsingModeManager.mode = sessionMode
|
||||
}
|
||||
|
||||
override fun attachBaseContext(base: Context) {
|
||||
StrictMode.allowThreadDiskReads().resetPoliciesAfter {
|
||||
super.attachBaseContext(base)
|
||||
|
|
|
@ -78,6 +78,7 @@ import org.mozilla.fenix.HomeActivity
|
|||
import org.mozilla.fenix.IntentReceiverActivity
|
||||
import org.mozilla.fenix.NavGraphDirections
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
||||
import org.mozilla.fenix.browser.readermode.DefaultReaderModeController
|
||||
import org.mozilla.fenix.components.FenixSnackbar
|
||||
import org.mozilla.fenix.components.FindInPageIntegration
|
||||
|
@ -690,7 +691,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
|||
|
||||
@CallSuper
|
||||
override fun onSessionSelected(session: Session) {
|
||||
(activity as HomeActivity).updateThemeForSession(session)
|
||||
updateThemeForSession(session)
|
||||
if (!browserInitialized) {
|
||||
// Initializing a new coroutineScope to avoid ConcurrentModificationException in ObserverRegistry
|
||||
// This will be removed when ObserverRegistry is deprecated by browser-state.
|
||||
|
@ -720,6 +721,8 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
|||
components.useCases.sessionUseCases.reload()
|
||||
}
|
||||
hideToolbar()
|
||||
|
||||
getSessionById()?.let { updateThemeForSession(it) }
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
|
@ -872,6 +875,14 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the activity normal/private theme to match the current session.
|
||||
*/
|
||||
private fun updateThemeForSession(session: Session) {
|
||||
val sessionMode = BrowsingMode.fromBoolean(session.private)
|
||||
(activity as HomeActivity).browsingModeManager.mode = sessionMode
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current session.
|
||||
*/
|
||||
|
@ -997,6 +1008,5 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
|||
private const val REQUEST_CODE_DOWNLOAD_PERMISSIONS = 1
|
||||
private const val REQUEST_CODE_PROMPT_PERMISSIONS = 2
|
||||
private const val REQUEST_CODE_APP_PERMISSIONS = 3
|
||||
private const val SNACKBAR_ELEVATION = 80f
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import mozilla.components.feature.tab.collections.TabCollection
|
|||
import mozilla.components.feature.tabs.WindowFeature
|
||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.addons.runIfFragmentIsAttached
|
||||
import org.mozilla.fenix.components.FenixSnackbar
|
||||
|
@ -40,8 +39,8 @@ import org.mozilla.fenix.ext.components
|
|||
import org.mozilla.fenix.ext.nav
|
||||
import org.mozilla.fenix.ext.navigateSafe
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.ext.resetPoliciesAfter
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.shortcut.FirstTimePwaObserver
|
||||
import org.mozilla.fenix.trackingprotection.TrackingProtectionOverlay
|
||||
|
||||
|
@ -178,9 +177,6 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
getSessionById()?.let {
|
||||
(activity as HomeActivity).updateThemeForSession(it)
|
||||
}
|
||||
requireComponents.core.tabCollectionStorage.register(collectionStorageObserver, this)
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class CustomTabsIntegration(
|
|||
)
|
||||
}
|
||||
|
||||
toolbar.background = getDrawable(activity, R.drawable.toolbar_background_private)
|
||||
toolbar.background = getDrawable(activity, R.drawable.toolbar_background)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<gradient
|
||||
android:angle="45"
|
||||
android:startColor="@color/toolbar_start_gradient_private_theme"
|
||||
android:centerColor="@color/toolbar_center_gradient_private_theme"
|
||||
android:endColor="@color/toolbar_end_gradient_private_theme"
|
||||
android:type="linear" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:gravity="top">
|
||||
<shape android:shape="rectangle">
|
||||
<size android:height="1dp" />
|
||||
<solid android:color="@color/neutral_faded_private_theme" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
Loading…
Reference in New Issue