Add marker in message list for currently opened message

This commit is contained in:
cketti 2013-01-24 15:36:59 +01:00
parent 933dd95047
commit 573058bffc
4 changed files with 46 additions and 1 deletions

View File

@ -48,6 +48,7 @@
<attr name="messageListUnreadItemBackgroundColor" format="reference|color"/>
<attr name="messageListThreadCountForegroundColor" format="reference|color"/>
<attr name="messageListThreadCountBackground" format="reference|color"/>
<attr name="messageListActiveItemBackgroundColor" format="reference|color"/>
</declare-styleable>

View File

@ -47,6 +47,7 @@
<item name="messageListUnreadItemBackgroundColor">#00ffffff</item>
<item name="messageListThreadCountForegroundColor">?android:attr/colorBackground</item>
<item name="messageListThreadCountBackground">@drawable/thread_count_box_light</item>
<item name="messageListActiveItemBackgroundColor">#ff2ea7d1</item>
</style>
<style name="Theme.K9.Dark.Base" parent="Theme.Sherlock">
@ -96,6 +97,7 @@
<item name="messageListUnreadItemBackgroundColor">#805a5a5a</item>
<item name="messageListThreadCountForegroundColor">?android:attr/colorBackground</item>
<item name="messageListThreadCountBackground">@drawable/thread_count_box_dark</item>
<item name="messageListActiveItemBackgroundColor">#ff33b5e5</item>
</style>
<style name="Theme.K9.Light" parent="Theme.K9.Light.Base">
@ -131,5 +133,5 @@
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
</style>
</style>
</resources>

View File

@ -627,6 +627,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
ft.replace(R.id.message_view_container, fragment);
mMessageViewFragment = fragment;
ft.commit();
mMessageListFragment.setActiveMessage(messageReference);
}
}
@ -763,6 +765,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
if (mMessageViewPlaceHolder.getParent() == null) {
mMessageViewContainer.addView(mMessageViewPlaceHolder);
}
mMessageListFragment.setActiveMessage(null);
}
@Override

View File

@ -310,6 +310,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
private static final String ARG_IS_THREAD_DISPLAY = "isThreadedDisplay";
private static final String STATE_SELECTED_MESSAGES = "selectedMessages";
private static final String STATE_ACTIVE_MESSAGE = "activeMessage";
private static final String STATE_REMOTE_SEARCH_PERFORMED = "remoteSearchPerformed";
/**
@ -413,6 +414,8 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
private Preferences mPreferences;
private MessageReference mActiveMessage;
/**
* This class is used to run operations that modify UI elements in the UI thread.
*
@ -751,6 +754,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
saveSelectedMessages(outState);
outState.putBoolean(STATE_REMOTE_SEARCH_PERFORMED, mRemoteSearchPerformed);
outState.putParcelable(STATE_ACTIVE_MESSAGE, mActiveMessage);
}
/**
@ -766,6 +770,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
restoreSelectedMessages(savedInstanceState);
mRemoteSearchPerformed = savedInstanceState.getBoolean(STATE_REMOTE_SEARCH_PERFORMED);
mActiveMessage = savedInstanceState.getParcelable(STATE_ACTIVE_MESSAGE);
}
/**
@ -1751,6 +1756,21 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
view.setBackgroundColor(outValue.data);
}
if (mActiveMessage != null) {
String uid = cursor.getString(UID_COLUMN);
String folderName = cursor.getString(FOLDER_NAME_COLUMN);
if (account.getUuid().equals(mActiveMessage.accountUuid) &&
folderName.equals(mActiveMessage.folderName) &&
uid.equals(mActiveMessage.uid)) {
int res = R.attr.messageListActiveItemBackgroundColor;
TypedValue outValue = new TypedValue();
getActivity().getTheme().resolveAttribute(res, outValue, true);
view.setBackgroundColor(outValue.data);
}
}
// Thread count
if (threadCount > 1) {
holder.threadCount.setText(Integer.toString(threadCount));
@ -3135,4 +3155,22 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
private void remoteSearchFinished() {
mRemoteSearchFuture = null;
}
/**
* Mark a message as 'active'.
*
* <p>
* The active message is the one currently displayed in the message view portion of the split
* view.
* </p>
*
* @param messageReference
* {@code null} to not mark any message as being 'active'.
*/
public void setActiveMessage(MessageReference messageReference) {
mActiveMessage = messageReference;
if (mAdapter != null) {
mAdapter.notifyDataSetChanged();
}
}
}