Skip to content

Commit

Permalink
SDK v3.2.1 | Sample v3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelskotnicki committed Jun 12, 2018
1 parent 631d505 commit c77bad8
Show file tree
Hide file tree
Showing 22 changed files with 141 additions and 122 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.

## [3.2.1] - 2018-06-11
### Added
- Auto-refreshing Client token in order to sustain it's session
- Setting custom client's email on demand
- Client's Analytics metrics
- Intent extras are now extractable from Synerise Simple Notification

### Removed
- Obsolete verification of internal modules initialization

## [3.2.0] - 2018-05-29
### Added
- SMS sign in and sign up support
Expand Down
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ apply plugin: 'synerise-plugin'
dependencies {
...
// Synerise Android SDK
implementation 'com.synerise.sdk:synerise-mobile-sdk:3.2.0'
implementation 'com.synerise.sdk:synerise-mobile-sdk:3.2.1'
}
```
Finally, please make sure your `Instant Run` is disabled.
Expand Down Expand Up @@ -80,6 +80,7 @@ public class App extends Application {
.syneriseDebugMode(DEBUG_MODE)
.trackerDebugMode(DEBUG_MODE)
.injectorDebugMode(DEBUG_MODE)
.clientRefresh(true)
.trackerTrackMode(FINE)
.trackerMinBatchSize(10)
.trackerMaxBatchSize(100)
Expand Down Expand Up @@ -114,14 +115,15 @@ Also, a default icon will be used if there is no custom icon provided.
2. `.syneriseDebugMode(boolean)` - simple flag may be provided in order to enable full network traffic logs. It is not recommended to use debug mode in release version of your app.
3. `.trackerDebugMode(boolean)` - you can receive some simple logs about sending events (like success, failure etc.) by enabling debug mode, which is disabled by default.
4. `.injectorDebugMode(boolean)` - you can receive some simple logs about Injector actions (like Walkthrough screen availability) by enabling debug mode, which is disabled by default.
5. `.trackerTrackMode(TrackMode)` - sets proper mode for view tracking. See Tracker section below.
6. `.trackerMinBatchSize(int)` - sets minimum number of events in queue required to send them.
7. `.trackerMaxBatchSize(int)` - sets maximum number of events, which may be sent in a single batch.
8. `.trackerAutoFlushTimeout(int)` - sets time required to elapse before event's queue will attempt to be sent.
9. `.injectorAutomatic(true)` - fetches your Walkthrough content right away. Note, that Walkthrough will be presented the moment it gets loaded atop of your Activity if it's id is different than previously presented. See Injector section for more information.
10. `.pushRegistrationRequired(this)` - it is important to register your customers for push messages. Please register for SDK callbacks when push registration is required.
11. `.customClientConfig(CustomClientAuthConfig)` - you can also provide your custom Client `Authorization Configuration`. At this moment, configuration handles `Base URL` changes.
12. `.build()` - builds Synerise SDK with provided data. Please note, that `Synerise.Builder.with(..)` method is mandatory and `Synerise.Builder.build()` method can be called only once during whole application lifecycle, so it is recommended to call this method in your `Application` class.<br>
5. `.clientRefresh(boolean)` - enables automatic client's token refresh.
6. `.trackerTrackMode(TrackMode)` - sets proper mode for view tracking. See Tracker section below.
7. `.trackerMinBatchSize(int)` - sets minimum number of events in queue required to send them.
8. `.trackerMaxBatchSize(int)` - sets maximum number of events, which may be sent in a single batch.
9. `.trackerAutoFlushTimeout(int)` - sets time required to elapse before event's queue will attempt to be sent.
10. `.injectorAutomatic(true)` - fetches your Walkthrough content right away. Note, that Walkthrough will be presented the moment it gets loaded atop of your Activity if it's id is different than previously presented. See Injector section for more information.
11. `.pushRegistrationRequired(this)` - it is important to register your customers for push messages. Please register for SDK callbacks when push registration is required.
12. `.customClientConfig(CustomClientAuthConfig)` - you can also provide your custom Client `Authorization Configuration`. At this moment, configuration handles `Base URL` changes.
13. `.build()` - builds Synerise SDK with provided data. Please note, that `Synerise.Builder.with(..)` method is mandatory and `Synerise.Builder.build()` method can be called only once during whole application lifecycle, so it is recommended to call this method in your `Application` class.<br>

### Errors

Expand Down Expand Up @@ -335,7 +337,10 @@ Log your custom data with `TrackerParams` class.
Flush method forces sending events from queue to server.

#### Tracker.setCustomIdentifier(String)
You can also pass your custom identifiers to match your users in our CRM.
You can also pass your custom identifier to match your users in our CRM. Your custom identifier will be sent within every event in event params.

#### Tracker.setCustomEmail(String)
You can also pass your custom email to match your users in our CRM. Your custom email will be sent within every event in event params.

## Client

Expand Down Expand Up @@ -389,6 +394,16 @@ Use this method to update client's account information.<br>
This method requires `AccountInformation` Builder Pattern object with client's account information. Not provided fields are not modified.
Method returns `IApiCall` to execute request.

#### Client.getAnalytics()
Get all available Analytics metrics for the client.<br>
Please note that in order to use this method, Client must be signed in first.<br>
This method returns `IDataApiCall` with parametrized `List<AnalyticsMetrics>` object to execute request.

#### Client.getAnalytics(String)
Fetch all available Analytics metrics for the client and return the first metric, which matches provided name.<br>
Please note that in order to use this method, Client must be signed in first.<br>
This method returns `IDataApiCall` with parametrized `AnalyticsMetrics` object to execute request.

#### Client.getToken()
Get valid JWT login token.<br>
Note, that error is thrown when Client is not logged in or token has expired and cannot be refreshed.<br>
Expand Down
8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
minSdkVersion 19
targetSdkVersion 26
applicationId "com.synerise.sample"
versionCode 9
versionName "3.0.0"
versionCode 10
versionName "3.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Expand Down Expand Up @@ -54,12 +54,12 @@ android {

ext {
daggerVersion = '2.15'
syneriseVersion = '3.2.0'
syneriseVersion = '3.2.1'
playServicesVersion = '15.0.2'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(include: ['*.jar'], dir: 'libs')
// Support
implementation rootProject.ext.supportAnnotations
implementation rootProject.ext.supportV4
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/java/com/synerise/sdk/sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private void initSynerise() {
.syneriseDebugMode(DEBUG_MODE)
.trackerDebugMode(DEBUG_MODE)
.injectorDebugMode(DEBUG_MODE)
.clientRefresh(true)
.trackerTrackMode(FINE)
.trackerMinBatchSize(10)
.trackerMaxBatchSize(100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private static ArrayList<Product> createProducts(Product... products) {
this.products = products;
}

@ColorRes
public int getBackground() {
return background;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

public abstract class BaseDialog extends DialogFragment {

protected interface Args {
String CONTENT = "args";
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ public class ConfirmNumberDialog extends BaseDialog {

@Inject AccountManager accountManager;

public static ConfirmNumberDialog newInstance() {
return new ConfirmNumberDialog();
public static ConfirmNumberDialog newInstance(String phone) {
Bundle args = new Bundle();
args.putString(Args.CONTENT, phone);
ConfirmNumberDialog confirmNumberDialog = new ConfirmNumberDialog();
confirmNumberDialog.setArguments(args);
return confirmNumberDialog;
}

@Override
Expand All @@ -63,8 +67,8 @@ protected void setViewContent(Context context, View view) {
confirmationProgress = view.findViewById(R.id.confirmation_code_progress);
toggleLoading(false);

phoneNumber = accountManager.getPhoneNumber();
if(phoneNumber == null || TextUtils.isEmpty(phoneNumber)){
phoneNumber = getArguments().getString(Args.CONTENT);
if (phoneNumber == null || TextUtils.isEmpty(phoneNumber)) {
dismiss();
}
confirmationCode.addTextChangedListener(new TextWatcher() {
Expand All @@ -75,7 +79,7 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(s.length() == 4){
if (s.length() == 4) {
confirmCode(String.valueOf(s));
}
}
Expand All @@ -93,15 +97,15 @@ private void confirmCode(String confirmationCode) {
} catch (InvalidPhoneNumberException e) {
dismiss();
}
if(confirmPhoneCall != null){
if (confirmPhoneCall != null) {
confirmPhoneCall.onSubscribe(() -> toggleLoading(true))
.doFinally(() -> toggleLoading(false))
.execute(this::onConfirmPhoneNumberSuccess, new DataActionListener<ApiError>() {
@Override
public void onDataAction(ApiError apiError) {
onConfirmPhoneNumberError(apiError);
}
});
.doFinally(() -> toggleLoading(false))
.execute(this::onConfirmPhoneNumberSuccess, new DataActionListener<ApiError>() {
@Override
public void onDataAction(ApiError apiError) {
onConfirmPhoneNumberError(apiError);
}
});
}
}

Expand All @@ -128,7 +132,7 @@ private void toggleLoading(boolean isLoading) {
@Override
public void onStop() {
super.onStop();
confirmPhoneCall.cancel();
if (confirmPhoneCall != null) confirmPhoneCall.cancel();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void onSignInButtonClicked(View v) {
} catch (InvalidEmailException e) {
textLogin.setError(getString(R.string.error_invalid_email));
} catch (InvalidPasswordException e) {
textLogin.setError(getString(R.string.error_invalid_password));
textPassword.setError(getString(R.string.error_invalid_password));
} catch (InvalidPhoneNumberException e) {
textLogin.setError(getString(R.string.error_invalid_phone));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.synerise.sdk.sample.R;
import com.synerise.sdk.sample.persistence.AccountManager;
import com.synerise.sdk.sample.ui.BaseActivity;
import com.synerise.sdk.sample.util.KeyboardHelper;
import com.synerise.sdk.sample.util.ToolbarHelper;

import javax.inject.Inject;
Expand Down Expand Up @@ -170,22 +169,21 @@ private void signUp(RegisterClient registerClient) {
Profile.registerClientByPhone(registerClient);
signUpCall.onSubscribe(() -> toggleLoading(true))
.doFinally(() -> toggleLoading(false))
.execute(this::onSignUpSuccessful, new DataActionListener<ApiError>() {
.execute(() -> onSignUpSuccessful(registerClient.getPhone()), new DataActionListener<ApiError>() {
@Override
public void onDataAction(ApiError apiError) {
onSignUpFailure(apiError);
}
});
}

private void onSignUpSuccessful() {
private void onSignUpSuccessful(String phone) {
if (loginType == LoginType.EMAIL) {
Snackbar.make(textLogin, R.string.sign_up_email_success, Snackbar.LENGTH_SHORT).show();
finish();
} else if (loginType == LoginType.PHONE) {
ConfirmNumberDialog confirmNumberDialog = ConfirmNumberDialog.newInstance();
ConfirmNumberDialog confirmNumberDialog = ConfirmNumberDialog.newInstance(phone);
confirmNumberDialog.show(getSupportFragmentManager(), ConfirmNumberDialog.class.getSimpleName());
KeyboardHelper.showKeyboard(this); // todo test
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -69,7 +68,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_dashboard);
((App) getApplication()).getComponent().inject(this);

Toolbar toolbar = ToolbarHelper.setActionBar(this);
ToolbarHelper.setUpToolbar(this);

drawer = findViewById(R.id.drawer_layout);

Expand Down Expand Up @@ -185,7 +184,7 @@ private void changeFragment(DrawerSection section) {

FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction
.setCustomAnimations(R.anim.fade_in, R.anim.fade_out)
// .setCustomAnimations(R.anim.fade_in, R.anim.fade_out)
.replace(R.id.container, currentFragment)
.commit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
view.findViewById(R.id.injector_api).setOnClickListener(v -> startActivity(InjectorApiActivity.createIntent(getContext())));
view.findViewById(R.id.reset).setOnClickListener(v -> {
ActivityManager activityManager = ((ActivityManager) getContext().getSystemService(ACTIVITY_SERVICE));
if (activityManager != null)
activityManager.clearApplicationUserData();
if (activityManager != null) activityManager.clearApplicationUserData();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
Expand All @@ -26,6 +28,7 @@
import com.google.android.gms.vision.MultiProcessor;
import com.google.android.gms.vision.barcode.Barcode;
import com.google.android.gms.vision.barcode.BarcodeDetector;
import com.google.firebase.iid.FirebaseInstanceId;
import com.jakewharton.processphoenix.ProcessPhoenix;
import com.synerise.sdk.sample.App;
import com.synerise.sdk.sample.R;
Expand Down Expand Up @@ -179,7 +182,16 @@ private boolean onTap(float rawX, float rawY) {
private void onFinishClicked() {
accountManager.setBusinessProfileApiKey(inputBusiness.getEditText().getText().toString());
accountManager.setClientApiKey(inputClient.getEditText().getText().toString());
ProcessPhoenix.triggerRebirth(QRScannerActivity.this);
HandlerThread ht = new HandlerThread("HandlerThread");
ht.start();
new Handler(ht.getLooper()).post(() -> {
try {
FirebaseInstanceId.getInstance().deleteInstanceId();
ProcessPhoenix.triggerRebirth(QRScannerActivity.this);
} catch (IOException e) {
e.printStackTrace();
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_tracker_view);

ToolbarHelper.setUpChildToolbar(this, R.string.tracker_view_title);
ToolbarHelper.updateToolbar(this, R.string.tracker_view_title);

((SeekBar) findViewById(R.id.seek_bar)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void saveChangesButtonClicked(View view) {
}

if (isValid) {
updateClient(updateClient,email, name, lastName);
updateClient(updateClient, email, name, lastName);
}
}

Expand All @@ -141,19 +141,19 @@ private void updateClient(UpdateClient updateClient, String email, String name,
if (getClientCall != null) {
getClientCall.cancel();
getClientCall.onSubscribe(() -> toggleLoading(true))
.doFinally(() -> toggleLoading(false))
.execute(data -> {
updateCall = Profile.updateClient(data.getClientId(),updateClient);
updateCall.onSubscribe(() -> toggleLoading(true))
.doFinally(() -> toggleLoading(false))
.execute(() -> onUpdateClientSuccessful(email,name,lastName), new DataActionListener<ApiError>() {
@Override
public void onDataAction(ApiError data) {
onUpdateClientFailure(data);
}

});
}, data -> toggleLoading(false));
.doFinally(() -> toggleLoading(false))
.execute(data -> {
updateCall = Profile.updateClient(data.getClientId(), updateClient);
updateCall.onSubscribe(() -> toggleLoading(true))
.doFinally(() -> toggleLoading(false))
.execute(() -> onUpdateClientSuccessful(email, name, lastName),
new DataActionListener<ApiError>() {
@Override
public void onDataAction(ApiError data) {
onUpdateClientFailure(data);
}
});
}, data -> toggleLoading(false));
}
}

Expand Down Expand Up @@ -184,8 +184,8 @@ private void toggleLoading(boolean isLoading) {
@Override
public void onStop() {
super.onStop();
getClientCall.cancel();
updateCall.cancel();
if (getClientCall != null) getClientCall.cancel();
if (updateCall != null) updateCall.cancel();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected void onCreate(Bundle savedInstanceState) {

section = (Section) getIntent().getSerializableExtra(Args.SERIALIZABLE);

ToolbarHelper.setUpChildToolbar(this, section.getName());
ToolbarHelper.setUpChildToolbar(this, section.getName(), section.getColor());

CategoriesRecyclerAdapter recyclerAdapter = new CategoriesRecyclerAdapter(this, this::onCategorySelected,
section.getCategories());
Expand Down
Loading

0 comments on commit c77bad8

Please sign in to comment.