Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad5ef49

Browse files
committed
updated projects for release 1.5 and resolved some Android lint issues
1 parent 036068c commit ad5ef49

File tree

11 files changed

+38
-67
lines changed

11 files changed

+38
-67
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ Thumbs.db
3737

3838
examples/server-nodejs/node_modules
3939
examples/server-nodejs/uploads
40+
build

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Let me know, and I'll be glad to include a link in the following list :)
88

99
- [VoiSmart IP Communicator](https://play.google.com/store/apps/details?id=com.voismart.softphone)
1010
- [DotShare](http://dot-share.com/index-en.html)
11-
- [NativeScript Background HTTP] (https://www.npmjs.com/package/nativescript-background-http)
11+
- [NativeScript Background HTTP](https://www.npmjs.com/package/nativescript-background-http)
1212

1313
## Purpose
1414
I needed an easy and efficient way to upload multipart form data (HTTP parameters and files) to a server, and
@@ -34,7 +34,7 @@ then in your dependencies section add:
3434

3535
```
3636
dependencies {
37-
compile 'com.alexbbb:uploadservice:1.4'
37+
compile 'com.alexbbb:uploadservice:1.5'
3838
}
3939
```
4040

examples/app/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.alexbbb.uploadservicedemo"
99
minSdkVersion 10
1010
targetSdkVersion 23
11-
versionCode 5
12-
versionName "1.4"
11+
versionCode 6
12+
versionName "1.5"
1313
}
1414
buildTypes {
1515
release {
@@ -22,5 +22,5 @@ android {
2222
dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
2424
compile 'com.android.support:appcompat-v7:23.0.1'
25-
compile 'com.alexbbb:uploadservice:1.4'
25+
compile 'com.alexbbb:uploadservice:1.5'
2626
}

examples/app/app/src/main/java/com/alexbbb/uploadservicedemo/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private void onUploadButtonClick() {
174174
getString(R.string.uploading),
175175
getString(R.string.upload_success),
176176
getString(R.string.upload_error),
177-
false);
177+
false, true);
178178

179179
// if you comment the following line, the system default user-agent will be used
180180
request.setCustomUserAgent("UploadServiceDemo/1.0");

uploadservice/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ def projectName = "android-upload-service"
88
def projectDesc = "Easily upload files in the background with automatic Android Notification Center progress indication."
99
def projectGroup = "com.alexbbb"
1010
group = projectGroup
11-
version = "1.4"
11+
version = "1.5"
1212

1313
android {
1414
compileSdkVersion 23
15-
buildToolsVersion "23.0.1"
15+
buildToolsVersion "23.0.2"
1616

1717
defaultConfig {
1818
minSdkVersion 10
1919
targetSdkVersion 23
20-
versionCode 10
20+
versionCode 11
2121
versionName version
2222
}
2323
buildTypes {
@@ -29,8 +29,7 @@ android {
2929
}
3030

3131
dependencies {
32-
compile fileTree(dir: 'libs', include: ['*.jar'])
33-
compile 'com.android.support:appcompat-v7:23.0.1'
32+
compile 'com.android.support:appcompat-v7:23.1.1'
3433
}
3534

3635
// add the following information to the file: local.properties situated in the parent directory of

uploadservice/src/main/java/com/alexbbb/uploadservice/HttpUploadRequest.java

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public void setNotificationConfig(final int iconResourceID, final String title,
103103
* @param error Text displayed in the notification when an error occurs
104104
* @param autoClearOnSuccess true if you want to automatically clear the notification when
105105
* the upload gets completed successfully
106-
* @param
106+
* @param autoClearOnAction true if you want to automatically clear the notification when
107+
* the user taps on it
107108
*/
108109
public void setNotificationConfig(final int iconResourceID, final String title, final String message,
109110
final String completed, final String error,
@@ -155,52 +156,42 @@ public void setMethod(final String method) {
155156
/**
156157
* Gets the HTTP method to use.
157158
*
158-
* @return
159+
* @return HTTP method
159160
*/
160161
protected String getMethod() {
161162
return method;
162163
}
163164

164165
/**
165-
* Gets the upload ID of this request.
166-
*
167-
* @return
166+
* @return Gets the upload ID of this request.
168167
*/
169168
protected String getUploadId() {
170169
return uploadId;
171170
}
172171

173172
/**
174-
* Gets the URL of the server side script that will handle the multipart form upload.
175-
*
176-
* @return
173+
* @return Gets the URL of the server side script that will handle the multipart form upload.
177174
*/
178175
protected String getServerUrl() {
179176
return url;
180177
}
181178

182179
/**
183-
* Gets the list of the headers.
184-
*
185-
* @return
180+
* @return Gets the list of the headers.
186181
*/
187182
protected ArrayList<NameValue> getHeaders() {
188183
return headers;
189184
}
190185

191186
/**
192-
* Gets the upload notification configuration.
193-
*
194-
* @return
187+
* @return Gets the upload notification configuration.
195188
*/
196189
protected UploadNotificationConfig getNotificationConfig() {
197190
return notificationConfig;
198191
}
199192

200193
/**
201-
* Gets the application context.
202-
*
203-
* @return
194+
* @return Gets the application context.
204195
*/
205196
protected Context getContext() {
206197
return context;
@@ -227,27 +218,25 @@ public final void setCustomUserAgent(String customUserAgent) {
227218
}
228219

229220
/**
230-
* Sets the intent to be executed when the user taps on the upload progress notification.
231-
*
232-
* @param intent
221+
* @param intent Sets the intent to be executed when the user taps on the upload progress notification.
233222
*/
234223
public final void setNotificationClickIntent(Intent intent) {
235224
notificationConfig.setClickIntent(intent);
236225
}
237226

238227
/**
239-
* Get the maximum number of retries that the library will do if an error occurs, before returning an error.
240-
*
241-
* @return
228+
* @return Get the maximum number of retries that the library will do if an error occurs,
229+
* before returning an error.
242230
*/
243231
public final int getMaxRetries() {
244232
return maxRetries;
245233
}
246234

247235
/**
248-
* Sets the maximum number of retries that the library will do if an error occurs, before returning an error.
236+
* Sets the maximum number of retries that the library will do if an error occurs,
237+
* before returning an error.
249238
*
250-
* @param maxRetries
239+
* @param maxRetries number of maximum retries on error
251240
*/
252241
public final void setMaxRetries(int maxRetries) {
253242
if (maxRetries < 0)

uploadservice/src/main/java/com/alexbbb/uploadservice/HttpUploadTask.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private void closeInputStream() {
179179
if (responseStream != null) {
180180
try {
181181
responseStream.close();
182-
} catch (Exception exc) {
182+
} catch (Exception ignored) {
183183
}
184184
}
185185
}
@@ -189,7 +189,7 @@ private void closeOutputStream() {
189189
try {
190190
requestStream.flush();
191191
requestStream.close();
192-
} catch (Exception exc) {
192+
} catch (Exception ignored) {
193193
}
194194
}
195195
}
@@ -198,7 +198,7 @@ private void closeConnection() {
198198
if (connection != null) {
199199
try {
200200
connection.disconnect();
201-
} catch (Exception exc) {
201+
} catch (Exception ignored) {
202202
}
203203
}
204204
}
@@ -225,7 +225,7 @@ private String getResponseBodyAsString(final InputStream inputStream) {
225225
try {
226226
if (reader != null)
227227
reader.close();
228-
} catch (Exception readerExc) {
228+
} catch (Exception ignored) {
229229
}
230230
}
231231

uploadservice/src/main/java/com/alexbbb/uploadservice/MultipartUploadRequest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,14 @@ public void addArrayParameter(final String paramName, final List<String> list) {
110110
}
111111

112112
/**
113-
* Gets the list of the parameters.
114-
*
115-
* @return
113+
* @return Gets the list of the parameters.
116114
*/
117115
protected ArrayList<NameValue> getParameters() {
118116
return parameters;
119117
}
120118

121119
/**
122-
* Gets the list of the files that has to be uploaded.
123-
*
124-
* @return
120+
* @return Gets the list of the files that has to be uploaded.
125121
*/
126122
protected ArrayList<MultipartUploadFile> getFilesToUpload() {
127123
return filesToUpload;

uploadservice/src/main/java/com/alexbbb/uploadservice/MultipartUploadTask.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,15 @@ protected HttpURLConnection getHttpURLConnection() throws IOException {
5757
}
5858

5959
private String getBoundary() {
60-
final StringBuilder builder = new StringBuilder();
61-
builder.append("---------------------------").append(System.currentTimeMillis());
62-
return builder.toString();
60+
return "---------------------------" + System.currentTimeMillis();
6361
}
6462

6563
private byte[] getBoundaryBytes() throws UnsupportedEncodingException {
66-
final StringBuilder builder = new StringBuilder();
67-
builder.append(NEW_LINE).append(TWO_HYPHENS).append(boundary).append(NEW_LINE);
68-
return builder.toString().getBytes("US-ASCII");
64+
return (NEW_LINE + TWO_HYPHENS + boundary + NEW_LINE).getBytes("US-ASCII");
6965
}
7066

7167
private byte[] getTrailerBytes() throws UnsupportedEncodingException {
72-
final StringBuilder builder = new StringBuilder();
73-
builder.append(NEW_LINE).append(TWO_HYPHENS).append(boundary).append(TWO_HYPHENS).append(NEW_LINE);
74-
return builder.toString().getBytes("US-ASCII");
68+
return (NEW_LINE + TWO_HYPHENS + boundary + TWO_HYPHENS + NEW_LINE).getBytes("US-ASCII");
7569
}
7670

7771
@Override
@@ -80,8 +74,7 @@ protected long getBodyLength() throws UnsupportedEncodingException {
8074
long parameterBytes = getRequestParametersLength();
8175
final long totalFileBytes = getFilesLength();
8276

83-
final long bodyLength = parameterBytes + totalFileBytes + trailerBytes.length;
84-
return bodyLength;
77+
return (parameterBytes + totalFileBytes + trailerBytes.length);
8578
}
8679

8780
private long getFilesLength() throws UnsupportedEncodingException {

uploadservice/src/main/java/com/alexbbb/uploadservice/NameValue.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,8 @@ public final String getValue() {
3232
}
3333

3434
public byte[] getBytes() throws UnsupportedEncodingException {
35-
final StringBuilder builder = new StringBuilder();
36-
37-
builder.append("Content-Disposition: form-data; name=\"")
38-
.append(name)
39-
.append("\"")
40-
.append(NEW_LINE)
41-
.append(NEW_LINE)
42-
.append(value);
43-
44-
return builder.toString().getBytes("UTF-8");
35+
return ("Content-Disposition: form-data; name=\"" + name + "\""
36+
+ NEW_LINE + NEW_LINE + value).getBytes("UTF-8");
4537
}
4638

4739
@Override

uploadservice/src/main/java/com/alexbbb/uploadservice/UploadService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ protected void onHandleIntent(Intent intent) {
133133
/**
134134
* Start the background file upload service.
135135
*
136+
* @param request request object
136137
* @deprecated As of 1.4, use startUpload() method on the upload request object
137138
* @throws IllegalArgumentException if one or more arguments passed are invalid
138139
* @throws MalformedURLException if the server URL is not valid

0 commit comments

Comments
 (0)