Skip to content

Commit 04b5d48

Browse files
committed
Switch repository to MavenCentral && Optimized performance
1 parent bd9769b commit 04b5d48

File tree

7 files changed

+94
-49
lines changed

7 files changed

+94
-49
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@
2020
## 引入
2121
添加如下依赖到你的 build.gradle 文件:
2222
```
23-
repositories {
24-
...
25-
maven { url 'https://jitpack.io' }
26-
}
2723
dependencies {
28-
implementation 'com.github.dkzwm:FormatEditText:0.2.0'
24+
implementation 'com.github.dkzwm:fet-core:0.2.1'
2925
}
3026
```
3127
## 使用

README_EN.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ Download [Demo.apk](https://github.com/dkzwm/FormatEditText/raw/master/apk/demo.
2020
## Installation
2121
Add the following dependency to your build.gradle file:
2222
```
23-
repositories {
24-
...
25-
maven { url 'https://jitpack.io' }
26-
}
2723
dependencies {
28-
implementation 'com.github.dkzwm:FormatEditText:0.2.0'
24+
implementation 'com.github.dkzwm:fet-core:0.2.1'
2925
}
3026
```
3127
## How to used

apk/demo.apk

58.2 KB
Binary file not shown.

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ android {
2121

2222
dependencies {
2323
implementation project(':core')
24-
implementation 'androidx.appcompat:appcompat:1.1.0'
24+
implementation 'androidx.appcompat:appcompat:1.3.1'
2525
}

build.gradle

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
23
buildscript {
34
repositories {
45
jcenter()
5-
maven { url 'https://jitpack.io' }
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:4.0.2'
10-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
9+
classpath 'com.android.tools.build:gradle:4.1.3'
1110
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1211
}
1312
}
1413

1514
plugins {
16-
id "com.diffplug.gradle.spotless" version "3.25.0"
15+
id "com.diffplug.spotless" version "5.3.0"
1716
}
1817

1918
allprojects {
@@ -25,8 +24,8 @@ allprojects {
2524
}
2625

2726
subprojects {
27+
apply plugin: 'com.diffplug.spotless'
2828
if (it.name != 'app') {
29-
apply plugin: 'com.diffplug.gradle.spotless'
3029
spotless {
3130
java {
3231
target fileTree('.') {
@@ -37,7 +36,6 @@ subprojects {
3736
}
3837
}
3938
} else {
40-
apply plugin: 'com.diffplug.gradle.spotless'
4139
spotless {
4240
java {
4341
target '**/*.java'
@@ -47,19 +45,20 @@ subprojects {
4745
}
4846
}
4947

48+
5049
ext {
5150
android = [
52-
compileSdkVersion: 29,
53-
buildToolsVersion: "29.0.3",
51+
compileSdkVersion: 30,
52+
buildToolsVersion: "30.0.3",
5453
minSdkVersion : 14,
55-
targetSdkVersion : 29,
56-
versionCode : 14,
57-
versionName : "0.2.0"
54+
targetSdkVersion : 30,
55+
versionCode : 15,
56+
versionName : "0.2.1"
5857
]
5958
bintray = [
6059
siteUrl : 'https://github.com/dkzwm/FormatEditText',
6160
gitUrl : 'https://github.com/dkzwm/FormatEditText.git',
62-
groupId : "me.dkzwm.widget.fet",
61+
groupId : "com.github.dkzwm",
6362
libVersion : android.versionName,
6463
developerId : "dkzwm",
6564
developerName : "Zhang Weiming",

core/build.gradle

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'com.github.dcendents.android-maven'
3-
apply plugin: 'com.jfrog.bintray'
4-
5-
group = rootProject.ext.bintray['groupId']
6-
version=rootProject.ext.android['versionName']
3+
apply plugin: 'maven-publish'
4+
apply plugin: 'signing'
75

86
android {
97
compileSdkVersion rootProject.ext.android.compileSdkVersion
@@ -24,24 +22,25 @@ android {
2422
}
2523

2624
dependencies {
27-
compileOnly 'androidx.appcompat:appcompat:1.1.0'
25+
compileOnly 'androidx.appcompat:appcompat:1.3.1'
2826
}
2927

3028
task sourcesJar(type: Jar) {
3129
from android.sourceSets.main.java.srcDirs
32-
classifier = 'sources'
30+
archiveClassifier.set('sources')
3331
}
3432

3533
task javadoc(type: Javadoc) {
3634
failOnError false
35+
options.encoding = 'UTF-8'
3736
source = android.sourceSets.main.java.sourceFiles
3837
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
3938
classpath += configurations.compile
4039
}
4140

4241
// build a jar with javadoc
4342
task javadocJar(type: Jar, dependsOn: javadoc) {
44-
classifier = 'javadoc'
43+
archiveClassifier.set('javadoc')
4544
from javadoc.destinationDir
4645
}
4746

@@ -58,8 +57,8 @@ install {
5857
name 'FormatEditText-Core'
5958
groupId rootProject.ext.bintray['groupId']
6059
url rootProject.ext.bintray['siteUrl']
61-
artifactId 'core'
62-
description 'FormatEditText can be used as a number formatted text input box.'
60+
artifactId 'fet-core'
61+
description 'FormatEditText can be used as a formatted text input box.'
6362
licenses {
6463
license {
6564
name rootProject.ext.bintray['licenseName']
@@ -83,21 +82,66 @@ install {
8382
}
8483
}
8584

86-
Properties properties = new Properties()
87-
properties.load(project.rootProject.file('local.properties').newDataInputStream())
85+
signing {
86+
sign publishing.publications
87+
}
88+
89+
publishing {
90+
publications {
91+
release(MavenPublication) {
92+
groupId rootProject.ext.bintray['groupId']
93+
artifactId 'fet-core'
94+
version rootProject.ext.bintray['libVersion']
8895

89-
bintray {
90-
user = properties.getProperty("bintray.user")
91-
key = properties.getProperty("bintray.key")
96+
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
97+
artifact sourcesJar
98+
artifact javadocJar
9299

93-
configurations = ['archives']
94-
pkg {
95-
repo = 'maven-fet'
96-
name = 'core'
97-
desc = 'FormatEditText can be used as a number formatted text input box.'
98-
websiteUrl = rootProject.ext.bintray['siteUrl']
99-
vcsUrl = rootProject.ext.bintray['gitUrl']
100-
licenses = rootProject.ext.allLicenses
101-
publish = true
100+
pom {
101+
name = 'fet-core'
102+
description = 'FormatEditText can be used as a formatted text input box.'
103+
url = rootProject.ext.bintray['siteUrl']
104+
licenses {
105+
license {
106+
name = rootProject.ext.bintray['licenseName']
107+
url = rootProject.ext.bintray['licenseUrl']
108+
}
109+
}
110+
developers {
111+
developer {
112+
id = rootProject.ext.bintray['developerId']
113+
name = rootProject.ext.bintray['developerName']
114+
email = rootProject.ext.bintray['developerEmail']
115+
}
116+
}
117+
scm {
118+
connection = rootProject.ext.bintray['gitUrl']
119+
developerConnection = rootProject.ext.bintray['gitUrl']
120+
url = rootProject.ext.bintray['siteUrl']
121+
}
122+
withXml {
123+
def dependenciesNode = asNode().appendNode('dependencies')
124+
125+
project.configurations.implementation.allDependencies.each {
126+
def dependencyNode = dependenciesNode.appendNode('dependency')
127+
dependencyNode.appendNode('groupId', it.group)
128+
dependencyNode.appendNode('artifactId', it.name)
129+
dependencyNode.appendNode('version', it.version)
130+
}
131+
}
132+
}
133+
}
134+
}
135+
repositories {
136+
maven {
137+
name = "sonatype"
138+
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
139+
credentials {
140+
Properties properties = new Properties()
141+
properties.load(project.rootProject.file('local.properties').newDataInputStream())
142+
username = properties.getProperty("bintray.user")
143+
password = properties.getProperty("bintray.key")
144+
}
145+
}
102146
}
103147
}

core/src/main/java/me/dkzwm/widget/fet/MaskNumberEditText.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private void formatNumber(final Editable editable) {
339339
if (spans.length > 0) {
340340
DecimalPointSpan span = spans[0];
341341
int start = editable.getSpanStart(span);
342-
int index = editable.toString().indexOf(DECIMAL_POINT_CHAR);
342+
int index = indexOfDecimalPointChar(editable);
343343
if (index != start) {
344344
editable.delete(start, start + 1);
345345
span = new DecimalPointSpan(getCurrentTextColor());
@@ -369,7 +369,7 @@ private void formatNumber(final Editable editable) {
369369
}
370370
}
371371
} else {
372-
int index = editable.toString().indexOf(DECIMAL_POINT_CHAR);
372+
int index = indexOfDecimalPointChar(editable);
373373
if (index == -1) {
374374
formatInteger(editable, editable.length());
375375
if (mAutoFillNumbers && mDecimalLength > 0) {
@@ -389,12 +389,22 @@ private void formatNumber(final Editable editable) {
389389
index + 1,
390390
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
391391
formatInteger(editable, index);
392-
formatDecimal(editable, editable.toString().indexOf(DECIMAL_POINT_CHAR));
392+
formatDecimal(editable, indexOfDecimalPointChar(editable));
393393
}
394394
}
395395
formatCurrencySymbol(editable);
396396
}
397397

398+
private int indexOfDecimalPointChar(Editable editable) {
399+
final int max = editable.length();
400+
for (int i = 0; i < max; i++) {
401+
if (editable.charAt(i) == DECIMAL_POINT_CHAR) {
402+
return i;
403+
}
404+
}
405+
return -1;
406+
}
407+
398408
private void formatCurrencySymbol(Editable editable) {
399409
if (mCurrencySymbol != null) {
400410
editable.insert(0, mCurrencySymbol);

0 commit comments

Comments
 (0)