Skip to content

Commit

Permalink
Release 1.0.12 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
chander-stripe authored Mar 17, 2020
1 parent 1aaf837 commit bda0566
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 70 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# CHANGELOG

## 1.0.12 - 2020-03-16
- No changes relative to 1.0.11

## 1.0.11 - 2020-03-16
- Change .aar name, but no external user changes since 1.0.9

## 1.0.10 - 2020-03-16
- No change relative to 1.0.9

## 1.0.9 - 2020-03-16
- Fixes a bug when launching the example app with location turned off would crash on start
- Updated gradle dependencies for various libraries
- Introduce `cardholder_name` as part of `CardPresentDetails`

## 1.0.8 - 2020-01-31
- Fixes Retrofit absolute path [bug](https://github.com/stripe/stripe-terminal-android/issues/82)
- Bumps internal dependency versions

## 1.0.7 - 2020-01-30
- No changes relative to 1.0.2; we've migrated our deploy process internally, and this was a no-op deploy to test the new publishing mechanism
Expand Down
16 changes: 14 additions & 2 deletions Example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.50'
ext.ktlint_version = '0.35.0'
ext.appcompat_version = '1.1.0'
ext.constraint_layout_version = '1.1.3'
ext.kotlin_version = '1.3.70'
ext.kotlin_coroutines_version = '1.3.4'
ext.ktlint_version = '0.36.0'
ext.leakcanary_version = '2.2'
ext.lifecycle_version = '2.2.0'
ext.material_version = '1.1.0'
ext.okhttp_version = '4.4.1'
ext.stetho_version = '1.5.1'

repositories {
google()
Expand All @@ -19,6 +27,10 @@ buildscript {
}
}

ext {
maxSdkVersion = 29
}

allprojects {
repositories {
google()
Expand Down
50 changes: 18 additions & 32 deletions Example/javaapp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
compileSdkVersion rootProject.ext.maxSdkVersion

defaultConfig {
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion rootProject.ext.maxSdkVersion
}

buildFeatures {
dataBinding = true
dataBinding {
enabled = true
}

compileOptions {
Expand All @@ -23,62 +23,48 @@ android {
}

ext {
buildToolsVersion = "29.0.0"
compileSdkVersion = 29
supportLibVersion = "28.0.0"

appcompatVersion = '1.1.0'
constraintVersion = '1.1.3'
constraintlayoutVersion = '1.1.3'
coreTestingVersion = '2.1.0'
coroutineVersion = '1.3.3'
databindingVersion = '3.1.4'
legacysupportVersion = '1.0.0'
materialVersion = '1.0.0'
okhttpVersion = '4.3.1'
retrofitVersion = '2.7.1'
stethoVersion = '1.5.1'
viewModelVersion = '2.2.0'

leakCanaryVersion = '2.1'

stripeTerminalVersion = '1.0.8'
stripeTerminalVersion = '1.0.12'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

api "com.google.android.material:material:$materialVersion"
api "com.google.android.material:material:$rootProject.ext.material_version"
implementation "androidx.legacy:legacy-support-v4:$legacysupportVersion"
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.appcompat:appcompat:$rootProject.ext.appcompat_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayoutVersion"
implementation "com.facebook.stetho:stetho:$stethoVersion"
implementation "com.facebook.stetho:stetho-okhttp3:$stethoVersion"
implementation "com.facebook.stetho:stetho:$rootProject.ext.stetho_version"
implementation "com.facebook.stetho:stetho-okhttp3:$rootProject.ext.stetho_version"

// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$viewModelVersion"
implementation "androidx.lifecycle:lifecycle-common-java8:$viewModelVersion"
annotationProcessor "androidx.lifecycle:lifecycle-common-java8:$viewModelVersion"
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.ext.lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$rootProject.ext.lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-common-java8:$rootProject.ext.lifecycle_version"
testImplementation "androidx.arch.core:core-testing:$coreTestingVersion"

// Databinding
annotationProcessor "com.android.databinding:compiler:$databindingVersion"

// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.ext.kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlin_coroutines_version"

// OK HTTP
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:okhttp:$rootProject.ext.okhttp_version"

// Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:retrofit:$rootProject.ext.retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$rootProject.ext.retrofit_version"

// Stripe Terminal library
implementation "com.stripe:stripeterminal:$stripeTerminalVersion"

// Leak canary
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
debugImplementation "com.squareup.leakcanary:leakcanary-android:$rootProject.ext.leakcanary_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.LocationManager;
import android.os.Bundle;
import android.provider.Settings;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
Expand Down Expand Up @@ -58,7 +65,7 @@ public void onResume() {
// Check for location permissions
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (!Terminal.isInitialized()) {
if (!Terminal.isInitialized() && verifyGpsEnabled()) {
initialize();
}
} else {
Expand All @@ -83,7 +90,7 @@ public void onRequestPermissionsResult(
@NotNull int[] grantResults
) {
// If we receive a response to our permission check, initialize
if (requestCode == REQUEST_CODE_LOCATION && !Terminal.isInitialized()) {
if (requestCode == REQUEST_CODE_LOCATION && !Terminal.isInitialized() && verifyGpsEnabled()) {
initialize();
}
}
Expand Down Expand Up @@ -204,4 +211,30 @@ private void navigateTo(String tag, Fragment fragment) {
.replace(R.id.container, frag != null ? frag : fragment, tag)
.commitAllowingStateLoss();
}

private boolean verifyGpsEnabled() {
final LocationManager locationManager =
(LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);

boolean gpsEnabled = false;
try {
gpsEnabled = locationManager != null &&
locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch (Exception exception) {
}

if (!gpsEnabled) {
// notify user
new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_DarkActionBar))
.setMessage("Please enable location services")
.setCancelable(false)
.setPositiveButton("Open location settings", (dialog, which) -> {
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
})
.create()
.show();
}

return gpsEnabled;
}
}
48 changes: 17 additions & 31 deletions Example/kotlinapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ configurations {
}

android {
compileSdkVersion 29
compileSdkVersion rootProject.ext.maxSdkVersion

defaultConfig {
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion rootProject.ext.maxSdkVersion
}

buildFeatures {
dataBinding = true
dataBinding {
enabled = true
}

compileOptions {
Expand All @@ -26,65 +26,51 @@ android {
}

ext {
buildToolsVersion = "29.0.0"
compileSdkVersion = 29
supportLibVersion = "28.0.0"

appcompatVersion = '1.1.0'
constraintVersion = '1.1.3'
constraintlayoutVersion = '1.1.3'
coreTestingVersion = '2.1.0'
coroutineVersion = '1.3.3'
databindingVersion = '3.1.4'
legacysupportVersion = '1.0.0'
materialVersion = '1.0.0'
okhttpVersion = '4.3.1'
retrofitVersion = '2.7.1'
stethoVersion = '1.5.1'
viewModelVersion = '2.2.0'

leakCanaryVersion = '2.1'

stripeTerminalVersion = '1.0.8'
stripeTerminalVersion = '1.0.12'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

api "com.google.android.material:material:$materialVersion"
api "com.google.android.material:material:$rootProject.ext.material_version"
implementation "androidx.legacy:legacy-support-v4:$legacysupportVersion"
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.appcompat:appcompat:$rootProject.ext.appcompat_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayoutVersion"
implementation "com.facebook.stetho:stetho:$stethoVersion"
implementation "com.facebook.stetho:stetho-okhttp3:$stethoVersion"
implementation "com.facebook.stetho:stetho:$rootProject.ext.stetho_version"
implementation "com.facebook.stetho:stetho-okhttp3:$rootProject.ext.stetho_version"

// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$viewModelVersion"
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.ext.lifecycle_version"
// We are using Kotlin, and not Java 8, so do not use the recommended Java 8 library
//noinspection LifecycleAnnotationProcessorWithJava8
kapt "androidx.lifecycle:lifecycle-compiler:$viewModelVersion"
kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.ext.lifecycle_version"
testImplementation "androidx.arch.core:core-testing:$coreTestingVersion"

// Databinding
kapt "com.android.databinding:compiler:$databindingVersion"

// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.ext.kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlin_coroutines_version"

// OK HTTP
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:okhttp:$rootProject.ext.okhttp_version"

// Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:retrofit:$rootProject.ext.retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$rootProject.ext.retrofit_version"

// Stripe Terminal library
implementation "com.stripe:stripeterminal:$stripeTerminalVersion"

// Leak canary
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
debugImplementation "com.squareup.leakcanary:leakcanary-android:$rootProject.ext.leakcanary_version"

// Ktlint
ktlint "com.pinterest:ktlint:$ktlint_version"
Expand Down
34 changes: 32 additions & 2 deletions Example/kotlinapp/src/main/java/com/stripe/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ package com.stripe.example

import android.Manifest
import android.bluetooth.BluetoothAdapter
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.location.LocationManager
import android.os.Bundle
import android.provider.Settings
import android.view.ContextThemeWrapper
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
Expand Down Expand Up @@ -53,7 +59,7 @@ class MainActivity : AppCompatActivity(), NavigationListener {
// Check for location permissions
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (!Terminal.isInitialized()) {
if (!Terminal.isInitialized() && verifyGpsEnabled()) {
initialize()
}
} else {
Expand All @@ -72,7 +78,7 @@ class MainActivity : AppCompatActivity(), NavigationListener {
grantResults: IntArray
) {
// If we receive a response to our permission check, initialize
if (requestCode == REQUEST_CODE_LOCATION && !Terminal.isInitialized()) {
if (requestCode == REQUEST_CODE_LOCATION && !Terminal.isInitialized() && verifyGpsEnabled()) {
initialize()
}
}
Expand Down Expand Up @@ -183,4 +189,28 @@ class MainActivity : AppCompatActivity(), NavigationListener {
.replace(R.id.container, frag, tag)
.commitAllowingStateLoss()
}

private fun verifyGpsEnabled(): Boolean {
val locationManager: LocationManager? =
applicationContext.getSystemService(Context.LOCATION_SERVICE) as LocationManager?
var gpsEnabled = false

try {
gpsEnabled = locationManager?.isProviderEnabled(LocationManager.GPS_PROVIDER) ?: false
} catch (exception: Exception) {}

if (!gpsEnabled) {
// notify user
AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_DarkActionBar))
.setMessage("Please enable location services")
.setCancelable(false)
.setPositiveButton("Open location settings") { param, paramInt ->
this.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
}
.create()
.show()
}

return gpsEnabled
}
}

0 comments on commit bda0566

Please sign in to comment.