Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
apradanas committed Aug 11, 2015
2 parents da092b9 + c0bb300 commit 1998ee1
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 89 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Installation
Add dependency

```
compile 'com.apradanas.simplelinkabletext:library:1.0.1@aar'
compile 'com.apradanas.simplelinkabletext:library:1.0.2@aar'
```


Expand Down
84 changes: 84 additions & 0 deletions gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

group = POM_GROUP_ID
version = POM_VERSION

def siteUrl = POM_SITE_URL // Homepage URL of the library
def gitUrl = POM_GIT_URL // Git repository URL

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

configurations = ['archives']
pkg {
repo = "maven"
name = BINTRAY_PKG_NAME
desc = BINTRAY_PKG_DESCRIPTION
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}

install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
name POM_PROJECT_NAME
url siteUrl
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email POM_DEVELOPER_EMAIL
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl

}
}
}
}
}

dependencies {
}

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

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

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}

task findConventions << {
println project.getConvention()
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
BINTRAY_PKG_NAME=simple-linkable-text
BINTRAY_PKG_DESCRIPTION=Simple way to create linked text in Android TextView and EditText

POM_SITE_URL=https://github.com/apradanas/simple-linkable-text
POM_GIT_URL=https://github.com/apradanas/simple-linkable-text.git
Expand All @@ -28,4 +29,4 @@ POM_DEVELOPER_NAME=Aditya Pradana Sugiarto
POM_DEVELOPER_EMAIL=adit@apradanas.com

POM_GROUP_ID=com.apradanas.simplelinkabletext
POM_VERSION=1.0.1
POM_VERSION=1.0.2
84 changes: 2 additions & 82 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

group = POM_GROUP_ID
version = POM_VERSION

android {
Expand All @@ -23,86 +20,9 @@ android {
}
}

def siteUrl = POM_SITE_URL // Homepage URL of the library
def gitUrl = POM_GIT_URL // Git repository URL

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

configurations = ['archives']
pkg {
repo = "maven"
name = BINTRAY_PKG_NAME
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}

install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
name POM_PROJECT_NAME
url siteUrl
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email POM_DEVELOPER_EMAIL
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl

}
}
}
}
}

dependencies {
}

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

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

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}

task findConventions << {
println project.getConvention()
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}

//apply from: '../gradle-mvn-push.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class LinkableEditText extends EditText implements TextWatcher {
private List<Link> mLinks = new ArrayList<>();

private LinkModifier mLinkModifier;
private OnTextChangedListener mOnTextChangedListener;

public LinkableEditText(Context context) {
super(context);
Expand Down Expand Up @@ -60,20 +61,41 @@ public LinkableEditText addLinks(List<Link> links) {
return this;
}

public LinkableEditText setTextChangedListener(OnTextChangedListener listener) {
mOnTextChangedListener = listener;
return this;
}

@Override
public void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
super.onTextChanged(text, start, lengthBefore, lengthAfter);

if(mOnTextChangedListener != null) {
mOnTextChangedListener.onTextChanged(text, start, lengthBefore, lengthAfter);
}
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

if(mOnTextChangedListener != null) {
mOnTextChangedListener.beforeTextChanged(s, start, count, after);
}
}

@Override
public void afterTextChanged(Editable s) {
mLinkModifier.setSpannable(s);

mLinkModifier.build();

if(mOnTextChangedListener != null) {
mOnTextChangedListener.afterTextChanged(s);
}
}

public interface OnTextChangedListener {
void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter);
void beforeTextChanged(CharSequence s, int start, int count, int after);
void afterTextChanged(Editable s);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
Expand Down Expand Up @@ -56,19 +57,40 @@ public void onClick(String text) {
links.add(linkAnd);

final LinkableTextView textView = (LinkableTextView) findViewById(R.id.textView);
textView.setText("#test #LinkableTextView: detecting #hashtags and @username")
final Button submitButton = (Button) findViewById(R.id.submitButton);
final LinkableEditText editText = (LinkableEditText) findViewById(R.id.editText);

textView.setText("#LinkableTextView: detecting #hashtags and @username")
.addLinks(links)
.build();

final LinkableEditText editText = (LinkableEditText) findViewById(R.id.editText);
editText.addLinks(links);

Button submitButton = (Button) findViewById(R.id.submitButton);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
textView.setText(editText.getText().toString()).build();
}
});


editText.addLinks(links);
editText.setTextChangedListener(new LinkableEditText.OnTextChangedListener() {
@Override
public void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {

}

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void afterTextChanged(Editable s) {
submitButton.setEnabled(s.length() > 0);
}
});


}
}
1 change: 1 addition & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:enabled="false"
android:text="@string/submit"/>

</LinearLayout>

0 comments on commit 1998ee1

Please sign in to comment.