Fix the color and size of text in the ActionBar.
Fix http://b/issue?id=6371494
Change-Id: I5e94014b84b6a2bff154d850a56fbf780a66bc37
diff --git a/res/layout/account_switch_spinner_dropdown_item.xml b/res/layout/account_switch_spinner_dropdown_item.xml
index 072c902..e38c124 100644
--- a/res/layout/account_switch_spinner_dropdown_item.xml
+++ b/res/layout/account_switch_spinner_dropdown_item.xml
@@ -32,25 +32,26 @@
android:layout_width="match_parent"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true">
+ <!-- Something is strange here. Gmail1 allows for two-line label names while Gmail2 does
+ not. TODO(viki): Fix. -->
<TextView
- android:id="@+id/account_spinner_folder"
+ android:id="@+id/account_spinner_first"
android:singleLine="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:ellipsize="end"
- style="@style/AccountSpinnerDropdownTextPrimary"
- android:visibility="gone"/>
+ style="@android:style/TextAppearance.Holo.Widget.ActionBar.Title" />
<TextView
- android:id="@+id/account_spinner_accountname"
+ android:id="@+id/account_spinner_second"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:ellipsize="end"
- android:layout_below="@id/account_spinner_folder"
- style="@style/AccountSpinnerDropdownTextSecondary"/>
+ android:layout_below="@id/account_spinner_first"
+ style="@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle" />
</RelativeLayout>
<TextView
android:id="@+id/account_spinner_unread_count"
style="@style/UnreadCount"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"/>
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
diff --git a/res/layout/account_switch_spinner_item.xml b/res/layout/account_switch_spinner_item.xml
index 2ffa2e5..41ecff7 100644
--- a/res/layout/account_switch_spinner_item.xml
+++ b/res/layout/account_switch_spinner_item.xml
@@ -38,7 +38,7 @@
android:layout_toLeftOf="@id/unread"
android:background="@drawable/spinner_ab_holo_light">
<TextView
- android:id="@+id/account_spinner_folder"
+ android:id="@+id/account_spinner_first"
style="@style/AccountSpinnerAnchorTextPrimary"
android:singleLine="true"
android:ellipsize="end"
@@ -46,7 +46,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
- android:id="@+id/account_spinner_account_name"
+ android:id="@+id/account_spinner_second"
style="@style/AccountSpinnerAnchorTextSecondary"
android:singleLine="true"
android:ellipsize="end"
diff --git a/res/layout/actionbar_label.xml b/res/layout/actionbar_label.xml
index 187f814..5bb6844 100644
--- a/res/layout/actionbar_label.xml
+++ b/res/layout/actionbar_label.xml
@@ -37,7 +37,6 @@
<TextView
android:id="@+id/account"
style="@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle"
- android:textColor="@color/actionbar_secondary"
android:singleLine="true"
android:ellipsize="end"
android:includeFontPadding="false"
diff --git a/res/layout/folder_switch_spinner_dropdown_item.xml b/res/layout/folder_switch_spinner_dropdown_item.xml
index 281ee49..60edb2c 100644
--- a/res/layout/folder_switch_spinner_dropdown_item.xml
+++ b/res/layout/folder_switch_spinner_dropdown_item.xml
@@ -33,7 +33,7 @@
android:layout_weight="1"
android:maxLines="2"
android:ellipsize="end"
- style="@style/AccountSpinnerDropdownTextPrimary" />
+ style="@android:style/TextAppearance.Holo.Widget.ActionBar.Title" />
<TextView
android:id="@+id/unread"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 3f71f9a..036c57f 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -27,7 +27,6 @@
<color name="date_text_color_unread">@color/senders_text_color_unread</color>
<color name="date_text_color_read">@color/senders_text_color_read</color>
<color name="folder_list_heading_text_color">#777777</color>
- <color name="actionbar_secondary">#777777</color>
<color name="subject_text_color">#333333</color>
<color name="faded_conversation_header">#7f99d6eb</color>
<color name="faded_activated_conversation_header">#7faccbf9</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a34b897..8192367 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -151,24 +151,11 @@
<item name="android:textSize">36dp</item>
</style>
- <style name="AccountSwitchSpinnerItem">
- <item name="android:layout_width">match_parent</item>
- </style>
-
- <style name="AccountSpinnerDropdownTextPrimary">
- <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
- </style>
-
- <style name="AccountSpinnerDropdownTextSecondary">
- <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
- <item name="android:textColor">@color/actionbar_secondary</item>
- </style>
-
+ <!-- No change in the default case. -->
<style name="AccountSpinnerAnchorTextPrimary" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
</style>
<style name="AccountSpinnerAnchorTextSecondary" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
- <item name="android:textColor">@color/actionbar_secondary</item>
</style>
<!-- Browse list item styles -->
diff --git a/src/com/android/mail/AccountSpinnerAdapter.java b/src/com/android/mail/AccountSpinnerAdapter.java
index c3aa19e..f8bab03 100644
--- a/src/com/android/mail/AccountSpinnerAdapter.java
+++ b/src/com/android/mail/AccountSpinnerAdapter.java
@@ -272,10 +272,10 @@
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = mInflater.inflate(R.layout.account_switch_spinner_item, null);
- ((TextView) convertView.findViewById(R.id.account_spinner_account_name))
- .setText(getCurrentAccountName());
- ((TextView) convertView.findViewById(R.id.account_spinner_folder))
- .setText(getFolderLabel());
+ ((TextView) convertView.findViewById(R.id.account_spinner_first))
+ .setText(getFolderLabel());
+ ((TextView) convertView.findViewById(R.id.account_spinner_second))
+ .setText(getCurrentAccountName());
populateUnreadCountView((TextView) convertView.findViewById(R.id.unread),
getFolderUnreadCount());
return convertView;
@@ -301,7 +301,10 @@
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
- String textLabel = "";
+ // Shown in the first text view with big font.
+ String bigText = "";
+ // Shown in the second text view with smaller font.
+ String smallText = "";
int color = 0;
int unreadCount = 0;
switch (getType(position)) {
@@ -316,22 +319,26 @@
}
return convertView;
case TYPE_ACCOUNT:
- textLabel = getAccountFolder(position);
+ // TODO(viki): Get real Inbox or Priority Inbox using the URI. Remove ugly hack.
+ bigText = "Inbox";
+ smallText = getAccountFolder(position);
color = getAccountColor(position);
break;
case TYPE_FOLDER:
final int offset = position - mNumAccounts - 1;
final Folder folder = mRecentFolderList.get(offset);
- textLabel = folder.name;
+ bigText = folder.name;
unreadCount = folder.unreadCount;
break;
case TYPE_ALL_FOLDERS:
- textLabel = mContext.getResources().getString(R.string.show_all_folders);
+ bigText = mContext.getResources().getString(R.string.show_all_folders);
break;
}
convertView = mInflater.inflate(R.layout.account_switch_spinner_dropdown_item, null);
- ((TextView) convertView.findViewById(R.id.account_spinner_accountname)).setText(textLabel);
- View colorView = convertView.findViewById(R.id.account_spinner_color);
+ displayOrHide(convertView, R.id.account_spinner_first, bigText);
+ displayOrHide(convertView, R.id.account_spinner_second, smallText);
+
+ final View colorView = convertView.findViewById(R.id.account_spinner_color);
if (color != 0) {
colorView.setVisibility(View.VISIBLE);
colorView.setBackgroundColor(color);
@@ -345,6 +352,21 @@
}
+ /**
+ * Sets the text of the TextView to the given text, if it is non-empty. If the given
+ * text is empty, then the TextView is hidden (set to View.GONE).
+ * @param v
+ * @param resourceId
+ * @param toDisplay the given text
+ */
+ static private void displayOrHide(View v, int resourceId, String toDisplay) {
+ final TextView target = (TextView) v.findViewById(resourceId);
+ if (toDisplay.isEmpty()) {
+ target.setVisibility(View.GONE);
+ return;
+ }
+ target.setText(toDisplay);
+ }
private void populateUnreadCountView(TextView unreadCountView, int unreadCount) {
unreadCountView.setText(Utils.getUnreadCountString(mContext, unreadCount));