Skip to content

Commit

Permalink
fixing build and warnings, init of hyperlog
Browse files Browse the repository at this point in the history
  • Loading branch information
usamir committed Oct 23, 2018
1 parent 3879770 commit 257cade
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Built application files
*.apk
*.ap_
*.patch

# Files for the ART/Dalvik VM
*.dex
Expand Down Expand Up @@ -35,6 +36,8 @@ captures/
# Intellij
*.iml
.idea/workspace.xml
.idea
.idea/

# Keystore files
*.jks
12 changes: 0 additions & 12 deletions .idea/libraries/support_core_ui_25_3_1.xml

This file was deleted.

18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.xendit.example"
minSdkVersion 16
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -24,12 +24,12 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
compile project(':xendit-android')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation project(':xendit-android')
}
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

Expand All @@ -16,6 +17,7 @@ buildscript {

allprojects {
repositories {
google()
jcenter()
}
}
Expand Down
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Tue Mar 07 15:08:50 EET 2017
#Wed Oct 17 13:59:33 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
17 changes: 10 additions & 7 deletions xendit-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ ext {
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"

Expand All @@ -51,10 +51,13 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.volley:volley:1.0.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
testCompile 'junit:junit:4.12'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.volley:volley:1.1.0'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
androidTestImplementation 'junit:junit:4.12'

// logging
implementation 'com.hypertrack:hyperlog:0.0.10'
}

apply from: 'https://raw.githubusercontent.com/xendit/JCenter/master/installv1.gradle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ public AuthenticationBroadcastReceiver(AuthenticationCallback authenticationCall

@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getExtras().getString(XenditActivity.MESSAGE_KEY);
String message = "";
try {
message = intent.getExtras().getString(XenditActivity.MESSAGE_KEY);
} catch (NullPointerException e) {
e.printStackTrace();
}

if (message != null && message.equals(context.getString(R.string.create_token_error_validation))) {
if (!message.isEmpty() && message.equals(context.getString(R.string.create_token_error_validation))) {
authenticationCallback.onError(new XenditError(context.getString(R.string.create_token_error_validation)));
} else if (message != null && message.equals(context.getString(R.string.tokenization_error))) {
authenticationCallback.onError(new XenditError("AUTHENTICATION_ERROR", context.getString(R.string.tokenization_error)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ public TokenBroadcastReceiver(TokenCallback tokenCallback) {

@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getExtras().getString(XenditActivity.MESSAGE_KEY);
if (message != null && message.equals(context.getString(R.string.create_token_error_validation))) {
String message = "";
try {
message = intent.getExtras().getString(XenditActivity.MESSAGE_KEY);
} catch (NullPointerException e) {
e.printStackTrace();
}
if (!message.isEmpty() && message.equals(context.getString(R.string.create_token_error_validation))) {
tokenCallback.onError(new XenditError(context.getString(R.string.create_token_error_validation)));
} else if (message != null && message.equals(context.getString(R.string.tokenization_error))) {
tokenCallback.onError(new XenditError("TOKENIZATION_ERROR", context.getString(R.string.tokenization_error)));
Expand Down
10 changes: 7 additions & 3 deletions xendit-android/src/main/java/com/xendit/Xendit.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Xendit(Context context, String publishableKey) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {

HttpStack stack = null;
HttpStack stack;
try {
stack = new HurlStack(null, new TLSSocketFactory());
} catch (KeyManagementException e) {
Expand Down Expand Up @@ -252,7 +252,7 @@ public void onFailure(NetworkError error) {
*/
@Deprecated
public void createAuthentication(final String tokenId, final String cardCvn, final String amount, final TokenCallback tokenCallback) {
if (tokenId == null || tokenId == "") {
if (tokenId == null || tokenId.isEmpty()) {
tokenCallback.onError(new XenditError(context.getString(R.string.create_token_error_validation)));
return;
}
Expand Down Expand Up @@ -382,7 +382,11 @@ private void tokenizeCreditCard(TokenConfiguration tokenConfig, Card card, Netwo
cardInfoJson.addProperty("cardNumber", card.getCreditCardNumber());
cardInfoJson.addProperty("cardExpirationMonth", card.getCardExpirationMonth());
cardInfoJson.addProperty("cardExpirationYear", card.getCardExpirationYear());
cardInfoJson.addProperty("cardType", CardValidator.getCardType(card.getCreditCardNumber()).getCardTypeKey());
try {
cardInfoJson.addProperty("cardType", CardValidator.getCardType(card.getCreditCardNumber()).getCardTypeKey());
} catch (NullPointerException e) {
e.printStackTrace();
}

request.addParam("keyId", tokenConfig.getTokenizationAuthKeyId());
request.addJsonParam("cardInfo", cardInfoJson);
Expand Down
6 changes: 4 additions & 2 deletions xendit-android/src/main/java/com/xendit/XenditActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xendit;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -33,15 +34,16 @@ public static Intent getLaunchIntent(Context context, Authentication authenticat
return intent;
}

@SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"})
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_xendit);

Authentication authentication = getIntent().getParcelableExtra(AUTHENTICATION_KEY);
WebView webView = (WebView) findViewById(R.id.webView_XenditActivity);
progressBar = (ProgressBar) findViewById(R.id.progressBar_XenditActivity);
WebView webView = findViewById(R.id.webView_XenditActivity);
progressBar = findViewById(R.id.progressBar_XenditActivity);

webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public NetworkError(VolleyError error) {
if (networkResponse.data != null) {
String errorString = new String(networkResponse.data);
try {
JSONObject errorJson = new JSONObject(errorString);
errorResponse = errorJson;
errorResponse = new JSONObject(errorString);
} catch (JSONException exception) {
exception.printStackTrace();
errorResponse = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,8 @@ private static boolean isNotInThePast(String expirationMonth, String expirationY
int expMonth = parseNumberSafely(expirationMonth);
int expYear = parseNumberSafely(expirationYear);

if ((expYear == currentYear && expMonth >= currentMonth) || expYear > currentYear) {
return true;
}
return (expYear == currentYear && expMonth >= currentMonth) || expYear > currentYear;

return false;
}

private static int parseNumberSafely(String numberStr) {
Expand All @@ -241,7 +238,9 @@ private static int parseNumberSafely(String numberStr) {
try {
number = Integer.parseInt(numberStr);
}
catch (Exception e) {}
catch (Exception e) {
e.printStackTrace();
}
}

return number;
Expand Down

0 comments on commit 257cade

Please sign in to comment.