1
0
Fork 0

No issue - Autoformatting (#4715)

master
Emily Kager 2019-08-14 10:40:46 -04:00 committed by Colin Lee
parent b733fcdbd5
commit 1328d686aa
3 changed files with 71 additions and 33 deletions

View File

@ -61,16 +61,17 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
lateinit var browsingModeManager: BrowsingModeManager lateinit var browsingModeManager: BrowsingModeManager
private val onDestinationChangedListener = NavController.OnDestinationChangedListener { _, dest, _ -> private val onDestinationChangedListener =
val fragmentName = resources.getResourceEntryName(dest.id) NavController.OnDestinationChangedListener { _, dest, _ ->
Sentry.getContext().recordBreadcrumb( val fragmentName = resources.getResourceEntryName(dest.id)
BreadcrumbBuilder() Sentry.getContext().recordBreadcrumb(
.setCategory("DestinationChanged") BreadcrumbBuilder()
.setMessage("Changing to fragment $fragmentName, isCustomTab: $isCustomTab") .setCategory("DestinationChanged")
.setLevel(Breadcrumb.Level.INFO) .setMessage("Changing to fragment $fragmentName, isCustomTab: $isCustomTab")
.build() .setLevel(Breadcrumb.Level.INFO)
) .build()
} )
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -107,7 +108,11 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
val appBarConfiguration = AppBarConfiguration.Builder().build() val appBarConfiguration = AppBarConfiguration.Builder().build()
val navigationToolbar = findViewById<Toolbar>(R.id.navigationToolbar) val navigationToolbar = findViewById<Toolbar>(R.id.navigationToolbar)
setSupportActionBar(navigationToolbar) setSupportActionBar(navigationToolbar)
NavigationUI.setupWithNavController(navigationToolbar, navHost.navController, appBarConfiguration) NavigationUI.setupWithNavController(
navigationToolbar,
navHost.navController,
appBarConfiguration
)
navigationToolbar.setNavigationOnClickListener { navigationToolbar.setNavigationOnClickListener {
onBackPressed() onBackPressed()
} }
@ -148,7 +153,10 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
attrs: AttributeSet attrs: AttributeSet
): View? = ): View? =
when (name) { when (name) {
EngineView::class.java.name -> components.core.engine.createView(context, attrs).asView() EngineView::class.java.name -> components.core.engine.createView(
context,
attrs
).asView()
else -> super.onCreateView(parent, name, context, attrs) else -> super.onCreateView(parent, name, context, attrs)
} }
@ -180,8 +188,11 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
private fun handleOpenedFromExternalSourceIfNecessary(intent: Intent?) { private fun handleOpenedFromExternalSourceIfNecessary(intent: Intent?) {
if (intent?.extras?.getBoolean(OPEN_TO_BROWSER_AND_LOAD) == true) { if (intent?.extras?.getBoolean(OPEN_TO_BROWSER_AND_LOAD) == true) {
this.intent.putExtra(OPEN_TO_BROWSER_AND_LOAD, false) this.intent.putExtra(OPEN_TO_BROWSER_AND_LOAD, false)
openToBrowserAndLoad(intent.getStringExtra( openToBrowserAndLoad(
IntentReceiverActivity.SPEECH_PROCESSING), true, BrowserDirection.FromGlobal, forceSearch = true) intent.getStringExtra(
IntentReceiverActivity.SPEECH_PROCESSING
), true, BrowserDirection.FromGlobal, forceSearch = true
)
return return
} else if (intent?.extras?.getBoolean(OPEN_TO_SEARCH) == true) { } else if (intent?.extras?.getBoolean(OPEN_TO_SEARCH) == true) {
this.intent.putExtra(OPEN_TO_SEARCH, false) this.intent.putExtra(OPEN_TO_SEARCH, false)
@ -220,7 +231,11 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
sessionObserver = subscribeToSessions() sessionObserver = subscribeToSessions()
with(navHost.navController) { with(navHost.navController) {
if (currentDestination?.id == R.id.browserFragment || popBackStack(R.id.browserFragment, false)) return if (currentDestination?.id == R.id.browserFragment || popBackStack(
R.id.browserFragment,
false
)
) return
} }
@IdRes var fragmentId: Int? = null @IdRes var fragmentId: Int? = null

View File

@ -129,7 +129,9 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
bookmarked = false, bookmarked = false,
readerActive = getSessionById()?.readerMode ?: false, readerActive = getSessionById()?.readerMode ?: false,
bounceNeeded = false, bounceNeeded = false,
isAppLink = getSessionById()?.let { appLink.invoke(it.url).hasExternalApp() } ?: false isAppLink = getSessionById()?.let {
appLink.invoke(it.url).hasExternalApp()
} ?: false
) )
) )
) )
@ -160,7 +162,12 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
engineView = engineView, engineView = engineView,
currentSession = session, currentSession = session,
viewModel = viewModel, viewModel = viewModel,
getSupportUrl = { SupportUtils.getSumoURLForTopic(context!!, SupportUtils.SumoTopic.HELP) }, getSupportUrl = {
SupportUtils.getSumoURLForTopic(
context!!,
SupportUtils.SumoTopic.HELP
)
},
openInFenixIntent = Intent(context, IntentReceiverActivity::class.java).also { openInFenixIntent = Intent(context, IntentReceiverActivity::class.java).also {
it.action = Intent.ACTION_VIEW it.action = Intent.ACTION_VIEW
it.flags = Intent.FLAG_ACTIVITY_NEW_TASK it.flags = Intent.FLAG_ACTIVITY_NEW_TASK
@ -169,7 +176,8 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
bottomSheetBehavior = BottomSheetBehavior.from(nestedScrollQuickAction) bottomSheetBehavior = BottomSheetBehavior.from(nestedScrollQuickAction)
) )
browserInteractor = createBrowserToolbarViewInteractor(browserToolbarController, session) browserInteractor =
createBrowserToolbarViewInteractor(browserToolbarController, session)
browserToolbarView = BrowserToolbarView( browserToolbarView = BrowserToolbarView(
container = view.browserLayout, container = view.browserLayout,
@ -224,7 +232,10 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
sessionManager = sessionManager, sessionManager = sessionManager,
fragmentManager = childFragmentManager, fragmentManager = childFragmentManager,
sessionId = customTabSessionId, sessionId = customTabSessionId,
downloadManager = FetchDownloadManager(requireContext().applicationContext, DownloadService::class), downloadManager = FetchDownloadManager(
requireContext().applicationContext,
DownloadService::class
),
onNeedToRequestPermissions = { permissions -> onNeedToRequestPermissions = { permissions ->
requestPermissions(permissions, REQUEST_CODE_DOWNLOAD_PERMISSIONS) requestPermissions(permissions, REQUEST_CODE_DOWNLOAD_PERMISSIONS)
}), }),
@ -268,7 +279,8 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
view = view view = view
) )
val accentHighContrastColor = ThemeManager.resolveAttribute(R.attr.accentHighContrast, requireContext()) val accentHighContrastColor =
ThemeManager.resolveAttribute(R.attr.accentHighContrast, requireContext())
sitePermissionsFeature.set( sitePermissionsFeature.set(
feature = SitePermissionsFeature( feature = SitePermissionsFeature(
@ -299,7 +311,8 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
FenixSnackbar.make(view.rootView, Snackbar.LENGTH_SHORT) FenixSnackbar.make(view.rootView, Snackbar.LENGTH_SHORT)
.setText(getString(R.string.full_screen_notification)) .setText(getString(R.string.full_screen_notification))
.show() .show()
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE activity?.requestedOrientation =
ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
activity?.enterToImmersiveMode() activity?.enterToImmersiveMode()
toolbar.visibility = View.GONE toolbar.visibility = View.GONE
nestedScrollQuickAction.visibility = View.GONE nestedScrollQuickAction.visibility = View.GONE
@ -314,7 +327,12 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
} }
view.swipeRefresh.apply { view.swipeRefresh.apply {
val (topMargin, bottomMargin) = if (inFullScreen) 0 to 0 else getEngineMargins() val (topMargin, bottomMargin) = if (inFullScreen) 0 to 0 else getEngineMargins()
(layoutParams as CoordinatorLayout.LayoutParams).setMargins(0, topMargin, 0, bottomMargin) (layoutParams as CoordinatorLayout.LayoutParams).setMargins(
0,
topMargin,
0,
bottomMargin
)
} }
}, },
owner = this, owner = this,
@ -323,7 +341,8 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
@Suppress("ConstantConditionIf") @Suppress("ConstantConditionIf")
if (FeatureFlags.pullToRefreshEnabled) { if (FeatureFlags.pullToRefreshEnabled) {
val primaryTextColor = ThemeManager.resolveAttribute(R.attr.primaryText, requireContext()) val primaryTextColor =
ThemeManager.resolveAttribute(R.attr.primaryText, requireContext())
view.swipeRefresh.setColorSchemeColors(primaryTextColor) view.swipeRefresh.setColorSchemeColors(primaryTextColor)
swipeRefreshFeature.set( swipeRefreshFeature.set(
feature = SwipeRefreshFeature( feature = SwipeRefreshFeature(
@ -448,7 +467,9 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
*/ */
protected open fun removeSessionIfNeeded(): Boolean { protected open fun removeSessionIfNeeded(): Boolean {
getSessionById()?.let { session -> getSessionById()?.let { session ->
if (session.source == Session.Source.ACTION_VIEW) requireComponents.core.sessionManager.remove(session) if (session.source == Session.Source.ACTION_VIEW) requireComponents.core.sessionManager.remove(
session
)
} }
return false return false
} }
@ -496,14 +517,15 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
} }
view?.let { view?.let {
val directions = BrowserFragmentDirections.actionBrowserFragmentToQuickSettingsSheetDialogFragment( val directions =
sessionId = session.id, BrowserFragmentDirections.actionBrowserFragmentToQuickSettingsSheetDialogFragment(
url = session.url, sessionId = session.id,
isSecured = session.securityInfo.secure, url = session.url,
isTrackingProtectionOn = session.trackerBlockingEnabled, isSecured = session.securityInfo.secure,
sitePermissions = sitePermissions, isTrackingProtectionOn = session.trackerBlockingEnabled,
gravity = getAppropriateLayoutGravity() sitePermissions = sitePermissions,
) gravity = getAppropriateLayoutGravity()
)
nav(R.id.browserFragment, directions) nav(R.id.browserFragment, directions)
} }
} }

View File

@ -95,7 +95,8 @@ class BrowserFragment : BaseBrowserFragment(), BackHandler {
return super.initializeUI(view)?.also { session -> return super.initializeUI(view)?.also { session ->
quickActionSheetView = QuickActionSheetView(view.nestedScrollQuickAction, browserInteractor) quickActionSheetView =
QuickActionSheetView(view.nestedScrollQuickAction, browserInteractor)
customTabSessionId?.let { customTabSessionId -> customTabSessionId?.let { customTabSessionId ->
customTabsIntegration.set( customTabsIntegration.set(