Skip to content

Commit

Permalink
Merge pull request #85 from clover/r284
Browse files Browse the repository at this point in the history
Release 284
  • Loading branch information
mtomko-clover authored Feb 23, 2022
2 parents d9aaed6 + bee8b70 commit 90e9236
Show file tree
Hide file tree
Showing 171 changed files with 17,125 additions and 1,095 deletions.
8 changes: 8 additions & 0 deletions JenkinsConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# See https://github.corp.clover.com/clover/jenkinsfiles/blob/master/templates/Jenkinsfile.oas-v1.0 for all the specifics.
# There are other configuration settings that can be passed if needed
pipeline_template: templates/Jenkinsfile.clover-libraries-v1.0
# Add app name and add file to associated app's code repo.
LIBRARY_NAME: clover-android-sdk
REPO_IS_MAVE: "false"
REPO_IS_GRADLE: "true"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2020 Clover Network, Inc.
Copyright (C) ${year} ${name}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
31 changes: 29 additions & 2 deletions app.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apply plugin: 'com.android.application'

apply from: file("${project.rootDir}/common.gradle")
apply from: file("${project.rootDir}/versions.gradle")
apply from: file("${project.rootDir}/signing.gradle")

/**
* Gets the full path of the proguard file specified by `name`.
Expand Down Expand Up @@ -62,10 +61,31 @@ android.applicationVariants.all { variant ->
}

android {
signingConfigs {
releaseSigning {
storeFile project.ext.signing.devKeyFile
storePassword project.ext.signing.cloverStorePassword
keyAlias project.ext.signing.cloverKeyAlias
keyPassword project.ext.signing.cloverKeyPassword
v1SigningEnabled true
v2SigningEnabled false
}

debug {
storeFile project.ext.signing.devKeyFile
storePassword project.ext.signing.cloverStorePassword
keyAlias project.ext.signing.cloverKeyAlias
keyPassword project.ext.signing.cloverKeyPassword
v1SigningEnabled true
v2SigningEnabled false
}
}

buildTypes {
debug {
zipAlignEnabled true
signingConfig signingConfigs.debug

minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
getCommonProguardFile('proguard-clover-apps.txt'),
Expand All @@ -82,6 +102,13 @@ android {
'proguard-rules.pro'
testProguardFiles getCommonProguardFile('proguard-test-rules.txt')
}

releaseSigned {
initWith release
signingConfig signingConfigs.releaseSigning

matchingFallbacks = ['release']
}
}

compileSdkVersion COMPILE_SDK_VERSION
Expand Down
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

buildscript {
apply from: "${project.rootDir}/deps.gradle"
repositories {
mavenLocal()
mavenCentral()
jcenter()
if (project.properties.containsKey("localArtifactoryUrl")) {
maven { url localArtifactoryUrl }
}
google()
mavenCentral()
}

dependencies {
classpath androidPlugin
classpath mavenPlugin
}
}

defaultTasks 'clean', 'install'

82 changes: 5 additions & 77 deletions clover-android-connector-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,91 +14,19 @@
* limitations under the License.
*/
group = 'com.clover.sdk'
version = '262.2'
version = '284'


apply from: file("${project.rootDir}/lib.gradle")
apply from: file("${projectDir}/../common_upload.gradle")

dependencies {
implementation project(':clover-android-sdk')
implementation "androidx.annotation:annotation:$ANDROIDX_ANNOTATION_VERSION"
implementation "com.google.code.gson:gson:$GSON_VERSION"
}

apply plugin: 'signing'

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3'
}
}
apply plugin: 'io.codearte.nexus-staging'

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "${upload_release_url}") {
authentication(userName: "${upload_user}", password: "${upload_password}")
}
snapshotRepository(url: "${upload_snapshot_url}") {
authentication(userName: "${upload_user}", password: "${upload_password}")
}

pom.project {
parent {
groupId 'org.sonatype.oss'
artifactId 'oss-parent'
version '7'
}

name 'Clover Android Connector SDK'
description 'Android services and objects used for interacting with Clover Connector Services'
url 'https://www.clover.com/'

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0'
distribution 'repo'
}
}

scm {
url "https://github.com/clover/clover-android-sdk"
connection "https://github.com/clover/clover-android-sdk.git"
developerConnection "git@github.com:clover/clover-android-sdk.git"
}

