Skip to content

Commit

Permalink
Merge pull request #207 from stytchauth/jordan/SDK-1400-java-dx
Browse files Browse the repository at this point in the history
SDK-1400 Improve Java DX
  • Loading branch information
jhaven-stytch authored Aug 30, 2024
2 parents 7048611 + 2e0f469 commit 1688c87
Show file tree
Hide file tree
Showing 150 changed files with 2,230 additions and 1,658 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.iml
.gradle
.idea/
.idea/*
!.idea/codeStyles
!.idea/inspectionProfiles
Expand Down
123 changes: 0 additions & 123 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

32 changes: 0 additions & 32 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MyViewModel : ViewModel() {
fun authenticateSmsOtp(code: String) {
viewModelScope.launch {
val response = StytchClient.otps.authenticate(
OTP.SmsOTP.AuthParameters(
OTP.AuthParameters(
token = code,
methodId = methodId
),
Expand All @@ -133,6 +133,26 @@ class MyViewModel : ViewModel() {
}
}
```
### Concurrency
While the Stytch Android SDK makes heavy use of Coroutines under the hood, every suspend function has a callback-compatible version for developers that are not using Coroutines. An example of the above `authenticateSmsOtp` method with callbacks might look like this:
```kotlin
fun authenticateSmsOtp(code: String) {
val params = OTP.AuthParameters(
token = code,
methodId = methodId
)
StytchClient.otps.authenticate(params) { response ->
when (response) {
is StytchResult.Success -> {
// the user has been authenticated
}
is StytchResult.Error -> {
// something went wrong
}
}
}
}
```

## Further Stytch Usage
For further information and tutorials on some of our more common implementations, see the following:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
kotlin_version = '1.8.22'
kotlin_version = '1.9.21'
dokka_version = '1.9.10'
retrofit_version = '2.11.0'
okhttp_version = '4.12.0'
Expand Down
1 change: 1 addition & 0 deletions example-apps/javademoapp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
48 changes: 48 additions & 0 deletions example-apps/javademoapp/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
plugins {
id 'com.android.application'
}
String publicToken = rootProject.ext["STYTCH_PUBLIC_TOKEN"]

android {
namespace 'com.stytch.javademoapp'
compileSdk 34

defaultConfig {
applicationId "com.stytch.javademoapp"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

manifestPlaceholders["stytchOAuthRedirectScheme"] = "stytchjavademoapp"
manifestPlaceholders["stytchOAuthRedirectHost"] = "oauth"
manifestPlaceholders["STYTCH_PUBLIC_TOKEN"] = publicToken

buildConfigField("String", "STYTCH_PUBLIC_TOKEN", "\"$publicToken\"")
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildFeatures {
buildConfig true
}
}

dependencies {
implementation project(":source:sdk")
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.activity:activity:1.9.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.lifecycle:lifecycle-viewmodel:2.8.4"
}
21 changes: 21 additions & 0 deletions example-apps/javademoapp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
22 changes: 22 additions & 0 deletions example-apps/javademoapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.StytchAndroidSDK">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit 1688c87

Please sign in to comment.