From ade773f5d33f2c3251ae87f29767efa29006b450 Mon Sep 17 00:00:00 2001 From: Arturo Mejia Date: Thu, 28 Feb 2019 16:10:52 -0500 Subject: [PATCH] [fenix] Adding support for Site Permissions. --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 2 ++ .../mozilla/fenix/browser/BrowserFragment.kt | 17 +++++++++++++++++ buildSrc/src/main/java/Dependencies.kt | 1 + 4 files changed, 21 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 4368b53512..796fc4244a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -191,6 +191,7 @@ dependencies { implementation Deps.mozilla_feature_tabs implementation Deps.mozilla_feature_findinpage implementation Deps.mozilla_feature_session_bundling + implementation Deps.mozilla_feature_site_permissions implementation Deps.mozilla_service_firefox_accounts implementation Deps.mozilla_service_fretboard diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f93af7994b..75530f99eb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,6 +7,8 @@ + + () private val customTabsToolbarFeature = ViewBoundFeatureWrapper() private val toolbarIntegration = ViewBoundFeatureWrapper() + private val sitePermissionsFeature = ViewBoundFeatureWrapper() var sessionId: String? = null override fun onCreateView( @@ -165,6 +167,17 @@ class BrowserFragment : Fragment(), BackHandler { feature = (toolbarComponent.uiView as ToolbarUIView).toolbarIntegration, owner = this, view = view) + + sitePermissionsFeature.set( + feature = SitePermissionsFeature( + anchorView = view.findInPageView, + sessionManager = sessionManager + ) { permissions -> + requestPermissions(permissions, REQUEST_CODE_APP_PERMISSIONS) + }, + owner = this, + view = view + ) } override fun onResume() { @@ -204,6 +217,9 @@ class BrowserFragment : Fragment(), BackHandler { REQUEST_CODE_PROMPT_PERMISSIONS -> promptsFeature.withFeature { it.onPermissionsResult(permissions, grantResults) } + REQUEST_CODE_APP_PERMISSIONS -> sitePermissionsFeature.withFeature { + it.onPermissionsResult(grantResults) + } } } @@ -257,6 +273,7 @@ class BrowserFragment : Fragment(), BackHandler { companion object { 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 TOOLBAR_HEIGHT = 56f private const val REPORT_SITE_ISSUE_URL = "https://webcompat.com/issues/new?url=%s&label=browser-fenix" } diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 04abbbfcee..870c5fa8cd 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -90,6 +90,7 @@ object Deps { const val mozilla_feature_toolbar = "org.mozilla.components:feature-toolbar:${Versions.mozilla_android_components}" const val mozilla_feature_findinpage = "org.mozilla.components:feature-findinpage:${Versions.mozilla_android_components}" const val mozilla_feature_session_bundling = "org.mozilla.components:feature-session-bundling:${Versions.mozilla_android_components}" + const val mozilla_feature_site_permissions = "org.mozilla.components:feature-sitepermissions:${Versions.mozilla_android_components}" const val mozilla_service_firefox_accounts = "org.mozilla.components:service-firefox-accounts:${Versions.mozilla_android_components}" const val mozilla_service_fretboard = "org.mozilla.components:service-fretboard:${Versions.mozilla_android_components}"