From 77acb11dd6e08153e55840b11bd37a6623559faa Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 3 Nov 2017 19:56:32 -0400 Subject: [PATCH] Removed unused variables --- .../main/java/com/fsck/k9/mail/Authentication.java | 3 +-- .../mail/internet/Iso2022JpToShiftJisInputStream.java | 3 +-- .../main/java/com/fsck/k9/activity/AccountList.java | 3 +-- .../com/fsck/k9/activity/compose/RecipientLoader.java | 3 +-- .../fsck/k9/activity/setup/AccountSetupBasics.java | 5 ++--- .../src/main/java/com/fsck/k9/fragment/MlfUtils.java | 7 +++---- k9mail/src/main/java/com/fsck/k9/helper/Contacts.java | 3 +-- .../com/fsck/k9/preferences/SettingsImporter.java | 3 +-- .../main/java/com/fsck/k9/service/BootReceiver.java | 3 +-- .../k9/mailstore/MessageViewInfoExtractorTest.java | 11 +++-------- .../java/com/fsck/k9/message/TextBodyBuilderTest.java | 3 +-- 11 files changed, 16 insertions(+), 31 deletions(-) diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/Authentication.java b/k9mail-library/src/main/java/com/fsck/k9/mail/Authentication.java index 2b753a5d8..08ab4a881 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/Authentication.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/Authentication.java @@ -76,9 +76,8 @@ public class Authentication { byte[] result = md.digest(firstPass); String plainCRAM = username + " " + Hex.encodeHex(result); - byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes()); - return b64CRAM; + return Base64.encodeBase64(plainCRAM.getBytes()); } catch (Exception e) { throw new MessagingException("Something went wrong during CRAM-MD5 computation", e); diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/internet/Iso2022JpToShiftJisInputStream.java b/k9mail-library/src/main/java/com/fsck/k9/mail/internet/Iso2022JpToShiftJisInputStream.java index 0b754a40f..1078074c5 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/internet/Iso2022JpToShiftJisInputStream.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/internet/Iso2022JpToShiftJisInputStream.java @@ -64,9 +64,8 @@ class Iso2022JpToShiftJisInputStream extends InputStream { throw new MalformedInputException(0); int out1 = (in1 + 1) / 2 + (in1 < 0x5f ? 0x70 : 0xb0); - int out2 = in2 + (in1 % 2 == 0 ? 0x7e : in2 < 0x60 ? 0x1f : 0x20); - out = out2; + out = in2 + (in1 % 2 == 0 ? 0x7e : in2 < 0x60 ? 0x1f : 0x20); hasOut = true; return out1; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/AccountList.java b/k9mail/src/main/java/com/fsck/k9/activity/AccountList.java index aad882323..efee913b2 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/AccountList.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/AccountList.java @@ -171,8 +171,7 @@ public abstract class AccountList extends K9ListActivity implements OnItemClickL class LoadAccounts extends AsyncTask> { @Override protected List doInBackground(Void... params) { - List accounts = Preferences.getPreferences(getApplicationContext()).getAccounts(); - return accounts; + return Preferences.getPreferences(getApplicationContext()).getAccounts(); } @Override diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientLoader.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientLoader.java index cbe6c31e0..21d02c2c7 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientLoader.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientLoader.java @@ -376,9 +376,8 @@ public class RecipientLoader extends AsyncTaskLoader> { Recipient recipient = new Recipient(name, email, addressLabel, contactId, lookupKey); if (recipient.isValidEmailAddress()) { - Uri photoUri = cursor.isNull(INDEX_PHOTO_URI) ? null : Uri.parse(cursor.getString(INDEX_PHOTO_URI)); - recipient.photoThumbnailUri = photoUri; + recipient.photoThumbnailUri = cursor.isNull(INDEX_PHOTO_URI) ? null : Uri.parse(cursor.getString(INDEX_PHOTO_URI)); recipientMap.put(email, recipient); recipients.add(recipient); } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java index 674d746c7..cdb6cb5c1 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java @@ -385,7 +385,6 @@ public class AccountSetupBasics extends K9Activity private void onManualSetup() { String email = mEmailView.getText().toString(); String[] emailParts = splitEmail(email); - String user = email; String domain = emailParts[1]; String password = null; @@ -408,9 +407,9 @@ public class AccountSetupBasics extends K9Activity // set default uris // NOTE: they will be changed again in AccountSetupAccountType! ServerSettings storeServer = new ServerSettings(ServerSettings.Type.IMAP, "mail." + domain, -1, - ConnectionSecurity.SSL_TLS_REQUIRED, authenticationType, user, password, clientCertificateAlias); + ConnectionSecurity.SSL_TLS_REQUIRED, authenticationType, email, password, clientCertificateAlias); ServerSettings transportServer = new ServerSettings(ServerSettings.Type.SMTP, "mail." + domain, -1, - ConnectionSecurity.SSL_TLS_REQUIRED, authenticationType, user, password, clientCertificateAlias); + ConnectionSecurity.SSL_TLS_REQUIRED, authenticationType, email, password, clientCertificateAlias); String storeUri = RemoteStore.createStoreUri(storeServer); String transportUri = TransportUris.createTransportUri(transportServer); mAccount.setStoreUri(storeUri); diff --git a/k9mail/src/main/java/com/fsck/k9/fragment/MlfUtils.java b/k9mail/src/main/java/com/fsck/k9/fragment/MlfUtils.java index 101f11d0e..f5b91717d 100644 --- a/k9mail/src/main/java/com/fsck/k9/fragment/MlfUtils.java +++ b/k9mail/src/main/java/com/fsck/k9/fragment/MlfUtils.java @@ -48,13 +48,12 @@ public class MlfUtils { } static String buildSubject(String subjectFromCursor, String emptySubject, int threadCount) { - String subject = subjectFromCursor; - if (TextUtils.isEmpty(subject)) { + if (TextUtils.isEmpty(subjectFromCursor)) { return emptySubject; } else if (threadCount > 1) { // If this is a thread, strip the RE/FW from the subject. "Be like Outlook." - return Utility.stripSubject(subject); + return Utility.stripSubject(subjectFromCursor); } - return subject; + return subjectFromCursor; } } diff --git a/k9mail/src/main/java/com/fsck/k9/helper/Contacts.java b/k9mail/src/main/java/com/fsck/k9/helper/Contacts.java index 790b5a723..9fee006cf 100644 --- a/k9mail/src/main/java/com/fsck/k9/helper/Contacts.java +++ b/k9mail/src/main/java/com/fsck/k9/helper/Contacts.java @@ -265,13 +265,12 @@ public class Contacts { */ private Cursor getContactByAddress(final String address) { final Uri uri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Email.CONTENT_LOOKUP_URI, Uri.encode(address)); - final Cursor c = mContentResolver.query( + return mContentResolver.query( uri, PROJECTION, null, null, SORT_ORDER); - return c; } } diff --git a/k9mail/src/main/java/com/fsck/k9/preferences/SettingsImporter.java b/k9mail/src/main/java/com/fsck/k9/preferences/SettingsImporter.java index 27dd4ee49..50d7ae74f 100644 --- a/k9mail/src/main/java/com/fsck/k9/preferences/SettingsImporter.java +++ b/k9mail/src/main/java/com/fsck/k9/preferences/SettingsImporter.java @@ -1010,8 +1010,7 @@ public class SettingsImporter { private static ImportedFolder parseFolder(XmlPullParser xpp) throws XmlPullParserException, IOException { ImportedFolder folder = new ImportedFolder(); - String name = xpp.getAttributeValue(null, SettingsExporter.NAME_ATTRIBUTE); - folder.name = name; + folder.name = xpp.getAttributeValue(null, SettingsExporter.NAME_ATTRIBUTE); folder.settings = parseSettings(xpp, SettingsExporter.FOLDER_ELEMENT); diff --git a/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java b/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java index f81fdb706..e3ac2990e 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java +++ b/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java @@ -85,8 +85,7 @@ public class BootReceiver extends CoreReceiver { i.putExtra(ALARMED_INTENT, alarmedIntent); Uri uri = Uri.parse("action://" + alarmedAction); i.setData(uri); - PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0); - return pi; + return PendingIntent.getBroadcast(context, 0, i, 0); } public static void scheduleIntent(Context context, long atTime, Intent alarmedIntent) { diff --git a/k9mail/src/test/java/com/fsck/k9/mailstore/MessageViewInfoExtractorTest.java b/k9mail/src/test/java/com/fsck/k9/mailstore/MessageViewInfoExtractorTest.java index 2d799629d..a74910994 100644 --- a/k9mail/src/test/java/com/fsck/k9/mailstore/MessageViewInfoExtractorTest.java +++ b/k9mail/src/test/java/com/fsck/k9/mailstore/MessageViewInfoExtractorTest.java @@ -122,13 +122,12 @@ public class MessageViewInfoExtractorTest { MessageExtractor.findViewablesAndAttachments(message, outputViewableParts, outputNonViewableParts); ViewableExtractedText container = messageViewInfoExtractor.extractTextFromViewables(outputViewableParts); - String expectedText = BODY_TEXT; String expectedHtml = "
" +
                 "K-9 Mail rocks :>" +
                 "
"; - assertEquals(expectedText, container.text); + assertEquals(BODY_TEXT, container.text); assertEquals(expectedHtml, container.html); } @@ -177,12 +176,8 @@ public class MessageViewInfoExtractorTest { assertEquals(outputViewableParts.size(), 1); ViewableExtractedText container = messageViewInfoExtractor.extractTextFromViewables(outputViewableParts); - String expectedText = BODY_TEXT; - String expectedHtml = - bodyText; - - assertEquals(expectedText, container.text); - assertEquals(expectedHtml, container.html); + assertEquals(BODY_TEXT, container.text); + assertEquals(bodyText, container.html); } @Test diff --git a/k9mail/src/test/java/com/fsck/k9/message/TextBodyBuilderTest.java b/k9mail/src/test/java/com/fsck/k9/message/TextBodyBuilderTest.java index 1aba706cf..abc6b6bf4 100644 --- a/k9mail/src/test/java/com/fsck/k9/message/TextBodyBuilderTest.java +++ b/k9mail/src/test/java/com/fsck/k9/message/TextBodyBuilderTest.java @@ -133,7 +133,7 @@ public class TextBodyBuilderTest { public String makeExpectedHtmlContent(String expectedText, String quotedContent, int footerInsertionPoint, boolean isBefore, String userContent, String compiledResult) { - String expectedHtmlContent = "InsertableHtmlContent{" + return "InsertableHtmlContent{" + "headerInsertionPoint=0," + " footerInsertionPoint=" + footerInsertionPoint + "," + " insertionLocation=" + (isBefore ? "BEFORE_QUOTE" : "AFTER_QUOTE") + "," @@ -141,7 +141,6 @@ public class TextBodyBuilderTest { + " userContent=" + userContent + "," + " compiledResult=" + compiledResult + "}"; - return expectedHtmlContent; } @Theory