1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Fix a number of build warnings.

This gets rid of about 50 warnings. Deprecation warnings still remain,
though.
This commit is contained in:
Danny Baumann 2013-02-04 11:18:49 +01:00
parent 0645cd8d8f
commit 275700e482
23 changed files with 49 additions and 120 deletions

View File

@ -70,7 +70,6 @@ import com.fsck.k9.activity.setup.Prefs;
import com.fsck.k9.activity.setup.WelcomeMessage;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.helper.SizeFormatter;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.ServerSettings;
import com.fsck.k9.mail.Store;
import com.fsck.k9.mail.Transport;
@ -100,11 +99,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
*/
private static final BaseAccount[] EMPTY_BASE_ACCOUNT_ARRAY = new BaseAccount[0];
/**
* Immutable empty {@link Flag} array
*/
private static final Flag[] EMPTY_FLAG_ARRAY = new Flag[0];
/**
* URL used to open Android Market application
*/
@ -1832,18 +1826,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
public LinearLayout accountsItemLayout;
}
}
private Flag[] combine(Flag[] set1, Flag[] set2) {
if (set1 == null) {
return set2;
}
if (set2 == null) {
return set1;
}
Set<Flag> flags = new HashSet<Flag>();
flags.addAll(Arrays.asList(set1));
flags.addAll(Arrays.asList(set2));
return flags.toArray(EMPTY_FLAG_ARRAY);
}
private class AccountClickListener implements OnClickListener {

View File

@ -7,12 +7,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@ -25,8 +22,6 @@ import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceScreen;
import android.preference.RingtonePreference;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import com.fsck.k9.Account;
import com.fsck.k9.Account.FolderMode;

View File

@ -14,7 +14,6 @@ import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import com.fsck.k9.*;
import com.fsck.k9.activity.K9Activity;
@ -39,7 +38,6 @@ public class AccountSetupBasics extends K9Activity
private final static String STATE_KEY_PROVIDER =
"com.fsck.k9.AccountSetupBasics.provider";
private Preferences mPrefs;
private EditText mEmailView;
private EditText mPasswordView;
private Button mNextButton;
@ -58,7 +56,6 @@ public class AccountSetupBasics extends K9Activity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_basics);
mPrefs = Preferences.getPreferences(this);
mEmailView = (EditText)findViewById(R.id.account_email);
mPasswordView = (EditText)findViewById(R.id.account_password);
mNextButton = (Button)findViewById(R.id.next);

View File

@ -3,9 +3,6 @@ package com.fsck.k9.activity.setup;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;

View File

@ -2,8 +2,6 @@ package com.fsck.k9.controller;
import java.io.CharArrayWriter;
import java.io.PrintWriter;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -721,7 +719,8 @@ public class MessagingController implements Runnable {
public Future searchRemoteMessages(final String acctUuid, final String folderName, final String query, final Flag[] requiredFlags, final Flag[] forbiddenFlags, final MessagingListener listener) {
public Future<?> searchRemoteMessages(final String acctUuid, final String folderName, final String query,
final Flag[] requiredFlags, final Flag[] forbiddenFlags, final MessagingListener listener) {
if (K9.DEBUG) {
String msg = "searchRemoteMessages ("
+ "acct=" + acctUuid
@ -5388,6 +5387,8 @@ public class MessagingController implements Runnable {
case FINISHED:
other.setPushActive(memory.account, memory.folderName, false);
break;
case FAILED:
break;
}
}
if (memory.processingState != null) {

View File

@ -756,12 +756,16 @@ public class Base64 {
}
static class DecoderException extends Exception {
private static final long serialVersionUID = -3786485780312120437L;
DecoderException(String error) {
super(error);
}
}
static class EncoderException extends Exception {
private static final long serialVersionUID = -5204809025392124652L;
EncoderException(String error) {
super(error);
}

View File

@ -23,10 +23,6 @@ import org.apache.james.mime4j.stream.BodyDescriptor;
import org.apache.james.mime4j.stream.Field;
import org.apache.james.mime4j.stream.MimeConfig;
import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.helper.HtmlConverter;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;

View File

@ -37,6 +37,7 @@ public class TextBody implements Body {
QuotedPrintableOutputStream qp = new QuotedPrintableOutputStream(out, false);
qp.write(bytes);
qp.flush();
qp.close();
}
}
}

View File

@ -77,7 +77,6 @@ import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.FetchProfile;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Folder.OpenMode;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part;
@ -962,7 +961,7 @@ public class ImapStore extends Store {
*/
private void parseFlags(ImapList flags) {
for (Object flag : flags) {
flag = flag.toString().toLowerCase();
flag = flag.toString().toLowerCase(Locale.US);
if (flag.equals("\\deleted")) {
mPermanentFlagsIndex.add(Flag.DELETED);
} else if (flag.equals("\\answered")) {
@ -1601,7 +1600,8 @@ public class ImapStore extends Store {
String fetch;
String partId = parts[0];
if ("TEXT".equalsIgnoreCase(partId)) {
fetch = String.format("BODY.PEEK[TEXT]<0.%d>", mAccount.getMaximumAutoDownloadMessageSize());
fetch = String.format(Locale.US, "BODY.PEEK[TEXT]<0.%d>",
mAccount.getMaximumAutoDownloadMessageSize());
} else {
fetch = String.format("BODY.PEEK[%s]", partId);
}
@ -2277,6 +2277,9 @@ public class ImapStore extends Store {
case RECENT:
imapQuery += "RECENT ";
break;
default:
break;
}
}
}
@ -2306,6 +2309,9 @@ public class ImapStore extends Store {
case RECENT:
imapQuery += "UNRECENT ";
break;
default:
break;
}
}
}

View File

@ -2322,46 +2322,6 @@ public class LocalStore extends Store implements Serializable {
}
}
/**
* Get the (database) ID of the message with the specified message ID.
*
* @param db
* A {@link SQLiteDatabase} instance to access the database.
* @param messageId
* The message ID to search for.
* @param onlyEmptyMessages
* {@code true} if only "empty messages" (placeholders for threading) should be
* searched
*
* @return If exactly one message with the specified message ID was found, the database ID
* of this message; {@code -1} otherwise.
*/
private long getDatabaseIdByMessageId(SQLiteDatabase db, String messageId,
boolean onlyEmptyMessages) {
long id = -1;
Cursor cursor = db.query("messages",
new String[] { "id" },
(onlyEmptyMessages) ?
"empty=1 AND folder_id=? AND message_id=?" :
"folder_id=? AND message_id=?",
new String[] { Long.toString(mFolderId), messageId },
null, null, null);
if (cursor != null) {
try {
if (cursor.getCount() == 1) {
cursor.moveToFirst();
id = cursor.getLong(0);
}
} finally {
cursor.close();
}
}
return id;
}
private ThreadInfo getThreadInfo(SQLiteDatabase db, String messageId) {
String sql = "SELECT t.id, t.message_id, t.root, t.parent " +
"FROM messages m " +

View File

@ -19,7 +19,6 @@ import java.net.*;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedList;
import java.util.HashMap;
@ -59,8 +58,6 @@ public class Pop3Store extends Store {
private static final String USER_CAPABILITY = "USER";
private static final String TOP_CAPABILITY = "TOP";
private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED };
/**
* Decodes a Pop3Store URI.
*
@ -1155,6 +1152,8 @@ public class Pop3Store extends Store {
* Exception that is thrown if the server returns an error response.
*/
static class Pop3ErrorResponse extends MessagingException {
private static final long serialVersionUID = 3672087845857867174L;
public Pop3ErrorResponse(String message) {
super(message, true);
}

View File

@ -1945,7 +1945,7 @@ public class WebDavStore extends Store {
if (!messageURL.endsWith("/")) {
messageURL += "/";
}
messageURL += URLEncoder.encode(message.getUid() + ":" + System.currentTimeMillis() + ".eml");
messageURL += URLEncoder.encode(message.getUid() + ":" + System.currentTimeMillis() + ".eml", "UTF-8");
Log.i(K9.LOG_TAG, "Uploading message as " + messageURL);

View File

@ -76,16 +76,16 @@ public class AccountSettings {
R.array.account_setup_expunge_policy_values))
));
s.put("folderDisplayMode", Settings.versions(
new V(1, new EnumSetting(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
));
s.put("folderPushMode", Settings.versions(
new V(1, new EnumSetting(FolderMode.class, FolderMode.FIRST_CLASS))
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.FIRST_CLASS))
));
s.put("folderSyncMode", Settings.versions(
new V(1, new EnumSetting(FolderMode.class, FolderMode.FIRST_CLASS))
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.FIRST_CLASS))
));
s.put("folderTargetMode", Settings.versions(
new V(1, new EnumSetting(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
));
s.put("goToUnreadMessageSearch", Settings.versions(
new V(1, new BooleanSetting(false))
@ -120,8 +120,8 @@ public class AccountSettings {
R.array.account_settings_message_age_values))
));
s.put("messageFormat", Settings.versions(
new V(1, new EnumSetting(Account.MessageFormat.class,
Account.DEFAULT_MESSAGE_FORMAT))
new V(1, new EnumSetting<Account.MessageFormat>(
Account.MessageFormat.class, Account.DEFAULT_MESSAGE_FORMAT))
));
s.put("messageFormatAuto", Settings.versions(
new V(2, new BooleanSetting(Account.DEFAULT_MESSAGE_FORMAT_AUTO))
@ -148,7 +148,8 @@ public class AccountSettings {
new V(1, new StringSetting(Account.DEFAULT_QUOTE_PREFIX))
));
s.put("quoteStyle", Settings.versions(
new V(1, new EnumSetting(Account.QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
new V(1, new EnumSetting<Account.QuoteStyle>(
Account.QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
));
s.put("replyAfterQuote", Settings.versions(
new V(1, new BooleanSetting(Account.DEFAULT_REPLY_AFTER_QUOTE))
@ -160,19 +161,21 @@ public class AccountSettings {
new V(1, new RingtoneSetting("content://settings/system/notification_sound"))
));
s.put("searchableFolders", Settings.versions(
new V(1, new EnumSetting(Account.Searchable.class, Account.Searchable.ALL))
new V(1, new EnumSetting<Account.Searchable>(
Account.Searchable.class, Account.Searchable.ALL))
));
s.put("sentFolderName", Settings.versions(
new V(1, new StringSetting("Sent"))
));
s.put("sortTypeEnum", Settings.versions(
new V(9, new EnumSetting(SortType.class, Account.DEFAULT_SORT_TYPE))
new V(9, new EnumSetting<SortType>(SortType.class, Account.DEFAULT_SORT_TYPE))
));
s.put("sortAscending", Settings.versions(
new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
));
s.put("showPicturesEnum", Settings.versions(
new V(1, new EnumSetting(Account.ShowPictures.class, Account.ShowPictures.NEVER))
new V(1, new EnumSetting<Account.ShowPictures>(
Account.ShowPictures.class, Account.ShowPictures.NEVER))
));
s.put("signatureBeforeQuotedText", Settings.versions(
new V(1, new BooleanSetting(false))

View File

@ -26,13 +26,13 @@ public class FolderSettings {
*/
s.put("displayMode", Settings.versions(
new V(1, new EnumSetting(FolderClass.class, FolderClass.NO_CLASS))
new V(1, new EnumSetting<FolderClass>(FolderClass.class, FolderClass.NO_CLASS))
));
s.put("syncMode", Settings.versions(
new V(1, new EnumSetting(FolderClass.class, FolderClass.INHERITED))
new V(1, new EnumSetting<FolderClass>(FolderClass.class, FolderClass.INHERITED))
));
s.put("pushMode", Settings.versions(
new V(1, new EnumSetting(FolderClass.class, FolderClass.INHERITED))
new V(1, new EnumSetting<FolderClass>(FolderClass.class, FolderClass.INHERITED))
));
s.put("inTopGroup", Settings.versions(
new V(1, new BooleanSetting(false))

View File

@ -44,7 +44,8 @@ public class GlobalSettings {
new V(1, new DirectorySetting(Environment.getExternalStorageDirectory().toString()))
));
s.put("backgroundOperations", Settings.versions(
new V(1, new EnumSetting(K9.BACKGROUND_OPS.class, K9.BACKGROUND_OPS.WHEN_CHECKED))
new V(1, new EnumSetting<K9.BACKGROUND_OPS>(
K9.BACKGROUND_OPS.class, K9.BACKGROUND_OPS.WHEN_CHECKED))
));
s.put("changeRegisteredNameColor", Settings.versions(
new V(1, new BooleanSetting(false))
@ -175,7 +176,7 @@ public class GlobalSettings {
new V(1, new BooleanSetting(true))
));
s.put("sortTypeEnum", Settings.versions(
new V(10, new EnumSetting(SortType.class, Account.DEFAULT_SORT_TYPE))
new V(10, new EnumSetting<SortType>(SortType.class, Account.DEFAULT_SORT_TYPE))
));
s.put("sortAscending", Settings.versions(
new V(10, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
@ -220,8 +221,8 @@ public class GlobalSettings {
new V(8, new BooleanSetting(true))
));
s.put("notificationHideSubject", Settings.versions(
new V(12, new EnumSetting(NotificationHideSubject.class,
NotificationHideSubject.NEVER))
new V(12, new EnumSetting<NotificationHideSubject>(
NotificationHideSubject.class, NotificationHideSubject.NEVER))
));
s.put("useBackgroundAsUnreadIndicator", Settings.versions(
new V(19, new BooleanSetting(true))
@ -230,7 +231,7 @@ public class GlobalSettings {
new V(20, new BooleanSetting(true))
));
s.put("splitViewMode", Settings.versions(
new V(23, new EnumSetting(SplitViewMode.class, SplitViewMode.NEVER))
new V(23, new EnumSetting<SplitViewMode>(SplitViewMode.class, SplitViewMode.NEVER))
));
SETTINGS = Collections.unmodifiableMap(s);

View File

@ -457,19 +457,18 @@ public class Settings {
* {@link Enum#toString()} is used to obtain the "pretty" string representation.
* </p>
*/
public static class EnumSetting extends SettingsDescription {
private Class<? extends Enum<?>> mEnumClass;
public static class EnumSetting<T extends Enum<T>> extends SettingsDescription {
private Class<T> mEnumClass;
public EnumSetting(Class<? extends Enum<?>> enumClass, Object defaultValue) {
public EnumSetting(Class<T> enumClass, Object defaultValue) {
super(defaultValue);
mEnumClass = enumClass;
}
@SuppressWarnings("unchecked")
@Override
public Object fromString(String value) throws InvalidSettingValueException {
try {
return Enum.valueOf((Class<? extends Enum>)mEnumClass, value);
return Enum.valueOf(mEnumClass, value);
} catch (Exception e) {
throw new InvalidSettingValueException();
}

View File

@ -1,6 +1,7 @@
package com.fsck.k9.preferences;
public class SettingsImportExportException extends Exception {
private static final long serialVersionUID = -6042736634079588513L;
public SettingsImportExportException() {
super();

View File

@ -124,13 +124,6 @@ public class EmailProvider extends ContentProvider {
private static final String THREADS_TABLE = "threads";
private static final String[] THREADS_COLUMNS = {
ThreadColumns.ID,
ThreadColumns.MESSAGE_ID,
ThreadColumns.ROOT,
ThreadColumns.PARENT
};
static {
UriMatcher matcher = sUriMatcher;

View File

@ -8,8 +8,6 @@ import java.util.Set;
import android.os.Parcel;
import android.os.Parcelable;
import com.fsck.k9.mail.Flag;
/**
* This class represents a local search.
*

View File

@ -9,9 +9,7 @@ import com.fsck.k9.activity.MessageCompose;
import com.fsck.k9.activity.MessageReference;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import android.app.PendingIntent;
import android.content.Context;

View File

@ -386,7 +386,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
static class SavedState extends BaseSavedState {
boolean additionalHeadersVisible;
@SuppressWarnings("hiding")
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override

View File

@ -173,7 +173,7 @@ public class MessageWebView extends TitleBarWebView {
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
shiftPressEvent.dispatch(this);
shiftPressEvent.dispatch(this, null, null);
Toast.makeText(getContext() , R.string.select_text_now, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Exception in emulateShiftHeld()", e);

View File

@ -800,7 +800,6 @@ public class SingleMessageView extends LinearLayout implements OnClickListener,
boolean hiddenAttachmentsVisible;
boolean showPictures;
@SuppressWarnings("hiding")
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override