Skip to content

Commit

Permalink
initial OpenSource project
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Kocel committed Aug 23, 2015
0 parents commit 224309f
Show file tree
Hide file tree
Showing 44 changed files with 1,699 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated files
bin/
gen/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Idea project files
*.iml

## Directory-based project format:
/.idea/
.idea

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml
sonar-project.properties
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: android

android:
components:
- android-22
- build-tools-22.0.1
- extra-android-m2repository

jdk:
- oraclejdk7

notifications:
email: false

sudo: false

cache:
directories:
- $HOME/.m2
- $HOME/.gradle

script: ./gradlew build test --info
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Slinger - deep linking library for Android
======

Slinger is a small Android library for handling custom Uri which uses regular expression to
catch and route URLs which won’t be handled by normal [intent-filter](http://developer.android.com/guide/topics/manifest/data-element.html#path) mechanism.

With slinger it’s possible to have deep links for quite complicated URLs.

![Scheme of Slinger resolving Activities using regular expression](assets/slinger_resolving_mechanism.png)

## How do I use it?

Declare Activity in your manifest that will handle links within particular domain.

```xml
<activity
android:name=".MySlingerRoutingActivity"
android:noHistory="true">
<intent-filter android:label="@string/app_name">
<data android:host="example.com"
android:pathPattern=".*"
android:scheme="http" />
</intent-filter>
</activity>
```

In `MySlingerRoutingActivity` provide custom `IntentResolver` that redirect URLs
to concrete Activities based on regular expressions.

```java
public class MySlingerRoutingActivity extends SlingerActivity {

...

private RedirectRule getRedirectRuleForAboutActivity() {
return RedirectRule.builder()
.intent(new Intent(context, MyConcreteActivityA.class))
.pattern("http://example.com/abc\\\\.html\\\\?query=a.*")
.build();
}

@Override protected IntentResolver getIntentResolver() {
return new IntentResolver(asList(getRedirectRuleForAboutActivity()));
}
}
```

In case when no redirect rule is matched Slinger will fallback to default URL handler (usually browser).

## Customizing

### Matching Activities

`IntentResolver` can be extended and `resolveIntentToSling` method can be overridden to match URLs using
other mechanism than regular expression matching.

### Enriching Slinged Intents with Referrer and input URL

Slinger enriches Intents with URL and [referrer](http://developer.android.com/reference/android/app/Activity.html#getReferrer()) by default.
This can be changed by overriding `enrichIntent` method in `SlingerActivity`

### Fallback mechanism when no rule is matched

To provide different way of starting Activities just override `excludeSlingerAndStartTargetActivity` method in `SlingerActivity`

## Security considerations

Slinger does not sanitize input in any way. So providing security for application is your responsibility.

## License

**slinger** is published under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
Binary file added assets/slinger_resolving_mechanism.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3'
}
}

plugins {
id 'pl.allegro.tech.build.axion-release' version '1.2.4'
}

apply plugin: 'io.codearte.nexus-staging'

nexusStaging {
packageGroup = 'pl.allegro'
}

allprojects {
group = GROUP
version = scmVersion.version

repositories {
mavenLocal()
jcenter()
maven { url "http://dl.bintray.com/populov/maven" }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://maven.fabric.io/public' }
}
}

ext {
compileSdkVersion = 22
buildToolsVersion = '22.0.1'
minSdkVersion = 9
targetSdkVersion = 22

supportAnnotations = 'com.android.support:support-annotations:22.2.0'

junit = 'junit:junit:4.12'
robolectric = 'org.robolectric:robolectric:3.0'
mavenAntTasks = 'org.apache.maven:maven-ant-tasks:2.1.3'
mockitoCore = 'org.mockito:mockito-core:1.10.19'
truth = 'com.google.truth:truth:0.26'
}
13 changes: 13 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
VERSION_CODE=1
GROUP=pl.allegro.android.slinger

POM_DESCRIPTION=Library to handle and define deep links in Android application.
POM_URL=https://github.com/allegro/slinger
POM_SCM_URL=https://github.com/allegro/slinger
POM_SCM_CONNECTION=scm:[email protected]:allegro/slinger.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:allegro/slinger.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=kkocel
POM_DEVELOPER_NAME=Christopher Kocel
114 changes: 114 additions & 0 deletions gradle/maven/mvn-publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'maven'
apply plugin: 'signing'

def isReleaseBuild() {
return scmVersion.version.contains("SNAPSHOT") == false
}

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getRepositoryUsername() {
return hasProperty('nexusUsername') ? nexusUsername : ""
}

def getRepositoryPassword() {
return hasProperty('nexusPassword') ? nexusPassword : ""
}

afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = scmVersion.version

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}

pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}

signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}

artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-all.zip
Loading

0 comments on commit 224309f

Please sign in to comment.