Skip to content
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
3 changes: 2 additions & 1 deletion .github/scripts/publish_crates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ crates=(
./crossbundle/tools
./crossbundle/cli
./plugins/admob-android
./plugins/play-games-services
./plugins/play-billing
./plugins/play-core
./plugins/play-games-services
)
for crate in "${crates[@]}"
do
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@ jobs:
cd ./plugins/play-billing/android
gradle build
USERNAME=dodorare gradle publish
- name: Build and publish Crossbow Play Core library
env:
TOKEN: ${{ secrets.GH_CROSSBOW_PUBLISH_TOKEN }}
run: |
cd ./plugins/play-core/android
gradle build
USERNAME=dodorare gradle publish
4 changes: 3 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ vulnerability = "deny"
unmaintained = "deny"
yanked = "deny"
notice = "deny"
ignore = []
# Only needed because of https://github.com/netvl/xml-rs.
# TODO: Remove this when repository will be maintained again.
ignore = ["RUSTSEC-2022-0048"]

[licenses]
unlicensed = "deny"
Expand Down
2 changes: 1 addition & 1 deletion plugins/play-billing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["DodoRare Team <[email protected]>"]
description = "Google Play Billing Plugin for Crossbow"
repository = "https://github.com/dodorare/crossbow"
license = "MIT OR Apache-2.0"
keywords = ["crossbow", "google", "admob", "android", "ads"]
keywords = ["crossbow", "google", "billing", "android"]
readme = "README.md"
exclude = ["android/"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import java.util.HashMap
import java.util.Arrays
import java.util.ArrayList

class CrossbowPlayBilling(crossbow: Crossbow?) : CrossbowPlugin(crossbow!!),
class CrossbowPlayBilling(crossbow: Crossbow) : CrossbowPlugin(crossbow),
PurchasesUpdatedListener, BillingClientStateListener, PriceChangeConfirmationListener {
private val billingClient: BillingClient
private val skuDetailsCache = HashMap<String, SkuDetails>()
Expand All @@ -49,7 +49,7 @@ class CrossbowPlayBilling(crossbow: Crossbow?) : CrossbowPlugin(crossbow!!),
}

override val pluginName: String
get() = "CrossbowPlayBilling"
get() = javaClass.simpleName

override val pluginSignals: Set<SignalInfo>
get() {
Expand Down Expand Up @@ -308,4 +308,4 @@ class CrossbowPlayBilling(crossbow: Crossbow?) : CrossbowPlugin(crossbow!!),
fun setObfuscatedProfileId(profileId: String) {
obfuscatedProfileId = profileId
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ object CrossbowPlayBillingUtils {
}
return skuDetailsDictionaries
}
}
}
14 changes: 14 additions & 0 deletions plugins/play-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "play-core"
version = "0.2.0"
edition = "2021"
authors = ["DodoRare Team <[email protected]>"]
description = "Google Play Core Plugin for Crossbow"
repository = "https://github.com/dodorare/crossbow"
license = "MIT OR Apache-2.0"
keywords = ["crossbow", "google", "core", "android"]
readme = "README.md"
exclude = ["android/"]

[dependencies]
crossbow-android = { path = "../../platform/android", version = "0.2.0" }
65 changes: 65 additions & 0 deletions plugins/play-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Crossbow Google Play Core Plugin

[![Crate Info](https://img.shields.io/crates/v/play-core.svg)](https://crates.io/crates/play-core)
[![Documentation](https://img.shields.io/badge/docs.rs-play_core-green)](https://docs.rs/play-core/)
[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/dodorare/crossbow#license)
[![GitHub Stars](https://img.shields.io/github/stars/dodorare/crossbow.svg?style=social)](https://github.com/dodorare/crossbow/stargazers)

## About

This project is a Crossbow Plugin for [Google Play Core libraries](https://developer.android.com/guide/playcore) written in Rust and Kotlin.

## Installation

> **Important:** Before using this plugin please read more about [Google Play Core libraries](https://developer.android.com/guide/playcore) and [In-app updates](https://developer.android.com/guide/playcore/in-app-updates).

Just add Rust dependencies like this:

```toml
[dependencies]
crossbow = "0.2.0"
[target.'cfg(target_os = "android")'.dependencies]
play-core = "0.2.0"
```

And finally, add this to your Crossbow Android configuration:

```toml
[package.metadata.android]
plugins_remote = ["com.crossbow.play_core:play_core:0.2.0"]
```

> That's it, now you can start using Play Core!

## Usage

First step is plugin initialization. In your rust project, you will need to initialize `Crossbow` instance and then get **Android** plugin:

```rust
#![cfg(target_os = "android")]

use crossbow::android::*;
let crossbow = CrossbowInstance::new();
let play_core: play_core::PlayCorePlugin = crossbow.get_plugin()?;
```

After plugin initialization you can use supported features. For example to start connection and query purchases you can use:

```rust
play_core.check_update()?;
play_core.in_progress_update()?;
```

To read signals:

```rust
if let Ok(signal) = play_core.get_receiver().recv().await {
println!("Signal: {:?}", signal);
}
```

Complete documentation you can find [here](https://docs.rs/play-core/).

## Future work

Ideally we will get rid of the Java wrapper and will create C++ wrapper around [Google Play Core native](https://developer.android.com/reference/native/play/core) - so that it will support all features and will work faster than with JNI. If you want to help us with it - welcome!
7 changes: 7 additions & 0 deletions plugins/play-core/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.crossbow.play_core">
<application>
<meta-data
android:name="com.crossbow.plugin.v1.CrossbowPlayCore"
android:value="com.crossbow.play_core.CrossbowPlayCore"/>
</application>
</manifest>
77 changes: 77 additions & 0 deletions plugins/play-core/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
buildscript {
apply from: "config.gradle"
repositories {
google()
mavenCentral()
mavenCrossbowGithub()
}
dependencies {
classpath libraries.androidGradlePlugin
classpath libraries.kotlinGradlePlugin
}
}

apply plugin: "com.android.library"
apply plugin: "org.jetbrains.kotlin.android"
apply from: "config.gradle"
apply from: "publish.gradle"

repositories {
google()
mavenCentral()
mavenCrossbowGithub()
}

dependencies {
implementation libraries.kotlinStdLib
implementation libraries.androidxAppcompat
implementation "com.google.android.play:app-update-ktx:2.0.0"

if (rootProject.findProject(":crossbow:lib")) {
implementation project(":crossbow:lib")
} else if(getCustomBuildMode()) {
// Custom build mode. In this scenario this project is the only one around and the Crossbow
// library is available through the pre-generated crossbow-lib.*.aar android archive files.
debugImplementation fileTree(dir: "../libs/debug", include: ["*.jar", "*.aar"])
releaseImplementation fileTree(dir: "../libs/release", include: ["*.jar", "*.aar"])
} else {
implementation libraries.crossbowLibrary
}
}

android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools

compileOptions {
sourceCompatibility versions.javaVersion
targetCompatibility versions.javaVersion
}

kotlinOptions {
jvmTarget = versions.javaVersion
}

defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk

missingDimensionStrategy "products", "template"
}

lintOptions {
abortOnError false
disable "MissingTranslation", "UnusedResources"
}

sourceSets {
main {
manifest.srcFile "AndroidManifest.xml"
java.srcDirs = ["src"]
assets.srcDirs = ["assets"]
res.srcDirs = ["res"]
}
}
}
42 changes: 42 additions & 0 deletions plugins/play-core/android/config.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ext.versions = [
crossbowLibrary : "0.2.0",
androidGradlePlugin: "7.0.0",
compileSdk : 31,
minSdk : 19,
targetSdk : 30,
buildTools : "30.0.3",
kotlinVersion : "1.6.21",
appcompatVersion : "1.4.0",
javaVersion : 11,
]

ext.libraries = [
androidGradlePlugin: "com.android.tools.build:gradle:$versions.androidGradlePlugin",
kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion",
kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion",
androidxAppcompat : "androidx.appcompat:appcompat:$versions.appcompatVersion",
crossbowLibrary : "com.crossbow.library:lib:$versions.crossbowLibrary"
]

/**
* Parse the project properties for the 'custom_build_mode' property and return
* it for turning on custom build mode.
*/
ext.getCustomBuildMode = { ->
// Retrieve the custom_build_mode from the project property set by the Crossbow build command.
return project.hasProperty("custom_build_mode") ? project.property("custom_build_mode") : false
}

/**
* Add Crossbow Gihub Maven repository with credentials to the project.
*/
ext.mavenCrossbowGithub = {
repositories.maven {
url = uri("https://maven.pkg.github.com/dodorare/crossbow")
credentials {
// Use this open machine user token because repo requires authentication
username = "token"
password = "\u0067hp_YQdtzsNYrpQM3lmZPOXYHpC5GXiord4Qodew"
}
}
}
26 changes: 26 additions & 0 deletions plugins/play-core/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
android.enableJetifier=true

# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading