Add support for local storage permission

pull/216/head
Arturo Mejia 4 years ago
parent 67593877ce
commit de521192e0

@ -25,6 +25,7 @@ fun SitePermissions.get(field: PhoneFeature) = when (field) {
PhoneFeature.NOTIFICATION -> notification
PhoneFeature.AUTOPLAY_AUDIBLE -> autoplayAudible
PhoneFeature.AUTOPLAY_INAUDIBLE -> autoplayInaudible
PhoneFeature.PERSISTENT_STORAGE -> localStorage
}
fun SitePermissions.update(field: PhoneFeature, value: SitePermissions.Status) = when (field) {
@ -34,6 +35,7 @@ fun SitePermissions.update(field: PhoneFeature, value: SitePermissions.Status) =
PhoneFeature.NOTIFICATION -> copy(notification = value)
PhoneFeature.AUTOPLAY_AUDIBLE -> copy(autoplayAudible = value)
PhoneFeature.AUTOPLAY_INAUDIBLE -> copy(autoplayInaudible = value)
PhoneFeature.PERSISTENT_STORAGE -> copy(localStorage = value)
}
/**

@ -30,7 +30,8 @@ enum class PhoneFeature(val androidPermissionsList: Array<String>) : Parcelable
MICROPHONE(arrayOf(RECORD_AUDIO)),
NOTIFICATION(emptyArray()),
AUTOPLAY_AUDIBLE(emptyArray()),
AUTOPLAY_INAUDIBLE(emptyArray());
AUTOPLAY_INAUDIBLE(emptyArray()),
PERSISTENT_STORAGE(emptyArray());
fun isAndroidPermissionGranted(context: Context): Boolean {
return context.isPermissionGranted(androidPermissionsList.asIterable())
@ -78,6 +79,7 @@ enum class PhoneFeature(val androidPermissionsList: Array<String>) : Parcelable
LOCATION -> context.getString(R.string.preference_phone_feature_location)
MICROPHONE -> context.getString(R.string.preference_phone_feature_microphone)
NOTIFICATION -> context.getString(R.string.preference_phone_feature_notification)
PERSISTENT_STORAGE -> context.getString(R.string.preference_phone_feature_persistent_storage)
AUTOPLAY_AUDIBLE, AUTOPLAY_INAUDIBLE -> context.getString(R.string.preference_browser_feature_autoplay)
}
}
@ -95,6 +97,7 @@ enum class PhoneFeature(val androidPermissionsList: Array<String>) : Parcelable
NOTIFICATION -> R.string.pref_key_phone_feature_notification
AUTOPLAY_AUDIBLE -> R.string.pref_key_browser_feature_autoplay_audible
AUTOPLAY_INAUDIBLE -> R.string.pref_key_browser_feature_autoplay_inaudible
PERSISTENT_STORAGE -> R.string.pref_key_browser_feature_persistent_storage
}
}

@ -56,7 +56,8 @@ class WebsitePermissionsView(
PhoneFeature.CAMERA to PermissionViewHolder(view.cameraLabel, view.cameraStatus),
PhoneFeature.LOCATION to PermissionViewHolder(view.locationLabel, view.locationStatus),
PhoneFeature.MICROPHONE to PermissionViewHolder(view.microphoneLabel, view.microphoneStatus),
PhoneFeature.NOTIFICATION to PermissionViewHolder(view.notificationLabel, view.notificationStatus)
PhoneFeature.NOTIFICATION to PermissionViewHolder(view.notificationLabel, view.notificationStatus),
PhoneFeature.PERSISTENT_STORAGE to PermissionViewHolder(view.persistentStorageLabel, view.persistentStorageStatus)
))
/**

@ -21,10 +21,7 @@ import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.settings.PhoneFeature
import org.mozilla.fenix.settings.PhoneFeature.CAMERA
import org.mozilla.fenix.settings.PhoneFeature.LOCATION
import org.mozilla.fenix.settings.PhoneFeature.MICROPHONE
import org.mozilla.fenix.settings.PhoneFeature.NOTIFICATION
import org.mozilla.fenix.settings.PhoneFeature.*
import org.mozilla.fenix.settings.requirePreference
class SitePermissionsDetailsExceptionsFragment : PreferenceFragmentCompat() {
@ -57,6 +54,7 @@ class SitePermissionsDetailsExceptionsFragment : PreferenceFragmentCompat() {
initPhoneFeature(LOCATION)
initPhoneFeature(MICROPHONE)
initPhoneFeature(NOTIFICATION)
initPhoneFeature(PERSISTENT_STORAGE)
bindClearPermissionsButton()
}

@ -774,7 +774,8 @@ class Settings(private val appContext: Context) : PreferencesHolder {
location = getSitePermissionsPhoneFeatureAction(PhoneFeature.LOCATION),
camera = getSitePermissionsPhoneFeatureAction(PhoneFeature.CAMERA),
autoplayAudible = getSitePermissionsPhoneFeatureAutoplayAction(PhoneFeature.AUTOPLAY_AUDIBLE),
autoplayInaudible = getSitePermissionsPhoneFeatureAutoplayAction(PhoneFeature.AUTOPLAY_INAUDIBLE)
autoplayInaudible = getSitePermissionsPhoneFeatureAutoplayAction(PhoneFeature.AUTOPLAY_INAUDIBLE),
persistentStorage = getSitePermissionsPhoneFeatureAction(PhoneFeature.PERSISTENT_STORAGE)
)
}

@ -0,0 +1,13 @@
<!-- 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/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:autoMirrored="true">
<path
android:fillColor="?primaryText"
android:pathData="M2,20h20v-4L2,16v4zM4,17h2v2L4,19v-2zM2,4v4h20L22,4L2,4zM6,7L4,7L4,5h2v2zM2,14h20v-4L2,10v4zM4,11h2v2L4,13v-2z"/>
</vector>

@ -12,6 +12,19 @@
android:layout_height="wrap_content"
android:layout_marginBottom="8dp">
<TextView
android:id="@+id/cameraLabel"
style="@style/QuickSettingsText.Icon"
android:layout_width="0dp"
android:layout_height="@dimen/quicksettings_item_height"
app:drawableStartCompat="@drawable/ic_camera"
android:text="@string/preference_phone_feature_camera"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/microphoneLabel"
app:layout_constraintEnd_toStartOf="@id/cameraStatus"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/cameraStatus"
style="@style/QuickSettingsText.PermissionItemEnd"
@ -25,15 +38,15 @@
tools:visibility="visible" />
<TextView
android:id="@+id/cameraLabel"
android:id="@+id/microphoneLabel"
style="@style/QuickSettingsText.Icon"
android:layout_width="0dp"
android:layout_height="@dimen/quicksettings_item_height"
app:drawableStartCompat="@drawable/ic_camera"
android:text="@string/preference_phone_feature_camera"
app:drawableStartCompat="@drawable/ic_microphone"
android:text="@string/preference_phone_feature_microphone"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/microphoneLabel"
app:layout_constraintEnd_toStartOf="@id/cameraStatus"
app:layout_constraintBottom_toTopOf="@id/notificationLabel"
app:layout_constraintEnd_toStartOf="@id/microphoneStatus"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
@ -50,15 +63,15 @@
tools:visibility="visible" />
<TextView
android:id="@+id/microphoneLabel"
android:id="@+id/notificationLabel"
style="@style/QuickSettingsText.Icon"
android:layout_width="0dp"
android:layout_height="@dimen/quicksettings_item_height"
app:drawableStartCompat="@drawable/ic_microphone"
android:text="@string/preference_phone_feature_microphone"
app:drawableStartCompat="@drawable/ic_notifications"
android:text="@string/preference_phone_feature_notification"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/notificationLabel"
app:layout_constraintEnd_toStartOf="@id/microphoneStatus"
app:layout_constraintBottom_toTopOf="@id/locationLabel"
app:layout_constraintEnd_toStartOf="@id/notificationStatus"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
@ -75,15 +88,15 @@
tools:visibility="visible" />
<TextView
android:id="@+id/notificationLabel"
android:id="@+id/locationLabel"
style="@style/QuickSettingsText.Icon"
android:layout_width="0dp"
android:layout_height="@dimen/quicksettings_item_height"
app:drawableStartCompat="@drawable/ic_notifications"
android:text="@string/preference_phone_feature_notification"
app:drawableStartCompat="@drawable/ic_location"
android:text="@string/preference_phone_feature_location"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/locationLabel"
app:layout_constraintEnd_toStartOf="@id/notificationStatus"
app:layout_constraintBottom_toTopOf="@id/persistentStorageLabel"
app:layout_constraintEnd_toStartOf="@id/locationStatus"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
@ -93,22 +106,35 @@
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/persistentStorageStatus"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/locationLabel"
tools:text="@string/preference_option_phone_feature_blocked"
tools:visibility="visible" />
<TextView
android:id="@+id/locationLabel"
android:id="@+id/persistentStorageLabel"
style="@style/QuickSettingsText.Icon"
android:layout_width="0dp"
android:layout_height="@dimen/quicksettings_item_height"
app:drawableStartCompat="@drawable/ic_location"
android:text="@string/preference_phone_feature_location"
app:drawableStartCompat="@drawable/ic_storage"
android:text="@string/preference_phone_feature_persistent_storage"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/locationStatus"
app:layout_constraintEnd_toStartOf="@id/persistentStorageStatus"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/persistentStorageStatus"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/persistentStorageLabel"
tools:text="@string/preference_option_phone_feature_blocked"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -110,6 +110,7 @@
<string name="pref_key_custom_settings" translatable="false">pref_key_custom_settings</string>
<string name="pref_key_browser_feature_autoplay_audible" translatable="false">pref_key_browser_feature_autoplay</string>
<string name="pref_key_browser_feature_autoplay_inaudible" translatable="false">pref_key_browser_feature_autoplay_inaudible</string>
<string name="pref_key_browser_feature_persistent_storage" translatable="false">pref_key_browser_feature_persistent_storage</string>
<string name="pref_key_phone_feature_camera" translatable="false">pref_key_phone_feature_camera</string>
<string name="pref_key_phone_feature_location" translatable="false">pref_key_phone_feature_location</string>
<string name="pref_key_phone_feature_microphone" translatable="false">pref_key_phone_feature_microphone</string>

@ -792,6 +792,8 @@
<string name="preference_phone_feature_location">Location</string>
<!-- Preference for altering the notification access for all websites -->
<string name="preference_phone_feature_notification">Notification</string>
<!-- Preference for altering the persistent storage access for all websites -->
<string name="preference_phone_feature_persistent_storage">Persistent Storage</string>
<!-- Label that indicates that a permission must be asked always -->
<string name="preference_option_phone_feature_ask_to_allow">Ask to allow</string>
<!-- Label that indicates that a permission must be blocked -->

@ -28,6 +28,12 @@
android:title="@string/preference_phone_feature_notification"
android:summary="@string/preference_option_phone_feature_ask_to_allow"/>
<androidx.preference.Preference
android:icon="@drawable/ic_storage"
android:key="@string/pref_key_browser_feature_persistent_storage"
android:title="@string/preference_phone_feature_persistent_storage"
android:summary="@string/preference_option_phone_feature_ask_to_allow"/>
<androidx.preference.Preference
android:key="@string/pref_key_exceptions_clear_site_permissions"
android:layout="@layout/layout_clear_permission_button"/>

@ -36,6 +36,13 @@
android:summary="@string/preference_option_phone_feature_ask_to_allow"
app:allowDividerBelow="true"/>
<androidx.preference.Preference
android:icon="@drawable/ic_storage"
android:key="@string/pref_key_browser_feature_persistent_storage"
android:title="@string/preference_phone_feature_persistent_storage"
android:summary="@string/preference_option_phone_feature_ask_to_allow"
app:allowDividerBelow="true"/>
<androidx.preference.Preference
android:icon="@drawable/ic_internet"
android:key="@string/pref_key_show_site_exceptions"

Loading…
Cancel
Save