1
0
Fork 0

For #2422 If TP disabled globally disable quicksettings TP exception toggle

master
ekager 2019-05-13 11:42:55 -07:00 committed by Emily Kager
parent 573e215577
commit a078f9e48b
6 changed files with 158 additions and 133 deletions

View File

@ -100,6 +100,7 @@ data class QuickSettingsState(val mode: Mode) : ViewState {
sealed class QuickSettingsAction : Action {
data class SelectReportProblem(val url: String) : QuickSettingsAction()
object SelectTrackingProtectionSettings : QuickSettingsAction()
data class ToggleTrackingProtection(val trackingProtection: Boolean) : QuickSettingsAction()
data class SelectBlockedByAndroid(val permissions: Array<String>) : QuickSettingsAction()
data class TogglePermission(val featurePhone: PhoneFeature) : QuickSettingsAction()

View File

@ -36,6 +36,7 @@ import org.mozilla.fenix.mvi.ActionBusFactory
import org.mozilla.fenix.mvi.getAutoDisposeObservable
import org.mozilla.fenix.mvi.getManagedEmitter
import org.mozilla.fenix.settings.PhoneFeature
import org.mozilla.fenix.utils.ItsNotBrokenSnack
import java.net.MalformedURLException
import java.net.URL
import kotlin.coroutines.CoroutineContext
@ -168,6 +169,12 @@ class QuickSettingsSheetDialogFragment : AppCompatDialogFragment(), CoroutineSco
is QuickSettingsAction.SelectBlockedByAndroid -> {
requestPermissions(it.permissions, REQUEST_CODE_QUICK_SETTINGS_PERMISSIONS)
}
is QuickSettingsAction.SelectTrackingProtectionSettings -> {
context?.let {
ItsNotBrokenSnack(it).showSnackbar("2422")
}
dismiss()
}
is QuickSettingsAction.SelectReportProblem -> {
launch(Dispatchers.Main) {
val reportUrl =

View File

@ -43,7 +43,7 @@ class QuickSettingsUIView(
private val securityInfoLabel: TextView
private val urlLabel: TextView
private val trackingProtectionSwitch: Switch
private val reportProblemAction: TextView
private val trackingProtectionAction: TextView
private val cameraActionLabel: TextView
private val cameraLabel: TextView
private val microphoneActionLabel: TextView
@ -60,7 +60,7 @@ class QuickSettingsUIView(
urlLabel = view.findViewById<AppCompatTextView>(R.id.url)
securityInfoLabel = view.findViewById<AppCompatTextView>(R.id.security_info)
trackingProtectionSwitch = view.findViewById(R.id.tracking_protection)
reportProblemAction = view.findViewById(R.id.report_problem)
trackingProtectionAction = view.findViewById(R.id.tracking_protection_action)
cameraActionLabel = view.findViewById<AppCompatTextView>(R.id.camera_action_label)
cameraLabel = view.findViewById<AppCompatTextView>(R.id.camera_icon)
microphoneActionLabel = view.findViewById<AppCompatTextView>(R.id.microphone_action_label)
@ -76,7 +76,7 @@ class QuickSettingsUIView(
is QuickSettingsState.Mode.Normal -> {
bindUrl(state.mode.url)
bindSecurityInfo(state.mode.isSecured)
bindReportProblemAction(state.mode.url)
bindTrackingProtectionAction(state.mode.url)
bindTrackingProtectionInfo(state.mode.isTrackingProtectionOn)
bindPhoneFeatureItem(CAMERA, state.mode.sitePermissions)
bindPhoneFeatureItem(MICROPHONE, state.mode.sitePermissions)
@ -97,12 +97,14 @@ class QuickSettingsUIView(
}
private fun bindTrackingProtectionInfo(isTrackingProtectionOn: Boolean) {
val globalTPSetting = Settings.getInstance(context).shouldUseTrackingProtection
val drawableId =
if (isTrackingProtectionOn) R.drawable.ic_tracking_protection else
R.drawable.ic_tracking_protection_disabled
val icon = AppCompatResources.getDrawable(context, drawableId)
trackingProtectionSwitch.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null)
trackingProtectionSwitch.isChecked = isTrackingProtectionOn
trackingProtectionSwitch.isEnabled = globalTPSetting
trackingProtectionSwitch.setOnCheckedChangeListener { _, isChecked ->
actionEmitter.onNext(
@ -113,11 +115,22 @@ class QuickSettingsUIView(
}
}
private fun bindReportProblemAction(url: String) {
reportProblemAction.setOnClickListener {
actionEmitter.onNext(
QuickSettingsAction.SelectReportProblem(url)
)
private fun bindTrackingProtectionAction(url: String) {
val globalTPSetting = Settings.getInstance(context).shouldUseTrackingProtection
trackingProtectionAction.text =
if (globalTPSetting)
context.getString(R.string.browser_menu_report_issue) else
context.getString(R.string.preferences_tracking_protection_turned_off_globally)
trackingProtectionAction.setOnClickListener {
if (globalTPSetting) {
actionEmitter.onNext(
QuickSettingsAction.SelectReportProblem(url)
)
} else {
actionEmitter.onNext(
QuickSettingsAction.SelectTrackingProtectionSettings
)
}
}
}

View File

@ -3,161 +3,160 @@
- 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/. -->
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/quick_action_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?foundation"
android:contentDescription="@string/quick_settings_sheet">
android:id="@+id/quick_action_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?foundation"
android:contentDescription="@string/quick_settings_sheet">
<TextView
android:id="@+id/url"
style="@style/QuickSettingsText"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="https://wikipedia.org"/>
android:id="@+id/url"
style="@style/QuickSettingsText"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="https://wikipedia.org" />
<TextView
android:id="@+id/security_info"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/url"
tools:drawableStartCompat="@drawable/mozac_ic_lock"
tools:drawableTint="@color/photonGreen50"
tools:text="Secure connection"/>
android:id="@+id/security_info"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/url"
tools:drawableStartCompat="@drawable/mozac_ic_lock"
tools:drawableTint="@color/photonGreen50"
tools:text="Secure connection" />
<View
android:id="@+id/line_divider_security"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?neutralFaded"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/security_info"/>
android:id="@+id/line_divider_security"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?neutralFaded"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/security_info" />
<Switch
android:id="@+id/tracking_protection"
style="@style/QuickSettingsText.Icon"
android:layout_width="match_parent"
android:layout_height="@dimen/quicksettings_item_height"
android:drawableStart="@drawable/ic_tracking_protection"
android:paddingEnd="24dp"
android:text="@string/preferences_tracking_protection"
app:layout_constraintBottom_toTopOf="@id/report_problem"
app:layout_constraintTop_toBottomOf="@id/line_divider_security"/>
android:id="@+id/tracking_protection"
style="@style/QuickSettingsText.Icon"
android:layout_width="match_parent"
android:layout_height="@dimen/quicksettings_item_height"
android:drawableStart="@drawable/ic_tracking_protection"
android:paddingEnd="24dp"
android:text="@string/preferences_tracking_protection"
app:layout_constraintBottom_toTopOf="@id/tracking_protection_action"
app:layout_constraintTop_toBottomOf="@id/line_divider_security" />
<TextView
android:id="@+id/report_problem"
style="@style/QuickSettingsText.Icon"
android:layout_width="match_parent"
android:layout_height="@dimen/quicksettings_item_height"
android:gravity="top"
android:paddingStart="48dp"
android:text="@string/browser_menu_report_issue"
android:textColor="?accentBright"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@id/line_divider"
app:layout_constraintTop_toBottomOf="@id/tracking_protection"/>
android:id="@+id/tracking_protection_action"
style="@style/QuickSettingsText.Icon"
android:layout_width="match_parent"
android:layout_height="@dimen/quicksettings_item_height"
android:gravity="top"
android:paddingStart="48dp"
android:text="@string/browser_menu_report_issue"
android:textColor="?accentBright"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@id/line_divider"
app:layout_constraintTop_toBottomOf="@id/tracking_protection" />
<View
android:id="@+id/line_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?neutralFaded"
app:layout_constraintBottom_toTopOf="@id/camera_icon"
app:layout_constraintStart_toStartOf="parent"/>
android:id="@+id/line_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?neutralFaded"
app:layout_constraintBottom_toTopOf="@id/camera_icon"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/camera_icon"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:text="@string/preference_phone_feature_camera"
app:drawableStartCompat="@drawable/ic_camera"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_divider"/>
android:id="@+id/camera_icon"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:text="@string/preference_phone_feature_camera"
app:drawableStartCompat="@drawable/ic_camera"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_divider" />
<TextView
android:id="@+id/camera_action_label"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_divider"
tools:text="Allowed"/>
android:id="@+id/camera_action_label"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_divider"
tools:text="Allowed" />
<TextView
android:id="@+id/microphone_icon"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:text="@string/preference_phone_feature_microphone"
app:drawableStartCompat="@drawable/ic_microphone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/camera_icon"/>
android:id="@+id/microphone_icon"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:text="@string/preference_phone_feature_microphone"
app:drawableStartCompat="@drawable/ic_microphone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/camera_icon" />
<TextView
android:id="@+id/microphone_action_label"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/camera_action_label"
tools:text="Blocked by Android"/>
android:id="@+id/microphone_action_label"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/camera_action_label"
tools:text="Blocked by Android" />
<TextView
android:id="@+id/notification_icon"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:text="@string/preference_phone_feature_notification"
app:drawableStartCompat="@drawable/ic_notification"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/microphone_icon"/>
android:id="@+id/notification_icon"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:text="@string/preference_phone_feature_notification"
app:drawableStartCompat="@drawable/ic_notification"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/microphone_icon" />
<TextView
android:id="@+id/notification_action_label"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/microphone_action_label"
tools:text="Blocked"/>
android:id="@+id/notification_action_label"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/microphone_action_label"
tools:text="Blocked" />
<TextView
android:id="@+id/location_icon"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:text="@string/preference_phone_feature_location"
app:drawableStartCompat="@drawable/ic_location"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/notification_icon"/>
android:id="@+id/location_icon"
style="@style/QuickSettingsText.Icon"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
android:text="@string/preference_phone_feature_location"
app:drawableStartCompat="@drawable/ic_location"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/notification_icon" />
<TextView
android:id="@+id/location_action_label"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/notification_action_label"
tools:text="Blocked"/>
android:id="@+id/location_action_label"
style="@style/QuickSettingsText.PermissionItemEnd"
android:layout_width="wrap_content"
android:layout_height="@dimen/quicksettings_item_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/notification_action_label"
tools:text="Blocked" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>

View File

@ -338,5 +338,8 @@
android:name="gravity"
app:argType="integer"
android:defaultValue="80" />
<action
android:id="@+id/action_quickSettingsSheetDialogFragment_to_trackingProtectionFragment"
app:destination="@id/trackingProtectionFragment" />
</dialog>
</navigation>

View File

@ -171,6 +171,8 @@
<string name="preferences_tracking_protection_exceptions_description">Tracking Protection is off for these websites</string>
<!-- Button in Exceptions Preference to turn on tracking protection for all sites (remove all exceptions) -->
<string name="preferences_tracking_protection_exceptions_turn_on_for_all">Turn on for all sites</string>
<!-- Description in Quick Settings that tells user tracking protection is off globally for all sites, and links to Settings to turn it on -->
<string name="preferences_tracking_protection_turned_off_globally">Turned off globally, go to Settings to turn it on.</string>
<!-- Preference switch for Telemetry -->
<string name="preferences_telemetry">Telemetry</string>