diff --git a/app/core/src/main/java/com/fsck/k9/Account.java b/app/core/src/main/java/com/fsck/k9/Account.java
index 04699289b..15b55245d 100644
--- a/app/core/src/main/java/com/fsck/k9/Account.java
+++ b/app/core/src/main/java/com/fsck/k9/Account.java
@@ -66,10 +66,6 @@ public class Account implements BaseAccount, StoreConfig {
this.setting = setting;
}
- public String preferenceString() {
- return Integer.toString(setting);
- }
-
public static DeletePolicy fromInt(int initialSetting) {
for (DeletePolicy policy: values()) {
if (policy.setting == initialSetting) {
@@ -275,7 +271,6 @@ public class Account implements BaseAccount, StoreConfig {
return description;
}
- @Override
public synchronized void setDescription(String description) {
this.description = description;
}
@@ -316,7 +311,6 @@ public class Account implements BaseAccount, StoreConfig {
return identities.get(0).getEmail();
}
- @Override
public synchronized void setEmail(String email) {
Identity newIdentity = identities.get(0).withEmail(email);
identities.set(0, newIdentity);
diff --git a/app/core/src/main/java/com/fsck/k9/BaseAccount.java b/app/core/src/main/java/com/fsck/k9/BaseAccount.java
index f663ee5ad..a2c1ad0e1 100644
--- a/app/core/src/main/java/com/fsck/k9/BaseAccount.java
+++ b/app/core/src/main/java/com/fsck/k9/BaseAccount.java
@@ -2,8 +2,6 @@ package com.fsck.k9;
public interface BaseAccount {
String getEmail();
- void setEmail(String email);
String getDescription();
- void setDescription(String description);
String getUuid();
}
diff --git a/app/core/src/main/java/com/fsck/k9/Throttle.java b/app/core/src/main/java/com/fsck/k9/Throttle.java
deleted file mode 100644
index 3dcc485d1..000000000
--- a/app/core/src/main/java/com/fsck/k9/Throttle.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.fsck.k9;
-
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import android.os.Handler;
-
-import timber.log.Timber;
-
-
-/**
- * This class used to "throttle" a flow of events.
- *
- * When {@link #onEvent()} is called, it calls the callback in a certain timeout later.
- * Initially {@link #minTimeout} is used as the timeout, but if it gets multiple {@link #onEvent}
- * calls in a certain amount of time, it extends the timeout, until it reaches {@link #maxTimeout}.
- *
- * This class is primarily used to throttle content changed events.
- */
-public class Throttle {
- private static final int TIMEOUT_EXTEND_INTERVAL = 500;
-
- private static final Timer TIMER = new Timer();
-
- private final Clock clock;
- private final Timer timer;
-
- private final String name;
- private final Handler handler;
- private final Runnable callback;
-
- private final int minTimeout;
- private final int maxTimeout;
- private int currentTimeout;
-
- /** When {@link #onEvent()} was last called. */
- private long lastEventTime;
-
- private MyTimerTask runningTimerTask;
-
- /** Constructor that takes custom timeout */
- public Throttle(String name, Runnable callback, Handler handler,int minTimeout,
- int maxTimeout) {
- this(name, callback, handler, minTimeout, maxTimeout, Clock.INSTANCE, TIMER);
- }
-
- /** Constructor for tests */
- private Throttle(String name, Runnable callback, Handler handler, int minTimeout,
- int maxTimeout, Clock clock, Timer timer) {
- if (maxTimeout < minTimeout) {
- throw new IllegalArgumentException();
- }
- this.name = name;
- this.callback = callback;
- this.clock = clock;
- this.timer = timer;
- this.handler = handler;
- this.minTimeout = minTimeout;
- this.maxTimeout = maxTimeout;
- currentTimeout = this.minTimeout;
- }
-
- private boolean isCallbackScheduled() {
- return runningTimerTask != null;
- }
-
- public void cancelScheduledCallback() {
- if (runningTimerTask != null) {
- Timber.d("Throttle: [%s] Canceling scheduled callback", name);
- runningTimerTask.cancel();
- runningTimerTask = null;
- }
- }
-
- private void updateTimeout() {
- final long now = clock.getTime();
- if ((now - lastEventTime) <= TIMEOUT_EXTEND_INTERVAL) {
- currentTimeout *= 2;
- if (currentTimeout >= maxTimeout) {
- currentTimeout = maxTimeout;
- }
- Timber.d("Throttle: [%s] Timeout extended %d", name, currentTimeout);
- } else {
- currentTimeout = minTimeout;
- Timber.d("Throttle: [%s] Timeout reset to %d", name, currentTimeout);
- }
-
- lastEventTime = now;
- }
-
- public void onEvent() {
- Timber.d("Throttle: [%s] onEvent", name);
-
- updateTimeout();
-
- if (isCallbackScheduled()) {
- Timber.d("Throttle: [%s] callback already scheduled", name);
- } else {
- Timber.d("Throttle: [%s] scheduling callback", name);
- runningTimerTask = new MyTimerTask();
- timer.schedule(runningTimerTask, currentTimeout);
- }
- }
-
- /**
- * Timer task called on timeout,
- */
- private class MyTimerTask extends TimerTask {
- private boolean mCanceled;
-
- @Override
- public void run() {
- handler.post(new HandlerRunnable());
- }
-
- @Override
- public boolean cancel() {
- mCanceled = true;
- return super.cancel();
- }
-
- private class HandlerRunnable implements Runnable {
- @Override
- public void run() {
- runningTimerTask = null;
- if (!mCanceled) { // This check has to be done on the UI thread.
- Timber.d("Throttle: [%s] Kicking callback", name);
- callback.run();
- }
- }
- }
- }
-}
diff --git a/app/core/src/main/java/com/fsck/k9/helper/FileHelper.java b/app/core/src/main/java/com/fsck/k9/helper/FileHelper.java
index 72cffbf85..4c68b3077 100644
--- a/app/core/src/main/java/com/fsck/k9/helper/FileHelper.java
+++ b/app/core/src/main/java/com/fsck/k9/helper/FileHelper.java
@@ -5,7 +5,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.Locale;
import timber.log.Timber;
@@ -13,61 +12,6 @@ import org.apache.commons.io.IOUtils;
public class FileHelper {
-
- /**
- * Regular expression that represents characters we won't allow in file names.
- *
- *
- * Allowed are:
- *
- * - word characters (letters, digits, and underscores): {@code \w}
- * - spaces: {@code " "}
- * - special characters: {@code !}, {@code #}, {@code $}, {@code %}, {@code &}, {@code '},
- * {@code (}, {@code )}, {@code -}, {@code @}, {@code ^}, {@code `},
{
,
- * }
, {@code ~}, {@code .}, {@code ,}
- *
- *
- * @see #sanitizeFilename(String)
- */
- private static final String INVALID_CHARACTERS = "[^\\w !#$%&'()\\-@\\^`{}~.,]";
-
- /**
- * Invalid characters in a file name are replaced by this character.
- *
- * @see #sanitizeFilename(String)
- */
- private static final String REPLACEMENT_CHARACTER = "_";
-
-
- /**
- * Creates a unique file in the given directory by appending a hyphen
- * and a number to the given filename.
- */
- public static File createUniqueFile(File directory, String filename) {
- File file = new File(directory, filename);
- if (!file.exists()) {
- return file;
- }
- // Get the extension of the file, if any.
- int index = filename.lastIndexOf('.');
- String name;
- String extension;
- if (index != -1) {
- name = filename.substring(0, index);
- extension = filename.substring(index);
- } else {
- name = filename;
- extension = "";
- }
- for (int i = 2; i < Integer.MAX_VALUE; i++) {
- file = new File(directory, String.format(Locale.US, "%s-%d%s", name, i, extension));
- if (!file.exists()) {
- return file;
- }
- }
- return null;
- }
-
public static void touchFile(final File parentDir, final String name) {
final File file = new File(parentDir, name);
try {
@@ -200,16 +144,4 @@ public class FileHelper {
Timber.w("cannot delete %s", fromDir.getAbsolutePath());
}
}
-
- /**
- * Replace characters we don't allow in file names with a replacement character.
- *
- * @param filename
- * The original file name.
- *
- * @return The sanitized file name containing only allowed characters.
- */
- public static String sanitizeFilename(String filename) {
- return filename.replaceAll(INVALID_CHARACTERS, REPLACEMENT_CHARACTER);
- }
}
diff --git a/app/core/src/main/java/com/fsck/k9/helper/UrlEncodingHelper.java b/app/core/src/main/java/com/fsck/k9/helper/UrlEncodingHelper.java
index 2e6f1d591..001e26dd0 100644
--- a/app/core/src/main/java/com/fsck/k9/helper/UrlEncodingHelper.java
+++ b/app/core/src/main/java/com/fsck/k9/helper/UrlEncodingHelper.java
@@ -1,25 +1,13 @@
package com.fsck.k9.helper;
import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
import java.net.URLEncoder;
/**
- * Wraps the java.net.URLDecoder to avoid unhelpful checked exceptions.
+ * Wraps the java.net.URLEncoder to avoid unhelpful checked exceptions.
*/
public class UrlEncodingHelper {
- public static String decodeUtf8(String s) {
- try {
- return URLDecoder.decode(s, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- /*
- * This is impossible, UTF-8 is always supported
- */
- throw new RuntimeException("UTF-8 not found");
- }
- }
-
public static String encodeUtf8(String s) {
try {
return URLEncoder.encode(s, "UTF-8");
diff --git a/app/core/src/main/java/com/fsck/k9/helper/Utility.java b/app/core/src/main/java/com/fsck/k9/helper/Utility.java
index 036142e5e..1788f8b3a 100644
--- a/app/core/src/main/java/com/fsck/k9/helper/Utility.java
+++ b/app/core/src/main/java/com/fsck/k9/helper/Utility.java
@@ -12,13 +12,10 @@ import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Handler;
-import android.os.Looper;
-import android.text.Editable;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;
-import org.apache.james.mime4j.util.MimeUtil;
import timber.log.Timber;
public class Utility {
@@ -48,15 +45,6 @@ public class Utility {
return false;
}
- public static boolean isAnyMimeType(String o, String... a) {
- for (String element : a) {
- if (MimeUtil.isSameMimeType(element, o)) {
- return true;
- }
- }
- return false;
- }
-
public static boolean arrayContainsAny(Object[] a, Object... o) {
for (Object element : a) {
if (arrayContains(o, element)) {
@@ -103,10 +91,6 @@ public class Utility {
}
- public static boolean requiredFieldValid(Editable s) {
- return s != null && s.length() > 0;
- }
-
public static boolean domainFieldValid(EditText view) {
if (view.getText() != null) {
String s = view.getText().toString();
@@ -311,16 +295,4 @@ public class Utility {
return null;
}
-
- /**
- * @return a {@link Handler} tied to the main thread.
- */
- public static Handler getMainThreadHandler() {
- if (sMainThreadHandler == null) {
- // No need to synchronize -- it's okay to create an extra Handler, which will be used
- // only once and then thrown away.
- sMainThreadHandler = new Handler(Looper.getMainLooper());
- }
- return sMainThreadHandler;
- }
}
diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/BinaryAttachmentBody.java b/app/core/src/main/java/com/fsck/k9/mailstore/BinaryAttachmentBody.java
index eecf8ed8c..637fff902 100644
--- a/app/core/src/main/java/com/fsck/k9/mailstore/BinaryAttachmentBody.java
+++ b/app/core/src/main/java/com/fsck/k9/mailstore/BinaryAttachmentBody.java
@@ -51,8 +51,4 @@ abstract class BinaryAttachmentBody implements Body {
public void setEncoding(String encoding) throws MessagingException {
mEncoding = encoding;
}
-
- public String getEncoding() {
- return mEncoding;
- }
}
diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/UnavailableStorageException.java b/app/core/src/main/java/com/fsck/k9/mailstore/UnavailableStorageException.java
index d764a0e39..914add6e6 100644
--- a/app/core/src/main/java/com/fsck/k9/mailstore/UnavailableStorageException.java
+++ b/app/core/src/main/java/com/fsck/k9/mailstore/UnavailableStorageException.java
@@ -14,14 +14,4 @@ public class UnavailableStorageException extends MessagingException {
public UnavailableStorageException(String message, boolean perm) {
super(message, perm);
}
-
- public UnavailableStorageException(String message, Throwable throwable) {
- // consider this exception as permanent failure by default
- this(message, true, throwable);
- }
-
- public UnavailableStorageException(String message, boolean perm, Throwable throwable) {
- super(message, perm, throwable);
- }
-
}
diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/util/FlowedMessageUtils.java b/app/core/src/main/java/com/fsck/k9/mailstore/util/FlowedMessageUtils.java
index 8cbf5a9ab..d30665a92 100644
--- a/app/core/src/main/java/com/fsck/k9/mailstore/util/FlowedMessageUtils.java
+++ b/app/core/src/main/java/com/fsck/k9/mailstore/util/FlowedMessageUtils.java
@@ -19,11 +19,6 @@ package com.fsck.k9.mailstore.util;
* Furthermore the header Content-Transfer-Encoding MUST NOT BE Quoted-Printable
* (see RFC3676 paragraph 4.2).(In fact this happens often for non 7bit messages).
*
- * When encoding the input text will be changed eliminating every space found before CRLF,
- * otherwise it won't be possible to recognize hard breaks from soft breaks.
- * In this scenario encoding and decoding a message will not return a message identical to
- * the original (lines with hard breaks will be trimmed)
- *
*
*/
public final class FlowedMessageUtils {
@@ -31,8 +26,6 @@ public final class FlowedMessageUtils {
private static final char RFC2646_QUOTE = '>';
private static final String RFC2646_SIGNATURE = "-- ";
private static final String RFC2646_CRLF = "\r\n";
- private static final String RFC2646_FROM = "From ";
- private static final int RFC2646_WIDTH = 78;
private FlowedMessageUtils() {
// this class cannot be instantiated
@@ -106,84 +99,4 @@ public final class FlowedMessageUtils {
return result.toString();
}
-
- /**
- * Encodes a text (using standard with).
- */
- public static String flow(String text, boolean delSp) {
- return flow(text, delSp, RFC2646_WIDTH);
- }
-
- /**
- * Decodes a text.
- */
- public static String flow(String text, boolean delSp, int width) {
- StringBuilder result = new StringBuilder();
- String[] lines = text.split("\r\n|\n", -1);
- for (int i = 0; i < lines.length; i ++) {
- String line = lines[i];
- boolean notempty = line.length() > 0;
-
- int quoteDepth = 0;
- while (quoteDepth < line.length() && line.charAt(quoteDepth) == RFC2646_QUOTE) quoteDepth ++;
- if (quoteDepth > 0) {
- if (quoteDepth + 1 < line.length() && line.charAt(quoteDepth) == RFC2646_SPACE) line = line.substring(quoteDepth + 1);
- else line = line.substring(quoteDepth);
- }
-
- while (notempty) {
- int extra = 0;
- if (quoteDepth == 0) {
- if (line.startsWith("" + RFC2646_SPACE) || line.startsWith("" + RFC2646_QUOTE) || line.startsWith(RFC2646_FROM)) {
- line = "" + RFC2646_SPACE + line;
- extra = 1;
- }
- } else {
- line = RFC2646_SPACE + line;
- for (int j = 0; j < quoteDepth; j++) line = "" + RFC2646_QUOTE + line;
- extra = quoteDepth + 1;
- }
-
- int j = width - 1;
- if (j >= line.length()) j = line.length() - 1;
- else {
- while (j >= extra && ((delSp && isAlphaChar(text, j)) || (!delSp && line.charAt(j) != RFC2646_SPACE))) j --;
- if (j < extra) {
- // Not able to cut a word: skip to word end even if greater than the max width
- j = width - 1;
- while (j < line.length() - 1 && ((delSp && isAlphaChar(text, j)) || (!delSp && line.charAt(j) != RFC2646_SPACE))) j ++;
- }
- }
-
- result.append(line.substring(0, j + 1));
- if (j < line.length() - 1) {
- if (delSp) result.append(RFC2646_SPACE);
- result.append(RFC2646_CRLF);
- }
-
- line = line.substring(j + 1);
- notempty = line.length() > 0;
- }
-
- if (i < lines.length - 1) {
- // NOTE: Have to trim the spaces before, otherwise it won't recognize soft-break from hard break.
- // Deflow of flowed message will not be identical to the original.
- while (result.length() > 0 && result.charAt(result.length() - 1) == RFC2646_SPACE) result.deleteCharAt(result.length() - 1);
- result.append(RFC2646_CRLF);
- }
- }
-
- return result.toString();
- }
-
- /**
- * Checks whether the char is part of a word.
- * RFC assert a word cannot be split (even if the length is greater than the maximum length).
- */
- public static boolean isAlphaChar(String text, int index) {
- // Note: a list of chars is available here:
- // http://www.zvon.org/tmRFC/RFC2646/Output/index.html
- char c = text.charAt(index);
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9');
- }
-}
\ No newline at end of file
+}
diff --git a/app/core/src/main/java/com/fsck/k9/message/quote/InsertableHtmlContent.java b/app/core/src/main/java/com/fsck/k9/message/quote/InsertableHtmlContent.java
index ee5bffdcc..4ce04f91d 100644
--- a/app/core/src/main/java/com/fsck/k9/message/quote/InsertableHtmlContent.java
+++ b/app/core/src/main/java/com/fsck/k9/message/quote/InsertableHtmlContent.java
@@ -93,15 +93,6 @@ public class InsertableHtmlContent implements Serializable {
footerInsertionPoint += content.length();
}
- /**
- * Remove all quoted content.
- */
- public void clearQuotedContent() {
- quotedContent.setLength(0);
- footerInsertionPoint = 0;
- headerInsertionPoint = 0;
- }
-
/**
* Set the inserted content to the specified content. Replaces anything currently in the
* inserted content buffer.
diff --git a/app/core/src/main/java/com/fsck/k9/search/SearchAccount.java b/app/core/src/main/java/com/fsck/k9/search/SearchAccount.java
index 8159a2d08..d51b9ecd5 100644
--- a/app/core/src/main/java/com/fsck/k9/search/SearchAccount.java
+++ b/app/core/src/main/java/com/fsck/k9/search/SearchAccount.java
@@ -53,7 +53,6 @@ public class SearchAccount implements BaseAccount {
return mEmail;
}
- @Override
public synchronized void setEmail(String email) {
this.mEmail = email;
}
@@ -63,7 +62,6 @@ public class SearchAccount implements BaseAccount {
return mDescription;
}
- @Override
public void setDescription(String description) {
this.mDescription = description;
}
diff --git a/app/ui/src/main/java/com/fsck/k9/activity/K9Activity.java b/app/ui/src/main/java/com/fsck/k9/activity/K9Activity.java
index 4c562a08d..1df533874 100644
--- a/app/ui/src/main/java/com/fsck/k9/activity/K9Activity.java
+++ b/app/ui/src/main/java/com/fsck/k9/activity/K9Activity.java
@@ -50,15 +50,6 @@ public abstract class K9Activity extends AppCompatActivity {
setSupportActionBar(toolbar);
}
- protected void setLayout(View view) {
- setContentView(view);
- Toolbar toolbar = findViewById(R.id.toolbar);
- if (toolbar == null) {
- throw new IllegalArgumentException("K9 layouts must provide a toolbar with id='toolbar'.");
- }
- setSupportActionBar(toolbar);
- }
-
public boolean hasPermission(Permission permission) {
return ContextCompat.checkSelfPermission(this, permission.permission) == PackageManager.PERMISSION_GRANTED;
}
diff --git a/app/ui/src/main/java/com/fsck/k9/activity/misc/ExtendedAsyncTask.java b/app/ui/src/main/java/com/fsck/k9/activity/misc/ExtendedAsyncTask.java
deleted file mode 100644
index f8bef5741..000000000
--- a/app/ui/src/main/java/com/fsck/k9/activity/misc/ExtendedAsyncTask.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.fsck.k9.activity.misc;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.os.AsyncTask;
-
-/**
- * Extends {@link AsyncTask} with methods to attach and detach an {@link Activity}.
- *
- *
- * This is necessary to properly handle configuration changes that will restart an activity.
- *
- * Note:
- * Implementing classes need to make sure they have no reference to the {@code Activity} instance
- * that created the instance of that class. So if it's implemented as inner class, it needs to be
- * {@code static}.
- *
- *
- * @param
- * see {@link AsyncTask}
- * @param