Fixes to various lint-detected issues

This commit is contained in:
joelowj 2017-03-11 09:48:33 +08:00 committed by Philip Whitehouse
parent ba21aaf412
commit 7e29a7eac3
2 changed files with 13 additions and 9 deletions

View file

@ -57,7 +57,7 @@ public class BinaryTempFileBody implements RawDataBody, SizeAware {
File newFile = File.createTempFile("body", null, mTempDirectory); File newFile = File.createTempFile("body", null, mTempDirectory);
final OutputStream out = new FileOutputStream(newFile); final OutputStream out = new FileOutputStream(newFile);
try { try {
OutputStream wrappedOut = null; OutputStream wrappedOut;
if (MimeUtil.ENC_QUOTED_PRINTABLE.equals(encoding)) { if (MimeUtil.ENC_QUOTED_PRINTABLE.equals(encoding)) {
wrappedOut = new QuotedPrintableOutputStream(out, false); wrappedOut = new QuotedPrintableOutputStream(out, false);
} else if (MimeUtil.ENC_BASE64.equals(encoding)) { } else if (MimeUtil.ENC_BASE64.equals(encoding)) {
@ -134,8 +134,11 @@ public class BinaryTempFileBody implements RawDataBody, SizeAware {
try { try {
super.close(); super.close();
} finally { } finally {
Timber.d("Deleting temporary binary file"); Timber.d("Deleting temporary binary file: %s", mFile.getName());
mFile.delete(); boolean fileSuccessfullyDeleted = mFile.delete();
if (!fileSuccessfullyDeleted) {
Timber.i("Failed to delete temporary binary file: %s", mFile.getName());
}
} }
} }

View file

@ -4,6 +4,8 @@ package com.fsck.k9;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -23,7 +25,6 @@ import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.StrictMode; import android.os.StrictMode;
import android.text.format.Time;
import com.fsck.k9.Account.SortType; import com.fsck.k9.Account.SortType;
import com.fsck.k9.activity.MessageCompose; import com.fsck.k9.activity.MessageCompose;
@ -979,14 +980,14 @@ public class K9 extends Application {
return false; return false;
} }
Time time = new Time(); GregorianCalendar gregorianCalendar = new GregorianCalendar();
time.setToNow();
Integer startHour = Integer.parseInt(mQuietTimeStarts.split(":")[0]); Integer startHour = Integer.parseInt(mQuietTimeStarts.split(":")[0]);
Integer startMinute = Integer.parseInt(mQuietTimeStarts.split(":")[1]); Integer startMinute = Integer.parseInt(mQuietTimeStarts.split(":")[1]);
Integer endHour = Integer.parseInt(mQuietTimeEnds.split(":")[0]); Integer endHour = Integer.parseInt(mQuietTimeEnds.split(":")[0]);
Integer endMinute = Integer.parseInt(mQuietTimeEnds.split(":")[1]); 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 quietStarts = startHour * 60 + startMinute;
Integer quietEnds = endHour * 60 + endMinute; Integer quietEnds = endHour * 60 + endMinute;
@ -1422,7 +1423,7 @@ public class K9 extends Application {
if (save) { if (save) {
Editor editor = sDatabaseVersionCache.edit(); Editor editor = sDatabaseVersionCache.edit();
editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.DB_VERSION); editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.DB_VERSION);
editor.commit(); editor.apply();
} }
} }