For #25915: Remove the hard coded default browser message

pull/543/head
Arturo Mejia 2 years ago committed by mergify[bot]
parent 3f89c010f0
commit 261569c2c5

@ -1,12 +1,4 @@
---
default-browser-message:
description: A small feature allowing experiments on the placement of a default browser message.
hasExposure: true
exposureDescription: ""
variables:
message-location:
type: string
description: Where is the message to be put.
engine-settings:
description: Contains a set of settings for controlling the web engine configurations.
hasExposure: true

@ -1668,17 +1668,6 @@
column="18"/>
</issue>
<issue
id="ContentDescription"
message="Missing `contentDescription` attribute on image"
errorLine1=" &lt;ImageView"
errorLine2=" ~~~~~~~~~">
<location
file="src/main/res/layout/default_browser_experiment_preference.xml"
line="14"
column="6"/>
</issue>
<issue
id="ContentDescription"
message="Missing `contentDescription` attribute on image"

@ -38,7 +38,6 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixAccountManager
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.nimbus.MessageSurfaceId
import org.mozilla.fenix.theme.ThemeManager
/**
@ -364,7 +363,6 @@ open class DefaultToolbarMenu(
@VisibleForTesting(otherwise = PRIVATE)
val coreMenuItems by lazy {
val defaultBrowserItem = getSetDefaultBrowserItem()
val menuItems =
listOfNotNull(
if (shouldUseBottomToolbar) null else menuToolbar,
@ -376,8 +374,6 @@ open class DefaultToolbarMenu(
extensionsItem,
syncMenuItem,
BrowserMenuDivider(),
defaultBrowserItem,
defaultBrowserItem?.let { BrowserMenuDivider() },
findInPageItem,
desktopSiteItem,
customizeReaderView.apply { visible = ::shouldShowReaderViewCustomization },
@ -449,20 +445,4 @@ open class DefaultToolbarMenu(
.any { it.url == newUrl }
}
}
private fun getSetDefaultBrowserItem(): BrowserMenuImageText? {
val settings = context.components.settings
return if (
settings.isDefaultBrowserMessageLocation(MessageSurfaceId.APP_MENU_ITEM)
) {
BrowserMenuImageText(
label = context.getString(R.string.preferences_set_as_default_browser),
imageResource = R.mipmap.ic_launcher
) {
onItemTapped.invoke(ToolbarMenu.Item.SetDefaultBrowser)
}
} else {
null
}
}
}

@ -5,7 +5,6 @@
package org.mozilla.fenix.settings
import android.annotation.SuppressLint
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.DialogInterface
import android.content.Intent
@ -51,11 +50,9 @@ import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.navigateToNotificationsSettings
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.REQUEST_CODE_BROWSER_ROLE
import org.mozilla.fenix.ext.openSetDefaultBrowserOption
import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.nimbus.MessageSurfaceId
import org.mozilla.fenix.perf.ProfilerViewModel
import org.mozilla.fenix.settings.account.AccountUiView
import org.mozilla.fenix.utils.BrowsersCache
@ -160,23 +157,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
val preferencesId = getPreferenceLayoutId()
setPreferencesFromResource(preferencesId, rootKey)
updateMakeDefaultBrowserPreference()
setPreferencesFromResource(R.xml.preferences, rootKey)
}
/**
* @return The preference layout to be used depending on flags and existing experiment branches.
* Note: Changing Settings screen before experiment is over requires changing all layouts.
*/
private fun getPreferenceLayoutId() =
if (isDefaultBrowserExperimentBranch()) {
R.xml.preferences_default_browser_experiment
} else {
R.xml.preferences
}
@SuppressLint("RestrictedApi")
override fun onResume() {
super.onResume()
@ -250,8 +233,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
requireComponents.backgroundServices.accountManager.accountProfile()
)
}
updateMakeDefaultBrowserPreference()
}
@SuppressLint("InflateParams")
@ -520,23 +501,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
}
@Suppress("DEPRECATION")
// https://github.com/mozilla-mobile/fenix/issues/19919
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
// If the user made us the default browser, update the switch
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_BROWSER_ROLE) {
updateMakeDefaultBrowserPreference()
}
}
private fun updateMakeDefaultBrowserPreference() {
if (!isDefaultBrowserExperimentBranch()) {
requirePreference<DefaultBrowserPreference>(R.string.pref_key_make_default_browser).updateSwitch()
}
}
private fun navigateFromSettings(directions: NavDirections) {
view?.findNavController()?.let { navController ->
if (navController.currentDestination?.id == R.id.settingsFragment) {
@ -656,9 +620,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
}
private fun isDefaultBrowserExperimentBranch(): Boolean =
requireContext().settings().isDefaultBrowserMessageLocation(MessageSurfaceId.SETTINGS)
private fun isFirefoxDefaultBrowser(): Boolean {
val browsers = BrowsersCache.all(requireContext())
return browsers.isFirefoxDefaultBrowser

@ -42,10 +42,8 @@ import org.mozilla.fenix.components.settings.lazyFeatureFlagPreference
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.nimbus.DefaultBrowserMessage
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.nimbus.HomeScreenSection
import org.mozilla.fenix.nimbus.MessageSurfaceId
import org.mozilla.fenix.settings.PhoneFeature
import org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataOnQuitType
import org.mozilla.fenix.settings.logins.SavedLoginsSortingStrategyMenu
@ -314,20 +312,6 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = false
)
private val defaultBrowserFeature: DefaultBrowserMessage by lazy {
FxNimbus.features.defaultBrowserMessage.value()
}
fun isDefaultBrowserMessageLocation(surfaceId: MessageSurfaceId): Boolean =
defaultBrowserFeature.messageLocation?.let { experimentalSurfaceId ->
if (experimentalSurfaceId == surfaceId) {
val browsers = BrowsersCache.all(appContext)
!browsers.isFirefoxDefaultBrowser
} else {
false
}
} ?: false
var gridTabView by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_tab_view_grid),
default = true

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
<item android:id="@android:id/mask">
<shape>
<solid android:color="#000000" />
<corners android:radius="4dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="?actionPrimary" />
<corners android:radius="4dp" />
</shape>
</item>
</ripple>

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/OnboardingCardLightWithPadding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="8dp"
android:layout_marginHorizontal="24dp">
<ImageView
android:id="@+id/app_icon"
android:layout_width="32dp"
android:layout_height="32dp"
app:layout_constraintEnd_toStartOf="@id/description_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_firefox" />
<TextView
android:id="@+id/description_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginBottom="16dp"
android:text="@string/default_browser_experiment_card_text"
android:textAppearance="@style/Body14TextStyle"
app:layout_constraintBottom_toTopOf="@id/set_default_browser"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/app_icon"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/set_default_browser"
style="@style/PositiveButton"
android:layout_height="36dp"
android:background="@drawable/rounded_button_background"
android:clickable="false"
android:focusable="false"
android:text="@string/preferences_set_as_default_browser"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/description_text" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,216 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<androidx.preference.PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.preference.Preference
android:key="@string/pref_key_make_default_browser"
android:layout="@layout/default_browser_experiment_preference"
app:allowDividerBelow="false" />
<androidx.preference.SwitchPreference
android:defaultValue="true"
android:key="@string/pref_key_allow_domestic_china_fxa_server"
android:title="@string/preferences_allow_domestic_china_fxa_server" />
<androidx.preference.EditTextPreference
android:inputType="textUri"
android:key="@string/pref_key_override_fxa_server"
android:title="@string/preferences_override_fxa_server"
app:iconSpaceReserved="false"
app:isPreferenceVisible="false" />
<androidx.preference.EditTextPreference
android:inputType="textUri"
android:key="@string/pref_key_override_sync_tokenserver"
android:title="@string/preferences_override_sync_tokenserver"
app:iconSpaceReserved="false"
app:isPreferenceVisible="false" />
<androidx.preference.PreferenceCategory
android:layout="@layout/preference_category_no_icon_style"
android:title="@string/preferences_category_general">
<androidx.preference.Preference
android:key="@string/pref_key_search_settings"
android:title="@string/preferences_search"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_tabs"
android:title="@string/preferences_tabs"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
app:iconSpaceReserved="false"
android:key="@string/pref_key_home"
android:title="@string/preferences_home_2" />
<androidx.preference.Preference
android:key="@string/pref_key_customize"
android:title="@string/preferences_customize"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_passwords"
android:title="@string/preferences_passwords_logins_and_passwords"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_credit_cards"
android:title="@string/preferences_credit_cards"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_accessibility"
android:title="@string/preferences_accessibility"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_language"
android:title="@string/preferences_language"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory
android:key="@string/pref_key_sign_in"
android:layout="@layout/preference_category_no_icon_style"
android:title="@string/preferences_category_account">
<androidx.preference.Preference
android:key="@string/pref_key_sign_in"
android:title="@string/preferences_sync"
app:allowDividerBelow="true"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory
android:key="@string/pref_key_account_category"
android:layout="@layout/preference_category_no_icon_style"
android:title="@string/preferences_category_account"
app:isPreferenceVisible="false">
<org.mozilla.fenix.settings.account.AccountPreference
android:key="@string/pref_key_account"
app:iconSpaceReserved="false"/>
<org.mozilla.fenix.settings.account.AccountAuthErrorPreference
android:key="@string/pref_key_account_auth_error"
app:iconSpaceReserved="false"/>
</androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory
android:layout="@layout/preference_category_no_icon_style"
android:title="@string/preferences_category_privacy_security">
<androidx.preference.Preference
android:key="@string/pref_key_private_browsing"
android:title="@string/preferences_private_browsing_options"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_tracking_protection_settings"
android:title="@string/preference_enhanced_tracking_protection"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_site_permissions"
android:title="@string/preferences_site_permissions"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_delete_browsing_data"
android:title="@string/preferences_delete_browsing_data"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_delete_browsing_data_on_quit_preference"
android:title="@string/preferences_delete_browsing_data_on_quit"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_notifications"
android:title="@string/preferences_notifications"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_data_choices"
android:title="@string/preferences_data_collection"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory>
<PreferenceCategory
android:key="@string/pref_key_advanced"
android:layout="@layout/preference_category_no_icon_style"
android:title="@string/preferences_category_advanced">
<androidx.preference.Preference
android:key="@string/pref_key_addons"
android:title="@string/preferences_addons"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_override_amo_collection"
android:title="@string/preferences_customize_amo_collection"
app:iconSpaceReserved="false" />
<androidx.preference.SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_open_links_in_external_app"
android:title="@string/preferences_open_links_in_apps"
app:iconSpaceReserved="false" />
<androidx.preference.SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_external_download_manager"
android:title="@string/preferences_external_download_manager"
app:iconSpaceReserved="false" />
<androidx.preference.SwitchPreference
android:defaultValue="true"
android:key="@string/pref_key_leakcanary"
android:title="@string/preference_leakcanary"
app:iconSpaceReserved="false"
app:isPreferenceVisible="@bool/IS_DEBUG" />
<androidx.preference.SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_remote_debugging"
android:title="@string/preferences_remote_debugging"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<androidx.preference.PreferenceCategory
android:layout="@layout/preference_category_no_icon_style"
android:title="@string/preferences_category_about"
app:iconSpaceReserved="false">
<androidx.preference.Preference
android:key="@string/pref_key_rate"
android:title="@string/preferences_rate"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_about"
android:title="@string/preferences_about"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="@string/pref_key_debug_settings"
android:title="@string/preferences_debug_settings"
app:iconSpaceReserved="false"
app:isPreferenceVisible="false" />
<androidx.preference.Preference
android:key="@string/pref_key_secret_debug_info"
android:title="@string/preferences_debug_info"
app:iconSpaceReserved="false"
app:isPreferenceVisible="false" />
<androidx.preference.Preference
android:key="@string/pref_key_nimbus_experiments"
android:title="@string/preferences_nimbus_experiments"
app:isPreferenceVisible="false" />
</androidx.preference.PreferenceCategory>
</androidx.preference.PreferenceScreen>

@ -63,13 +63,6 @@ features:
- channel: developer
value:
enabled: true
default-browser-message:
description: A small feature allowing experiments on the placement of a default browser message.
variables:
message-location:
description: Where is the message to be put.
type: Option<MessageSurfaceId>
default: null
messaging:
description: |
Configuration for the messaging system.

Loading…
Cancel
Save