mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-24 08:38:51 -05:00
Set MessageList title in action bar depending on display mode
This commit is contained in:
parent
c11e5ef76b
commit
6b143d845a
@ -1,50 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_layout"
|
||||
android:layout_width="0dip"
|
||||
android:id="@+id/actionbar_message_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_layout"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title_first"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="start"
|
||||
android:singleLine="true"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title_sub"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/actionbar_progress"
|
||||
style="?android:attr/indeterminateProgressStyle"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title_first"
|
||||
android:id="@+id/actionbar_unread_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="start"
|
||||
android:singleLine="true"
|
||||
android:textSize="14sp" />
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="12dip"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textSize="32sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title_sub"
|
||||
<LinearLayout
|
||||
android:id="@+id/actionbar_message_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" >
|
||||
|
||||
<com.fsck.k9.view.MessageTitleView
|
||||
android:id="@+id/message_title_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="2"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/actionbar_progress"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center"
|
||||
style="?android:attr/indeterminateProgressStyle"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_unread_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="12dip"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textSize="32sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
@ -1,50 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_layout"
|
||||
android:layout_width="0dip"
|
||||
android:id="@+id/actionbar_message_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_layout"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title_first"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="start"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title_sub"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/actionbar_progress"
|
||||
style="?android:attr/indeterminateProgressStyle"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title_first"
|
||||
android:id="@+id/actionbar_unread_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="start"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="12dip"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textSize="36sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_title_sub"
|
||||
<LinearLayout
|
||||
android:id="@+id/actionbar_message_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" >
|
||||
|
||||
<com.fsck.k9.view.MessageTitleView
|
||||
android:id="@+id/message_title_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="2"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/actionbar_progress"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center"
|
||||
style="?android:attr/indeterminateProgressStyle"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actionbar_unread_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="12dip"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:textSize="36sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
@ -44,8 +44,7 @@
|
||||
android:textSize="10sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:visibility="gone"/>
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||
|
||||
<!-- From -->
|
||||
<LinearLayout
|
||||
|
@ -49,6 +49,7 @@ import com.fsck.k9.search.SearchSpecification.Attribute;
|
||||
import com.fsck.k9.search.SearchSpecification.Searchfield;
|
||||
import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
||||
import com.fsck.k9.view.MessageHeader;
|
||||
import com.fsck.k9.view.MessageTitleView;
|
||||
|
||||
import de.cketti.library.changelog.ChangeLog;
|
||||
|
||||
@ -139,6 +140,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
private StorageManager.StorageListener mStorageListener = new StorageListenerImplementation();
|
||||
|
||||
private ActionBar mActionBar;
|
||||
private View mActionBarMessageList;
|
||||
private View mActionBarMessageView;
|
||||
private MessageTitleView mActionBarSubject;
|
||||
private TextView mActionBarTitle;
|
||||
private TextView mActionBarSubTitle;
|
||||
private TextView mActionBarUnread;
|
||||
@ -463,6 +467,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
mActionBar.setCustomView(R.layout.actionbar_custom);
|
||||
|
||||
View customView = mActionBar.getCustomView();
|
||||
mActionBarMessageList = customView.findViewById(R.id.actionbar_message_list);
|
||||
mActionBarMessageView = customView.findViewById(R.id.actionbar_message_view);
|
||||
mActionBarSubject = (MessageTitleView) customView.findViewById(R.id.message_title_view);
|
||||
mActionBarTitle = (TextView) customView.findViewById(R.id.actionbar_title_first);
|
||||
mActionBarSubTitle = (TextView) customView.findViewById(R.id.actionbar_title_sub);
|
||||
mActionBarUnread = (TextView) customView.findViewById(R.id.actionbar_unread_count);
|
||||
@ -1174,6 +1181,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
ft.remove(mMessageViewFragment);
|
||||
mMessageViewFragment = null;
|
||||
ft.commit();
|
||||
|
||||
showDefaultTitleView();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1243,7 +1252,9 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
|
||||
@Override
|
||||
public void displayMessageSubject(String subject) {
|
||||
setTitle(subject);
|
||||
if (mDisplayMode == DisplayMode.MESSAGE_VIEW) {
|
||||
mActionBarSubject.setText(subject);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1284,7 +1295,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
|
||||
@Override
|
||||
public void messageHeaderViewAvailable(MessageHeader header) {
|
||||
//TODO: implement
|
||||
mActionBarSubject.setMessageHeader(header);
|
||||
}
|
||||
|
||||
private void showNextMessage() {
|
||||
@ -1309,6 +1320,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
mMessageListContainer.setVisibility(View.VISIBLE);
|
||||
removeMessageViewFragment();
|
||||
mMessageListFragment.setActiveMessage(null);
|
||||
|
||||
showDefaultTitleView();
|
||||
}
|
||||
|
||||
private void showMessageView() {
|
||||
@ -1316,6 +1329,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
|
||||
mMessageListContainer.setVisibility(View.GONE);
|
||||
mMessageViewContainer.setVisibility(View.VISIBLE);
|
||||
|
||||
showMessageTitleView();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1348,4 +1363,24 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
|
||||
restartActivity();
|
||||
}
|
||||
|
||||
private void showDefaultTitleView() {
|
||||
mActionBarMessageView.setVisibility(View.GONE);
|
||||
mActionBarMessageList.setVisibility(View.VISIBLE);
|
||||
|
||||
if (mMessageListFragment != null) {
|
||||
mMessageListFragment.updateTitle();
|
||||
}
|
||||
|
||||
mActionBarSubject.setMessageHeader(null);
|
||||
}
|
||||
|
||||
private void showMessageTitleView() {
|
||||
mActionBarMessageList.setVisibility(View.GONE);
|
||||
mActionBarMessageView.setVisibility(View.VISIBLE);
|
||||
|
||||
if (mMessageViewFragment != null) {
|
||||
mMessageViewFragment.updateTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -417,6 +417,12 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
|
||||
private MessageReference mActiveMessage;
|
||||
|
||||
/**
|
||||
* {@code true} after {@link #onCreate(Bundle)} was executed. Used in {@link #updateTitle()} to
|
||||
* make sure we don't access member variables before initialization is complete.
|
||||
*/
|
||||
private boolean mInitialized = false;
|
||||
|
||||
/**
|
||||
* This class is used to run operations that modify UI elements in the UI thread.
|
||||
*
|
||||
@ -501,7 +507,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
break;
|
||||
}
|
||||
case ACTION_REFRESH_TITLE: {
|
||||
MessageListFragment.this.refreshTitle();
|
||||
updateTitle();
|
||||
break;
|
||||
}
|
||||
case ACTION_PROGRESS: {
|
||||
@ -562,7 +568,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
updateFooterView();
|
||||
}
|
||||
|
||||
private void refreshTitle() {
|
||||
public void updateTitle() {
|
||||
if (!mInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
setWindowTitle();
|
||||
if (!mSearch.isManualSearch()) {
|
||||
setWindowProgress();
|
||||
@ -716,6 +726,8 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
mCheckboxes = K9.messageListCheckboxes();
|
||||
|
||||
decodeArguments();
|
||||
|
||||
mInitialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -973,7 +985,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
mController.getFolderUnreadMessageCount(mAccount, mFolderName, mListener);
|
||||
}
|
||||
|
||||
refreshTitle();
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
private void initializePullToRefresh(LayoutInflater inflater, View layout) {
|
||||
@ -3148,7 +3160,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
if (StringUtils.isNullOrEmpty(mTitle)) {
|
||||
mTitle = getString(R.string.general_no_subject);
|
||||
}
|
||||
refreshTitle();
|
||||
updateTitle();
|
||||
} else {
|
||||
//TODO: empty thread view -> return to full message list
|
||||
}
|
||||
|
@ -791,6 +791,12 @@ public class MessageViewFragment extends SherlockFragment implements OnClickList
|
||||
&& mAccount.hasSpamFolder());
|
||||
}
|
||||
|
||||
public void updateTitle() {
|
||||
if (mMessage != null) {
|
||||
displayMessageSubject(mMessage.getSubject());
|
||||
}
|
||||
}
|
||||
|
||||
public interface MessageViewFragmentListener {
|
||||
public void onForward(Message mMessage, PgpData mPgpData);
|
||||
public void disableDeleteAction();
|
||||
|
@ -431,10 +431,7 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The subject line defaults to GONE. Make it visible.
|
||||
*/
|
||||
public void showSubjectLine() {
|
||||
mSubjectView.setVisibility(VISIBLE);
|
||||
public void hideSubjectLine() {
|
||||
mSubjectView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,15 @@ package com.fsck.k9.view;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
import com.fsck.k9.K9;
|
||||
|
||||
/**
|
||||
* This {@link TextView} is used in the title of the {@link com.fsck.k9.activity.MessageView} ActionBar.
|
||||
* It'll un-hide the subject line {@link MessageHeader} if it doesn't fit in the ActionBar's title area.
|
||||
* This {@link TextView} is used in the custom view of the {@link com.fsck.k9.activity.MessageList}
|
||||
* action bar.
|
||||
* It will hide the subject line in {@link MessageHeader} if the subject fits completely into the
|
||||
* action bar's title view.
|
||||
*/
|
||||
public class MessageTitleView extends TextView {
|
||||
private static final String LOG_PREFIX = "MessageTitleView: ";
|
||||
private MessageHeader mHeader;
|
||||
|
||||
public MessageTitleView(Context context) {
|
||||
@ -28,28 +27,17 @@ public class MessageTitleView extends TextView {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if we need to unhide the subject line in the MessageHeader or not.
|
||||
* @param canvas Canvas to draw on.
|
||||
* Check to see if we need to hide the subject line in {@link MessageHeader} or not.
|
||||
*/
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
if(mHeader != null && getLayout() != null) {
|
||||
if(getLayout().getEllipsisCount(1) > 0) {
|
||||
if(K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, LOG_PREFIX +
|
||||
"Subject was truncated; enabling the subject line in the message header.");
|
||||
}
|
||||
mHeader.showSubjectLine();
|
||||
} else {
|
||||
if (K9.DEBUG) {
|
||||
Log.d(K9.LOG_TAG, LOG_PREFIX + "Subject was fully shown in ActionBar.");
|
||||
}
|
||||
}
|
||||
if (mHeader != null && getLayout() != null && getLayout().getEllipsisCount(1) == 0) {
|
||||
mHeader.hideSubjectLine();
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
public void setMessageHeader(final MessageHeader header) {
|
||||
this.mHeader = header;
|
||||
mHeader = header;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user