Skip to content

Commit cf6f240

Browse files
committed
Merge commit 'a2e3dcec42f1bfa020de253008d3a13966437742' into develop
2 parents 83de3e8 + e2fca68 commit cf6f240

File tree

5 files changed

+73
-65
lines changed

5 files changed

+73
-65
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# WordPress-Utils-Android
22

3-
Part of the [WordPress-Android] project.
3+
Collection of utility methods for Android and WordPress.
44

5-
[WordPress-Android]: https://github.com/wordpress-mobile/WordPress-Android
5+
## Use the library
6+
7+
* In your build.gradle:
8+
```groovy
9+
dependencies {
10+
// use the latest 1.x version
11+
compile 'org.wordpress:utils:1.+'
12+
}
13+
```
14+
15+
## Publish it to bintray
16+
17+
```shell
18+
$ ./gradlew assemble publishToMavenLocal bintrayUpload -PbintrayUser=FIXME -PbintrayKey=FIXME -PdryRun=false
19+
```
20+
21+
## Apps that use this library
22+
- [WordPress for Android][1]
23+
24+
## License
25+
Dual licensed under MIT, and GPL.
26+
27+
[1]: https://github.com/wordpress-mobile/WordPress-Android

WordPressUtils/build.gradle

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ buildscript {
44
}
55
dependencies {
66
classpath 'com.android.tools.build:gradle:2.1.3'
7+
classpath 'com.novoda:bintray-release:0.3.4'
78
}
89
}
910

1011
apply plugin: 'com.android.library'
11-
apply plugin: 'maven'
12-
apply plugin: 'signing'
12+
apply plugin: 'com.novoda.bintray-release'
1313

1414
repositories {
1515
jcenter()
@@ -32,68 +32,13 @@ android {
3232
buildToolsVersion "24.0.2"
3333

3434
defaultConfig {
35-
versionName "1.10.0"
35+
versionName "1.12.0"
3636
minSdkVersion 14
3737
targetSdkVersion 24
3838
}
3939
}
4040

41-
version android.defaultConfig.versionName
42-
group = "org.wordpress"
43-
archivesBaseName = "utils"
44-
45-
signing {
46-
required {
47-
has("release") && project.properties.containsKey("signing.keyId") && project.properties.containsKey("signing.secretKeyRingFile")
48-
}
49-
sign configurations.archives
50-
}
51-
52-
uploadArchives {
53-
repositories {
54-
mavenDeployer {
55-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
56-
57-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
58-
authentication(userName: project.properties.ossrhUsername, password: project.properties.ossrhPassword)
59-
}
60-
61-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
62-
authentication(userName: project.properties.ossrhUsername, password: project.properties.ossrhPassword)
63-
}
64-
65-
pom.project {
66-
name 'WordPress-Utils-Android'
67-
packaging 'aar'
68-
description 'Utils lib for WordPress-Android'
69-
url 'https://github.com/wordpress-mobile/WordPress-Utils-Android'
70-
scm {
71-
connection 'scm:git:https://github.com/wordpress-mobile/WordPress-Utils-Android.git'
72-
developerConnection 'scm:git:https://github.com/wordpress-mobile/WordPress-Utils-Android.git'
73-
url 'https://github.com/wordpress-mobile/WordPress-Utils-Android'
74-
}
75-
76-
licenses {
77-
license {
78-
name 'The MIT License (MIT)'
79-
url 'http://opensource.org/licenses/MIT'
80-
}
81-
}
82-
83-
developers {
84-
developer {
85-
id 'maxme'
86-
name 'Maxime Biais'
87-
email 'maxime@automattic.com'
88-
}
89-
}
90-
}
91-
}
92-
}
93-
}
94-
9541
android.libraryVariants.all { variant ->
96-
9742
task("generate${variant.name}Javadoc", type: Javadoc) {
9843
description "Generates Javadoc for $variant.name."
9944
source = variant.javaCompile.source
@@ -105,3 +50,16 @@ android.libraryVariants.all { variant ->
10550
exclude '**/R.java'
10651
}
10752
}
53+
54+
publish {
55+
artifactId = 'utils'
56+
userOrg = 'wordpress-mobile'
57+
groupId = 'org.wordpress'
58+
uploadName = 'utils'
59+
description = 'Utils library for Android'
60+
publishVersion = android.defaultConfig.versionName
61+
licences = ['MIT', 'GPL']
62+
website = 'https://github.com/wordpress-mobile/WordPress-Utils-Android/'
63+
dryRun = 'false'
64+
autoPublish = 'true'
65+
}

WordPressUtils/src/main/java/org/wordpress/android/util/MapUtils.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,40 @@ public static long getMapLong(final Map<?, ?> map, final String key, long defaul
4747
}
4848
}
4949

50+
/*
51+
* float version of above
52+
*/
53+
public static float getMapFloat(final Map<?, ?> map, final String key) {
54+
return getMapFloat(map, key, 0);
55+
}
56+
public static float getMapFloat(final Map<?, ?> map, final String key, float defaultValue) {
57+
try {
58+
return Float.parseFloat(getMapStr(map, key));
59+
} catch (NumberFormatException e) {
60+
return defaultValue;
61+
}
62+
}
63+
64+
/*
65+
* double version of above
66+
*/
67+
public static double getMapDouble(final Map<?, ?> map, final String key) {
68+
return getMapDouble(map, key, 0);
69+
}
70+
public static double getMapDouble(final Map<?, ?> map, final String key, double defaultValue) {
71+
try {
72+
return Double.parseDouble(getMapStr(map, key));
73+
} catch (NumberFormatException e) {
74+
return defaultValue;
75+
}
76+
}
77+
5078
/*
5179
* returns a date object from the passed key in the passed map
5280
* returns null if key doesn't exist or isn't a date
5381
*/
5482
public static Date getMapDate(final Map<?, ?> map, final String key) {
55-
if (map==null || key==null || !map.containsKey(key))
83+
if (map == null || key == null || !map.containsKey(key))
5684
return null;
5785
try {
5886
return (Date) map.get(key);

WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ public static String replaceUnicodeSurrogateBlocksWithHTMLEntities(final String
225225
* Used to convert a language code ([lc]_[rc] where lc is language code (en, fr, es, etc...)
226226
* and rc is region code (zh-CN, zh-HK, zh-TW, etc...) to a displayable string with the languages
227227
* name.
228-
* <p/>
228+
*
229229
* The input string must be between 2 and 6 characters, inclusive. An empty string is returned
230230
* if that is not the case.
231-
* <p/>
231+
*
232232
* If the input string is recognized by {@link Locale} the result of this method is the given
233233
*
234234
* @return non-null
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Jul 09 11:48:51 CEST 2014
1+
#Tue Sep 06 11:08:13 CEST 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

0 commit comments

Comments
 (0)