Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 3247542

Browse files
Sam1301kunall17
authored andcommitted
Fix lint errors.
1 parent 60e4cb5 commit 3247542

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public void onClick(View v) {
355355
onTextChangeOfPeopleSearchEditText();
356356
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
357357
mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
358-
.setColor(getColor(R.color.notif_background));
358+
.setColor(ContextCompat.getColor(this, R.color.notif_background));
359359
ivSearchPeopleCancel.setOnClickListener(new View.OnClickListener() {
360360
@Override
361361
public void onClick(View v) {
@@ -899,7 +899,7 @@ protected void onNewIntent(Intent intent) {
899899
if (mBuilder == null) {
900900
mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
901901
.setContentTitle(getString(R.string.notif_title))
902-
.setColor(getColor(R.color.notif_background));
902+
.setColor(ContextCompat.getColor(this, R.color.notif_background));
903903
}
904904

905905
// Get action and MIME type of intent
@@ -941,8 +941,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
941941

942942
// activity transition animation
943943
ActivityTransitionAnim.transition(ZulipActivity.this);
944-
}
945-
else if (requestCode == REQUEST_PICK_FILE && resultCode == RESULT_OK) {
944+
} else if (requestCode == REQUEST_PICK_FILE && resultCode == RESULT_OK) {
946945
List<Uri> fileUris = new ArrayList<>();
947946
if (data.getData() != null) {
948947
fileUris.add(data.getData());
@@ -1214,8 +1213,6 @@ private void uploadFile(final File file) {
12141213
// MultipartBody.Part is used to send also the actual file name
12151214
MultipartBody.Part body = prepareFilePart("file", file, notifId);
12161215

1217-
final String loadingMsg = getResources().getString(R.string.uploading_message);
1218-
12191216
// start notification
12201217
setNotification(notifId, getString(R.string.init_notif_title));
12211218

@@ -1225,40 +1222,44 @@ private void uploadFile(final File file) {
12251222
call.enqueue(new DefaultCallback<UploadResponse>() {
12261223
@Override
12271224
public void onSuccess(Call<UploadResponse> call, Response<UploadResponse> response) {
1228-
if (!isDestroyed()) {
1229-
String filePathOnServer = "";
1230-
UploadResponse uploadResponse = response.body();
1231-
filePathOnServer = uploadResponse.getUri();
1232-
if (!filePathOnServer.equals("")) {
1233-
endNotification(notifId, getString(R.string.finish_notif_title));
1234-
1235-
// add uploaded file url on server to composed message
1236-
messageEt.append("\n[" + file.getName() + "](" +
1237-
UrlHelper.addHost(filePathOnServer) + ")");
1238-
displayFAB(false);
1239-
displayChatBox(true);
1240-
} else {
1241-
endNotification(notifId, getString(R.string.failed_to_upload));
1242-
}
1243-
mNotificationManager.cancel(notifId);
1225+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed()) {
1226+
return;
12441227
}
1228+
String filePathOnServer = "";
1229+
UploadResponse uploadResponse = response.body();
1230+
filePathOnServer = uploadResponse.getUri();
1231+
if (!filePathOnServer.equals("")) {
1232+
endNotification(notifId, getString(R.string.finish_notif_title));
1233+
1234+
// add uploaded file url on server to composed message
1235+
messageEt.append("\n[" + file.getName() + "](" +
1236+
UrlHelper.addHost(filePathOnServer) + ")");
1237+
displayFAB(false);
1238+
displayChatBox(true);
1239+
} else {
1240+
endNotification(notifId, getString(R.string.failed_to_upload));
1241+
}
1242+
mNotificationManager.cancel(notifId);
1243+
12451244
}
12461245

12471246
@Override
12481247
public void onError(Call<UploadResponse> call, Response<UploadResponse> response) {
1249-
if (!isDestroyed()) {
1250-
endNotification(notifId, getString(R.string.failed_to_upload));
1251-
mNotificationManager.cancel(notifId);
1248+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed()) {
1249+
return;
12521250
}
1251+
endNotification(notifId, getString(R.string.failed_to_upload));
1252+
mNotificationManager.cancel(notifId);
12531253
}
12541254

12551255
@Override
12561256
public void onFailure(Call<UploadResponse> call, Throwable t) {
1257-
if (!isDestroyed()) {
1258-
endNotification(notifId, getString(R.string.failed_to_upload));
1259-
mNotificationManager.cancel(notifId);
1260-
ZLog.logException(t);
1257+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed()) {
1258+
return;
12611259
}
1260+
endNotification(notifId, getString(R.string.failed_to_upload));
1261+
mNotificationManager.cancel(notifId);
1262+
ZLog.logException(t);
12621263
}
12631264
});
12641265
}

app/src/main/java/com/zulip/android/util/FileUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.zulip.android.util;
1818

19+
import android.annotation.SuppressLint;
1920
import android.content.ContentResolver;
2021
import android.content.ContentUris;
2122
import android.content.Context;
@@ -246,6 +247,7 @@ public static String getDataColumn(Context context, Uri uri, String selection,
246247
* @see #getFile(Context, Uri)
247248
* @author paulburke
248249
*/
250+
@SuppressLint("NewApi")
249251
public static String getPath(final Context context, final Uri uri) {
250252

251253
if (DEBUG)

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
<string name="star_message">Star message</string>
109109
<string name="un_star_message">Unstar message</string>
110110
<string name="login_failed">Unable to login</string>
111-
<string name="uploading_message">Uploading</string>
112111
<string name="cannot_upload_file">Cannot upload file</string>
113112
<string name="cannot_find_file">Cannot find requested file</string>
114113
<string name="failed_to_upload">Failed</string>
@@ -167,7 +166,6 @@
167166
<string name="people_drawer_recent_pm_label">Recent Private Messages</string>
168167
<string name="people_drawer_others_label">New Private Message</string>
169168
<string name="mentions">\@-mentions</string>
170-
<string name="attach">Attach</string>
171169
<string name="notif_title">Upload to Zulip</string>
172170
<string name="init_notif_title">Starting upload</string>
173171
<string name="finish_notif_title">Complete</string>

0 commit comments

Comments
 (0)