Skip to content

Commit 9988726

Browse files
committed
Added:
- new setOnYotiButtonClickListener method. Changelog file - gradle plugin for closing and publication of the repo on OSSRH (maven central) Modified: - Deprecating setOnYotiScenarioListener method - Using newest version of base-commons-ui that adds space between the image and the text of the Yoti button - Sorting out issues in the gradle files. - Small changes in the Readme file Removed: - Retrieve profile section from the README file
1 parent 103471b commit 9988726

File tree

16 files changed

+142
-251
lines changed

16 files changed

+142
-251
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
5+
## [0.0.6] - 2018-04-10
6+
### Added
7+
- setOnYotiButtonClickListener method
8+
- Changelog file
9+
10+
### Changed
11+
- Deprecating setOnYotiScenarioListener method
12+
- Using newest version of base-commons-ui that adds space between the image and the text of the Yoti button
13+
- Sorting out issues in the gradle files.
14+
- Small changes in the Readme file
15+
16+
### Removed
17+
- Retrieve profile section from the README file
18+
19+
## [0.0.5] - 2015-12-03
20+
### Added
21+
- Sample app where callback is handled manually
22+
- License file
23+
24+
### Changed
25+
- "Yoti not installed" scenario can now be dealt with by the user
26+

README.md

Lines changed: 41 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This repo contains the tools and step by step instructions so that your users ca
2020
## Requirements
2121

2222
* You will need to have the Yoti app on your phone
23-
* You will need to ensure the minimum version of your android is 2.2.3 or above.
23+
* You will need to ensure the minimum version of your android is 4.0.3 or above.
2424

2525

