mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-11 13:11:01 +00:00
Fix merge
This commit is contained in:
parent
7dcbf8c542
commit
1ebeca1e19
@ -17,6 +17,7 @@ class ReviewManager {
|
|||||||
fun requestReviewFlow(): FakeReviewFlowTask {
|
fun requestReviewFlow(): FakeReviewFlowTask {
|
||||||
return FakeReviewFlowTask()
|
return FakeReviewFlowTask()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER", "UNUSED_EXPRESSION")
|
@Suppress("UNUSED_PARAMETER", "UNUSED_EXPRESSION")
|
||||||
fun launchReviewFlow(ignored1: Any, ignored2: Any) {
|
fun launchReviewFlow(ignored1: Any, ignored2: Any) {
|
||||||
1
|
1
|
||||||
|
@ -57,7 +57,7 @@ class PagedAddonCollectionProvider(
|
|||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val client: Client,
|
private val client: Client,
|
||||||
private val serverURL: String = DEFAULT_SERVER_URL,
|
private val serverURL: String = DEFAULT_SERVER_URL,
|
||||||
private val maxCacheAgeInMinutes: Long = -1
|
private val maxCacheAgeInMinutes: Long = -1,
|
||||||
) : AddonsProvider {
|
) : AddonsProvider {
|
||||||
|
|
||||||
private val logger = Logger("PagedAddonCollectionProvider")
|
private val logger = Logger("PagedAddonCollectionProvider")
|
||||||
@ -72,11 +72,11 @@ class PagedAddonCollectionProvider(
|
|||||||
if (Config.channel.isNightlyOrDebug && context.settings().amoCollectionOverrideConfigured()) {
|
if (Config.channel.isNightlyOrDebug && context.settings().amoCollectionOverrideConfigured()) {
|
||||||
result = context.settings().overrideAmoUser
|
result = context.settings().overrideAmoUser
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Determined collection account: ${result}")
|
logger.info("Determined collection account: $result")
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the collection name we should be fetching addons from.
|
* Get the collection name we should be fetching addons from.
|
||||||
*/
|
*/
|
||||||
@ -85,8 +85,8 @@ class PagedAddonCollectionProvider(
|
|||||||
if (Config.channel.isNightlyOrDebug && context.settings().amoCollectionOverrideConfigured()) {
|
if (Config.channel.isNightlyOrDebug && context.settings().amoCollectionOverrideConfigured()) {
|
||||||
result = context.settings().overrideAmoCollection
|
result = context.settings().overrideAmoCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Determined collection name: ${result}")
|
logger.info("Determined collection name: $result")
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,22 +108,22 @@ class PagedAddonCollectionProvider(
|
|||||||
override suspend fun getAvailableAddons(
|
override suspend fun getAvailableAddons(
|
||||||
allowCache: Boolean,
|
allowCache: Boolean,
|
||||||
readTimeoutInSeconds: Long?,
|
readTimeoutInSeconds: Long?,
|
||||||
language: String?
|
language: String?,
|
||||||
): List<Addon> {
|
): List<Addon> {
|
||||||
val cachedAddons = if (allowCache && !cacheExpired(context)) {
|
val cachedAddons = if (allowCache && !cacheExpired(context)) {
|
||||||
readFromDiskCache()
|
readFromDiskCache()
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
val collectionAccount = getCollectionAccount()
|
val collectionAccount = getCollectionAccount()
|
||||||
val collectionName = getCollectionName()
|
val collectionName = getCollectionName()
|
||||||
|
|
||||||
if (cachedAddons != null) {
|
if (cachedAddons != null) {
|
||||||
logger.info("Providing cached list of addons for ${collectionAccount} collection ${collectionName}")
|
logger.info("Providing cached list of addons for $collectionAccount collection $collectionName")
|
||||||
return cachedAddons
|
return cachedAddons
|
||||||
} else {
|
} else {
|
||||||
logger.info("Fetching fresh list of addons for ${collectionAccount} collection ${collectionName}")
|
logger.info("Fetching fresh list of addons for $collectionAccount collection $collectionName")
|
||||||
return getAllPages(
|
return getAllPages(
|
||||||
listOf(
|
listOf(
|
||||||
serverURL,
|
serverURL,
|
||||||
@ -132,9 +132,9 @@ class PagedAddonCollectionProvider(
|
|||||||
collectionAccount,
|
collectionAccount,
|
||||||
"collections",
|
"collections",
|
||||||
collectionName,
|
collectionName,
|
||||||
"addons"
|
"addons",
|
||||||
).joinToString("/"),
|
).joinToString("/"),
|
||||||
readTimeoutInSeconds ?: DEFAULT_READ_TIMEOUT_IN_SECONDS
|
readTimeoutInSeconds ?: DEFAULT_READ_TIMEOUT_IN_SECONDS,
|
||||||
).also {
|
).also {
|
||||||
// Cache the JSON object before we parse out the addons
|
// Cache the JSON object before we parse out the addons
|
||||||
if (maxCacheAgeInMinutes > 0) {
|
if (maxCacheAgeInMinutes > 0) {
|
||||||
@ -164,8 +164,8 @@ class PagedAddonCollectionProvider(
|
|||||||
client.fetch(
|
client.fetch(
|
||||||
Request(
|
Request(
|
||||||
url = nextURL,
|
url = nextURL,
|
||||||
readTimeout = Pair(readTimeoutInSeconds, TimeUnit.SECONDS)
|
readTimeout = Pair(readTimeoutInSeconds, TimeUnit.SECONDS),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.use { response ->
|
.use { response ->
|
||||||
if (!response.isSuccess) {
|
if (!response.isSuccess) {
|
||||||
@ -201,7 +201,7 @@ class PagedAddonCollectionProvider(
|
|||||||
var bitmap: Bitmap? = null
|
var bitmap: Bitmap? = null
|
||||||
if (addon.iconUrl != "") {
|
if (addon.iconUrl != "") {
|
||||||
client.fetch(
|
client.fetch(
|
||||||
Request(url = addon.iconUrl.sanitizeURL())
|
Request(url = addon.iconUrl.sanitizeURL()),
|
||||||
).use { response ->
|
).use { response ->
|
||||||
if (response.isSuccess) {
|
if (response.isSuccess) {
|
||||||
response.body.useStream {
|
response.body.useStream {
|
||||||
@ -288,7 +288,7 @@ internal fun JSONObject.toAddons(): Addon {
|
|||||||
iconUrl = getSafeString("icon_url"),
|
iconUrl = getSafeString("icon_url"),
|
||||||
siteUrl = getSafeString("url"),
|
siteUrl = getSafeString("url"),
|
||||||
rating = getRating(),
|
rating = getRating(),
|
||||||
defaultLocale = getSafeString("default_locale").ifEmpty { Addon.DEFAULT_LOCALE }
|
defaultLocale = getSafeString("default_locale").ifEmpty { Addon.DEFAULT_LOCALE },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,7 +298,7 @@ internal fun JSONObject.getRating(): Addon.Rating? {
|
|||||||
return if (jsonRating != null) {
|
return if (jsonRating != null) {
|
||||||
Addon.Rating(
|
Addon.Rating(
|
||||||
reviews = jsonRating.optInt("count"),
|
reviews = jsonRating.optInt("count"),
|
||||||
average = jsonRating.optDouble("average").toFloat()
|
average = jsonRating.optDouble("average").toFloat(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
@ -357,7 +357,7 @@ internal fun JSONObject.getAuthors(): List<Addon.Author> {
|
|||||||
id = authorJson.getSafeString("id"),
|
id = authorJson.getSafeString("id"),
|
||||||
name = authorJson.getSafeString("name"),
|
name = authorJson.getSafeString("name"),
|
||||||
username = authorJson.getSafeString("username"),
|
username = authorJson.getSafeString("username"),
|
||||||
url = authorJson.getSafeString("url")
|
url = authorJson.getSafeString("url"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ private const val KEY_DIALOG_WIDTH_MATCH_PARENT = "KEY_DIALOG_WIDTH_MATCH_PARENT
|
|||||||
private const val KEY_CONFIRM_BUTTON_BACKGROUND_COLOR = "KEY_CONFIRM_BUTTON_BACKGROUND_COLOR"
|
private const val KEY_CONFIRM_BUTTON_BACKGROUND_COLOR = "KEY_CONFIRM_BUTTON_BACKGROUND_COLOR"
|
||||||
private const val KEY_CONFIRM_BUTTON_TEXT_COLOR = "KEY_CONFIRM_BUTTON_TEXT_COLOR"
|
private const val KEY_CONFIRM_BUTTON_TEXT_COLOR = "KEY_CONFIRM_BUTTON_TEXT_COLOR"
|
||||||
private const val KEY_CONFIRM_BUTTON_RADIUS = "KEY_CONFIRM_BUTTON_RADIUS"
|
private const val KEY_CONFIRM_BUTTON_RADIUS = "KEY_CONFIRM_BUTTON_RADIUS"
|
||||||
|
|
||||||
@VisibleForTesting internal const val KEY_ICON = "KEY_ICON"
|
@VisibleForTesting internal const val KEY_ICON = "KEY_ICON"
|
||||||
|
|
||||||
private const val DEFAULT_VALUE = Int.MAX_VALUE
|
private const val DEFAULT_VALUE = Int.MAX_VALUE
|
||||||
@ -59,8 +60,10 @@ private const val DEFAULT_VALUE = Int.MAX_VALUE
|
|||||||
@SuppressLint("all")
|
@SuppressLint("all")
|
||||||
class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
||||||
private val scope = CoroutineScope(Dispatchers.IO)
|
private val scope = CoroutineScope(Dispatchers.IO)
|
||||||
|
|
||||||
@VisibleForTesting internal var iconJob: Job? = null
|
@VisibleForTesting internal var iconJob: Job? = null
|
||||||
private val logger = Logger("PagedAddonInstallationDialogFragment")
|
private val logger = Logger("PagedAddonInstallationDialogFragment")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A lambda called when the confirm button is clicked.
|
* A lambda called when the confirm button is clicked.
|
||||||
*/
|
*/
|
||||||
@ -84,7 +87,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
get() =
|
get() =
|
||||||
safeArguments.getInt(
|
safeArguments.getInt(
|
||||||
KEY_DIALOG_GRAVITY,
|
KEY_DIALOG_GRAVITY,
|
||||||
DEFAULT_VALUE
|
DEFAULT_VALUE,
|
||||||
)
|
)
|
||||||
internal val dialogShouldWidthMatchParent: Boolean
|
internal val dialogShouldWidthMatchParent: Boolean
|
||||||
get() =
|
get() =
|
||||||
@ -94,14 +97,14 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
get() =
|
get() =
|
||||||
safeArguments.getInt(
|
safeArguments.getInt(
|
||||||
KEY_CONFIRM_BUTTON_BACKGROUND_COLOR,
|
KEY_CONFIRM_BUTTON_BACKGROUND_COLOR,
|
||||||
DEFAULT_VALUE
|
DEFAULT_VALUE,
|
||||||
)
|
)
|
||||||
|
|
||||||
internal val confirmButtonTextColor
|
internal val confirmButtonTextColor
|
||||||
get() =
|
get() =
|
||||||
safeArguments.getInt(
|
safeArguments.getInt(
|
||||||
KEY_CONFIRM_BUTTON_TEXT_COLOR,
|
KEY_CONFIRM_BUTTON_TEXT_COLOR,
|
||||||
DEFAULT_VALUE
|
DEFAULT_VALUE,
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
@ -141,8 +144,8 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
rootView,
|
rootView,
|
||||||
LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +155,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
val rootView = LayoutInflater.from(requireContext()).inflate(
|
val rootView = LayoutInflater.from(requireContext()).inflate(
|
||||||
R.layout.mozac_feature_addons_fragment_dialog_addon_installed,
|
R.layout.mozac_feature_addons_fragment_dialog_addon_installed,
|
||||||
null,
|
null,
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
|
|
||||||
val binding = MozacFeatureAddonsFragmentDialogAddonInstalledBinding.bind(rootView)
|
val binding = MozacFeatureAddonsFragmentDialogAddonInstalledBinding.bind(rootView)
|
||||||
@ -161,7 +164,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
requireContext().getString(
|
requireContext().getString(
|
||||||
R.string.mozac_feature_addons_installed_dialog_title,
|
R.string.mozac_feature_addons_installed_dialog_title,
|
||||||
addon.translateName(requireContext()),
|
addon.translateName(requireContext()),
|
||||||
requireContext().appName
|
requireContext().appName,
|
||||||
)
|
)
|
||||||
|
|
||||||
val icon = safeArguments.getParcelable<Bitmap>(KEY_ICON)
|
val icon = safeArguments.getParcelable<Bitmap>(KEY_ICON)
|
||||||
@ -199,8 +202,8 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
shape.setColor(
|
shape.setColor(
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
confirmButtonBackgroundColor
|
confirmButtonBackgroundColor,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
shape.cornerRadius = confirmButtonRadius
|
shape.cornerRadius = confirmButtonRadius
|
||||||
confirmButton.background = shape
|
confirmButton.background = shape
|
||||||
@ -226,7 +229,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
val att = context.theme.resolveAttribute(android.R.attr.textColorPrimary)
|
val att = context.theme.resolveAttribute(android.R.attr.textColorPrimary)
|
||||||
iconView.setColorFilter(ContextCompat.getColor(context, att))
|
iconView.setColorFilter(ContextCompat.getColor(context, att))
|
||||||
iconView.setImageDrawable(
|
iconView.setImageDrawable(
|
||||||
ContextCompat.getDrawable(context, R.drawable.mozac_ic_extensions)
|
ContextCompat.getDrawable(context, R.drawable.mozac_ic_extensions),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
logger.error("Attempt to fetch the ${addon.id} icon failed", e)
|
logger.error("Attempt to fetch the ${addon.id} icon failed", e)
|
||||||
@ -260,11 +263,10 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
addonCollectionProvider: PagedAddonCollectionProvider,
|
addonCollectionProvider: PagedAddonCollectionProvider,
|
||||||
promptsStyling: PromptsStyling? = PromptsStyling(
|
promptsStyling: PromptsStyling? = PromptsStyling(
|
||||||
gravity = Gravity.BOTTOM,
|
gravity = Gravity.BOTTOM,
|
||||||
shouldWidthMatchParent = true
|
shouldWidthMatchParent = true,
|
||||||
),
|
),
|
||||||
onConfirmButtonClicked: ((Addon, Boolean) -> Unit)? = null
|
onConfirmButtonClicked: ((Addon, Boolean) -> Unit)? = null,
|
||||||
): PagedAddonInstallationDialogFragment {
|
): PagedAddonInstallationDialogFragment {
|
||||||
|
|
||||||
val fragment = PagedAddonInstallationDialogFragment()
|
val fragment = PagedAddonInstallationDialogFragment()
|
||||||
val arguments = fragment.arguments ?: Bundle()
|
val arguments = fragment.arguments ?: Bundle()
|
||||||
|
|
||||||
@ -302,7 +304,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
|
|||||||
val confirmButtonBackgroundColor: Int? = null,
|
val confirmButtonBackgroundColor: Int? = null,
|
||||||
@ColorRes
|
@ColorRes
|
||||||
val confirmButtonTextColor: Int? = null,
|
val confirmButtonTextColor: Int? = null,
|
||||||
val confirmButtonRadius: Float? = null
|
val confirmButtonRadius: Float? = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ class PagedAddonsManagerAdapter(
|
|||||||
) : ListAdapter<Any, CustomViewHolder>(DifferCallback) {
|
) : ListAdapter<Any, CustomViewHolder>(DifferCallback) {
|
||||||
private val scope = CoroutineScope(Dispatchers.IO)
|
private val scope = CoroutineScope(Dispatchers.IO)
|
||||||
private val logger = Logger("PagedAddonsManagerAdapter")
|
private val logger = Logger("PagedAddonsManagerAdapter")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents all the add-ons that will be distributed in multiple headers like
|
* Represents all the add-ons that will be distributed in multiple headers like
|
||||||
* enabled, recommended and unsupported, this help have the data source of the items,
|
* enabled, recommended and unsupported, this help have the data source of the items,
|
||||||
@ -106,7 +107,7 @@ class PagedAddonsManagerAdapter(
|
|||||||
val view = inflater.inflate(
|
val view = inflater.inflate(
|
||||||
R.layout.mozac_feature_addons_section_unsupported_section_item,
|
R.layout.mozac_feature_addons_section_unsupported_section_item,
|
||||||
parent,
|
parent,
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
val titleView = view.findViewById<TextView>(R.id.title)
|
val titleView = view.findViewById<TextView>(R.id.title)
|
||||||
val descriptionView = view.findViewById<TextView>(R.id.description)
|
val descriptionView = view.findViewById<TextView>(R.id.description)
|
||||||
@ -135,7 +136,7 @@ class PagedAddonsManagerAdapter(
|
|||||||
ratingAccessibleView,
|
ratingAccessibleView,
|
||||||
userCountView,
|
userCountView,
|
||||||
addButton,
|
addButton,
|
||||||
allowedInPrivateBrowsingLabel
|
allowedInPrivateBrowsingLabel,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ class PagedAddonsManagerAdapter(
|
|||||||
is AddonViewHolder -> bindAddon(holder, item as Addon)
|
is AddonViewHolder -> bindAddon(holder, item as Addon)
|
||||||
is UnsupportedSectionViewHolder -> bindNotYetSupportedSection(
|
is UnsupportedSectionViewHolder -> bindNotYetSupportedSection(
|
||||||
holder,
|
holder,
|
||||||
item as NotYetSupportedSection
|
item as NotYetSupportedSection,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,7 +172,7 @@ class PagedAddonsManagerAdapter(
|
|||||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||||
internal fun bindNotYetSupportedSection(
|
internal fun bindNotYetSupportedSection(
|
||||||
holder: UnsupportedSectionViewHolder,
|
holder: UnsupportedSectionViewHolder,
|
||||||
section: NotYetSupportedSection
|
section: NotYetSupportedSection,
|
||||||
) {
|
) {
|
||||||
val unsupportedAddons = addonsMap.values.filter { it.inUnsupportedSection() }
|
val unsupportedAddons = addonsMap.values.filter { it.inUnsupportedSection() }
|
||||||
val context = holder.itemView.context
|
val context = holder.itemView.context
|
||||||
@ -182,7 +183,7 @@ class PagedAddonsManagerAdapter(
|
|||||||
} else {
|
} else {
|
||||||
context.getString(
|
context.getString(
|
||||||
R.string.mozac_feature_addons_unsupported_caption_plural,
|
R.string.mozac_feature_addons_unsupported_caption_plural,
|
||||||
unsupportedAddons.size.toString()
|
unsupportedAddons.size.toString(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ class PagedAddonsManagerAdapter(
|
|||||||
val ratingContentDescription =
|
val ratingContentDescription =
|
||||||
String.format(
|
String.format(
|
||||||
context.getString(R.string.mozac_feature_addons_rating_content_description),
|
context.getString(R.string.mozac_feature_addons_rating_content_description),
|
||||||
it.average
|
it.average,
|
||||||
)
|
)
|
||||||
holder.ratingView.contentDescription = ratingContentDescription
|
holder.ratingView.contentDescription = ratingContentDescription
|
||||||
// Android RatingBar is not very accessibility-friendly, we will use non visible TextView
|
// Android RatingBar is not very accessibility-friendly, we will use non visible TextView
|
||||||
@ -337,7 +338,7 @@ class PagedAddonsManagerAdapter(
|
|||||||
val addonSummaryTextColor: Int? = null,
|
val addonSummaryTextColor: Int? = null,
|
||||||
val sectionsTypeFace: Typeface? = null,
|
val sectionsTypeFace: Typeface? = null,
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
val addonAllowPrivateBrowsingLabelDrawableRes: Int? = null
|
val addonAllowPrivateBrowsingLabelDrawableRes: Int? = null,
|
||||||
) {
|
) {
|
||||||
internal fun maybeSetSectionsTextColor(textView: TextView) {
|
internal fun maybeSetSectionsTextColor(textView: TextView) {
|
||||||
sectionsTextColor?.let {
|
sectionsTextColor?.let {
|
||||||
|
@ -21,8 +21,7 @@ object FeatureFlags {
|
|||||||
/**
|
/**
|
||||||
* Enables the Sync Addresses feature.
|
* Enables the Sync Addresses feature.
|
||||||
*/
|
*/
|
||||||
<<<<<<< HEAD
|
const val syncAddressesFeature = true
|
||||||
const val syncAddressesFeature = false
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables the onboarding sync CFR on the home screen.
|
* Enables the onboarding sync CFR on the home screen.
|
||||||
@ -38,9 +37,6 @@ object FeatureFlags {
|
|||||||
* Enables the first run onboarding updates.
|
* Enables the first run onboarding updates.
|
||||||
*/
|
*/
|
||||||
const val showFirstRunOnboardingUpdates = false
|
const val showFirstRunOnboardingUpdates = false
|
||||||
=======
|
|
||||||
const val addressesFeature = true
|
|
||||||
>>>>>>> e1281c453... Do all of Iceraven in one commit
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables the "recent" tabs feature in the home screen.
|
* Enables the "recent" tabs feature in the home screen.
|
||||||
|
@ -52,9 +52,9 @@ import java.util.concurrent.CancellationException
|
|||||||
*/
|
*/
|
||||||
@Suppress("TooManyFunctions", "LargeClass")
|
@Suppress("TooManyFunctions", "LargeClass")
|
||||||
class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management) {
|
class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management) {
|
||||||
|
|
||||||
private val logger = Logger("AddonsManagementFragment")
|
private val logger = Logger("AddonsManagementFragment")
|
||||||
|
|
||||||
private val args by navArgs<AddonsManagementFragmentArgs>()
|
private val args by navArgs<AddonsManagementFragmentArgs>()
|
||||||
|
|
||||||
private var binding: FragmentAddOnsManagementBinding? = null
|
private var binding: FragmentAddOnsManagementBinding? = null
|
||||||
@ -64,6 +64,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
|
|||||||
*/
|
*/
|
||||||
private var isInstallationInProgress = false
|
private var isInstallationInProgress = false
|
||||||
private var adapter: PagedAddonsManagerAdapter? = null
|
private var adapter: PagedAddonsManagerAdapter? = null
|
||||||
|
|
||||||
// We must save the add-on list in the class, or we won't have it
|
// We must save the add-on list in the class, or we won't have it
|
||||||
// downloaded for the non-suspending search function
|
// downloaded for the non-suspending search function
|
||||||
private var addons: List<Addon>? = null
|
private var addons: List<Addon>? = null
|
||||||
@ -71,7 +72,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
|
|||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?,
|
||||||
): View? {
|
): View? {
|
||||||
logger.info("Creating view for AddonsManagementFragment")
|
logger.info("Creating view for AddonsManagementFragment")
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
@ -108,7 +109,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
|
|||||||
override fun onQueryTextChange(newText: String): Boolean {
|
override fun onQueryTextChange(newText: String): Boolean {
|
||||||
return searchAddons(newText.trim())
|
return searchAddons(newText.trim())
|
||||||
}
|
}
|
||||||
})
|
},)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun searchAddons(addonNameSubStr: String): Boolean {
|
private fun searchAddons(addonNameSubStr: String): Boolean {
|
||||||
@ -167,17 +168,17 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
|
|||||||
|
|
||||||
private fun bindRecyclerView() {
|
private fun bindRecyclerView() {
|
||||||
logger.info("Binding recycler view for AddonsManagementFragment")
|
logger.info("Binding recycler view for AddonsManagementFragment")
|
||||||
|
|
||||||
val managementView = AddonsManagementView(
|
val managementView = AddonsManagementView(
|
||||||
navController = findNavController(),
|
navController = findNavController(),
|
||||||
showPermissionDialog = ::showPermissionDialog,
|
showPermissionDialog = ::showPermissionDialog,
|
||||||
)
|
)
|
||||||
|
|
||||||
val recyclerView = binding?.addOnsList
|
val recyclerView = binding?.addOnsList
|
||||||
recyclerView?.layoutManager = LinearLayoutManager(requireContext())
|
recyclerView?.layoutManager = LinearLayoutManager(requireContext())
|
||||||
val shouldRefresh = adapter != null
|
val shouldRefresh = adapter != null
|
||||||
|
|
||||||
logger.info("AddonsManagementFragment should refresh? ${shouldRefresh}")
|
logger.info("AddonsManagementFragment should refresh? $shouldRefresh")
|
||||||
|
|
||||||
// If the fragment was launched to install an "external" add-on from AMO, we deactivate
|
// If the fragment was launched to install an "external" add-on from AMO, we deactivate
|
||||||
// the cache to get the most up-to-date list of add-ons to match against.
|
// the cache to get the most up-to-date list of add-ons to match against.
|
||||||
@ -193,7 +194,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
|
|||||||
requireContext().components.addonCollectionProvider,
|
requireContext().components.addonCollectionProvider,
|
||||||
managementView,
|
managementView,
|
||||||
addons!!,
|
addons!!,
|
||||||
style = createAddonStyle(requireContext())
|
style = createAddonStyle(requireContext()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
isInstallationInProgress = false
|
isInstallationInProgress = false
|
||||||
|
@ -108,7 +108,7 @@ class Components(private val context: Context) {
|
|||||||
context,
|
context,
|
||||||
core.client,
|
core.client,
|
||||||
serverURL = BuildConfig.AMO_SERVER_URL,
|
serverURL = BuildConfig.AMO_SERVER_URL,
|
||||||
maxCacheAgeInMinutes = AMO_COLLECTION_MAX_CACHE_AGE
|
maxCacheAgeInMinutes = AMO_COLLECTION_MAX_CACHE_AGE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,11 +114,15 @@ class BrowserToolbarView(
|
|||||||
|
|
||||||
display.urlFormatter =
|
display.urlFormatter =
|
||||||
if (settings.shouldStripUrl) {
|
if (settings.shouldStripUrl) {
|
||||||
url ->
|
{
|
||||||
URLStringUtils.toDisplayUrl(url)
|
url ->
|
||||||
|
URLStringUtils.toDisplayUrl(url)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
url ->
|
{
|
||||||
url
|
url ->
|
||||||
|
url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
display.colors = display.colors.copy(
|
display.colors = display.colors.copy(
|
||||||
|
@ -91,7 +91,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
STATE_COLLAPSED,
|
STATE_COLLAPSED,
|
||||||
STATE_DRAGGING,
|
STATE_DRAGGING,
|
||||||
STATE_SETTLING,
|
STATE_SETTLING,
|
||||||
STATE_HIDDEN
|
STATE_HIDDEN,
|
||||||
)
|
)
|
||||||
@kotlin.annotation.Retention(AnnotationRetention.SOURCE)
|
@kotlin.annotation.Retention(AnnotationRetention.SOURCE)
|
||||||
annotation class State
|
annotation class State
|
||||||
@ -115,7 +115,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
if (mViewRef != null && mViewRef!!.get() != null) {
|
if (mViewRef != null && mViewRef!!.get() != null) {
|
||||||
mMinOffset =
|
mMinOffset =
|
||||||
(-mViewRef!!.get()!!.height).coerceAtLeast(
|
(-mViewRef!!.get()!!.height).coerceAtLeast(
|
||||||
-(mViewRef!!.get()!!.height - mPeekHeight)
|
-(mViewRef!!.get()!!.height - mPeekHeight),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
init {
|
init {
|
||||||
val a = context.obtainStyledAttributes(
|
val a = context.obtainStyledAttributes(
|
||||||
attrs,
|
attrs,
|
||||||
R.styleable.BottomSheetBehavior_Layout
|
R.styleable.BottomSheetBehavior_Layout,
|
||||||
)
|
)
|
||||||
shapeThemingEnabled =
|
shapeThemingEnabled =
|
||||||
a.hasValue(R.styleable.BottomSheetBehavior_Layout_shapeAppearance)
|
a.hasValue(R.styleable.BottomSheetBehavior_Layout_shapeAppearance)
|
||||||
@ -159,11 +159,11 @@ class TopSheetBehavior<V : View?>
|
|||||||
peekHeight = (context.resources.displayMetrics.heightPixels * PEEK_HEIGHT_RATIO).toInt()
|
peekHeight = (context.resources.displayMetrics.heightPixels * PEEK_HEIGHT_RATIO).toInt()
|
||||||
isHideable = a.getBoolean(
|
isHideable = a.getBoolean(
|
||||||
R.styleable.BottomSheetBehavior_Layout_behavior_hideable,
|
R.styleable.BottomSheetBehavior_Layout_behavior_hideable,
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
skipCollapsed = a.getBoolean(
|
skipCollapsed = a.getBoolean(
|
||||||
R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed,
|
R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed,
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
a.recycle()
|
a.recycle()
|
||||||
val configuration =
|
val configuration =
|
||||||
@ -175,16 +175,16 @@ class TopSheetBehavior<V : View?>
|
|||||||
return SavedState(
|
return SavedState(
|
||||||
super.onSaveInstanceState(
|
super.onSaveInstanceState(
|
||||||
parent,
|
parent,
|
||||||
child!!
|
child!!,
|
||||||
),
|
),
|
||||||
mState
|
mState,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRestoreInstanceState(
|
override fun onRestoreInstanceState(
|
||||||
parent: CoordinatorLayout,
|
parent: CoordinatorLayout,
|
||||||
child: V,
|
child: V,
|
||||||
state: Parcelable
|
state: Parcelable,
|
||||||
) {
|
) {
|
||||||
val ss =
|
val ss =
|
||||||
state as SavedState
|
state as SavedState
|
||||||
@ -201,7 +201,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
override fun onLayoutChild(
|
override fun onLayoutChild(
|
||||||
parent: CoordinatorLayout,
|
parent: CoordinatorLayout,
|
||||||
child: V,
|
child: V,
|
||||||
layoutDirection: Int
|
layoutDirection: Int,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child as View)) {
|
if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child as View)) {
|
||||||
child.fitsSystemWindows = true
|
child.fitsSystemWindows = true
|
||||||
@ -252,7 +252,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
override fun onInterceptTouchEvent(
|
override fun onInterceptTouchEvent(
|
||||||
parent: CoordinatorLayout,
|
parent: CoordinatorLayout,
|
||||||
child: V,
|
child: V,
|
||||||
event: MotionEvent
|
event: MotionEvent,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (!child!!.isShown) {
|
if (!child!!.isShown) {
|
||||||
return false
|
return false
|
||||||
@ -300,14 +300,14 @@ class TopSheetBehavior<V : View?>
|
|||||||
!parent.isPointInChildBounds(
|
!parent.isPointInChildBounds(
|
||||||
scroll,
|
scroll,
|
||||||
event.x.toInt(),
|
event.x.toInt(),
|
||||||
event.y.toInt()
|
event.y.toInt(),
|
||||||
) && abs(mInitialY - event.y) > mViewDragHelper!!.touchSlop
|
) && abs(mInitialY - event.y) > mViewDragHelper!!.touchSlop
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(
|
override fun onTouchEvent(
|
||||||
parent: CoordinatorLayout,
|
parent: CoordinatorLayout,
|
||||||
child: V,
|
child: V,
|
||||||
event: MotionEvent
|
event: MotionEvent,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (!child!!.isShown) {
|
if (!child!!.isShown) {
|
||||||
return false
|
return false
|
||||||
@ -334,7 +334,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
) {
|
) {
|
||||||
mViewDragHelper!!.captureChildView(
|
mViewDragHelper!!.captureChildView(
|
||||||
child,
|
child,
|
||||||
event.getPointerId(event.actionIndex)
|
event.getPointerId(event.actionIndex),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
child: V,
|
child: V,
|
||||||
directTargetChild: View,
|
directTargetChild: View,
|
||||||
target: View,
|
target: View,
|
||||||
nestedScrollAxes: Int
|
nestedScrollAxes: Int,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
mLastNestedScrollDy = 0
|
mLastNestedScrollDy = 0
|
||||||
mNestedScrolled = false
|
mNestedScrolled = false
|
||||||
@ -359,7 +359,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
target: View,
|
target: View,
|
||||||
dx: Int,
|
dx: Int,
|
||||||
dy: Int,
|
dy: Int,
|
||||||
consumed: IntArray
|
consumed: IntArray,
|
||||||
) {
|
) {
|
||||||
val scrollingChild = mNestedScrollingChildRef!!.get()
|
val scrollingChild = mNestedScrollingChildRef!!.get()
|
||||||
if (target !== scrollingChild) {
|
if (target !== scrollingChild) {
|
||||||
@ -399,7 +399,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
override fun onStopNestedScroll(
|
override fun onStopNestedScroll(
|
||||||
coordinatorLayout: CoordinatorLayout,
|
coordinatorLayout: CoordinatorLayout,
|
||||||
child: V,
|
child: V,
|
||||||
target: View
|
target: View,
|
||||||
) {
|
) {
|
||||||
if (child!!.top == mMaxOffset) {
|
if (child!!.top == mMaxOffset) {
|
||||||
setStateInternal(STATE_EXPANDED)
|
setStateInternal(STATE_EXPANDED)
|
||||||
@ -435,8 +435,8 @@ class TopSheetBehavior<V : View?>
|
|||||||
child,
|
child,
|
||||||
SettleRunnable(
|
SettleRunnable(
|
||||||
child,
|
child,
|
||||||
targetState
|
targetState,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
setStateInternal(targetState)
|
setStateInternal(targetState)
|
||||||
@ -449,14 +449,17 @@ class TopSheetBehavior<V : View?>
|
|||||||
child: V,
|
child: V,
|
||||||
target: View,
|
target: View,
|
||||||
velocityX: Float,
|
velocityX: Float,
|
||||||
velocityY: Float
|
velocityY: Float,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return target === mNestedScrollingChildRef!!.get() &&
|
return target === mNestedScrollingChildRef!!.get() &&
|
||||||
(
|
(
|
||||||
mState != STATE_EXPANDED ||
|
mState != STATE_EXPANDED ||
|
||||||
super.onNestedPreFling(
|
super.onNestedPreFling(
|
||||||
coordinatorLayout, child!!, target,
|
coordinatorLayout,
|
||||||
velocityX, velocityY
|
child!!,
|
||||||
|
target,
|
||||||
|
velocityX,
|
||||||
|
velocityY,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -508,7 +511,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
if (mViewDragHelper!!.smoothSlideViewTo(child, child.left, top)) {
|
if (mViewDragHelper!!.smoothSlideViewTo(child, child.left, top)) {
|
||||||
ViewCompat.postOnAnimation(
|
ViewCompat.postOnAnimation(
|
||||||
child,
|
child,
|
||||||
SettleRunnable(child, state)
|
SettleRunnable(child, state),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -596,7 +599,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
@Suppress("ReturnCount")
|
@Suppress("ReturnCount")
|
||||||
override fun tryCaptureView(
|
override fun tryCaptureView(
|
||||||
child: View,
|
child: View,
|
||||||
pointerId: Int
|
pointerId: Int,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (mState == STATE_DRAGGING) {
|
if (mState == STATE_DRAGGING) {
|
||||||
return false
|
return false
|
||||||
@ -619,7 +622,7 @@ class TopSheetBehavior<V : View?>
|
|||||||
left: Int,
|
left: Int,
|
||||||
top: Int,
|
top: Int,
|
||||||
dx: Int,
|
dx: Int,
|
||||||
dy: Int
|
dy: Int,
|
||||||
) {
|
) {
|
||||||
dispatchOnSlide(top)
|
dispatchOnSlide(top)
|
||||||
}
|
}
|
||||||
@ -633,9 +636,10 @@ class TopSheetBehavior<V : View?>
|
|||||||
override fun onViewReleased(
|
override fun onViewReleased(
|
||||||
releasedChild: View,
|
releasedChild: View,
|
||||||
xvel: Float,
|
xvel: Float,
|
||||||
yvel: Float
|
yvel: Float,
|
||||||
) {
|
) {
|
||||||
val top: Int
|
val top: Int
|
||||||
|
|
||||||
@State val targetState: Int
|
@State val targetState: Int
|
||||||
if (yvel > 0) { // Moving up
|
if (yvel > 0) { // Moving up
|
||||||
top = mMaxOffset
|
top = mMaxOffset
|
||||||
@ -662,8 +666,8 @@ class TopSheetBehavior<V : View?>
|
|||||||
releasedChild,
|
releasedChild,
|
||||||
SettleRunnable(
|
SettleRunnable(
|
||||||
releasedChild,
|
releasedChild,
|
||||||
targetState
|
targetState,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
setStateInternal(targetState)
|
setStateInternal(targetState)
|
||||||
@ -673,19 +677,19 @@ class TopSheetBehavior<V : View?>
|
|||||||
override fun clampViewPositionVertical(
|
override fun clampViewPositionVertical(
|
||||||
child: View,
|
child: View,
|
||||||
top: Int,
|
top: Int,
|
||||||
dy: Int
|
dy: Int,
|
||||||
): Int {
|
): Int {
|
||||||
return constrain(
|
return constrain(
|
||||||
top,
|
top,
|
||||||
if (isHideable) -child.height else mMinOffset,
|
if (isHideable) -child.height else mMinOffset,
|
||||||
mMaxOffset
|
mMaxOffset,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clampViewPositionHorizontal(
|
override fun clampViewPositionHorizontal(
|
||||||
child: View,
|
child: View,
|
||||||
left: Int,
|
left: Int,
|
||||||
dx: Int
|
dx: Int,
|
||||||
): Int {
|
): Int {
|
||||||
return child.left
|
return child.left
|
||||||
}
|
}
|
||||||
@ -701,14 +705,14 @@ class TopSheetBehavior<V : View?>
|
|||||||
|
|
||||||
private fun createMaterialShapeDrawable(
|
private fun createMaterialShapeDrawable(
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet
|
attrs: AttributeSet,
|
||||||
) {
|
) {
|
||||||
if (shapeThemingEnabled) {
|
if (shapeThemingEnabled) {
|
||||||
shapeAppearanceModelDefault = ShapeAppearanceModel.builder(
|
shapeAppearanceModelDefault = ShapeAppearanceModel.builder(
|
||||||
context,
|
context,
|
||||||
attrs,
|
attrs,
|
||||||
R.attr.bottomSheetStyle,
|
R.attr.bottomSheetStyle,
|
||||||
DEF_STYLE_RES
|
DEF_STYLE_RES,
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
materialShapeDrawable = MaterialShapeDrawable(shapeAppearanceModelDefault!!)
|
materialShapeDrawable = MaterialShapeDrawable(shapeAppearanceModelDefault!!)
|
||||||
@ -739,12 +743,13 @@ class TopSheetBehavior<V : View?>
|
|||||||
mCallback!!.onSlide(
|
mCallback!!.onSlide(
|
||||||
topSheet,
|
topSheet,
|
||||||
(top - mMinOffset).toFloat() / mPeekHeight,
|
(top - mMinOffset).toFloat() / mPeekHeight,
|
||||||
isOpening
|
isOpening,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
mCallback!!.onSlide(
|
mCallback!!.onSlide(
|
||||||
topSheet,
|
topSheet,
|
||||||
(top - mMinOffset).toFloat() / (mMaxOffset - mMinOffset), isOpening
|
(top - mMinOffset).toFloat() / (mMaxOffset - mMinOffset),
|
||||||
|
isOpening,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -752,7 +757,8 @@ class TopSheetBehavior<V : View?>
|
|||||||
|
|
||||||
private inner class SettleRunnable internal constructor(
|
private inner class SettleRunnable internal constructor(
|
||||||
private val mView: View,
|
private val mView: View,
|
||||||
@field:State @param:State private val mTargetState: Int
|
@field:State @param:State
|
||||||
|
private val mTargetState: Int,
|
||||||
) :
|
) :
|
||||||
Runnable {
|
Runnable {
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class CustomizationFragment : PreferenceFragmentCompat() {
|
|||||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// Used to send telemetry data about toolbar position changes
|
// Used to send telemetry data about toolbar position changes
|
||||||
enum class Position { TOP, BOTTOM }
|
enum class Position { TOP, BOTTOM }
|
||||||
|
@ -16,9 +16,9 @@ import org.mozilla.fenix.ext.settings
|
|||||||
* The preference key is used as the shared preference key.
|
* The preference key is used as the shared preference key.
|
||||||
*/
|
*/
|
||||||
open class SharedPreferenceUpdater : Preference.OnPreferenceChangeListener {
|
open class SharedPreferenceUpdater : Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
private val logger = Logger("SharedPreferenceUpdater")
|
private val logger = Logger("SharedPreferenceUpdater")
|
||||||
|
|
||||||
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
||||||
if (newValue is Boolean) {
|
if (newValue is Boolean) {
|
||||||
preference.context.settings().preferences.edit {
|
preference.context.settings().preferences.edit {
|
||||||
@ -28,14 +28,13 @@ open class SharedPreferenceUpdater : Preference.OnPreferenceChangeListener {
|
|||||||
preference.context.settings().preferences.edit {
|
preference.context.settings().preferences.edit {
|
||||||
putString(preference.key, newValue)
|
putString(preference.key, newValue)
|
||||||
}
|
}
|
||||||
logger.info("Set string preference ${preference.key} to ${newValue}")
|
logger.info("Set string preference ${preference.key} to $newValue")
|
||||||
if (preference.key == preference.context.getString(R.string.pref_key_addons_custom_account) ||
|
if (preference.key == preference.context.getString(R.string.pref_key_addons_custom_account) ||
|
||||||
preference.key == preference.context.getString(R.string.pref_key_addons_custom_collection)
|
preference.key == preference.context.getString(R.string.pref_key_addons_custom_collection)
|
||||||
) {
|
) {
|
||||||
logger.info("Preference suggests clearing add-on cache")
|
logger.info("Preference suggests clearing add-on cache")
|
||||||
preference.context.components.clearAddonCache()
|
preference.context.components.clearAddonCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -16,7 +16,7 @@ class ReleaseChannelTest {
|
|||||||
fun `isReleased and isDebug channels are mutually exclusive`() {
|
fun `isReleased and isDebug channels are mutually exclusive`() {
|
||||||
val debugChannels = setOf(
|
val debugChannels = setOf(
|
||||||
Debug,
|
Debug,
|
||||||
ForkDebug
|
ForkDebug,
|
||||||
)
|
)
|
||||||
|
|
||||||
val nonDebugChannels = ReleaseChannel.values().toSet() - debugChannels
|
val nonDebugChannels = ReleaseChannel.values().toSet() - debugChannels
|
||||||
|
@ -62,7 +62,7 @@ class AppStoreTest {
|
|||||||
currentMode = CurrentMode(
|
currentMode = CurrentMode(
|
||||||
context,
|
context,
|
||||||
onboarding,
|
onboarding,
|
||||||
browsingModeManager
|
browsingModeManager,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
appState = AppState(
|
appState = AppState(
|
||||||
@ -72,7 +72,7 @@ class AppStoreTest {
|
|||||||
topSites = emptyList(),
|
topSites = emptyList(),
|
||||||
showCollectionPlaceholder = true,
|
showCollectionPlaceholder = true,
|
||||||
showSetAsDefaultBrowserCard = true,
|
showSetAsDefaultBrowserCard = true,
|
||||||
recentTabs = emptyList()
|
recentTabs = emptyList(),
|
||||||
)
|
)
|
||||||
|
|
||||||
appStore = AppStore(appState)
|
appStore = AppStore(appState)
|
||||||
@ -122,8 +122,8 @@ class AppStoreTest {
|
|||||||
val highlight = RecentHistoryHighlight(title = group2.title, "")
|
val highlight = RecentHistoryHighlight(title = group2.title, "")
|
||||||
appStore = AppStore(
|
appStore = AppStore(
|
||||||
AppState(
|
AppState(
|
||||||
recentHistory = listOf(group1, group2, group3, highlight)
|
recentHistory = listOf(group1, group2, group3, highlight),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
assertEquals(0, appStore.state.recentTabs.size)
|
assertEquals(0, appStore.state.recentTabs.size)
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class AppStoreTest {
|
|||||||
val h1 = RecentHistoryHighlight(title = "highlight One", url = "url1")
|
val h1 = RecentHistoryHighlight(title = "highlight One", url = "url1")
|
||||||
val h2 = RecentHistoryHighlight(title = "highlight two", url = "url2")
|
val h2 = RecentHistoryHighlight(title = "highlight two", url = "url2")
|
||||||
val recentHistoryState = AppState(
|
val recentHistoryState = AppState(
|
||||||
recentHistory = listOf(g1, g2, h1, h2)
|
recentHistory = listOf(g1, g2, h1, h2),
|
||||||
)
|
)
|
||||||
appStore = AppStore(recentHistoryState)
|
appStore = AppStore(recentHistoryState)
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ class AppStoreTest {
|
|||||||
appStore.dispatch(AppAction.RemoveRecentHistoryHighlight(h1.url)).join()
|
appStore.dispatch(AppAction.RemoveRecentHistoryHighlight(h1.url)).join()
|
||||||
assertEquals(
|
assertEquals(
|
||||||
recentHistoryState.copy(recentHistory = listOf(g1, g2, h2)),
|
recentHistoryState.copy(recentHistory = listOf(g1, g2, h2)),
|
||||||
appStore.state
|
appStore.state,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,8 +251,8 @@ class AppStoreTest {
|
|||||||
showCollectionPlaceholder = true,
|
showCollectionPlaceholder = true,
|
||||||
recentTabs = recentTabs,
|
recentTabs = recentTabs,
|
||||||
recentBookmarks = recentBookmarks,
|
recentBookmarks = recentBookmarks,
|
||||||
recentHistory = recentHistory
|
recentHistory = recentHistory,
|
||||||
)
|
),
|
||||||
).join()
|
).join()
|
||||||
|
|
||||||
assertEquals(collections, appStore.state.collections)
|
assertEquals(collections, appStore.state.collections)
|
||||||
@ -273,8 +273,8 @@ class AppStoreTest {
|
|||||||
pocketStoriesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
|
pocketStoriesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
|
||||||
pocketStoriesCategoriesSelections = listOf(
|
pocketStoriesCategoriesSelections = listOf(
|
||||||
PocketRecommendedStoriesSelectedCategory(otherStoriesCategory.name),
|
PocketRecommendedStoriesSelectedCategory(otherStoriesCategory.name),
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
mockkStatic("org.mozilla.fenix.ext.AppStateKt") {
|
mockkStatic("org.mozilla.fenix.ext.AppStateKt") {
|
||||||
@ -301,9 +301,9 @@ class AppStoreTest {
|
|||||||
pocketStoriesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
|
pocketStoriesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
|
||||||
pocketStoriesCategoriesSelections = listOf(
|
pocketStoriesCategoriesSelections = listOf(
|
||||||
PocketRecommendedStoriesSelectedCategory(otherStoriesCategory.name),
|
PocketRecommendedStoriesSelectedCategory(otherStoriesCategory.name),
|
||||||
PocketRecommendedStoriesSelectedCategory(anotherStoriesCategory.name)
|
PocketRecommendedStoriesSelectedCategory(anotherStoriesCategory.name),
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
mockkStatic("org.mozilla.fenix.ext.AppStateKt") {
|
mockkStatic("org.mozilla.fenix.ext.AppStateKt") {
|
||||||
@ -346,13 +346,13 @@ class AppStoreTest {
|
|||||||
every { any<AppState>().getFilteredStories(any()) } returns firstFilteredStories
|
every { any<AppState>().getFilteredStories(any()) } returns firstFilteredStories
|
||||||
|
|
||||||
appStore.dispatch(
|
appStore.dispatch(
|
||||||
AppAction.PocketStoriesCategoriesChange(listOf(otherStoriesCategory, anotherStoriesCategory))
|
AppAction.PocketStoriesCategoriesChange(listOf(otherStoriesCategory, anotherStoriesCategory)),
|
||||||
).join()
|
).join()
|
||||||
verify { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
|
verify { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
|
||||||
assertTrue(
|
assertTrue(
|
||||||
appStore.state.pocketStoriesCategories.containsAll(
|
appStore.state.pocketStoriesCategories.containsAll(
|
||||||
listOf(otherStoriesCategory, anotherStoriesCategory)
|
listOf(otherStoriesCategory, anotherStoriesCategory),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
assertSame(firstFilteredStories, appStore.state.pocketStories)
|
assertSame(firstFilteredStories, appStore.state.pocketStories)
|
||||||
|
|
||||||
@ -361,8 +361,8 @@ class AppStoreTest {
|
|||||||
every { any<AppState>().getFilteredStories(any()) } returns secondFilteredStories
|
every { any<AppState>().getFilteredStories(any()) } returns secondFilteredStories
|
||||||
appStore.dispatch(
|
appStore.dispatch(
|
||||||
AppAction.PocketStoriesCategoriesChange(
|
AppAction.PocketStoriesCategoriesChange(
|
||||||
updatedCategories
|
updatedCategories,
|
||||||
)
|
),
|
||||||
).join()
|
).join()
|
||||||
verify(exactly = 2) { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
|
verify(exactly = 2) { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
|
||||||
assertTrue(updatedCategories.containsAll(appStore.state.pocketStoriesCategories))
|
assertTrue(updatedCategories.containsAll(appStore.state.pocketStoriesCategories))
|
||||||
@ -384,17 +384,17 @@ class AppStoreTest {
|
|||||||
appStore.dispatch(
|
appStore.dispatch(
|
||||||
AppAction.PocketStoriesCategoriesSelectionsChange(
|
AppAction.PocketStoriesCategoriesSelectionsChange(
|
||||||
storiesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
|
storiesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
|
||||||
categoriesSelected = listOf(selectedCategory)
|
categoriesSelected = listOf(selectedCategory),
|
||||||
)
|
),
|
||||||
).join()
|
).join()
|
||||||
verify { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
|
verify { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
|
||||||
assertTrue(
|
assertTrue(
|
||||||
appStore.state.pocketStoriesCategories.containsAll(
|
appStore.state.pocketStoriesCategories.containsAll(
|
||||||
listOf(otherStoriesCategory, anotherStoriesCategory)
|
listOf(otherStoriesCategory, anotherStoriesCategory),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
assertTrue(
|
assertTrue(
|
||||||
appStore.state.pocketStoriesCategoriesSelections.containsAll(listOf(selectedCategory))
|
appStore.state.pocketStoriesCategoriesSelections.containsAll(listOf(selectedCategory)),
|
||||||
)
|
)
|
||||||
assertSame(firstFilteredStories, appStore.state.pocketStories)
|
assertSame(firstFilteredStories, appStore.state.pocketStories)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user