diff --git a/README.md b/README.md index 4e7c0309..5bd9ae17 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,9 @@ MaterialEditText ================ [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MaterialEditText-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1085) -> ## NOTE: 2.0 is NOT BACKWARDS COMPATIBLE! See more on [wiki](https://github.com/rengwuxian/MaterialEditText/wiki) or [中文看这里](http://www.rengwuxian.com/post/materialedittext) - +> ## This is a fork of MaterialEditText from [here](https://github.com/rengwuxian/MaterialEditText). In this fork, the following functionality has been added:- +> 1. ability to wrap long floating labels +> 2. ![MaterialEditText](./images/material_edittext.png) diff --git a/build.gradle b/build.gradle index 87c964dc..55292376 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.0' + classpath 'com.android.tools.build:gradle:2.2.0' } } diff --git a/gradle.properties b/gradle.properties index eee79ff0..5ad6c485 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,18 @@ -VERSION_NAME=2.1.4 -VERSION_CODE=43 -GROUP=com.rengwuxian.materialedittext +VERSION_NAME=2.1.6-SNAPSHOT +VERSION_CODE=44 +GROUP=org.smartregister -POM_DESCRIPTION=Android EditText in Material Design -POM_URL=https://github.com/rengwuxian/MaterialEditText -POM_SCM_URL=https://github.com/rengwuxian/MaterialEditText -POM_SCM_CONNECTION=scm:git@github.com:rengwuxian/MaterialEditText.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:rengwuxian/MaterialEditText.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=rengwuxian -POM_DEVELOPER_NAME=Kai Zhu +POM_SETTING_DESCRIPTION=Android EditText in Material Design +POM_SETTING_URL=https://github.com/OpenSRP/MaterialEditText +POM_SETTING_SCM_URL=https://github.com/OpenSRP/MaterialEditText +POM_SETTING_SCM_CONNECTION=scm:git@github.com:OpenSRP/MaterialEditText.git +POM_SETTING_SCM_DEV_CONNECTION=scm:git@github.com:OpenSRP/MaterialEditText.git +POM_SETTING_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_SETTING_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_SETTING_LICENCE_DIST=repo +POM_SETTING_DEVELOPER_ID=opensrp +POM_SETTING_DEVELOPER_NAME=OpenSRP Onadev ANDROID_BUILD_TARGET_SDK_VERSION=22 ANDROID_BUILD_TOOLS_VERSION=22.0.1 -ANDROID_BUILD_SDK_VERSION=22 \ No newline at end of file +ANDROID_BUILD_SDK_VERSION=22 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c8208cfb..d7fa5122 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Dec 07 22:23:47 CST 2014 +#Mon Jul 29 17:53:44 EAT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index 56336167..d3c89d1b 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) - buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION + buildToolsVersion '22.0.1' defaultConfig { minSdkVersion 7 @@ -23,4 +23,4 @@ dependencies { } // Used to push in maven -apply from: '../maven_push.gradle' +apply from: '../maven.gradle' diff --git a/library/gradle.properties b/library/gradle.properties index c7c2f1c5..5bf0c894 100644 --- a/library/gradle.properties +++ b/library/gradle.properties @@ -1,3 +1,3 @@ -POM_NAME=Material EditText Library -POM_ARTIFACT_ID=library -POM_PACKAGING=aar \ No newline at end of file +POM_SETTING_NAME=Material EditText Library +POM_SETTING_ARTIFACT_ID=opensrp-client-materialedittext +POM_SETTING_PACKAGING=aar diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 516722e6..f040b719 100755 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -1384,7 +1384,29 @@ protected void onDraw(@NonNull Canvas canvas) { textPaint.setAlpha(alpha); // draw the floating label - canvas.drawText(floatingLabelText.toString(), floatingLabelStartX, floatingLabelStartY, textPaint); + int count = floatingLabelText.toString().length() - floatingLabelText.toString().replace("\n", + "").length(); + if (count == 0) { + canvas.drawText(floatingLabelText.toString(), floatingLabelStartX, floatingLabelStartY, textPaint); + } else { + int i = 1; + for (String label: floatingLabelText.toString().split("\n")) { + // recalculate horizontal position + floatingLabelWidth = textPaint.measureText(label); + if ((getGravity() & Gravity.RIGHT) == Gravity.RIGHT || isRTL()) { + floatingLabelStartX = (int) (endX - floatingLabelWidth); + } else if ((getGravity() & Gravity.LEFT) == Gravity.LEFT) { + floatingLabelStartX = startX; + } else { + floatingLabelStartX = startX + (int) (getInnerPaddingLeft() + (getWidth() - getInnerPaddingLeft() - getInnerPaddingRight() - floatingLabelWidth) / 2); + } + // end of horizontal position recalculation + + floatingLabelStartY = (innerPaddingTop + floatingLabelTextSize * i + floatingLabelPadding - distance * (floatingLabelAlwaysShown ? 1 : 2) + getScrollY()); + canvas.drawText(label, floatingLabelStartX, floatingLabelStartY, textPaint); + i++; + } + } } // draw the bottom ellipsis diff --git a/maven.gradle b/maven.gradle new file mode 100644 index 00000000..bc202e14 --- /dev/null +++ b/maven.gradle @@ -0,0 +1,134 @@ +apply plugin: 'maven' +apply plugin: 'signing' + +def sonatypeRepositoryURL +def mavenLocalFlag = hasProperty('mavenLocal') ? mavenLocal.toBoolean() : true; + +if (isReleaseBuild()) { + println 'PROCESSING MAVEN ' + (mavenLocalFlag ? 'LOCAL' : 'REMOTE') + ' RELEASE BUILD VERSION ' + project.VERSION_NAME + '...' + sonatypeRepositoryURL = hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL + : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" +} else { + println 'PROCESSING MAVEN ' + (mavenLocalFlag ? 'LOCAL' : 'REMOTE') + ' SNAPSHOT BUILD VERSION ' + project.VERSION_NAME + '...' + sonatypeRepositoryURL = hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL + : "https://oss.sonatype.org/content/repositories/snapshots/" + +} + +def getRepositoryPassword() { + return hasProperty('sonatypePassword') ? sonatypePassword : "" +} + +def getRepositoryUsername() { + return hasProperty('sonatypeUsername') ? sonatypeUsername : "" +} + +afterEvaluate { project -> + uploadArchives { + repositories { + + if (mavenLocalFlag) { + + mavenDeployer { + + pom.artifactId = POM_SETTING_ARTIFACT_ID + + repository(url: mavenLocal().url) + + pom.project { + name POM_SETTING_NAME + packaging POM_SETTING_PACKAGING + description POM_SETTING_DESCRIPTION + url POM_SETTING_URL + + scm { + url POM_SETTING_SCM_URL + connection POM_SETTING_SCM_CONNECTION + developerConnection POM_SETTING_SCM_DEV_CONNECTION + } + + licenses { + license { + name POM_SETTING_LICENCE_NAME + url POM_SETTING_LICENCE_URL + distribution POM_SETTING_LICENCE_DIST + } + } + + developers { + developer { + id POM_SETTING_DEVELOPER_ID + name POM_SETTING_DEVELOPER_NAME + } + } + } + } + } else { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + pom.artifactId = POM_SETTING_ARTIFACT_ID + + repository(url: sonatypeRepositoryURL) { + authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) + } + + pom.project { + name POM_SETTING_NAME + packaging POM_SETTING_PACKAGING + description POM_SETTING_DESCRIPTION + url POM_SETTING_URL + + scm { + url POM_SETTING_SCM_URL + connection POM_SETTING_SCM_CONNECTION + developerConnection POM_SETTING_SCM_DEV_CONNECTION + } + + licenses { + license { + name POM_SETTING_LICENCE_NAME + url POM_SETTING_LICENCE_URL + distribution POM_SETTING_LICENCE_DIST + } + } + + developers { + developer { + id POM_SETTING_DEVELOPER_ID + name POM_SETTING_DEVELOPER_NAME + } + } + } + } + + } + } + } + + signing { + required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives + } + + task androidJavadocs(type: Javadoc) { + } + + task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + classifier = 'javadoc' + } + + task androidSourcesJar(type: Jar) { + classifier = 'sources' + } + + artifacts { + archives androidSourcesJar + archives androidJavadocsJar + } + + /*nexusStaging { + username getRepositoryUsername() + password getRepositoryPassword() + }*/ +} \ No newline at end of file diff --git a/maven_push.gradle b/maven_push.gradle deleted file mode 100644 index 5b9379c0..00000000 --- a/maven_push.gradle +++ /dev/null @@ -1,92 +0,0 @@ -apply plugin: 'maven' -apply plugin: 'signing' - -def sonatypeRepositoryUrl -if (isReleaseBuild()) { - println 'RELEASE BUILD' - sonatypeRepositoryUrl = hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL - : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" -} else { - println 'DEBUG BUILD' - sonatypeRepositoryUrl = 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.artifactId = POM_ARTIFACT_ID - - repository(url: sonatypeRepositoryUrl) { - 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.sourceFiles - } - - task androidJavadocsJar(type: Jar) { - classifier = 'javadoc' - //basename = artifact_id - from androidJavadocs.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - //basename = artifact_id - from android.sourceSets.main.java.sourceFiles - } - - artifacts { - //archives packageReleaseJar - archives androidSourcesJar - archives androidJavadocsJar - } -} \ No newline at end of file diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 4c45dc19..3014c8c2 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -101,10 +101,21 @@ android:textSize="14sp" /> + android:layout_alignParentTop="true" + android:layout_marginEnd="12dp" + android:layout_marginRight="12dp" + android:hint="Floating Label way tooooo\nlong text sample here\nthird line test here" + android:layout_toStartOf="@+id/material_edit_text_edit_button" + android:layout_toLeftOf="@+id/material_edit_text_edit_button" + android:textSize="20dp" + app:met_floatingLabel="normal" + app:met_floatingLabelTextSize="20dp" + app:met_primaryColor="?colorAccent" + app:met_textColorHint="#808080" /> +