Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 12289
Browse files Browse the repository at this point in the history
  • Loading branch information
iorgamgabriel committed Jun 23, 2022
2 parents e14785a + 961e37a commit e440c9c
Show file tree
Hide file tree
Showing 19 changed files with 145 additions and 37 deletions.
3 changes: 3 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ object Versions {
const val mozilla_appservices = "93.5.0"

const val mozilla_glean = "50.1.0"
// FIXME(bug 1775073): Hack to deploy a tiny bug fix without requiring a full Glean update
// Will be removed with the next update again.
const val mozilla_glean_plugin = "50.1.1"

const val material = "1.2.1"

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Gecko.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object Gecko {
/**
* GeckoView Version.
*/
const val version = "103.0.20220619065701"
const val version = "103.0.20220622094342"

/**
* GeckoView channel
Expand Down
2 changes: 1 addition & 1 deletion components/browser/engine-gecko/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean_plugin}"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import mozilla.components.browser.engine.gecko.ext.toAutocompleteAddress
import mozilla.components.browser.engine.gecko.ext.toCreditCardEntry
import mozilla.components.browser.engine.gecko.ext.toLoginEntry
import mozilla.components.concept.storage.CreditCard
Expand All @@ -32,6 +33,21 @@ class GeckoAutocompleteStorageDelegate(
private val loginStorageDelegate: LoginStorageDelegate
) : Autocomplete.StorageDelegate {

override fun onAddressFetch(): GeckoResult<Array<Autocomplete.Address>>? {
val result = GeckoResult<Array<Autocomplete.Address>>()

@OptIn(DelicateCoroutinesApi::class)
GlobalScope.launch(IO) {
val addresses = creditCardsAddressesStorageDelegate.onAddressesFetch()
.map { it.toAutocompleteAddress() }
.toTypedArray()

result.complete(addresses)
}

return result
}

override fun onCreditCardFetch(): GeckoResult<Array<Autocomplete.CreditCard>> {
val result = GeckoResult<Array<Autocomplete.CreditCard>>()

Expand Down
15 changes: 4 additions & 11 deletions components/browser/errorpages/src/main/assets/errorPageScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,13 @@ function updateShowSSL(queryMap) {
}

/**
* Used to show or hide the "advanced" button based for the HSTS error page
* Used to show or hide the "accept" button based for the HSTS error page
*/
function updateShowHSTS(queryMap) {
/** @type {'true' | 'false'} */
const showHSTS = queryMap.showHSTS;
if (typeof document.addCertException === "undefined") {
document.getElementById('advancedButton').style.display='none';
} else {
if (showHSTS === 'true') {
document.getElementById('advancedButton').style.display='block';
document.getElementById('advancedPanelAcceptButton').style.display='none';
} else {
document.getElementById('advancedButton').style.display='none';
}
if (showHSTS === 'true') {
document.getElementById('advancedButton').style.display='block';
document.getElementById('advancedPanelAcceptButton').style.display='none';
}
}

Expand Down
1 change: 1 addition & 0 deletions components/concept/storage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
api Dependencies.kotlin_coroutines

implementation project(':support-ktx')
implementation Dependencies.androidx_annotation

testImplementation project(':support-test')
testImplementation Dependencies.testing_junit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package mozilla.components.concept.storage

import android.annotation.SuppressLint
import android.os.Parcelable
import androidx.annotation.VisibleForTesting
import kotlinx.parcelize.Parcelize
import mozilla.components.concept.storage.CreditCard.Companion.ellipsesEnd
import mozilla.components.concept.storage.CreditCard.Companion.ellipsesStart
Expand Down Expand Up @@ -372,6 +373,30 @@ data class Address(
get() = listOf(givenName, additionalName, familyName)
.filter { it.isNotEmpty() }
.joinToString(" ")

/**
* Returns a label for the [Address]. The ordering is based on the
* priorities defined by the desktop code found here:
* https://searchfox.org/mozilla-central/rev/d989c65584ded72c2de85cb40bede7ac2f176387/toolkit/components/formautofill/FormAutofillUtils.jsm#323
*/
val addressLabel: String
get() = listOf(
streetAddress.toOneLineAddress(),
addressLevel3,
addressLevel2,
organization,
addressLevel1,
country,
postalCode,
tel,
email
).filter { it.isNotEmpty() }.joinToString(", ")

companion object {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun String.toOneLineAddress(): String =
this.split("\n").joinToString(separator = " ") { it.trim() }
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package mozilla.components.concept.storage

import mozilla.components.concept.storage.Address.Companion.toOneLineAddress
import org.junit.Assert.assertEquals
import org.junit.Test

Expand Down Expand Up @@ -44,6 +45,62 @@ class AddressTest {
assertEquals(address.familyName, fullName)
}

@Test
fun `WHEN all address properties are present THEN full address present in label`() {
val address = generateAddress()
val expected =
"${address.streetAddress}, ${address.addressLevel3}, ${address.addressLevel2}, " +
"${address.organization}, ${address.addressLevel1}, ${address.country}, " +
"${address.postalCode}, ${address.tel}, ${address.email}"

assertEquals(expected, address.addressLabel)
}

@Test
fun `WHEN any address properties are missing THEN label only includes only properties that are available`() {
val address = generateAddress(
addressLevel3 = "",
organization = "",
email = "",
)
val expected =
"${address.streetAddress}, ${address.addressLevel2}, ${address.addressLevel1}, " +
"${address.country}, ${address.postalCode}, ${address.tel}"

assertEquals(expected, address.addressLabel)
}

@Test
fun `WHEN no address properties are present THEN label is the empty string`() {
val address = generateAddress(
givenName = "",
additionalName = "",
familyName = "",
organization = "",
streetAddress = "",
addressLevel3 = "",
addressLevel2 = "",
addressLevel1 = "",
postalCode = "",
country = "",
tel = "",
email = ""
)

assertEquals("", address.addressLabel)
}

@Test
fun `GIVEN multiline street address WHEN one line address is called THEN an one line address is returned`() {
val streetAddress = """
line1
line2
line3
""".trimIndent()

assertEquals("line1 line2 line3", streetAddress.toOneLineAddress())
}

private fun generateAddress(
guid: String = "",
givenName: String = "Firefox",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,10 @@ internal class AddressViewHolder(

fun bind(address: Address) {
this.address = address
itemView.findViewById<TextView>(R.id.address_name)?.text = address.displayFormat()
itemView.findViewById<TextView>(R.id.address_name)?.text = address.addressLabel
}

override fun onClick(v: View?) {
onAddressSelected(address)
}
}

/**
* Format the address details to be displayed to the user.
*/
fun Address.displayFormat(): String =
"${this.streetAddress}, ${this.addressLevel2}, ${this.addressLevel1}, ${this.postalCode}"
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="56dp"
android:text="@string/mozac_feature_prompts_select_address"
android:text="@string/mozac_feature_prompts_select_address_2"
android:textColor="?android:colorEdgeEffect"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
6 changes: 4 additions & 2 deletions components/feature/prompts/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- 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/. -->
<resources>
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:moz="http://mozac.org/tools">
<!-- Text for confirmation for a positive action in dialog -->
<string name="mozac_feature_prompts_ok">OK</string>
<!-- Text for confirmation for a negative action in dialog. -->
Expand Down Expand Up @@ -119,7 +119,9 @@

<!-- Address Autofill -->
<!-- Header for the select address prompt to allow users to fill a form with a saved address. -->
<string name="mozac_feature_prompts_select_address">Select addresses</string>
<string name="mozac_feature_prompts_select_address" moz:removedIn="104" tools:ignore="UnusedResources">Select addresses</string>
<!-- Header for the select address prompt to allow users to fill a form with a saved address. -->
<string name="mozac_feature_prompts_select_address_2">Select address</string>
<!-- Content description for expanding the select addresses options in the select address prompt. -->
<string name="mozac_feature_prompts_expand_address_content_description">Expand suggested addresses</string>
<!-- Content description for collapsing the select address options in the select address prompt. -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* 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/. */

package mozilla.components.feature.prompts.address

Expand Down Expand Up @@ -56,19 +59,21 @@ class AddressAdapterTest {
@Test
fun `WHEN an address is bound to the adapter THEN set the address display name`() {
val view =
LayoutInflater.from(testContext).inflate(R.layout.mozac_feature_prompts_address_list_item, null)
LayoutInflater.from(testContext)
.inflate(R.layout.mozac_feature_prompts_address_list_item, null)
val addressName: TextView = view.findViewById(R.id.address_name)

AddressViewHolder(view) {}.bind(address)
AddressViewHolder(view, onAddressSelected = {}).bind(address)

assertEquals(address.displayFormat(), addressName.text)
assertEquals(address.addressLabel, addressName.text)
}

@Test
fun `WHEN an address item is clicked THEN call the onAddressSelected callback`() {
var addressSelected = false
val view =
LayoutInflater.from(testContext).inflate(R.layout.mozac_feature_prompts_address_list_item, null)
LayoutInflater.from(testContext)
.inflate(R.layout.mozac_feature_prompts_address_list_item, null)
val onAddressSelect: (Address) -> Unit = { addressSelected = true }

AddressViewHolder(view, onAddressSelect).bind(address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}

.mozac-readerview-body.dark {
background-color: #222222;
background-color: #1c1b22;
color: #eeeeee;
}

Expand Down Expand Up @@ -172,11 +172,23 @@
font-weight: normal;
}

.mozac-readerview-body.dark :is(
.mozac-readerview-content a,
.mozac-readerview-content a:hover,
.mozac-readerview-content a:active
):not(.mozac-readerview-content a:visited) {
color: #45a1ff !important;
}

.mozac-readerview-content a,
.mozac-readerview-content a:visited,
.mozac-readerview-content a:hover,
.mozac-readerview-content a:active {
color: #00acff !important;
.mozac-readerview-content a:active
:not(.mozac-readerview-content a:visited) {
color: #0060df !important;
}

.mozac-readerview-content a:visited {
color: #b5007f !important;
}

.mozac-readerview-content h1 {
Expand Down
2 changes: 1 addition & 1 deletion components/lib/crash/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean_plugin}"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/support/migration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean_plugin}"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/support/sync-telemetry/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean_plugin}"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/tooling/glean-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
dependencies {
implementation gradleApi()
implementation localGroovy()
implementation "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
implementation "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean_plugin}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}

Expand Down
2 changes: 1 addition & 1 deletion samples/glean/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean_plugin}"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/glean/samples-glean-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean_plugin}"
}
}
}
Expand Down

0 comments on commit e440c9c

Please sign in to comment.