2626
## Installing the SDK
@@ -40,7 +40,7 @@ For more information please follow our developer page instructions located [here
4040

4141
Make sure you have mavenCentral repository added in your allProjects entry in your root build.gradle:
4242

43-
```javascript
43+
```gradle
4444
allprojects {
4545
repositories {
4646
mavenCentral()
@@ -50,15 +50,20 @@ allprojects {
5050

5151
Please start by adding dependencies in the "build.grade" file inside your application module directory:
5252

53-
```javascript
53+
```gradle
5454
dependencies {
55-
compile(group: 'com.yoti.mobile.android.sdk', name: 'yoti-button-sdk', version: '0.0.5', ext: 'aar'){
56-
transitive = true
57-
}
58-
...
55+
compile(com.yoti.mobile.android.sdk:yoti-button-sdk:0.0.6)
56+
}
57+
```
58+
OR if you are using a recent version of gradle (>= 3.x):
59+
```gradle
60+
dependencies {
61+
implementation(com.yoti.mobile.android.sdk:yoti-button-sdk:0.0.6)
5962
}
6063
```
6164

65+
[See this code in one of our sample apps](./sample-app/build.gradle)
66+
6267
After syncing, go to your layout file where you wish the Yoti button to appear add the below config:
6368

6469
```xml
@@ -70,7 +75,7 @@ android:layout_width="wrap_content"
7075
android:text="My Yoti Button"
7176
yoti:useCaseId="YOUR_USE_CASE_ID"/>
7277
```
73-
78+
[See this code in one of our sample apps](./sample-app/src/main/res/layout/activity_main.xml)
7479

7580
The client end of the integration is now complete.
7681

@@ -86,6 +91,7 @@ Add the below configuration to your manifest:
8691
</intent-filter>
8792
</receiver>
8893
```
94+
[See this code in one of our sample apps](./sample-app/src/main/AndroidManifest.xml)
8995

9096
Adding this broadcast receiver class, this acts as a listener for Yoti to get the callback URL from the Yoti app. Please note there are two call back options:
9197

@@ -102,7 +108,7 @@ To be able to listen to those actions you will need to:
102108
The AbstractYotiBroadcastReceiver will handle the logic regarding those actions, that's why your BroadcastReceiver will have to extend it. The first action defined (MY_CALLBACK_ACTION) will be used by the Yoti app to give you the result of the attributes sharing with your app.
103109
We have included both config below :
104110

105-
```javascript
111+
```java
106112
@Override
107113
public boolean onCallbackReceived(String useCaseId, String callbackRoot, String token, String fullUrl) {
108114
// triggered by MY_CALLBACK_ACTION
@@ -127,12 +133,14 @@ We have included both config below :
127133
}
128134
}
129135
```
136+
[See this code in one of our sample apps](./sample-app/src/main/java/com/yoti/mobile/android/sdk/sampleapp/ShareAttributesResultBroadcastReceiver.java)
137+
130138

131139
You will now need to specify your Client SDK ID and Scenario ID ready from your application dashboard.
132140
The SDK can be initialised like this:
133141

134142

135-
```javascript
143+
```java
136144
Scenario scenario = null;
137145
try {
138146
scenario = new Scenario.Builder()
@@ -149,17 +157,38 @@ try {
149157
YotiSDK.addScenario(scenario);
150158
```
151159

160+
[See this code in one of our sample apps](./sample-app/src/main/java/com/yoti/mobile/android/sdk/sampleapp/MainActivity.java)
161+
162+
In order to set a listener for the events on the Yoti button you can specify one this way:
163+
164+
```java
165+
yotiSDKButton.setOnYotiButtonListener(new YotiSDKButton.OnYotiButtonClickListener() {
166+
@Override
167+
public void onStartScenario() {
168+
yotiSDKButton.setVisibility(View.GONE);
169+
progress.setVisibility(View.VISIBLE);
170+
message.setText(null);
171+
}
172+
173+
@Override
174+
public void onStartScenarioError(YotiSDKException cause){
175+
yotiSDKButton.setVisibility(View.VISIBLE);
176+
progress.setVisibility(View.GONE);
177+
message.setText(R.string.loc_error_unknown); }
178+
});
179+
```
180+
152181

153182
You can activate a verbose mode for the SDK by using this method :
154-
```javascript
183+
```java
155184
YotiSDK.enableSDKLogging(true);
156185
```
157186

158187
If the Yoti app is not installed in the user's phone by default the SDK will send and intent to
159188
open a website that invites the user to download the Yoti app.
160189
Alternatively, an error listener can be set up so you can deal with this situation by yourself.
161190

162-
```javascript
191+
```java
163192
yotiSDKButton.setOnYotiAppNotInstalledListener(new YotiSDKButton.OnYotiAppNotInstalledListener() {
164193
@Override
165194
public void onYotiAppNotInstalledError(YotiSDKNoYotiAppException cause) {
@@ -168,65 +197,6 @@ Alternatively, an error listener can be set up so you can deal with this situati
168197
});
169198
```
170199

171-
## Profile Retrieval
172-
173-
Once the profile has been retrieved, you can present that data in the app.
174-
175-
To get the profile details you could do something like this:
176-
177-
```javascript
178-
Gson g = new GsonBuilder().create();
179-
Profile profile = g.fromJson(new String(response), Profile.class);
180-
181-
Intent intent = new Intent(this, ProfileActivity.class);
182-
intent.putExtra(NAME_EXTRA, profile.getGivenNames() + " " + profile.getFamilyName());
183-
intent.putExtra(EMAIL_EXTRA, profile.getEmailAddress());
184-
intent.putExtra(IMAGE_EXTRA, profile.getSelfie());
185-
intent.putExtra(DOB_EXTRA, profile.getDateOfBirth());
186-
intent.putExtra(ADDRESS_EXTRA, profile.getPostalAddress());
187-
intent.putExtra(MOBILE_EXTRA, profile.getMobNum());
188-
intent.putExtra(GENDER_EXTRA, profile.getGender());
189-
startActivity(intent);
190-
```
191-
192-
And then display that data as you would normally do:
193-
194-
```javascript
195-
@Override
196-
protected void onCreate(Bundle savedInstanceState) {
197-
super.onCreate(savedInstanceState);
198-
setContentView(R.layout.activity_profile);
199-
200-
ImageView profile = findViewById(R.id.img_profile);
201-
TextView nameTextView = findViewById(R.id.text_view_name);
202-
TextView emailTextView = findViewById(R.id.text_view_email);
203-
TextView addressTextView = findViewById(R.id.text_view_address);
204-
TextView mobileTextView = findViewById(R.id.text_view_mobile);
205-
TextView genderTextView = findViewById(R.id.text_view_gender);
206-
TextView dobTextView = findViewById(R.id.text_view_dob);
207-
TextView nationalityTextView = findViewById(R.id.text_view_nationality);
208-
209-
String imageString = getIntent().getStringExtra("image");
210-
byte[] decodedString = Base64.decode(imageString.substring(imageString.indexOf(",") + 1), Base64.DEFAULT);
211-
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
212-
profile.setImageBitmap(decodedByte);
213-
214-
nameTextView.setText(getIntent().getStringExtra("name"));
215-
emailTextView.setText(getIntent().getStringExtra("email"));
216-
addressTextView.setText(getIntent().getStringExtra("address"));
217-
mobileTextView.setText(getIntent().getStringExtra("mobile"));
218-
genderTextView.setText(getIntent().getStringExtra("gender"));
219-
dobTextView.setText(getIntent().getStringExtra("dob"));
220-
nationalityTextView.setText(getIntent().getStringExtra("nationality"));
221-
}
222-
}
223-
```
224-
225-
## Handling Users
226-
227-
The Web SDK will handle the user storage. When you retrieve the user profile, you receive a user ID generated by Yoti exclusively for your application. This means that if the same individual logs into another app, Yoti will assign her/him a different ID. You can use this ID to verify whether (for your application) the retrieved profile identifies a new or an existing user. Please see relevant github pages for more information.
228-
229-
230200
## Running the Example
231201

232202
In this repository we provide two sample apps.

build.gradle

Lines changed: 5 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,25 @@ buildscript {
44
repositories {
55
jcenter()
66
google()
7+
mavenCentral()
78
}
89
dependencies {
910
classpath 'com.android.tools.build:gradle:3.0.1'
10-
11-
// NOTE: Do not place your application dependencies here; they belong
12-
// in the individual module build.gradle files
11+
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0"
1312
}
1413
}
1514

15+
apply plugin: 'io.codearte.nexus-staging'
16+
17+
1618
allprojects {
1719
repositories {
1820
mavenCentral()
1921
jcenter()
20-
// maven { url lkRepoRelease }
21-
// maven { url lkRepoSnapshot }
2222
google()
2323
}
2424

2525
ext {
26-
2726
// Android config
2827
androidBuildToolsVersion = project.ext.buildToolsVersion
2928
androidMinSdkVersion = minSdkVersionVersion.toInteger()
@@ -35,90 +34,5 @@ allprojects {
3534
// Testing
3635
libJunit = "junit:junit:${libJunitVersion}"
3736
libMockito = "org.mockito:mockito-all:${libMockitoVersion}"
38-
39-
updatePomClosure = { MavenPublication publication, String flavor, String buildType, buildTask ->
40-
String flavorAsSuffix = (flavor == null ? "" : "-" + flavor);
41-
String aarName = "yoti-sdk-" + flavorAsSuffix + "-" + buildType;
42-
43-
publication.groupId "com.yoti.mobile.android.sdk"
44-
publication.artifact source: "$buildDir/outputs/aar/" + aarName + ".aar", builtBy: buildTask
45-
publication.artifactId = "button-sdk" + flavorAsSuffix
46-
publication.version = currentVersion + (buildType.equalsIgnoreCase("debug") ? "-SNAPSHOT" : "")
47-
48-
publication.pom.withXml {
49-
def dependenciesNode = asNode().appendNode('dependencies')
50-
51-
Set<String> used = new HashSet<>();
52-
configurations.each {
53-
54-
def configuration = it.name.toLowerCase()
55-
56-
if (configuration.contains("compile") && !configuration.contains("test") && !it.empty) {
57-
58-
def dependencies = it.allDependencies.iterator()
59-
60-
while (dependencies.hasNext()) {
61-
62-
def dependency = dependencies.next();
63-
64-
if (dependency.group) {
65-
66-
def artifactId = dependency.name;
67-
def dependencyVersion = dependency.version;
68-
69-
// For yoti specific dependency, it must either start with buildType or Contain Flavour and
70-
if (((flavor != null && !configuration.contains(flavor)
71-
&& !configuration.startsWith(buildType))
72-
|| !configuration.contains(buildType))
73-
&& dependency.group.startsWith("com.yoti")) {
74-
continue;
75-
}
76-
77-
// For yoti specific Project Dependencies add the build suffix to dependency version depending on buildType of dependency configuration.
78-
if (dependency instanceof ProjectDependency) {
79-
def depConf = ((ProjectDependency) dependency).projectConfiguration.name;
80-
if (depConf.toLowerCase().contains("debug")) {
81-
dependencyVersion += "-SNAPSHOT"
82-
}
83-
println(depConf);
84-
}
85-
86-
// For yoti specific dependencies add the environment name to the artifactId
87-
if (dependency.group.contains("com.yoti.mobile.android.core") ||
88-
dependency.group.contains("com.yoti.mobile.android.app")) {
89-
90-
if (configuration.contains("prep")) {
91-
artifactId = dependency.name + "-prep"
92-
93-
} else if (configuration.contains("prod")) {
94-
artifactId = dependency.name + "-prod"
95-
96-
} else if (configuration.contains("staging")) {
97-
artifactId = dependency.name + "-staging"
98-
}
99-
}
100-
101-
def fullArtefact = dependency.group + ":" + artifactId + ":" + dependencyVersion;
102-
println("artficat-LOG:: " + fullArtefact)
103-
104-
if (!used.contains(fullArtefact)) {
105-
used.add(fullArtefact)
106-
107-
def dependencyNode = dependenciesNode.appendNode('dependency')
108-
dependencyNode.appendNode('groupId', dependency.group)
109-
dependencyNode.appendNode('artifactId', artifactId)
110-
dependencyNode.appendNode('version', dependencyVersion)
111-
dependencyNode.appendNode('scope', 'compile')
112-
}
113-
}
114-
}
115-
}
116-
}
117-
}
118-
}
11937
}
12038
}
121-
122-
task clean(type: Delete) {
123-
delete rootProject.buildDir
124-
}

gradle.properties

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,31 @@ minSdkVersionVersion=15
2626
targetSdkVersion=25
2727
compileSdkVersion=25
2828

29-
yotiCommonUIVersion=0.0.3
29+
yotiCommonUIVersion=0.0.5
3030
supportLibraryVersion=25.3.1
3131

3232
libJunitVersion=4.12
3333
libMockitoVersion=1.10.19
3434

35-
currentVersion=0.0.5
36-
currentVersionCode=000005
35+
currentVersion=0.0.6
36+
currentVersionCode=000006
3737
currentAppName=Mobile Button SDK
3838
artefactName=yoti-button-sdk
3939

4040
# OSSRH repositories
4141
ossrhSnapshotRepository=https://oss.sonatype.org/content/repositories/snapshots
4242
ossrhRepository=https://oss.sonatype.org/service/local/staging/deploy/maven2/
4343

44+
# Empty sonatype username and password so we can assemble locally
45+
# To publish define these in your global gradle properties with the correct values or use -P in the command line
46+
sonatypeUsername
47+
sonatypePassword
48+
4449
# POM configuration
4550
pomGroup=com.yoti.mobile.android.sdk
4651
pomName=Yoti Button SDK
4752
pomPackaging=aar
48-
pomDescription=Button SDK that allows a 3rd party app to trigger Yoti as support app
53+
pomDescription=Button SDK that allws 3rd party to trigger Yoti as support app
4954
pomUrl=https://github.com/getyoti/android-sdk-button.git
5055

5156
pomScmUrl=scm:https://github.com/getyoti/android-sdk-button.git
@@ -55,9 +60,9 @@ pomScmDevConnection=https://github.com/getyoti/android-sdk-button.git
5560
pomLicenseName=Yoti License
5661
pomLicenseUrl=https://github.com/getyoti/java/LICENSE.txt
5762

58-
pomDeveloperNames=Adrien Violet,Cyrille Quemin, Eduardo Gomez
59-
pomDeveloperIds=AdrienVioletYoti,cquemin,eduardoyoti
63+
pomDeveloperNames=Adrien Violet,Cyrille Quemin
64+
pomDeveloperIds=AdrienVioletYoti,cquemin
6065

6166
#name of thask that will generate extra artifact to archives
6267
#artifactsToArchive=generateDebugJavadocJar,generateDebugSourcesJar
63-
artifactsToArchive=generateReleaseJavadocJar,generateReleaseSourcesJar
68+
artifactsToArchive=generateReleaseJavadocJar,generateReleaseSourcesJar

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Tue Jan 30 14:55:41 GMT 2018
1+
#Thu Apr 26 16:21:18 BST 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)