Skip to content

Commit aadb913

Browse files
authored
Merge pull request #6 from freshbits/v2.3
Add image to sdk user
2 parents f3ea95e + 5764153 commit aadb913

File tree

10 files changed

+94
-77
lines changed

10 files changed

+94
-77
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## 2.3.0 - 2018-12-01
4+
### Changed
5+
- Added image support to user
6+
- Added support to define if customer can update session destination
7+
- Minor improvements
8+
39
## 2.2.0 - 2018-09-10
410
### Changed
511
- Added email address to user

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
## Requirements
2525

26-
`PathshareSDK` for Android supports Android 5.x, 6.x, 7.x and 8.x.
26+
`PathshareSDK` for Android supports Android 5.x, 6.x, 7.x, 8.x and 9.x.
2727

2828
## Installation
2929

@@ -95,7 +95,7 @@ Before creating a session, you need to save a user:
9595

9696
###### Java
9797
```java
98-
Pathshare.client().saveUser("Candice", "[email protected]", "+12345678901", UserType.DRIVER, new ResponseListener() {
98+
Pathshare.client().saveUser("Candice", "[email protected]", "+12345678901", UserType.DRIVER, getResources().getDrawable(R.drawable.face, null), new ResponseListener() {
9999
@Override
100100
public void onSuccess() {
101101
// ...
@@ -110,7 +110,7 @@ Pathshare.client().saveUser("Candice", "[email protected]", "+12345678901", UserType.
110110

111111
###### Kotlin
112112
```kotlin
113-
Pathshare.client().saveUser("SDK User Android", "[email protected]", "+12345678901", UserType.DRIVER, object: ResponseListener {
113+
Pathshare.client().saveUser("SDK User Android", "[email protected]", "+12345678901", UserType.DRIVER, resources.getDrawable(R.drawable.face, null), object: ResponseListener {
114114
override fun onSuccess() {
115115
// ...
116116
}
@@ -122,6 +122,8 @@ Pathshare.client().saveUser("SDK User Android", "[email protected]", "+12345678901",
122122
```
123123
The email address can be `null`.
124124

125+
Use the same method Pathshare.client().saveUser() to create or update the user.
126+
125127
There are different types of users for specific industries:
126128

127129
User Types | Description

android-example-app/app-kotlin/build.gradle

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-android-extensions'
4+
45
android {
56
compileSdkVersion 27
67

78
defaultConfig {
89
applicationId "ch.freshbits.pathshare.example"
910
minSdkVersion 21
1011
targetSdkVersion 27
11-
versionCode 2_2_0
12-
versionName "2.2.0"
12+
versionCode 2_3_0
13+
versionName "2.3.0"
1314

1415
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1516
}
1617

18+
packagingOptions {
19+
exclude 'META-INF/DEPENDENCIES'
20+
}
21+
22+
compileOptions {
23+
sourceCompatibility 1.8
24+
targetCompatibility 1.8
25+
}
26+
1727
lintOptions {
1828
abortOnError false
1929
}
@@ -41,7 +51,7 @@ dependencies {
4151
implementation fileTree(dir: 'libs', include: ['*.jar'])
4252
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4353
implementation 'com.android.support:appcompat-v7:27.1.1'
44-
implementation 'ch.freshbits.pathshare.sdk:pathshare-sdk:2.2.0'
54+
implementation 'ch.freshbits.pathshare.sdk:pathshare-sdk:2.3.0'
4555
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
4656
implementation 'com.android.support:design:27.1.1'
4757
}

android-example-app/app-kotlin/src/main/java/ch/freshbits/pathshare/example/MainActivity.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ class MainActivity : AppCompatActivity() {
4747
createButton = findViewById<View>(R.id.create_session) as Button
4848
createButton.isEnabled = true
4949
createButton.setOnClickListener {
50-
Pathshare.client().saveUser("SDK User Android", "[email protected]", "+12345678901", UserType.DRIVER, object: ResponseListener {
50+
Pathshare.client().saveUser(
51+
"SDK User Android",
52+
53+
"+12345678901",
54+
UserType.TECHNICIAN,
55+
resources.getDrawable(R.drawable.face, null),
56+
object: ResponseListener {
5157
override fun onSuccess() {
5258
Log.d("User", "Success")
5359
createSession()
@@ -150,7 +156,13 @@ class MainActivity : AppCompatActivity() {
150156
private fun inviteCustomer() {
151157
if (session.isExpired) return
152158

153-
session.inviteUser("Customer", UserType.MOTORIST, "[email protected]", "+12345678901", object: InvitationResponseListener {
159+
session.inviteUser(
160+
"Customer",
161+
UserType.MOTORIST,
162+
163+
"+12345678901",
164+
true,
165+
object: InvitationResponseListener {
154166
override fun onSuccess(url: URL?) {
155167
Log.d("Invite", "Success")
156168
Log.d("URL", url.toString())
273 KB
Loading

android-example-app/app/build.gradle

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 27
5-
buildToolsVersion "27.0.3"
65

76
defaultConfig {
87
applicationId "ch.freshbits.pathshare.example"
98
minSdkVersion 25
109
targetSdkVersion 27
11-
versionCode 2_2_0
12-
versionName "2.2.0"
10+
versionCode 2_3_0
11+
versionName "2.3.0"
12+
}
13+
14+
packagingOptions {
15+
exclude 'META-INF/DEPENDENCIES'
16+
}
17+
18+
compileOptions {
19+
sourceCompatibility 1.8
20+
targetCompatibility 1.8
1321
}
1422

1523
lintOptions {
@@ -36,9 +44,9 @@ repositories {
3644
}
3745

3846
dependencies {
39-
compile fileTree(dir: 'libs', include: ['*.jar'])
40-
testCompile 'junit:junit:4.12'
47+
implementation fileTree(dir: 'libs', include: ['*.jar'])
48+
testImplementation 'junit:junit:4.12'
4149
//noinspection GradleCompatible
42-
compile 'com.android.support:appcompat-v7:27.1.1'
43-
compile 'ch.freshbits.pathshare.sdk:pathshare-sdk:2.2.0'
50+
implementation 'com.android.support:appcompat-v7:27.1.1'
51+
implementation 'ch.freshbits.pathshare.sdk:pathshare-sdk:2.3.0'
4452
}

android-example-app/app/src/main/java/ch/freshbits/pathshare/example/MainActivity.java

Lines changed: 38 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -50,58 +50,44 @@ protected void onCreate(Bundle savedInstanceState) {
5050
}
5151

5252
private void initializeCreateButton() {
53-
setCreateButton((Button) findViewById(R.id.create_session));
53+
setCreateButton(findViewById(R.id.create_session));
5454
getCreateButton().setEnabled(true);
55-
getCreateButton().setOnClickListener(new View.OnClickListener() {
55+
getCreateButton().setOnClickListener(view -> Pathshare.client().saveUser(
56+
"SDK User",
57+
58+
"+12345678901",
59+
UserType.TECHNICIAN,
60+
getResources().getDrawable(R.drawable.face, null),
61+
new ResponseListener() {
5662
@Override
57-
public void onClick(View view) {
58-
Pathshare.client().saveUser("SDK User", "[email protected]", "+12345678901", UserType.DRIVER, new ResponseListener() {
59-
@Override
60-
public void onSuccess() {
61-
Log.d("User", "Success");
62-
createSession();
63-
}
64-
65-
@Override
66-
public void onError() {
67-
Log.e("User", "Error");
68-
}
69-
});
63+
public void onSuccess() {
64+
Log.d("User", "Success");
65+
createSession();
7066
}
71-
});
67+
68+
@Override
69+
public void onError() {
70+
Log.e("User", "Error");
71+
}
72+
}));
7273
}
7374

7475
private void initializeJoinButton() {
75-
setJoinButton((Button) findViewById(R.id.join_session));
76+
setJoinButton(findViewById(R.id.join_session));
7677
getJoinButton().setEnabled(false);
77-
getJoinButton().setOnClickListener(new View.OnClickListener() {
78-
@Override
79-
public void onClick(View v) {
80-
joinSession();
81-
}
82-
});
78+
getJoinButton().setOnClickListener(view -> joinSession());
8379
}
8480

8581
private void initializeInviteButton() {
86-
setInviteButton((Button) findViewById(R.id.invite_customer));
82+
setInviteButton(findViewById(R.id.invite_customer));
8783
getInviteButton().setEnabled(false);
88-
getInviteButton().setOnClickListener(new View.OnClickListener() {
89-
@Override
90-
public void onClick(View v) {
91-
inviteCustomer();
92-
}
93-
});
84+
getInviteButton().setOnClickListener(view -> inviteCustomer());
9485
}
9586

9687
private void initializeLeaveButton() {
97-
setLeaveButton((Button) findViewById(R.id.leave_session));
88+
setLeaveButton(findViewById(R.id.leave_session));
9889
getLeaveButton().setEnabled(false);
99-
getLeaveButton().setOnClickListener(new View.OnClickListener() {
100-
@Override
101-
public void onClick(View v) {
102-
leaveSession();
103-
}
104-
});
90+
getLeaveButton().setOnClickListener(view -> leaveSession());
10591
}
10692

10793
private void createSession() {
@@ -118,12 +104,7 @@ private void createSession() {
118104
.setDestination(destination)
119105
.setExpirationDate(expirationDate)
120106
.setName("simple session")
121-
.setSessionExpirationListener(new SessionExpirationListener() {
122-
@Override
123-
public void onExpiration() {
124-
handleSessionExpiration();
125-
}
126-
})
107+
.setSessionExpirationListener(() -> handleSessionExpiration())
127108
.build();
128109

129110
getSession().save(new ResponseListener() {
@@ -161,7 +142,13 @@ private void joinSession() {
161142
private void inviteCustomer() {
162143
if (getSession().isExpired()) { return; }
163144

164-
getSession().inviteUser("Customer", UserType.MOTORIST, "[email protected]", "+12345678901", new InvitationResponseListener() {
145+
getSession().inviteUser(
146+
"Customer",
147+
UserType.MOTORIST,
148+
149+
"+12345678901",
150+
true,
151+
new InvitationResponseListener() {
165152
@Override
166153
public void onSuccess(URL url) {
167154
Log.d("Invite", "Success");
@@ -260,15 +247,12 @@ private void deleteSessionIdentifier() {
260247
}
261248

262249
private void handleSessionExpiration() {
263-
this.runOnUiThread(new Runnable() {
264-
@Override
265-
public void run() {
266-
getInviteButton().setEnabled(false);
267-
getLeaveButton().setEnabled(false);
268-
getCreateButton().setEnabled(true);
269-
deleteSessionIdentifier();
270-
showToast("Session expired.");
271-
}
250+
this.runOnUiThread(() -> {
251+
getInviteButton().setEnabled(false);
252+
getLeaveButton().setEnabled(false);
253+
getCreateButton().setEnabled(true);
254+
deleteSessionIdentifier();
255+
showToast("Session expired.");
272256
});
273257
}
274258

@@ -330,12 +314,7 @@ public void onSuccess(Session session) {
330314

331315
} else {
332316
Log.d("Session", "Name: " + session.getName());
333-
session.setSessionExpirationListener(new SessionExpirationListener() {
334-
@Override
335-
public void onExpiration() {
336-
handleSessionExpiration();
337-
}
338-
});
317+
session.setSessionExpirationListener(() -> handleSessionExpiration());
339318

340319
setSession(session);
341320

273 KB
Loading

android-example-app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
google()
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.0.1'
11+
classpath 'com.android.tools.build:gradle:3.2.1'
1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files
1414
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon May 21 19:09:15 CEST 2018
1+
#Sat Dec 01 00:29:09 CET 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

0 commit comments

Comments
 (0)