Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate example app to Kotlin #1297

Merged
merged 2 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ before_install:
- yes | sdkmanager "platforms;android-28"

script:
- ./gradlew :stripe:checkstyle :example:checkstyle :samplestore:checkstyle :samplestore:ktlint lint
- ./gradlew :stripe:checkstyle :example:checkstyle :samplestore:checkstyle :example:ktlint :samplestore:ktlint lint
- ./gradlew clean test
8 changes: 3 additions & 5 deletions example/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
android:exported="false"/>

<activity
android:name=".activity.RedirectActivity"
android:launchMode="singleTask">
android:name=".activity.RedirectActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

Expand All @@ -61,8 +60,7 @@
</intent-filter>
</activity>
<activity
android:name=".activity.LauncherActivity"
android:launchMode="singleTask">
android:name=".activity.LauncherActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand Down Expand Up @@ -97,7 +95,7 @@
android:name=".activity.PaymentAuthActivity" />

<activity
android:name=".activity.FragmentExampesActivity" />
android:name=".activity.FragmentExamplesActivity" />
</application>

</manifest>
27 changes: 27 additions & 0 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'checkstyle'
assemble.dependsOn('lint')
check.dependsOn('checkstyle')

configurations {
ktlint
}

dependencies {
implementation project(':stripe')
implementation 'com.android.support:multidex:1.0.3'
Expand Down Expand Up @@ -39,6 +45,8 @@ dependencies {
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
// Optional, if you use support library fragments:
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'

ktlint "com.pinterest:ktlint:0.33.0"
}

android {
Expand Down Expand Up @@ -85,3 +93,22 @@ android {
}
}
}

task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// see https://github.com/pinterest/ktlint#usage for more
}
check.dependsOn ktlint

task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}

This file was deleted.

33 changes: 33 additions & 0 deletions example/src/main/java/com/stripe/example/ExampleApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.stripe.example

import android.os.StrictMode
import android.support.multidex.MultiDexApplication

import com.facebook.stetho.Stetho
import com.squareup.leakcanary.LeakCanary

class ExampleApplication : MultiDexApplication() {

override fun onCreate() {
super.onCreate()

StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build())

Stetho.initializeWithDefaults(this)

if (BuildConfig.DEBUG && LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return
}

if (BuildConfig.DEBUG) {
LeakCanary.install(this)
}
}
}
26 changes: 26 additions & 0 deletions example/src/main/java/com/stripe/example/Settings.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.stripe.example

/**
* See [Configuring the example app](https://github.com/stripe/stripe-android#building-the-example-project)
* for instructions on how to configure the app before running it.
*/
internal object Settings {
/**
* Set to the base URL of your test backend. If you are using
* [example-ios-backend](https://github.com/stripe/example-ios-backend),
* the URL will be something like `https://hidden-beach-12345.herokuapp.com/`.
*/
const val BASE_URL = "put your base url here"

/**
* Set to publishable key from https://dashboard.stripe.com/test/apikeys
*/
const val PUBLISHABLE_KEY = "pk_test_your_key_goes_here"

/**
* Optionally, set to a Connect Account id to use for API requests to test Connect
*
* See https://dashboard.stripe.com/test/connect/accounts/overview
*/
val STRIPE_ACCOUNT_ID: String? = null
}

This file was deleted.

Loading