From 7e29a7eac3d50766b8abf6c8d44e54c8804bea58 Mon Sep 17 00:00:00 2001 From: joelowj Date: Sat, 11 Mar 2017 09:48:33 +0800 Subject: [PATCH] Fixes to various lint-detected issues --- .../com/fsck/k9/mail/internet/BinaryTempFileBody.java | 11 +++++++---- k9mail/src/main/java/com/fsck/k9/K9.java | 11 ++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/internet/BinaryTempFileBody.java b/k9mail-library/src/main/java/com/fsck/k9/mail/internet/BinaryTempFileBody.java index a54a1d6cf..2c664bbfb 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/internet/BinaryTempFileBody.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/internet/BinaryTempFileBody.java @@ -57,7 +57,7 @@ public class BinaryTempFileBody implements RawDataBody, SizeAware { File newFile = File.createTempFile("body", null, mTempDirectory); final OutputStream out = new FileOutputStream(newFile); try { - OutputStream wrappedOut = null; + OutputStream wrappedOut; if (MimeUtil.ENC_QUOTED_PRINTABLE.equals(encoding)) { wrappedOut = new QuotedPrintableOutputStream(out, false); } else if (MimeUtil.ENC_BASE64.equals(encoding)) { @@ -134,8 +134,11 @@ public class BinaryTempFileBody implements RawDataBody, SizeAware { try { super.close(); } finally { - Timber.d("Deleting temporary binary file"); - mFile.delete(); + Timber.d("Deleting temporary binary file: %s", mFile.getName()); + boolean fileSuccessfullyDeleted = mFile.delete(); + if (!fileSuccessfullyDeleted) { + Timber.i("Failed to delete temporary binary file: %s", mFile.getName()); + } } } @@ -143,4 +146,4 @@ public class BinaryTempFileBody implements RawDataBody, SizeAware { super.close(); } } -} +} \ No newline at end of file diff --git a/k9mail/src/main/java/com/fsck/k9/K9.java b/k9mail/src/main/java/com/fsck/k9/K9.java index d2288cfe7..8b64f696d 100644 --- a/k9mail/src/main/java/com/fsck/k9/K9.java +++ b/k9mail/src/main/java/com/fsck/k9/K9.java @@ -4,6 +4,8 @@ package com.fsck.k9; import java.io.File; import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -23,7 +25,6 @@ import android.os.Environment; import android.os.Handler; import android.os.Looper; import android.os.StrictMode; -import android.text.format.Time; import com.fsck.k9.Account.SortType; import com.fsck.k9.activity.MessageCompose; @@ -979,14 +980,14 @@ public class K9 extends Application { return false; } - Time time = new Time(); - time.setToNow(); + GregorianCalendar gregorianCalendar = new GregorianCalendar(); + Integer startHour = Integer.parseInt(mQuietTimeStarts.split(":")[0]); Integer startMinute = Integer.parseInt(mQuietTimeStarts.split(":")[1]); Integer endHour = Integer.parseInt(mQuietTimeEnds.split(":")[0]); Integer endMinute = Integer.parseInt(mQuietTimeEnds.split(":")[1]); - Integer now = (time.hour * 60) + time.minute; + Integer now = (gregorianCalendar.get(Calendar.HOUR) * 60) + gregorianCalendar.get(Calendar.MINUTE); Integer quietStarts = startHour * 60 + startMinute; Integer quietEnds = endHour * 60 + endMinute; @@ -1422,7 +1423,7 @@ public class K9 extends Application { if (save) { Editor editor = sDatabaseVersionCache.edit(); editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.DB_VERSION); - editor.commit(); + editor.apply(); } }