From 5793d18da7b8edc984eb7ca55dc2c7990d710408 Mon Sep 17 00:00:00 2001 From: Emily Kager Date: Tue, 21 May 2019 14:34:03 -0700 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/2530 - Show report site issue and TP off globally in quick settings --- .../quicksettings/QuickSettingsUIView.kt | 32 ++++++++++--------- .../fragment_quick_settings_dialog_sheet.xml | 16 ++++++++-- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsUIView.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsUIView.kt index 2fa6013222..306464494f 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsUIView.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsUIView.kt @@ -44,6 +44,7 @@ class QuickSettingsUIView( private val urlLabel: TextView private val trackingProtectionSwitch: Switch private val trackingProtectionAction: TextView + private val reportSiteIssueAction: TextView private val cameraActionLabel: TextView private val cameraLabel: TextView private val microphoneActionLabel: TextView @@ -61,6 +62,7 @@ class QuickSettingsUIView( securityInfoLabel = view.findViewById(R.id.security_info) trackingProtectionSwitch = view.findViewById(R.id.tracking_protection) trackingProtectionAction = view.findViewById(R.id.tracking_protection_action) + reportSiteIssueAction = view.findViewById(R.id.report_site_issue_action) cameraActionLabel = view.findViewById(R.id.camera_action_label) cameraLabel = view.findViewById(R.id.camera_icon) microphoneActionLabel = view.findViewById(R.id.microphone_action_label) @@ -76,7 +78,8 @@ class QuickSettingsUIView( is QuickSettingsState.Mode.Normal -> { bindUrl(state.mode.url) bindSecurityInfo(state.mode.isSecured) - bindTrackingProtectionAction(state.mode.url) + bindReportSiteIssueAction(state.mode.url) + bindTrackingProtectionAction() bindTrackingProtectionInfo(state.mode.isTrackingProtectionOn) bindPhoneFeatureItem(CAMERA, state.mode.sitePermissions) bindPhoneFeatureItem(MICROPHONE, state.mode.sitePermissions) @@ -115,22 +118,21 @@ class QuickSettingsUIView( } } - private fun bindTrackingProtectionAction(url: String) { + private fun bindTrackingProtectionAction() { 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.visibility = if (globalTPSetting) View.GONE else View.VISIBLE trackingProtectionAction.setOnClickListener { - if (globalTPSetting) { - actionEmitter.onNext( - QuickSettingsAction.SelectReportProblem(url) - ) - } else { - actionEmitter.onNext( - QuickSettingsAction.SelectTrackingProtectionSettings - ) - } + actionEmitter.onNext( + QuickSettingsAction.SelectTrackingProtectionSettings + ) + } + } + + private fun bindReportSiteIssueAction(url: String) { + reportSiteIssueAction.setOnClickListener { + actionEmitter.onNext( + QuickSettingsAction.SelectReportProblem(url) + ) } } diff --git a/app/src/main/res/layout/fragment_quick_settings_dialog_sheet.xml b/app/src/main/res/layout/fragment_quick_settings_dialog_sheet.xml index 6bb21b0273..894b0f7ac8 100644 --- a/app/src/main/res/layout/fragment_quick_settings_dialog_sheet.xml +++ b/app/src/main/res/layout/fragment_quick_settings_dialog_sheet.xml @@ -65,11 +65,23 @@ android:layout_height="@dimen/quicksettings_item_height" android:gravity="top" android:paddingStart="48dp" + android:text="@string/preferences_tracking_protection_turned_off_globally" + android:textColor="?accentBright" + android:visibility="gone" + app:layout_constraintBottom_toTopOf="@id/report_site_issue_action" + app:layout_constraintTop_toBottomOf="@id/tracking_protection" /> + + + app:layout_constraintTop_toBottomOf="@id/tracking_protection_action" />