Pixel pefect: account spinner.
The expanded account spinner is completed, but the collapsed view needs some more work. (That'll probably be a rather large CL, so I'll finish it in a separate CL.) Bug 3434135 Change-Id: Ia732e6b57b8c0d3e1609c3134b26411539ab6a18
This commit is contained in:
parent
3f60e9312b
commit
b3c3f1afc6
|
@ -17,36 +17,34 @@
|
|||
<!--
|
||||
Custom view set to the action bar on 2-pane.
|
||||
Displays the current mailbox and the unread count.
|
||||
|
||||
layout_width/height are set at runtime using ActionBar.setCustomView()
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingBottom="18dip"
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="12dip"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="32dp"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/mailbox_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:textSize="14dip"
|
||||
android:textColor="#000"
|
||||
android:gravity="bottom"
|
||||
android:maxWidth="@dimen/action_bar_mailbox_name_max_width"
|
||||
android:textSize="18dp"
|
||||
android:textColor="@color/text_ternary_color"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="none"
|
||||
android:ellipsize="end"
|
||||
android:gravity="left|center"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/unread_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginLeft="10dip"
|
||||
android:textSize="14dip"
|
||||
android:textColor="#000"
|
||||
android:gravity="bottom"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="none"
|
||||
android:layout_marginLeft="16dp"
|
||||
style="@style/action_bar_unread_count"
|
||||
android:gravity="center"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -14,15 +14,17 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!--
|
||||
TextView for the collapsed account spinner.
|
||||
TODO: Need to widen maxWidth dynamically when the mailbox name isn't shown
|
||||
on the action bar.
|
||||
-->
|
||||
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/display_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center"
|
||||
android:maxWidth="@dimen/action_bar_account_name_max_width"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
style="@style/action_bar_account_name"
|
||||
/>
|
||||
|
|
|
@ -15,51 +15,46 @@
|
|||
-->
|
||||
|
||||
<!--
|
||||
The width set here will be ignored. The actual width will be the same as the dropdown view.
|
||||
Not a RelativeLayout - we want to hide @id/email_address at runtime and then @id/display_name
|
||||
should be center-vertical
|
||||
-->
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:maxWidth="@dimen/account_spinner_dropdown_account_name_max_width"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center|left"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/display_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="@dimen/account_spinner_dropdown_account_name_max_width"
|
||||
style="@style/action_bar_account_name"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/email_address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="@dimen/account_spinner_dropdown_account_name_max_width"
|
||||
style="@style/action_bar_account_name_secondary"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/unread_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:singleLine="true"
|
||||
android:paddingTop="12dip"
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingRight="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="16dp"
|
||||
android:gravity="center|right"
|
||||
style="@style/action_bar_unread_count"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/display_name"
|
||||
android:layout_width="@dimen/action_bar_account_dropdown_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_toLeftOf="@id/unread_count"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:paddingTop="12dip"
|
||||
android:paddingLeft="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/email_address"
|
||||
android:layout_width="@dimen/action_bar_account_dropdown_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@id/display_name"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:paddingLeft="12dip"
|
||||
android:paddingBottom="12dip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
<!-- width of the message list, on the message list + message view mode. -->
|
||||
<dimen name="message_list_width">466dip</dimen>
|
||||
|
||||
<dimen name="action_bar_account_name_max_width">336dip</dimen>
|
||||
<!-- Narrower than action_bar_account_name_max_width, to account for unread count -->
|
||||
<dimen name="action_bar_account_dropdown_width">320dip</dimen>
|
||||
<dimen name="action_bar_account_name_max_width">256dip</dimen>
|
||||
<dimen name="action_bar_mailbox_name_left_margin">32dip</dimen>
|
||||
<dimen name="action_bar_mailbox_name_max_width">256dip</dimen>
|
||||
|
||||
<dimen name="widget_senders_font_size">14sp</dimen>
|
||||
<dimen name="widget_subject_font_size">14sp</dimen>
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
-->
|
||||
<dimen name="message_list_width">440dip</dimen>
|
||||
|
||||
<dimen name="action_bar_account_name_max_width">176dip</dimen>
|
||||
<!-- Narrower than action_bar_account_name_max_width, to account for unread count -->
|
||||
<dimen name="action_bar_account_dropdown_width">160dip</dimen>
|
||||
<dimen name="action_bar_account_name_max_width">128dip</dimen>
|
||||
<dimen name="action_bar_mailbox_name_left_margin">16dip</dimen>
|
||||
<dimen name="action_bar_mailbox_name_max_width">128dip</dimen>
|
||||
|
||||
<dimen name="widget_senders_font_size">14sp</dimen>
|
||||
<dimen name="widget_subject_font_size">14sp</dimen>
|
||||
|
|
|
@ -113,4 +113,25 @@
|
|||
<item name="android:layout_height">48dip</item>
|
||||
<item name="android:padding">8dip</item>
|
||||
</style>
|
||||
|
||||
<style name="action_bar_account_name">
|
||||
<item name="android:textSize">18dip</item>
|
||||
<item name="android:textColor">@color/text_primary_color</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">end</item>
|
||||
</style>
|
||||
|
||||
<style name="action_bar_account_name_secondary">
|
||||
<item name="android:textSize">14dip</item>
|
||||
<item name="android:textColor">@color/text_ternary_color</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">end</item>
|
||||
</style>
|
||||
|
||||
<style name="action_bar_unread_count">
|
||||
<item name="android:textSize">36dip</item>
|
||||
<item name="android:textColor">@color/text_ternary_color</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">end</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -65,4 +65,6 @@
|
|||
<dimen name="settings_buttons_padding_top">48dip</dimen>
|
||||
<dimen name="settings_buttons_padding_bottom">48dip</dimen>
|
||||
|
||||
<dimen name="account_spinner_dropdown_account_name_max_width">352dip</dimen>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package com.android.email.activity;
|
||||
|
||||
import com.android.email.R;
|
||||
import com.android.email.UiUtilities;
|
||||
import com.android.email.data.ClosingMatrixCursor;
|
||||
import com.android.email.data.ThrottlingCursorLoader;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
|
@ -96,11 +97,15 @@ public class AccountSelectorAdapter extends CursorAdapter {
|
|||
displayNameView.setText(displayName);
|
||||
|
||||
// Show the email address only when it's different from the display name.
|
||||
// If same, show " " instead of "", so that the text view won't get completely
|
||||
// collapsed. (TextView's height will be 0px if it's "match_content" and the
|
||||
// content is "".)
|
||||
emailAddressView.setText(emailAddress.equals(displayName) ? " " : emailAddress);
|
||||
unreadCountView.setText(Integer.toString(getAccountUnreadCount(position)));
|
||||
if (emailAddress.equals(displayName)) {
|
||||
emailAddressView.setVisibility(View.GONE);
|
||||
} else {
|
||||
emailAddressView.setVisibility(View.VISIBLE);
|
||||
emailAddressView.setText(emailAddress);
|
||||
}
|
||||
|
||||
unreadCountView.setText(UiUtilities.getMessageCountForUi(mContext,
|
||||
getAccountUnreadCount(position), false));
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.android.email.activity;
|
|||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.R;
|
||||
import com.android.email.UiUtilities;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.EmailContent.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.Mailbox;
|
||||
|
@ -29,6 +30,7 @@ import android.os.Bundle;
|
|||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
@ -151,7 +153,12 @@ class MessageListXLFragmentManager {
|
|||
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
mActionBarMailboxNameView = inflater.inflate(R.layout.action_bar_current_mailbox, null);
|
||||
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
mActionBar.setCustomView(mActionBarMailboxNameView);
|
||||
final ActionBar.LayoutParams customViewLayout = new ActionBar.LayoutParams(
|
||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||
ActionBar.LayoutParams.MATCH_PARENT);
|
||||
customViewLayout.setMargins(mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.action_bar_mailbox_name_left_margin) , 0, 0, 0);
|
||||
mActionBar.setCustomView(mActionBarMailboxNameView, customViewLayout);
|
||||
|
||||
mActionBarMailboxName =
|
||||
(TextView) mActionBarMailboxNameView.findViewById(R.id.mailbox_name);
|
||||
|
@ -323,13 +330,11 @@ class MessageListXLFragmentManager {
|
|||
|
||||
public void setCurrentMailboxName(String mailboxName, int unreadCount) {
|
||||
mActionBarMailboxName.setText(mailboxName);
|
||||
if (unreadCount == 0) {
|
||||
// No unread messages, or it's the mailbox doesn't have the idea of "unread".
|
||||
// (e.g. outbox)
|
||||
mActionBarUnreadCount.setText("");
|
||||
} else {
|
||||
mActionBarUnreadCount.setText(Integer.toString(unreadCount));
|
||||
}
|
||||
|
||||
// Note on action bar, we show only "unread count". Some mailboxes such as Outbox don't
|
||||
// have the idea of "unread count", in which case we just omit the count.
|
||||
mActionBarUnreadCount.setText(
|
||||
UiUtilities.getMessageCountForUi(mContext, unreadCount, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue