-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hotwired/strata-to-strada
Strata to strada
- Loading branch information
Showing
49 changed files
with
406 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Publish to GitHub Packages | ||
|
||
on: | ||
release: | ||
types: [prereleased, released] | ||
|
||
jobs: | ||
publish-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Publish artifact to GitHub Packages | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: ./gradlew -Pversion=${{ github.event.release.tag_name }} clean build -x test publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run tests | ||
run: ./gradlew testRelease |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2021 Basecamp, LLC | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,24 @@ | ||
# Strata | ||
# Strada | ||
|
||
Strada is a light-weight library that provides a bridge for bi-directional, async communication between a native [iOS](https://github.com/hotwired/strada-ios)/Android app and a [web app](https://github.com/hotwired/strada-web) embedded in a web view. The bridge allows sending/receiving messages with a standard format. | ||
|
||
## Installation | ||
|
||
While this repository is still private, Strata for Android can be installed via Gradle. Point a custom Maven repository to the library artifacts in your `app/build.gradle` file: | ||
|
||
```groovy | ||
repositories { | ||
... | ||
maven { | ||
def repo = 'strata' | ||
def branch = 'master' | ||
def path = 'android/strata/artifacts' | ||
url "https://raw.githubusercontent.com/basecamp/$repo/$branch/$path" | ||
authentication { basic(BasicAuthentication) } | ||
credentials { username <github-username>; password <github-access-token> } | ||
} | ||
} | ||
``` | ||
**Note:** The Hotwire frameworks are presented in beta form. We're using them all in production with HEY, but expect that significant changes might be made in response to early feedback. ✌️❤️ | ||
|
||
Then, include the Strata dependency in your `app/build.gradle` file using the `aar` library artifact: | ||
--------- | ||
|
||
```groovy | ||
dependencies { | ||
implementation 'com.basecamp:strata:0.1' | ||
} | ||
``` | ||
|
||
The primary object is `Bridge`. You create a `Bridge` using the `WebView` instance in your app: | ||
|
||
```kotlin | ||
val bridge = Bridge(webView) | ||
``` | ||
|
||
Load the `Bridge` into the current `WebView` page when the `WebViewClient`'s `onPageFinished()` is called: | ||
|
||
```kotlin | ||
webView.webViewClient = object : WebViewClient() { | ||
override fun onPageFinished(view: WebView?, url: String?) { | ||
super.onPageFinished(view, url) | ||
bridge.load() | ||
} | ||
} | ||
``` | ||
Strada is a light-weight library that provides a bridge for bi-directional, async communication between a native [iOS](https://github.com/hotwired/strada-ios)/Android app and a [web app](https://github.com/hotwired/strada-web) embedded in a web view. The bridge allows sending/receiving messages with a standard format. | ||
|
||
This injects the bundled strata.js file and setups everything needed for communicating with the web bridge. | ||
## Documentation | ||
|
||
### Receiving | ||
To receive messages from the web bridge, you want to set a `delegate` on the bridge. | ||
1. [Installation](docs/INSTALLATION.md) | ||
1. [Quick Start](docs/QUICK-START.md) | ||
|
||
```kotlin | ||
bridge.delegate = this | ||
## Contributing | ||
|
||
// BridgeDelegate | ||
override fun bridgeDidInitialize() { | ||
// Configure your supported components | ||
} | ||
Strada Android is open-source software, freely distributable under the terms of an [MIT-style license](LICENSE). The [source code is hosted on GitHub](https://github.com/hotwired/strada-android). Development is sponsored by [Basecamp](https://basecamp.com/). | ||
|
||
override fun bridgeDidReceiveMessage(message: Message) { | ||
// Inspect message and perform related actions | ||
} | ||
``` | ||
We welcome contributions in the form of bug reports, pull requests, or thoughtful discussions in the [GitHub issue tracker](https://github.com/hotwired/strada-android/issues). | ||
|
||
### Sending | ||
You send over the bridge by creating a `Message` and calling `send`: | ||
Please note that this project is released with a [Contributor Code of Conduct](docs/CONDUCT.md). By participating in this project you agree to abide by its terms. | ||
|
||
```kotlin | ||
bridge.send(message) | ||
``` | ||
--------- | ||
|
||
This can be a new message, or a message previously received from the web bridge to "reply" to a message. | ||
© 2021 Basecamp, LLC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, gender identity and expression, level of experience, | ||
nationality, personal appearance, race, religion, or sexual identity and | ||
orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting one of the project maintainers listed below. All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. The project team is | ||
obligated to maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Project Maintainers | ||
|
||
* Jay Ohms <<jay@basecamp.com>> | ||
* Dan Kim <<dan@basecamp.com>> | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, | ||
available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Installation | ||
|
||
## Gradle | ||
Add the dependency from jCenter to your app module's (not top-level) `build.gradle` file: | ||
|
||
```groovy | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
implementation 'dev.hotwire:strada:1.0.0-beta01' | ||
} | ||
``` | ||
|
||
See the [latest version](https://bintray.com/hotwire/maven/strada-android) available on Bintray/JCenter. | ||
|
||
## Required `minSdkVersion` | ||
Android SDK 24 (or greater) is required as the `minSdkVersion` in your app module's `build.gradle` file: | ||
```groovy | ||
defaultConfig { | ||
minSdkVersion 24 | ||
... | ||
} | ||
``` | ||
|
||
# Pre-release Builds | ||
Pre-release builds will be published to [GitHub Packages](https://github.com/features/packages). | ||
|
||
## Personal Access Token | ||
If you'd like to use a pre-release version, you'll need to create a [Personal Access Token](https://docs.github.com/en/free-pro-team@latest/packages/learn-github-packages/about-github-packages#authenticating-to-github-packages) in your GitHub account and give it the `read:packages` permission. | ||
|
||
Copy your access token to your `.bash_profile` (or another accessible place that's outside of source control): | ||
|
||
```bash | ||
export GITHUB_USER='<your username>' | ||
export GITHUB_ACCESS_TOKEN='<your personal access token>' | ||
``` | ||
|
||
## Gradle | ||
Add the GitHub Packages maven repository and the dependency to your app module's `build.gradle` file: | ||
|
||
```groovy | ||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = uri("https://maven.pkg.github.com/hotwired/strada-android") | ||
credentials { | ||
username = System.getenv('GITHUB_USER') | ||
password = System.getenv('GITHUB_ACCESS_TOKEN') | ||
} | ||
} | ||
} | ||
dependencies { | ||
implementation 'dev.hotwire:strada:1.0.0-alpha01' | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Quick Start Guide | ||
|
||
## Load the Bridge | ||
|
||
The primary object is `Bridge`. You create a `Bridge` using the `WebView` instance in your app: | ||
|
||
```kotlin | ||
val bridge = Bridge(webView) | ||
``` | ||
|
||
Load the `Bridge` into the current `WebView` page when the `WebViewClient`'s `onPageFinished()` is called: | ||
|
||
```kotlin | ||
webView.webViewClient = object : WebViewClient() { | ||
override fun onPageFinished(view: WebView?, url: String?) { | ||
super.onPageFinished(view, url) | ||
bridge.load() | ||
} | ||
} | ||
``` | ||
|
||
This injects the bundled strada.js file and setups everything needed for communicating with the web bridge. | ||
|
||
### Receiving | ||
To receive messages from the web bridge, you want to set a `delegate` on the bridge. | ||
|
||
```kotlin | ||
bridge.delegate = this | ||
|
||
// BridgeDelegate | ||
override fun bridgeDidInitialize() { | ||
// Configure your supported components | ||
} | ||
|
||
override fun bridgeDidReceiveMessage(message: Message) { | ||
// Inspect message and perform related actions | ||
} | ||
``` | ||
|
||
### Sending | ||
You send over the bridge by creating a `Message` and calling `send`: | ||
|
||
```kotlin | ||
bridge.send(message) | ||
``` | ||
|
||
This can be a new message, or a message previously received from the web bridge to "reply" to a message. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu Jul 18 07:52:23 EDT 2019 | ||
#Mon Jan 04 10:27:28 EST 2021 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include ':strata' | ||
include ':strada' |
File renamed without changes.
Oops, something went wrong.