1
0
Fork 0

Adding support for Site Permissions.

master
Arturo Mejia 2019-02-28 16:10:52 -05:00 committed by Jeff Boek
parent dfd3e93d17
commit 725074ec16
4 changed files with 21 additions and 0 deletions

View File

@ -191,6 +191,7 @@ dependencies {
implementation Deps.mozilla_feature_tabs implementation Deps.mozilla_feature_tabs
implementation Deps.mozilla_feature_findinpage implementation Deps.mozilla_feature_findinpage
implementation Deps.mozilla_feature_session_bundling implementation Deps.mozilla_feature_session_bundling
implementation Deps.mozilla_feature_site_permissions
implementation Deps.mozilla_service_firefox_accounts implementation Deps.mozilla_service_firefox_accounts
implementation Deps.mozilla_service_fretboard implementation Deps.mozilla_service_fretboard

View File

@ -7,6 +7,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application <application
android:allowBackup="true" android:allowBackup="true"

View File

@ -26,6 +26,7 @@ import mozilla.components.feature.downloads.DownloadsFeature
import mozilla.components.feature.prompts.PromptFeature import mozilla.components.feature.prompts.PromptFeature
import mozilla.components.feature.session.SessionFeature import mozilla.components.feature.session.SessionFeature
import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.session.SessionUseCases
import mozilla.components.feature.sitepermissions.SitePermissionsFeature
import mozilla.components.support.base.feature.BackHandler import mozilla.components.support.base.feature.BackHandler
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import org.mozilla.fenix.BrowsingModeManager import org.mozilla.fenix.BrowsingModeManager
@ -54,6 +55,7 @@ class BrowserFragment : Fragment(), BackHandler {
private val findInPageIntegration = ViewBoundFeatureWrapper<FindInPageIntegration>() private val findInPageIntegration = ViewBoundFeatureWrapper<FindInPageIntegration>()
private val customTabsToolbarFeature = ViewBoundFeatureWrapper<CustomTabsToolbarFeature>() private val customTabsToolbarFeature = ViewBoundFeatureWrapper<CustomTabsToolbarFeature>()
private val toolbarIntegration = ViewBoundFeatureWrapper<ToolbarIntegration>() private val toolbarIntegration = ViewBoundFeatureWrapper<ToolbarIntegration>()
private val sitePermissionsFeature = ViewBoundFeatureWrapper<SitePermissionsFeature>()
var sessionId: String? = null var sessionId: String? = null
override fun onCreateView( override fun onCreateView(
@ -165,6 +167,17 @@ class BrowserFragment : Fragment(), BackHandler {
feature = (toolbarComponent.uiView as ToolbarUIView).toolbarIntegration, feature = (toolbarComponent.uiView as ToolbarUIView).toolbarIntegration,
owner = this, owner = this,
view = view) 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() { override fun onResume() {
@ -204,6 +217,9 @@ class BrowserFragment : Fragment(), BackHandler {
REQUEST_CODE_PROMPT_PERMISSIONS -> promptsFeature.withFeature { REQUEST_CODE_PROMPT_PERMISSIONS -> promptsFeature.withFeature {
it.onPermissionsResult(permissions, grantResults) it.onPermissionsResult(permissions, grantResults)
} }
REQUEST_CODE_APP_PERMISSIONS -> sitePermissionsFeature.withFeature {
it.onPermissionsResult(grantResults)
}
} }
} }
@ -257,6 +273,7 @@ class BrowserFragment : Fragment(), BackHandler {
companion object { companion object {
private const val REQUEST_CODE_DOWNLOAD_PERMISSIONS = 1 private const val REQUEST_CODE_DOWNLOAD_PERMISSIONS = 1
private const val REQUEST_CODE_PROMPT_PERMISSIONS = 2 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 TOOLBAR_HEIGHT = 56f
private const val REPORT_SITE_ISSUE_URL = "https://webcompat.com/issues/new?url=%s&label=browser-fenix" private const val REPORT_SITE_ISSUE_URL = "https://webcompat.com/issues/new?url=%s&label=browser-fenix"
} }

View File

@ -90,6 +90,7 @@ object Deps {
const val mozilla_feature_toolbar = "org.mozilla.components:feature-toolbar:${Versions.mozilla_android_components}" 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_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_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_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}" const val mozilla_service_fretboard = "org.mozilla.components:service-fretboard:${Versions.mozilla_android_components}"