Skip to content

Commit

Permalink
Merge pull request #6 from freshbits/v2.3
Browse files Browse the repository at this point in the history
Add image to sdk user
  • Loading branch information
jhabr committed Dec 1, 2018
2 parents f3ea95e + 5764153 commit aadb913
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 77 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 2.3.0 - 2018-12-01
### Changed
- Added image support to user
- Added support to define if customer can update session destination
- Minor improvements

## 2.2.0 - 2018-09-10
### Changed
- Added email address to user
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

## Requirements

`PathshareSDK` for Android supports Android 5.x, 6.x, 7.x and 8.x.
`PathshareSDK` for Android supports Android 5.x, 6.x, 7.x, 8.x and 9.x.

## Installation

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

###### Java
```java
Pathshare.client().saveUser("Candice", "me@email.com", "+12345678901", UserType.DRIVER, new ResponseListener() {
Pathshare.client().saveUser("Candice", "me@email.com", "+12345678901", UserType.DRIVER, getResources().getDrawable(R.drawable.face, null), new ResponseListener() {
@Override
public void onSuccess() {
// ...
Expand All @@ -110,7 +110,7 @@ Pathshare.client().saveUser("Candice", "me@email.com", "+12345678901", UserType.

###### Kotlin
```kotlin
Pathshare.client().saveUser("SDK User Android", "me@email.com", "+12345678901", UserType.DRIVER, object: ResponseListener {
Pathshare.client().saveUser("SDK User Android", "me@email.com", "+12345678901", UserType.DRIVER, resources.getDrawable(R.drawable.face, null), object: ResponseListener {
override fun onSuccess() {
// ...
}
Expand All @@ -122,6 +122,8 @@ Pathshare.client().saveUser("SDK User Android", "me@email.com", "+12345678901",
```
The email address can be `null`.

Use the same method Pathshare.client().saveUser() to create or update the user.

There are different types of users for specific industries:

User Types | Description
Expand Down
16 changes: 13 additions & 3 deletions android-example-app/app-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27

defaultConfig {
applicationId "ch.freshbits.pathshare.example"
minSdkVersion 21
targetSdkVersion 27
versionCode 2_2_0
versionName "2.2.0"
versionCode 2_3_0
versionName "2.3.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}

lintOptions {
abortOnError false
}
Expand Down Expand Up @@ -41,7 +51,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'ch.freshbits.pathshare.sdk:pathshare-sdk:2.2.0'
implementation 'ch.freshbits.pathshare.sdk:pathshare-sdk:2.3.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ class MainActivity : AppCompatActivity() {
createButton = findViewById<View>(R.id.create_session) as Button
createButton.isEnabled = true
createButton.setOnClickListener {
Pathshare.client().saveUser("SDK User Android", "me@email.com", "+12345678901", UserType.DRIVER, object: ResponseListener {
Pathshare.client().saveUser(
"SDK User Android",
"me@email.com",
"+12345678901",
UserType.TECHNICIAN,
resources.getDrawable(R.drawable.face, null),
object: ResponseListener {
override fun onSuccess() {
Log.d("User", "Success")
createSession()
Expand Down Expand Up @@ -150,7 +156,13 @@ class MainActivity : AppCompatActivity() {
private fun inviteCustomer() {
if (session.isExpired) return

session.inviteUser("Customer", UserType.MOTORIST, "customer@me.com", "+12345678901", object: InvitationResponseListener {
session.inviteUser(
"Customer",
UserType.MOTORIST,
"customer@me.com",
"+12345678901",
true,
object: InvitationResponseListener {
override fun onSuccess(url: URL?) {
Log.d("Invite", "Success")
Log.d("URL", url.toString())
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 15 additions & 7 deletions android-example-app/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "ch.freshbits.pathshare.example"
minSdkVersion 25
targetSdkVersion 27
versionCode 2_2_0
versionName "2.2.0"
versionCode 2_3_0
versionName "2.3.0"
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}

lintOptions {
Expand All @@ -36,9 +44,9 @@ repositories {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'ch.freshbits.pathshare.sdk:pathshare-sdk:2.2.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'ch.freshbits.pathshare.sdk:pathshare-sdk:2.3.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,58 +50,44 @@ protected void onCreate(Bundle savedInstanceState) {
}

private void initializeCreateButton() {
setCreateButton((Button) findViewById(R.id.create_session));
setCreateButton(findViewById(R.id.create_session));
getCreateButton().setEnabled(true);
getCreateButton().setOnClickListener(new View.OnClickListener() {
getCreateButton().setOnClickListener(view -> Pathshare.client().saveUser(
"SDK User",
"me@email.com",
"+12345678901",
UserType.TECHNICIAN,
getResources().getDrawable(R.drawable.face, null),
new ResponseListener() {
@Override
public void onClick(View view) {
Pathshare.client().saveUser("SDK User", "me@email.com", "+12345678901", UserType.DRIVER, new ResponseListener() {
@Override
public void onSuccess() {
Log.d("User", "Success");
createSession();
}

@Override
public void onError() {
Log.e("User", "Error");
}
});
public void onSuccess() {
Log.d("User", "Success");
createSession();
}
});

@Override
public void onError() {
Log.e("User", "Error");
}
}));
}

private void initializeJoinButton() {
setJoinButton((Button) findViewById(R.id.join_session));
setJoinButton(findViewById(R.id.join_session));
getJoinButton().setEnabled(false);
getJoinButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
joinSession();
}
});
getJoinButton().setOnClickListener(view -> joinSession());
}

private void initializeInviteButton() {
setInviteButton((Button) findViewById(R.id.invite_customer));
setInviteButton(findViewById(R.id.invite_customer));
getInviteButton().setEnabled(false);
getInviteButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
inviteCustomer();
}
});
getInviteButton().setOnClickListener(view -> inviteCustomer());
}

private void initializeLeaveButton() {
setLeaveButton((Button) findViewById(R.id.leave_session));
setLeaveButton(findViewById(R.id.leave_session));
getLeaveButton().setEnabled(false);
getLeaveButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
leaveSession();
}
});
getLeaveButton().setOnClickListener(view -> leaveSession());
}

private void createSession() {
Expand All @@ -118,12 +104,7 @@ private void createSession() {
.setDestination(destination)
.setExpirationDate(expirationDate)
.setName("simple session")
.setSessionExpirationListener(new SessionExpirationListener() {
@Override
public void onExpiration() {
handleSessionExpiration();
}
})
.setSessionExpirationListener(() -> handleSessionExpiration())
.build();

getSession().save(new ResponseListener() {
Expand Down Expand Up @@ -161,7 +142,13 @@ private void joinSession() {
private void inviteCustomer() {
if (getSession().isExpired()) { return; }

getSession().inviteUser("Customer", UserType.MOTORIST, "customer@me.com", "+12345678901", new InvitationResponseListener() {
getSession().inviteUser(
"Customer",
UserType.MOTORIST,
"customer@me.com",
"+12345678901",
true,
new InvitationResponseListener() {
@Override
public void onSuccess(URL url) {
Log.d("Invite", "Success");
Expand Down Expand Up @@ -260,15 +247,12 @@ private void deleteSessionIdentifier() {
}

private void handleSessionExpiration() {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
getInviteButton().setEnabled(false);
getLeaveButton().setEnabled(false);
getCreateButton().setEnabled(true);
deleteSessionIdentifier();
showToast("Session expired.");
}
this.runOnUiThread(() -> {
getInviteButton().setEnabled(false);
getLeaveButton().setEnabled(false);
getCreateButton().setEnabled(true);
deleteSessionIdentifier();
showToast("Session expired.");
});
}

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

} else {
Log.d("Session", "Name: " + session.getName());
session.setSessionExpirationListener(new SessionExpirationListener() {
@Override
public void onExpiration() {
handleSessionExpiration();
}
});
session.setSessionExpirationListener(() -> handleSessionExpiration());

setSession(session);

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion android-example-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Expand Down
4 changes: 2 additions & 2 deletions android-example-app/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 21 19:09:15 CEST 2018
#Sat Dec 01 00:29:09 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

0 comments on commit aadb913

Please sign in to comment.