astyle
This commit is contained in:
parent
7bd8fc3599
commit
7030967fa7
9 changed files with 132 additions and 112 deletions
|
@ -54,10 +54,11 @@ public class K9ListActivity extends ListActivity
|
|||
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||
{
|
||||
ListView listView = getListView();
|
||||
if(K9.useVolumeKeysForNavigationEnabled())
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
|
||||
if (listView.getSelectedItemPosition() > 0) {
|
||||
if (listView.getSelectedItemPosition() > 0)
|
||||
{
|
||||
listView.setSelection(listView.getSelectedItemPosition()-1);
|
||||
}
|
||||
return true;
|
||||
|
@ -66,9 +67,10 @@ public class K9ListActivity extends ListActivity
|
|||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||
{
|
||||
ListView listView = getListView();
|
||||
if(K9.useVolumeKeysForNavigationEnabled())
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
if (listView.getSelectedItemPosition() < listView.getCount()) {
|
||||
if (listView.getSelectedItemPosition() < listView.getCount())
|
||||
{
|
||||
listView.setSelection(listView.getSelectedItemPosition()+1);
|
||||
}
|
||||
return true;
|
||||
|
@ -82,8 +84,10 @@ public class K9ListActivity extends ListActivity
|
|||
public boolean onKeyUp(int keyCode, KeyEvent event)
|
||||
{
|
||||
// Swallow these events too to avoid the audible notification of a volume change
|
||||
if(K9.useVolumeKeysForNavigationEnabled()) {
|
||||
if((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
|
||||
{
|
||||
if (K9.DEBUG)
|
||||
Log.v(K9.LOG_TAG, "Swallowed key up.");
|
||||
return true;
|
||||
|
|
|
@ -141,7 +141,8 @@ public class MessageInfoHolder implements Comparable<MessageInfoHolder>
|
|||
{
|
||||
CharSequence to = Address.toFriendly(message .getRecipients(RecipientType.TO), mContacts);
|
||||
this.compareCounterparty = to.toString();
|
||||
this.sender = new SpannableStringBuilder(context.getString(R.string.message_list_to_fmt)).append(to); }
|
||||
this.sender = new SpannableStringBuilder(context.getString(R.string.message_list_to_fmt)).append(to);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sender = Address.toFriendly(addrs, mContacts);
|
||||
|
|
|
@ -681,15 +681,16 @@ public class MessageList
|
|||
switch (keyCode)
|
||||
{
|
||||
|
||||
// messagelist is actually a K9Activity, not a K9ListActivity
|
||||
// This saddens me greatly, but to support volume key navigation
|
||||
// in MessageView, we implement this bit of wrapper code
|
||||
// messagelist is actually a K9Activity, not a K9ListActivity
|
||||
// This saddens me greatly, but to support volume key navigation
|
||||
// in MessageView, we implement this bit of wrapper code
|
||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||
{
|
||||
if(K9.useVolumeKeysForNavigationEnabled())
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
|
||||
if (mListView.getSelectedItemPosition() > 0) {
|
||||
if (mListView.getSelectedItemPosition() > 0)
|
||||
{
|
||||
mListView.setSelection(mListView.getSelectedItemPosition()-1);
|
||||
}
|
||||
return true;
|
||||
|
@ -697,9 +698,10 @@ public class MessageList
|
|||
}
|
||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||
{
|
||||
if(K9.useVolumeKeysForNavigationEnabled())
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
if (mListView.getSelectedItemPosition() < mListView.getCount()) {
|
||||
if (mListView.getSelectedItemPosition() < mListView.getCount())
|
||||
{
|
||||
mListView.setSelection(mListView.getSelectedItemPosition()+1);
|
||||
}
|
||||
return true;
|
||||
|
@ -836,8 +838,10 @@ public class MessageList
|
|||
public boolean onKeyUp(int keyCode, KeyEvent event)
|
||||
{
|
||||
// Swallow these events too to avoid the audible notification of a volume change
|
||||
if(K9.useVolumeKeysForNavigationEnabled()) {
|
||||
if((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
|
||||
{
|
||||
if (K9.DEBUG)
|
||||
Log.v(K9.LOG_TAG, "Swallowed key up.");
|
||||
return true;
|
||||
|
@ -2060,83 +2064,83 @@ public class MessageList
|
|||
{
|
||||
public void run()
|
||||
{
|
||||
boolean needsSort = false;
|
||||
final List<MessageInfoHolder> messagesToAdd = new ArrayList<MessageInfoHolder>();
|
||||
List<MessageInfoHolder> messagesToRemove = new ArrayList<MessageInfoHolder>();
|
||||
List<Message> messagesToSearch = new ArrayList<Message>();
|
||||
boolean needsSort = false;
|
||||
final List<MessageInfoHolder> messagesToAdd = new ArrayList<MessageInfoHolder>();
|
||||
List<MessageInfoHolder> messagesToRemove = new ArrayList<MessageInfoHolder>();
|
||||
List<Message> messagesToSearch = new ArrayList<Message>();
|
||||
|
||||
for (Message message : messages)
|
||||
{
|
||||
MessageInfoHolder m = getMessage(message);
|
||||
if (message.isSet(Flag.DELETED))
|
||||
{
|
||||
if (m != null)
|
||||
for (Message message : messages)
|
||||
{
|
||||
messagesToRemove.add(m);
|
||||
}
|
||||
}
|
||||
else if (m == null)
|
||||
{
|
||||
if (updateForMe(account, folder))
|
||||
{
|
||||
m = new MessageInfoHolder(context, message);
|
||||
messagesToAdd.add(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mQueryString != null)
|
||||
MessageInfoHolder m = getMessage(message);
|
||||
if (message.isSet(Flag.DELETED))
|
||||
{
|
||||
if (verifyAgainstSearch)
|
||||
if (m != null)
|
||||
{
|
||||
messagesToSearch.add(message);
|
||||
messagesToRemove.add(m);
|
||||
}
|
||||
else
|
||||
}
|
||||
else if (m == null)
|
||||
{
|
||||
if (updateForMe(account, folder))
|
||||
{
|
||||
m = new MessageInfoHolder(context, message);
|
||||
messagesToAdd.add(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mQueryString != null)
|
||||
{
|
||||
if (verifyAgainstSearch)
|
||||
{
|
||||
messagesToSearch.add(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
m = new MessageInfoHolder(context, message);
|
||||
messagesToAdd.add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m.populate(context, message, new FolderInfoHolder(context, message.getFolder(), account), account);
|
||||
needsSort = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m.populate(context, message, new FolderInfoHolder(context, message.getFolder(), account), account);
|
||||
needsSort = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesToSearch.size() > 0)
|
||||
{
|
||||
mController.searchLocalMessages(mAccountUuids, mFolderNames, messagesToSearch.toArray(EMPTY_MESSAGE_ARRAY), mQueryString, mIntegrate, mQueryFlags, mForbiddenFlags,
|
||||
new MessagingListener()
|
||||
{
|
||||
@Override
|
||||
public void listLocalMessagesAddMessages(Account account, String folder, List<Message> messages)
|
||||
if (messagesToSearch.size() > 0)
|
||||
{
|
||||
addOrUpdateMessages(account, folder, messages, false);
|
||||
mController.searchLocalMessages(mAccountUuids, mFolderNames, messagesToSearch.toArray(EMPTY_MESSAGE_ARRAY), mQueryString, mIntegrate, mQueryFlags, mForbiddenFlags,
|
||||
new MessagingListener()
|
||||
{
|
||||
@Override
|
||||
public void listLocalMessagesAddMessages(Account account, String folder, List<Message> messages)
|
||||
{
|
||||
addOrUpdateMessages(account, folder, messages, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (messagesToRemove.size() > 0)
|
||||
{
|
||||
removeMessages(messagesToRemove);
|
||||
}
|
||||
if (messagesToRemove.size() > 0)
|
||||
{
|
||||
removeMessages(messagesToRemove);
|
||||
}
|
||||
|
||||
if (messagesToAdd.size() > 0)
|
||||
{
|
||||
mHandler.addMessages(messagesToAdd);
|
||||
}
|
||||
if (messagesToAdd.size() > 0)
|
||||
{
|
||||
mHandler.addMessages(messagesToAdd);
|
||||
}
|
||||
|
||||
if (needsSort)
|
||||
{
|
||||
mHandler.sortMessages();
|
||||
mHandler.resetUnreadCount();
|
||||
if (needsSort)
|
||||
{
|
||||
mHandler.sortMessages();
|
||||
mHandler.resetUnreadCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
public MessageInfoHolder getMessage(Message message)
|
||||
{
|
||||
|
@ -2434,15 +2438,15 @@ public class MessageList
|
|||
|
||||
// Create our span sections, and assign a format to each.
|
||||
str.setSpan(new StyleSpan(Typeface.BOLD),
|
||||
0,
|
||||
message.sender.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
0,
|
||||
message.sender.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
str.setSpan(new ForegroundColorSpan(Color.rgb(128,128,128)), // TODO: How do I can specify the android.R.attr.textColorTertiary
|
||||
message.sender.length(),
|
||||
str.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
message.sender.length(),
|
||||
str.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -217,7 +217,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||
{
|
||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||
{
|
||||
if(K9.useVolumeKeysForNavigationEnabled())
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
onNext(true);
|
||||
return true;
|
||||
|
@ -225,7 +225,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||
}
|
||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||
{
|
||||
if(K9.useVolumeKeysForNavigationEnabled())
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
onPrevious(true);
|
||||
return true;
|
||||
|
@ -356,8 +356,10 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||
public boolean onKeyUp(int keyCode, KeyEvent event)
|
||||
{
|
||||
// Swallow these events too to avoid the audible notification of a volume change
|
||||
if(K9.useVolumeKeysForNavigationEnabled()) {
|
||||
if((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
|
||||
if (K9.useVolumeKeysForNavigationEnabled())
|
||||
{
|
||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
|
||||
{
|
||||
if (K9.DEBUG)
|
||||
Log.v(K9.LOG_TAG, "Swallowed key up.");
|
||||
return true;
|
||||
|
|
|
@ -271,7 +271,7 @@ public class AccountSetupBasics extends K9Activity
|
|||
* manual setup.
|
||||
*/
|
||||
onManualSetup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onNext()
|
||||
|
|
|
@ -190,11 +190,11 @@ public class ContactsSdk3_4 extends com.fsck.k9.helper.Contacts
|
|||
}
|
||||
|
||||
final Cursor c = mContentResolver.query(
|
||||
Contacts.ContactMethods.CONTENT_EMAIL_URI,
|
||||
PROJECTION,
|
||||
where,
|
||||
args,
|
||||
SORT_ORDER);
|
||||
Contacts.ContactMethods.CONTENT_EMAIL_URI,
|
||||
PROJECTION,
|
||||
where,
|
||||
args,
|
||||
SORT_ORDER);
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
|
|
|
@ -155,11 +155,11 @@ public class ContactsSdk5 extends com.fsck.k9.helper.Contacts
|
|||
final String filter = (address == null) ? "" : address;
|
||||
final Uri uri = Uri.withAppendedPath(Email.CONTENT_FILTER_URI, Uri.encode(filter));
|
||||
final Cursor c = mContentResolver.query(
|
||||
uri,
|
||||
PROJECTION,
|
||||
null,
|
||||
null,
|
||||
SORT_ORDER);
|
||||
uri,
|
||||
PROJECTION,
|
||||
null,
|
||||
null,
|
||||
SORT_ORDER);
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
|
|
|
@ -248,26 +248,34 @@ public class Address
|
|||
|
||||
public CharSequence toFriendly(Contacts contacts)
|
||||
{
|
||||
if (contacts != null) {
|
||||
if (contacts != null)
|
||||
{
|
||||
String name = sContactsName.get(mAddress);
|
||||
if (name != null && name != NO_ENTRY) {
|
||||
if (name != null && name != NO_ENTRY)
|
||||
{
|
||||
return Html.fromHtml("<font color=\"Blue\">" + name + "</font>"); // TODO: use setSpan
|
||||
}
|
||||
if (name == null) {
|
||||
if (name == null)
|
||||
{
|
||||
Cursor cursor = contacts.searchByAddress(mAddress);
|
||||
if (cursor != null) {
|
||||
try {
|
||||
if (cursor.getCount() > 0) {
|
||||
if (cursor != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (cursor.getCount() > 0)
|
||||
{
|
||||
cursor.moveToFirst();
|
||||
name = contacts.getName(cursor);
|
||||
sContactsName.put(mAddress, name);
|
||||
return Html.fromHtml("<font color=\"Blue\">" + name + "</font>"); // TODO: use setSpan
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
sContactsName.put(mAddress, NO_ENTRY);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
Log.i(K9.LOG_TAG, "cursor closed");
|
||||
// cursor.close(); // TODO: should close cursor.
|
||||
}
|
||||
|
|
|
@ -2190,16 +2190,17 @@ public class LocalStore extends Store implements Serializable
|
|||
public void deleteMessagesOlderThan(long cutoff) throws MessagingException
|
||||
{
|
||||
final String where = "folder_id = ? and date < ?";
|
||||
final String[] params = new String[] {
|
||||
Long.toString(mFolderId), Long.toString(cutoff)
|
||||
final String[] params = new String[]
|
||||
{
|
||||
Long.toString(mFolderId), Long.toString(cutoff)
|
||||
};
|
||||
|
||||
open(OpenMode.READ_ONLY);
|
||||
Message[] messages = LocalStore.this.getMessages(
|
||||
null,
|
||||
this,
|
||||
"SELECT " + GET_MESSAGES_COLS + "FROM messages WHERE " + where,
|
||||
params);
|
||||
null,
|
||||
this,
|
||||
"SELECT " + GET_MESSAGES_COLS + "FROM messages WHERE " + where,
|
||||
params);
|
||||
|
||||
for (Message message : messages)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue