Misc fixes and dead code removal.
Change-Id: I48b2fa5f7bf619197d882c71e8b174d31d130e26
This commit is contained in:
parent
cd5da3c445
commit
2577842269
|
@ -80,7 +80,7 @@ public class Address {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddress(String address) {
|
public void setAddress(String address) {
|
||||||
this.mAddress = REMOVE_OPTIONAL_BRACKET.matcher(address).replaceAll("$1");;
|
mAddress = REMOVE_OPTIONAL_BRACKET.matcher(address).replaceAll("$1");;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +107,7 @@ public class Address {
|
||||||
personal = null;
|
personal = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mPersonal = personal;
|
mPersonal = personal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -447,73 +447,4 @@ public class Address {
|
||||||
return address + LIST_DELIMITER_PERSONAL + personal;
|
return address + LIST_DELIMITER_PERSONAL + personal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Legacy unpack() used for reading the old data (migration),
|
|
||||||
* as found in LocalStore (Donut; db version up to 24).
|
|
||||||
* @See unpack()
|
|
||||||
*/
|
|
||||||
public static Address[] legacyUnpack(String addressList) {
|
|
||||||
if (addressList == null || addressList.length() == 0) {
|
|
||||||
return new Address[] { };
|
|
||||||
}
|
|
||||||
ArrayList<Address> addresses = new ArrayList<Address>();
|
|
||||||
int length = addressList.length();
|
|
||||||
int pairStartIndex = 0;
|
|
||||||
int pairEndIndex = 0;
|
|
||||||
int addressEndIndex = 0;
|
|
||||||
while (pairStartIndex < length) {
|
|
||||||
pairEndIndex = addressList.indexOf(',', pairStartIndex);
|
|
||||||
if (pairEndIndex == -1) {
|
|
||||||
pairEndIndex = length;
|
|
||||||
}
|
|
||||||
addressEndIndex = addressList.indexOf(';', pairStartIndex);
|
|
||||||
String address = null;
|
|
||||||
String personal = null;
|
|
||||||
if (addressEndIndex == -1 || addressEndIndex > pairEndIndex) {
|
|
||||||
address =
|
|
||||||
Utility.fastUrlDecode(addressList.substring(pairStartIndex, pairEndIndex));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
address =
|
|
||||||
Utility.fastUrlDecode(addressList.substring(pairStartIndex, addressEndIndex));
|
|
||||||
personal =
|
|
||||||
Utility.fastUrlDecode(addressList.substring(addressEndIndex + 1, pairEndIndex));
|
|
||||||
}
|
|
||||||
addresses.add(new Address(address, personal));
|
|
||||||
pairStartIndex = pairEndIndex + 1;
|
|
||||||
}
|
|
||||||
return addresses.toArray(new Address[] { });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Legacy pack() used for writing to old data (migration),
|
|
||||||
* as found in LocalStore (Donut; db version up to 24).
|
|
||||||
* @See unpack()
|
|
||||||
*/
|
|
||||||
public static String legacyPack(Address[] addresses) {
|
|
||||||
if (addresses == null) {
|
|
||||||
return null;
|
|
||||||
} else if (addresses.length == 0) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
for (int i = 0, count = addresses.length; i < count; i++) {
|
|
||||||
Address address = addresses[i];
|
|
||||||
try {
|
|
||||||
sb.append(URLEncoder.encode(address.getAddress(), "UTF-8"));
|
|
||||||
if (address.getPersonal() != null) {
|
|
||||||
sb.append(';');
|
|
||||||
sb.append(URLEncoder.encode(address.getPersonal(), "UTF-8"));
|
|
||||||
}
|
|
||||||
if (i < count - 1) {
|
|
||||||
sb.append(',');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException uee) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
|
@ -105,12 +105,6 @@ public class MessagingController implements Runnable {
|
||||||
*/
|
*/
|
||||||
private static final String LOCAL_SERVERID_PREFIX = "Local-";
|
private static final String LOCAL_SERVERID_PREFIX = "Local-";
|
||||||
|
|
||||||
/**
|
|
||||||
* Projections & CVs used by pruneCachedAttachments
|
|
||||||
*/
|
|
||||||
private static final String[] PRUNE_ATTACHMENT_PROJECTION = new String[] {
|
|
||||||
AttachmentColumns.LOCATION
|
|
||||||
};
|
|
||||||
private static final ContentValues PRUNE_ATTACHMENT_CV = new ContentValues();
|
private static final ContentValues PRUNE_ATTACHMENT_CV = new ContentValues();
|
||||||
static {
|
static {
|
||||||
PRUNE_ATTACHMENT_CV.putNull(AttachmentColumns.CONTENT_URI);
|
PRUNE_ATTACHMENT_CV.putNull(AttachmentColumns.CONTENT_URI);
|
||||||
|
@ -1401,7 +1395,8 @@ public class MessagingController implements Runnable {
|
||||||
}
|
}
|
||||||
if (deleteUpdate) {
|
if (deleteUpdate) {
|
||||||
// Finally, delete the update (if any)
|
// Finally, delete the update (if any)
|
||||||
Uri uri = ContentUris.withAppendedId(EmailContent.Message.UPDATED_CONTENT_URI, messageId);
|
Uri uri = ContentUris.withAppendedId(
|
||||||
|
EmailContent.Message.UPDATED_CONTENT_URI, messageId);
|
||||||
resolver.delete(uri, null, null);
|
resolver.delete(uri, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ public class MessageList extends Activity implements MessageListFragment.Callbac
|
||||||
private MessageListFragment mListFragment;
|
private MessageListFragment mListFragment;
|
||||||
private TextView mErrorBanner;
|
private TextView mErrorBanner;
|
||||||
|
|
||||||
private Controller mController;
|
|
||||||
private RefreshManager mRefreshManager;
|
private RefreshManager mRefreshManager;
|
||||||
private final RefreshListener mRefreshListener = new RefreshListener();
|
private final RefreshListener mRefreshListener = new RefreshListener();
|
||||||
|
|
||||||
|
@ -108,7 +107,6 @@ public class MessageList extends Activity implements MessageListFragment.Callbac
|
||||||
ActivityHelper.debugSetWindowFlags(this);
|
ActivityHelper.debugSetWindowFlags(this);
|
||||||
setContentView(R.layout.message_list);
|
setContentView(R.layout.message_list);
|
||||||
|
|
||||||
mController = Controller.getInstance(this);
|
|
||||||
mRefreshManager = RefreshManager.getInstance(this);
|
mRefreshManager = RefreshManager.getInstance(this);
|
||||||
mRefreshManager.registerListener(mRefreshListener);
|
mRefreshManager.registerListener(mRefreshListener);
|
||||||
mListFragment = (MessageListFragment) getFragmentManager()
|
mListFragment = (MessageListFragment) getFragmentManager()
|
||||||
|
@ -344,7 +342,7 @@ public class MessageList extends Activity implements MessageListFragment.Callbac
|
||||||
// launch the security setup activity
|
// launch the security setup activity
|
||||||
Intent i = AccountSecurity.actionUpdateSecurityIntent(
|
Intent i = AccountSecurity.actionUpdateSecurityIntent(
|
||||||
MessageList.this, accountId, true);
|
MessageList.this, accountId, true);
|
||||||
MessageList.this.startActivityForResult(i, REQUEST_SECURITY);
|
startActivityForResult(i, REQUEST_SECURITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class MessageListFragment extends ListFragment
|
||||||
// Controller access
|
// Controller access
|
||||||
private Controller mController;
|
private Controller mController;
|
||||||
private RefreshManager mRefreshManager;
|
private RefreshManager mRefreshManager;
|
||||||
private RefreshListener mRefreshListener = new RefreshListener();
|
private final RefreshListener mRefreshListener = new RefreshListener();
|
||||||
|
|
||||||
// UI Support
|
// UI Support
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
@ -500,11 +500,11 @@ public class MessageListFragment extends ListFragment
|
||||||
/** Height of the draggable view */
|
/** Height of the draggable view */
|
||||||
private final int mDragHeight;
|
private final int mDragHeight;
|
||||||
|
|
||||||
private String mMessageText;
|
private final String mMessageText;
|
||||||
private PointF mMessagePoint;
|
private final PointF mMessagePoint;
|
||||||
|
|
||||||
private String mCountText;
|
private final String mCountText;
|
||||||
private PointF mCountPoint;
|
private final PointF mCountPoint;
|
||||||
private int mOldOrientation = Configuration.ORIENTATION_UNDEFINED;
|
private int mOldOrientation = Configuration.ORIENTATION_UNDEFINED;
|
||||||
|
|
||||||
/** Margin applied to the right of count text */
|
/** Margin applied to the right of count text */
|
||||||
|
|
|
@ -589,7 +589,7 @@ public class MessageListXL extends Activity implements MessageListXLFragmentMana
|
||||||
|
|
||||||
// STOPSHIP Temporary mailbox settings UI
|
// STOPSHIP Temporary mailbox settings UI
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id, Bundle args) {
|
||||||
Mailbox mailbox = Mailbox.restoreMailboxWithId(this, mFragmentManager.getMailboxId());
|
Mailbox mailbox = Mailbox.restoreMailboxWithId(this, mFragmentManager.getMailboxId());
|
||||||
if (mailbox == null) return null;
|
if (mailbox == null) return null;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
|
|
@ -166,7 +166,6 @@ import java.util.Set;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||||
//return mInflater.inflate(R.layout.message_list_item, parent, false);
|
|
||||||
MessageListItem item = new MessageListItem(context);
|
MessageListItem item = new MessageListItem(context);
|
||||||
item.setVisibility(View.VISIBLE);
|
item.setVisibility(View.VISIBLE);
|
||||||
return item;
|
return item;
|
||||||
|
|
|
@ -16,14 +16,12 @@
|
||||||
|
|
||||||
package com.android.emailcommon.mail;
|
package com.android.emailcommon.mail;
|
||||||
|
|
||||||
import com.android.emailcommon.mail.Address;
|
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
import org.apache.james.mime4j.decoder.DecoderUtil;
|
import org.apache.james.mime4j.decoder.DecoderUtil;
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a series of unit tests for the Address class. These tests must be locally
|
* This is a series of unit tests for the Address class. These tests must be locally
|
||||||
|
@ -48,7 +46,8 @@ public class AddressUnitTests extends AndroidTestCase {
|
||||||
|
|
||||||
private static final Address PACK_ADDR_1 = new Address("john@gmail.com", "John Doe");
|
private static final Address PACK_ADDR_1 = new Address("john@gmail.com", "John Doe");
|
||||||
private static final Address PACK_ADDR_2 = new Address("foo@bar.com", null);
|
private static final Address PACK_ADDR_2 = new Address("foo@bar.com", null);
|
||||||
private static final Address PACK_ADDR_3 = new Address("mar.y+test@gmail.com", "Mar-y, B; B*arr");
|
private static final Address PACK_ADDR_3 = new Address(
|
||||||
|
"mar.y+test@gmail.com", "Mar-y, B; B*arr");
|
||||||
private static final Address[][] PACK_CASES = {
|
private static final Address[][] PACK_CASES = {
|
||||||
{PACK_ADDR_2}, {PACK_ADDR_1},
|
{PACK_ADDR_2}, {PACK_ADDR_1},
|
||||||
{PACK_ADDR_1, PACK_ADDR_2}, {PACK_ADDR_2, PACK_ADDR_1},
|
{PACK_ADDR_1, PACK_ADDR_2}, {PACK_ADDR_2, PACK_ADDR_1},
|
||||||
|
@ -353,7 +352,8 @@ public class AddressUnitTests extends AndroidTestCase {
|
||||||
assertEquals("no name 1", "noname1@dom1.com", addresses[0].toString());
|
assertEquals("no name 1", "noname1@dom1.com", addresses[0].toString());
|
||||||
assertEquals("no name 2", "noname2@dom2.com", addresses[1].toString());
|
assertEquals("no name 2", "noname2@dom2.com", addresses[1].toString());
|
||||||
assertEquals("simple name", "simple name <address3@dom3.org>", addresses[2].toString());
|
assertEquals("simple name", "simple name <address3@dom3.org>", addresses[2].toString());
|
||||||
assertEquals("double quoted name", "\"name,4\" <address4@dom4.org>", addresses[3].toString());
|
assertEquals("double quoted name",
|
||||||
|
"\"name,4\" <address4@dom4.org>", addresses[3].toString());
|
||||||
assertEquals("quoted name", "\"big \"G\"\" <bigG@dom5.net>", addresses[4].toString());
|
assertEquals("quoted name", "\"big \"G\"\" <bigG@dom5.net>", addresses[4].toString());
|
||||||
assertEquals("utf-16 name", "\u65E5\u672C\u8A9E <address6@co.jp>",
|
assertEquals("utf-16 name", "\u65E5\u672C\u8A9E <address6@co.jp>",
|
||||||
addresses[5].toString());
|
addresses[5].toString());
|
||||||
|
@ -619,13 +619,6 @@ public class AddressUnitTests extends AndroidTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLegacyPackUnpack() {
|
|
||||||
for (Address[] list : PACK_CASES) {
|
|
||||||
String packed = legacyPack(list);
|
|
||||||
assertTrue(packed, addressArrayEquals(list, Address.legacyUnpack(packed)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that unpackToString() returns the same result as toString(unpack()).
|
* Tests that unpackToString() returns the same result as toString(unpack()).
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue