forked from emilsjolander/IntentBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit. First working version.
- Loading branch information
0 parents
commit 2b95d26
Showing
32 changed files
with
925 additions
and
0 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,69 @@ | ||
###Android### | ||
|
||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# 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 | ||
|
||
|
||
###IntelliJ### | ||
|
||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
|
||
###OSX### | ||
|
||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
|
||
###Linux### | ||
|
||
*~ | ||
|
||
# KDE directory preferences | ||
.directory |
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,43 @@ | ||
#IntentBuilder | ||
IntentBuilder is a type safe way of creating intents and populating them with extras. Intents were created to be very dynamic but often times the dynamic nature of intents is not needed and just gets in the way of writing safe code. | ||
|
||
##Installation | ||
```groovy | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' | ||
} | ||
} | ||
apply plugin: 'com.neenbedankt.android-apt' | ||
dependencies { | ||
compile 'se.emilsjolander:intentbuilder-api:0.9.0' | ||
apt 'se.emilsjolander:intentbuilder-compiler:0.9.0' | ||
} | ||
``` | ||
|
||
##Usage | ||
Annotate your activities and services with an `@IntentBuilder` annotation so that they are picked up by the library. For every class with an `@IntentBuilder` annotation a class named `MyActivityIntentBuilder` will be generated (Replace 'MyActivity' in the class name whith whatever the name of your Activity or Service class is). If your activity or service takes in parameters via extras in the intent you can now mark field with the `@Extra` annotation and they can be injected with the static `inject` method on the generated intent builder class. Extras can be marked as optional with the `@Optional` annotation. | ||
|
||
```java | ||
@IntentBuilder | ||
class DetailActivity extends Activity { | ||
|
||
@Extra | ||
String id; | ||
|
||
@Extra @Optional | ||
String title; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
DetailActivityIntentBuilder.inject(getIntent(), this); | ||
// TODO use id and title | ||
} | ||
|
||
} |
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,43 @@ | ||
#IntentBuilder | ||
IntentBuilder is a type safe way of creating intents and populating them with extras. Intents were created to be very dynamic but often times the dynamic nature of intents is not needed and just gets in the way of writing safe code. | ||
|
||
##Installation | ||
```groovy | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' | ||
} | ||
} | ||
|
||
apply plugin: 'com.neenbedankt.android-apt' | ||
|
||
dependencies { | ||
compile 'se.emilsjolander:intentbuilder-api:%%version%%' | ||
apt 'se.emilsjolander:intentbuilder-compiler:%%version%%' | ||
} | ||
``` | ||
|
||
##Usage | ||
Annotate your activities and services with an `@IntentBuilder` annotation so that they are picked up by the library. For every class with an `@IntentBuilder` annotation a class named `MyActivityIntentBuilder` will be generated (Replace 'MyActivity' in the class name whith whatever the name of your Activity or Service class is). If your activity or service takes in parameters via extras in the intent you can now mark field with the `@Extra` annotation and they can be injected with the static `inject` method on the generated intent builder class. Extras can be marked as optional with the `@Optional` annotation. | ||
|
||
```java | ||
@IntentBuilder | ||
class DetailActivity extends Activity { | ||
|
||
@Extra | ||
String id; | ||
|
||
@Extra @Optional | ||
String title; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
DetailActivityIntentBuilder.inject(getIntent(), this); | ||
// TODO use id and title | ||
} | ||
|
||
} |
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,30 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'bintray-release' | ||
|
||
android { | ||
compileSdkVersion 22 | ||
buildToolsVersion "23.0.0 rc2" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 22 | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
} | ||
|
||
publish { | ||
userOrg = 'emilsjolander' | ||
groupId = 'se.emilsjolander' | ||
artifactId = 'intentbuilder-api' | ||
version = VERSION | ||
description = 'Generate type safe code for building intents.' | ||
website = 'https://github.com/emilsjolander/intentbuilder' | ||
licences = ['Apache-2.0'] | ||
} |
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,7 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="se.emilsjolander.api"> | ||
|
||
<application android:allowBackup="true"> | ||
|
||
</application> | ||
|
||
</manifest> |
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,4 @@ | ||
package se.emilsjolander.intentbuilder; | ||
|
||
public @interface Extra { | ||
} |
4 changes: 4 additions & 0 deletions
4
api/src/main/java/se/emilsjolander/intentbuilder/IntentBuilder.java
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,4 @@ | ||
package se.emilsjolander.intentbuilder; | ||
|
||
public @interface IntentBuilder { | ||
} |
7 changes: 7 additions & 0 deletions
7
api/src/main/java/se/emilsjolander/intentbuilder/Optional.java
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,7 @@ | ||
package se.emilsjolander.intentbuilder; | ||
|
||
/** | ||
* Created by emilsjolander on 6/14/15. | ||
*/ | ||
public @interface Optional { | ||
} |
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 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:1.2.3' | ||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' | ||
classpath 'com.novoda:bintray-release:0.2.10' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
ext { | ||
VERSION = version() | ||
} | ||
|
||
task bumpMajor << { | ||
ant.propertyfile(file: 'version.properties') { | ||
entry(key: 'major', type: 'int', operation: '+', value: 1) | ||
entry(key: 'minor', type: 'int', operation: '=', value: 0) | ||
entry(key: 'patch', type: 'int', operation: '=', value: 0) | ||
} | ||
} | ||
|
||
task bumpMinor << { | ||
ant.propertyfile(file: 'version.properties') { | ||
entry(key: 'minor', type: 'int', operation: '+', value: 1) | ||
entry(key: 'patch', type: 'int', operation: '=', value: 0) | ||
} | ||
} | ||
|
||
task bumpPatch << { | ||
ant.propertyfile(file: 'version.properties') { | ||
entry(key: 'patch', type: 'int', operation: '+', value: 1) | ||
} | ||
} | ||
|
||
task genReadMe << { | ||
def template = file('README.md.template').text | ||
def result = template.replaceAll("%%version%%", version()) | ||
file("README.md").withWriter{ it << result } | ||
} | ||
|
||
task version << { | ||
println version() | ||
} | ||
|
||
def String version() { | ||
def versionPropsFile = file('version.properties') | ||
def Properties versionProps = new Properties() | ||
versionProps.load(new FileInputStream(versionPropsFile)) | ||
|
||
return versionProps['major'] + "." + versionProps['minor'] + "." + versionProps['patch'] | ||
} |
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,29 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'bintray-release' | ||
|
||
sourceCompatibility = 1.7 | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDirs = ['src/main/java', '../api/src/main/java'] | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile project(':api') | ||
compile 'com.squareup:javapoet:1.0.0' | ||
compile 'com.google.android:android:4.1.1.4' | ||
} | ||
|
||
publish { | ||
userOrg = 'emilsjolander' | ||
groupId = 'se.emilsjolander' | ||
artifactId = 'intentbuilder-compiler' | ||
version = VERSION | ||
description = 'Generate type safe code for building intents.' | ||
website = 'https://github.com/emilsjolander/intentbuilder' | ||
licences = ['Apache-2.0'] | ||
} |
Oops, something went wrong.