forked from mozilla-mobile/android-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For mozilla-mobile#12060 - Add support for select address prompt request
- Loading branch information
Alexandru2909
committed
May 3, 2022
1 parent
ab8b5a5
commit bc27cbb
Showing
7 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/ext/Address.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* 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.browser.engine.gecko.ext | ||
|
||
import mozilla.components.concept.engine.prompt.Address | ||
import org.mozilla.geckoview.Autocomplete | ||
|
||
/** | ||
* Converts a GeckoView [Autocomplete.Address] to an Android Components [Address]. | ||
*/ | ||
fun Autocomplete.Address.toAddress() = Address( | ||
guid = guid, | ||
givenName = givenName, | ||
additionalName = additionalName, | ||
familyName = familyName, | ||
organization = organization, | ||
streetAddress = streetAddress, | ||
addressLevel3 = addressLevel3, | ||
addressLevel2 = addressLevel2, | ||
addressLevel1 = addressLevel1, | ||
postalCode = postalCode, | ||
country = country, | ||
tel = tel, | ||
email = email | ||
) | ||
|
||
/** | ||
* Converts an Android Components [Address] to a GeckoView [Autocomplete.Address]. | ||
*/ | ||
fun Address.toAutocompleteAddress() = Autocomplete.Address.Builder() | ||
.guid(guid) | ||
.givenName(givenName) | ||
.additionalName(additionalName) | ||
.familyName(familyName) | ||
.organization(organization) | ||
.streetAddress(streetAddress) | ||
.addressLevel3(addressLevel3) | ||
.addressLevel2(addressLevel2) | ||
.addressLevel1(addressLevel1) | ||
.postalCode(postalCode) | ||
.country(country) | ||
.tel(tel) | ||
.email(email) | ||
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
components/concept/engine/src/main/java/mozilla/components/concept/engine/prompt/Address.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* 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.concept.engine.prompt | ||
|
||
import android.annotation.SuppressLint | ||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* Information about an address. | ||
* | ||
* @property guid The unique identifier for this address. | ||
* @property givenName First name. | ||
* @property additionalName Middle name. | ||
* @property familyName Last name. | ||
* @property organization Organization. | ||
* @property streetAddress Street address. | ||
* @property addressLevel3 Sublocality (Suburb) name type. | ||
* @property addressLevel2 Locality (City/Town) name type. | ||
* @property addressLevel1 Province/State name type. | ||
* @property postalCode Postal code. | ||
* @property country Country. | ||
* @property tel Telephone number. | ||
* @property email E-mail address. | ||
* @property timeCreated Time of creation in milliseconds from the unix epoch. | ||
* @property timeLastUsed Time of last use in milliseconds from the unix epoch. | ||
* @property timeLastModified Time of last modified in milliseconds from the unix epoch. | ||
* @property timesUsed Number of times the address was used. | ||
*/ | ||
@SuppressLint("ParcelCreator") | ||
@Parcelize | ||
data class Address( | ||
val guid: String?, | ||
val givenName: String, | ||
val additionalName: String, | ||
val familyName: String, | ||
val organization: String, | ||
val streetAddress: String, | ||
val addressLevel3: String, | ||
val addressLevel2: String, | ||
val addressLevel1: String, | ||
val postalCode: String, | ||
val country: String, | ||
val tel: String, | ||
val email: String, | ||
val timeCreated: Long = 0L, | ||
val timeLastUsed: Long? = 0L, | ||
val timeLastModified: Long = 0L, | ||
val timesUsed: Long = 0L | ||
) : Parcelable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters