2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00

[fenix] Add support for local storage permission

This commit is contained in:
Arturo Mejia 2020-10-05 16:55:39 -04:00
parent 84b6d129df
commit 4f67095c8b
11 changed files with 91 additions and 31 deletions

View File

@ -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)
}
/**

View File

@ -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
}
}

View File

@ -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)
))
/**

View File

@ -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()
}

View File

@ -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)
)
}

View File

@ -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>

View File

@ -12,18 +12,6 @@
android:layout_height="wrap_content"
android:layout_marginBottom="8dp">
<TextView
android:id="@+id/cameraStatus"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/microphoneStatus"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/cameraLabel"
tools:text="Allowed"
tools:visibility="visible" />
<TextView
android:id="@+id/cameraLabel"
style="@style/QuickSettingsText.Icon"
@ -38,15 +26,15 @@
tools:visibility="visible" />
<TextView
android:id="@+id/microphoneStatus"
android:id="@+id/cameraStatus"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/notificationStatus"
app:layout_constraintBottom_toTopOf="@id/microphoneStatus"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/microphoneLabel"
tools:text="@string/phone_feature_blocked_by_android"
app:layout_constraintStart_toEndOf="@id/cameraLabel"
tools:text="Allowed"
tools:visibility="visible" />
<TextView
@ -63,15 +51,15 @@
tools:visibility="visible" />
<TextView
android:id="@+id/notificationStatus"
android:id="@+id/microphoneStatus"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/locationStatus"
app:layout_constraintBottom_toTopOf="@id/notificationStatus"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/notificationLabel"
tools:text="@string/preference_option_phone_feature_blocked"
app:layout_constraintStart_toEndOf="@id/microphoneLabel"
tools:text="@string/phone_feature_blocked_by_android"
tools:visibility="visible" />
<TextView
@ -88,14 +76,14 @@
tools:visibility="visible" />
<TextView
android:id="@+id/locationStatus"
android:id="@+id/notificationStatus"
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_constraintBottom_toTopOf="@id/locationStatus"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/locationLabel"
app:layout_constraintStart_toEndOf="@id/notificationLabel"
tools:text="@string/preference_option_phone_feature_blocked"
tools:visibility="visible" />
@ -107,8 +95,46 @@
app:drawableStartCompat="@drawable/ic_location"
android:text="@string/preference_phone_feature_location"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/persistentStorageLabel"
app:layout_constraintEnd_toStartOf="@id/locationStatus"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
<TextView
android:id="@+id/locationStatus"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:visibility="gone"
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/persistentStorageLabel"
style="@style/QuickSettingsText.Icon"
android:layout_width="0dp"
android:layout_height="@dimen/quicksettings_item_height"
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/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>

View File

@ -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>

View File

@ -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 -->

View File

@ -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"/>

View File

@ -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"