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.
Issue mozilla-mobile#9801: Refactor AutofillCreditCardsAddressesStora…
…ge into its own :service-sync-autofill component
- Loading branch information
1 parent
a22f285
commit 768f2b7
Showing
17 changed files
with
199 additions
and
90 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# [Android Components](../../../README.md) > Service > Firefox Sync - Autofill | ||
|
||
A library for autofilling addresses and credit cards based on `concept-storage` backed by [application-services' Autofill lib](https://github.com/mozilla/application-services). | ||
|
||
## Usage | ||
|
||
### Setting up the dependency | ||
|
||
Use Gradle to download the library from [maven.mozilla.org](https://maven.mozilla.org/) ([Setup repository](../../../README.md#maven-repository)): | ||
|
||
```Groovy | ||
implementation "org.mozilla.components:service-sync-autofill:{latest-version}" | ||
``` | ||
|
||
## License | ||
|
||
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/ |
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/. */ | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion config.compileSdkVersion | ||
|
||
defaultConfig { | ||
minSdkVersion config.minSdkVersion | ||
targetSdkVersion config.targetSdkVersion | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
api Dependencies.mozilla_sync_autofill | ||
|
||
api project(':concept-storage') | ||
|
||
implementation project(':support-utils') | ||
|
||
implementation Dependencies.kotlin_stdlib | ||
|
||
testImplementation project(':support-test') | ||
|
||
testImplementation Dependencies.androidx_test_core | ||
testImplementation Dependencies.androidx_test_junit | ||
testImplementation Dependencies.testing_robolectric | ||
testImplementation Dependencies.testing_mockito | ||
testImplementation Dependencies.testing_coroutines | ||
testImplementation Dependencies.mozilla_full_megazord_forUnitTests | ||
} | ||
|
||
apply from: '../../../publish.gradle' | ||
ext.configurePublish(config.componentsGroupId, archivesBaseName, project.ext.description) |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
5 changes: 5 additions & 0 deletions
5
components/service/sync-autofill/src/main/AndroidManifest.xml
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,5 @@ | ||
<!-- 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/. --> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="mozilla.components.browser.storage.sync.autofill" /> |
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
89 changes: 89 additions & 0 deletions
89
...nts/service/sync-autofill/src/main/java/mozilla/components/service/sync/autofill/Types.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,89 @@ | ||
/* 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.service.sync.autofill | ||
|
||
import mozilla.components.concept.storage.Address | ||
import mozilla.components.concept.storage.CreditCard | ||
import mozilla.appservices.autofill.UpdatableAddressFields | ||
import mozilla.appservices.autofill.UpdatableCreditCardFields | ||
|
||
// We have type definitions at the concept level, and "external" types defined within Autofill. | ||
// In practice these two types are largely the same, and this file is the conversion point. | ||
|
||
/** | ||
* Conversion from a generic [UpdatableAddressFields] into its richer comrade within the 'autofill' lib. | ||
*/ | ||
internal fun mozilla.components.concept.storage.UpdatableAddressFields.into(): UpdatableAddressFields { | ||
return UpdatableAddressFields( | ||
givenName = this.givenName, | ||
additionalName = this.additionalName, | ||
familyName = this.familyName, | ||
organization = this.organization, | ||
streetAddress = this.streetAddress, | ||
addressLevel3 = this.addressLevel3, | ||
addressLevel2 = this.addressLevel2, | ||
addressLevel1 = this.addressLevel1, | ||
postalCode = this.postalCode, | ||
country = this.country, | ||
tel = this.tel, | ||
email = this.email | ||
) | ||
} | ||
|
||
/** | ||
* Conversion from a generic [UpdatableCreditCardFields] into its richer comrade within the 'autofill' lib. | ||
*/ | ||
internal fun mozilla.components.concept.storage.UpdatableCreditCardFields.into(): UpdatableCreditCardFields { | ||
return UpdatableCreditCardFields( | ||
ccName = this.billingName, | ||
ccNumber = this.cardNumber, | ||
ccExpMonth = this.expiryMonth, | ||
ccExpYear = this.expiryYear, | ||
ccType = this.cardType | ||
) | ||
} | ||
|
||
/** | ||
* Conversion from a "native" autofill [Address] into its generic comrade. | ||
*/ | ||
internal fun mozilla.appservices.autofill.Address.into(): Address { | ||
return Address( | ||
guid = this.guid, | ||
givenName = this.givenName, | ||
additionalName = this.additionalName, | ||
familyName = this.familyName, | ||
organization = this.organization, | ||
streetAddress = this.streetAddress, | ||
addressLevel3 = this.addressLevel3, | ||
addressLevel2 = this.addressLevel2, | ||
addressLevel1 = this.addressLevel1, | ||
postalCode = this.postalCode, | ||
country = this.country, | ||
tel = this.tel, | ||
email = this.email, | ||
timeCreated = this.timeCreated, | ||
timeLastUsed = this.timeLastUsed, | ||
timeLastModified = this.timeLastModified, | ||
timesUsed = this.timesUsed | ||
) | ||
} | ||
|
||
/** | ||
* Conversion from a "native" autofill [CreditCard] into its generic comrade. | ||
*/ | ||
internal fun mozilla.appservices.autofill.CreditCard.into(): CreditCard { | ||
return CreditCard( | ||
guid = this.guid, | ||
billingName = this.ccName, | ||
cardNumber = this.ccNumber, | ||
expiryMonth = this.ccExpMonth, | ||
expiryYear = this.ccExpYear, | ||
cardType = this.ccType, | ||
timeCreated = this.timeCreated, | ||
timeLastUsed = this.timeLastUsed, | ||
timeLastModified = this.timeLastModified, | ||
timesUsed = this.timesUsed | ||
) | ||
} |
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
1 change: 1 addition & 0 deletions
1
...service/sync-autofill/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
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 @@ | ||
mock-maker-inline |
1 change: 1 addition & 0 deletions
1
components/service/sync-autofill/src/test/resources/robolectric.properties
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 @@ | ||
sdk=28 |
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