developers {
developer {
name 'Clover Engineering Team'
url 'https://www.clover.com'
}
}
}
}
}
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}

artifacts {
archives sourcesJar
}

signing {
required = { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

nexusStaging {
packageGroup = "com.clover" //optional if packageGroup == project.getGroup() ------> NOTE: project.getGroup() returns com.clover.sdk
ext {
project_name = 'Clover Android Connector SDK'
project_description = 'Android services and objects used for interacting with Clover Connector Services'
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;

/*
This connector exposes session data used by Remote Pay during the processing
Expand All @@ -49,13 +46,17 @@ public class SessionConnector implements Serializable, SessionListener {

public static final String QUERY_PARAMETER_VALUE = "value";
public static final String QUERY_PARAMETER_NAME = "name";
public static final String QUERY_PARAMETER_SRC = "src";
public static final String BUNDLE_KEY_MERCHANT = "Merchant";
public static final String BUNDLE_KEY_EMPLOYEE = "Employee";
public static final String BUNDLE_KEY_TYPE = "TYPE";
public static final String BUNDLE_KEY_DATA = "DATA";
public static final String BUNDLE_KEY_MESSAGE = "MESSAGE";
public static final String BUNDLE_KEY_DURATION = "DURATION";
public static final String BUNDLE_KEY_TRANSACTION = "TRANSACTION";
private static final String EXTERNAL = "EXTERNAL";
private static final String INTERNAL = "INTERNAL";
protected String messageUuid;

private static final String TAG = "SessionConnector";

Expand Down Expand Up @@ -120,6 +121,10 @@ public boolean clear() {
return true;
}

protected ContentProviderClient getSessionContentProviderClient() {
return sessionContentProviderClient;
}

public CustomerInfo getCustomerInfo() {
CustomerInfo customerInfo = null;
try {
Expand Down Expand Up @@ -232,6 +237,9 @@ public void setProperty(String key, String value) {
Bundle bundle = new Bundle();
bundle.putString(SessionContract.COLUMN_KEY, key);
bundle.putString(SessionContract.COLUMN_VALUE, value);
bundle.putString(SessionContract.COLUMN_SRC, EXTERNAL);
messageUuid = UUID.randomUUID().toString();
bundle.putString("messageUuid", messageUuid);
sessionContentProviderClient.call(SessionContract.CALL_METHOD_SET_PROPERTY, null, bundle);
}
} catch (Exception e) {
Expand All @@ -255,6 +263,25 @@ public String getProperty(String key) {
return null;
}

private JsonObject getPropertyWithSrc(String key) {
try {
if (!connect()) return null;
String selectionClause = SessionContract.COLUMN_KEY + " = ?";
String[] selectionArgs = {key};
try (Cursor cursor = sessionContentProviderClient.query(SessionContract.PROPERTIES_URI, null, selectionClause, selectionArgs, null)) {
if (null != cursor && cursor.moveToFirst()) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("value", cursor.getString(1));
jsonObject.addProperty("src", cursor.getString(2));
return jsonObject;
}
}
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
}
return null;
}

public void removeProperty(String key) {
try {
if (!connect()) return;
Expand Down Expand Up @@ -330,9 +357,8 @@ public void onSessionEvent(String type, String data) {
private static void registerContentObserver(Context context, SessionContentObserver sessionContentObserver) {
if (null == context || null == sessionContentObserver) return;

// Intentionally, not registering for SessionContract.SESSION_URI because it triggers two event notifications
// Intentionally, not registering for SessionContract.PROPERTIES_URI and SessionContract.SESSION_URI because it triggers two event notifications
// for every change.
context.getContentResolver().registerContentObserver(SessionContract.PROPERTIES_URI, true, sessionContentObserver);
context.getContentResolver().registerContentObserver(SessionContract.PROPERTIES_KEY_URI, true, sessionContentObserver);
context.getContentResolver().registerContentObserver(SessionContract.EVENT_URI, true, sessionContentObserver);
context.getContentResolver().registerContentObserver(SessionContract.SESSION_TRANSACTION_URI, true, sessionContentObserver);
Expand All @@ -355,6 +381,7 @@ private static void unregisterContentObserver(Context context, SessionContentObs
*/
static class SessionContentObserver extends ContentObserver {
private SessionConnector connector;
private static String lastUuid="";

SessionContentObserver(SessionConnector connector) {
super(new Handler());
Expand Down Expand Up @@ -383,45 +410,64 @@ public void onChange(boolean selfChange) {
public void onChange(boolean selfChange, Uri uri) {
if (null == getConnector()) return;

switch (SessionContract.matcher.match(uri)) {
case SessionContract.SESSION:
Log.d(TAG, "Session Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(SESSION, null);
break;
case SessionContract.SESSION_CUSTOMER_INFO:
Log.d(TAG, "CustomerInfo Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(CUSTOMER_INFO, getConnector().getCustomerInfo());
break;
case SessionContract.SESSION_DISPLAY_ORDER:
Log.d(TAG, "DisplayOrder Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(DISPLAY_ORDER, getConnector().getDisplayOrder());
break;
case SessionContract.PROPERTIES:
Log.d(TAG, "Properties Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(PROPERTIES, null);
break;
case SessionContract.PROPERTIES_KEY:
String key = uri.getLastPathSegment();
String value = getConnector().getProperty(key);
Log.d(TAG, "Property key: " + key + " with value: " + value + " Changed: --> " + uri.toString());

JsonObject obj = new JsonObject();
obj.addProperty(QUERY_PARAMETER_NAME, key);
obj.addProperty(QUERY_PARAMETER_VALUE, value);
getConnector().onSessionDataChanged(PROPERTIES, obj);
break;
case SessionContract.SESSION_TRANSACTION:
Log.d(TAG, "Transaction Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(TRANSACTION, getConnector().getTransaction());
break;
case SessionContract.EVENT:
String type = uri.getLastPathSegment();
String payload = uri.getQueryParameter(QUERY_PARAMETER_VALUE);
getConnector().onSessionEvent(type, payload);
break;
default:
Log.d(TAG, "Unknown URI - Changed: --> " + uri.toString());
return;
String messageUuid = uri.getQueryParameter("messageUuid"); //this ID is to determine if this instance was the one to set the property
//If the message has the same id, then we don't want duplicate notifications
if ((messageUuid == null || !messageUuid.equals(lastUuid))) {
lastUuid = messageUuid;
switch (SessionContract.matcher.match(uri)) {
case SessionContract.SESSION:
Log.d(TAG, "Session Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(SESSION, null);
break;
case SessionContract.SESSION_CUSTOMER_INFO:
Log.d(TAG, "CustomerInfo Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(CUSTOMER_INFO, getConnector().getCustomerInfo());
break;
case SessionContract.SESSION_DISPLAY_ORDER:
Log.d(TAG, "DisplayOrder Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(DISPLAY_ORDER, getConnector().getDisplayOrder());
break;
case SessionContract.PROPERTIES:
Log.d(TAG, "Properties Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(PROPERTIES, null);
break;
case SessionContract.PROPERTIES_KEY:
//We don't want to send a notification to the instance that set the property
if (messageUuid == null || !messageUuid.equals(getConnector().messageUuid)) {
String key = uri.getLastPathSegment();
JsonObject property = getConnector().getPropertyWithSrc(key);
String value = null;
if (property != null && property.has("value")) {
value = property.get("value").toString();
}
String src = null;
if (property != null && property.has("src")) {
src = property.get("src").getAsString();
}
//We don't want to send internally sourced notifications
if (src == null || !src.equals(INTERNAL)) {
Log.d(TAG, "Property key: " + key + " with value: " + value + " Changed: --> " + uri.toString());

JsonObject obj = new JsonObject();
obj.addProperty(QUERY_PARAMETER_NAME, key);
obj.addProperty(QUERY_PARAMETER_VALUE, value);
getConnector().onSessionDataChanged(PROPERTIES, obj);
}
}
break;
case SessionContract.SESSION_TRANSACTION:
Log.d(TAG, "Transaction Changed: --> " + uri.toString());
getConnector().onSessionDataChanged(TRANSACTION, getConnector().getTransaction());
break;
case SessionContract.EVENT:
String type = uri.getLastPathSegment();
String payload = uri.getQueryParameter(QUERY_PARAMETER_VALUE);
getConnector().onSessionEvent(type, payload);
break;
default:
Log.d(TAG, "Unknown URI - Changed: --> " + uri.toString());
return;
}
}
super.onChange(selfChange, uri);
}
Expand Down
Loading

0 comments on commit 90e9236

Please sign in to comment.