Merge "Fix spacing and align in drawer" into jb-ub-mail-ur9
diff --git a/res/layout/account_item.xml b/res/layout/account_item.xml
index 1781761..9db0f9c 100644
--- a/res/layout/account_item.xml
+++ b/res/layout/account_item.xml
@@ -37,33 +37,26 @@
android:src="@drawable/account_radio_button"
android:layout_centerVertical="true"/>
- <LinearLayout
+ <TextView
+ android:id="@+id/name"
android:layout_height="wrap_content"
- android:layout_width="match_parent"
+ android:layout_width="wrap_content"
android:layout_toRightOf="@id/account_radio_button"
android:layout_alignWithParentIfMissing="true"
android:layout_marginLeft="@dimen/account_item_left_margin"
android:layout_marginRight="@dimen/account_item_right_margin"
- android:layout_centerVertical="true" >
+ android:layout_centerVertical="true"
+ android:includeFontPadding="false"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:textColor="@color/account_item_text_color"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
- <TextView
- android:id="@+id/name"
- android:layout_height="wrap_content"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_marginRight="@dimen/account_item_right_margin"
- android:includeFontPadding="false"
- android:singleLine="true"
- android:ellipsize="end"
- android:textColor="@color/account_item_text_color"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <TextView
- android:id="@+id/unread"
- style="@style/UnreadCount"
- android:layout_alignWithParentIfMissing="true"
- android:layout_alignParentRight="true"
- android:textColor="@color/account_item_text_color" />
- </LinearLayout>
+ <TextView
+ android:id="@+id/unread"
+ style="@style/UnreadCount"
+ android:layout_marginRight="@dimen/account_item_right_margin"
+ android:layout_alignParentRight="true"
+ android:textColor="@color/account_item_text_color" />
</com.android.mail.ui.AccountItemView>
diff --git a/res/layout/folder_item.xml b/res/layout/folder_item.xml
index ae4890a..40f952e 100644
--- a/res/layout/folder_item.xml
+++ b/res/layout/folder_item.xml
@@ -46,44 +46,32 @@
android:layout_marginLeft="@dimen/folder_list_item_left_margin"
android:visibility="gone" />
- <LinearLayout
- android:layout_width="match_parent"
+ <TextView
+ android:id="@+id/name"
android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/folder_icon"
android:layout_alignWithParentIfMissing="true"
android:layout_marginLeft="@dimen/folder_list_item_left_margin"
android:layout_marginRight="@dimen/folder_list_item_right_margin"
- android:layout_marginTop="@dimen/folder_swatch_height"
- android:layout_marginBottom="@dimen/folder_swatch_height">
+ android:includeFontPadding="false"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:textColor="@color/folder_item_text_color"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
- <TextView
- android:id="@+id/name"
- android:layout_height="wrap_content"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_marginRight="@dimen/folder_list_item_right_margin"
- android:includeFontPadding="false"
- android:maxLines="2"
- android:ellipsize="end"
- android:textColor="@color/folder_item_text_color"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ <TextView
+ android:id="@+id/unread"
+ style="@style/UnreadCount"
+ android:layout_marginRight="@dimen/folder_list_item_right_margin"
+ android:layout_alignParentRight="true"
+ android:textColor="@color/folder_item_text_color" />
- <TextView
- android:id="@+id/unread"
- style="@style/UnreadCount"
- android:layout_alignWithParentIfMissing="true"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@id/name"
- android:textColor="@color/folder_item_text_color" />
-
- <TextView
- android:id="@+id/unseen"
- style="@style/UnseenCount"
- android:layout_alignWithParentIfMissing="true"
- android:layout_alignParentRight="true"
- android:layout_alignBaseline="@id/name" />
-
- </LinearLayout>
+ <TextView
+ android:id="@+id/unseen"
+ style="@style/UnseenCount"
+ android:layout_marginRight="@dimen/folder_list_item_right_margin"
+ android:layout_alignParentRight="true"/>
</com.android.mail.ui.FolderItemView>
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index 289212c..cf54a9c 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -70,6 +70,7 @@
<dimen name="folder_list_popup_width">200dip</dimen>
<dimen name="folder_list_folder_color_width">36dip</dimen>
<dimen name="folder_list_item_minimum_height">48dip</dimen>
+ <dimen name="folder_list_item_left_offset">9dp</dimen>
<dimen name="account_item_left_margin">14dp</dimen>
<dimen name="account_item_right_margin">8dp</dimen>
<dimen name="account_item_minimum_height">48dip</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 9fafa2d..cd4f70b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -152,9 +152,10 @@
<style name="UnreadCount">
<item name="android:layout_width">44dp</item>
<item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_centerVertical">true</item>
<item name="android:gravity">center</item>
<item name="android:singleLine">true</item>
- <item name="android:includeFontPadding">false</item>
+ <item name="android:includeFontPadding">true</item>
<item name="android:textSize">14sp</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">4dp</item>
@@ -181,6 +182,7 @@
<style name="UnseenCount">
<item name="android:layout_width">44dp</item>
<item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_centerVertical">true</item>
<item name="android:gravity">center</item>
<item name="android:singleLine">true</item>
<item name="android:includeFontPadding">false</item>
diff --git a/src/com/android/mail/adapter/DrawerItem.java b/src/com/android/mail/adapter/DrawerItem.java
index a372fdc..0991f68 100644
--- a/src/com/android/mail/adapter/DrawerItem.java
+++ b/src/com/android/mail/adapter/DrawerItem.java
@@ -362,7 +362,7 @@
}
folderItemView.bind(mFolder, mActivity);
Folder.setFolderBlockColor(mFolder, folderItemView.findViewById(R.id.color_block));
- Folder.setIcon(mFolder, (ImageView) folderItemView.findViewById(R.id.folder_icon));
+ folderItemView.setIcon(mFolder);
return folderItemView;
}
diff --git a/src/com/android/mail/ui/FolderItemView.java b/src/com/android/mail/ui/FolderItemView.java
index 1d9d857..329f59f 100644
--- a/src/com/android/mail/ui/FolderItemView.java
+++ b/src/com/android/mail/ui/FolderItemView.java
@@ -161,6 +161,23 @@
}
/**
+ * Sets the icon, if any. If the image view's visibility is set to gone, the text view will
+ * be moved over to account for the change.
+ */
+ public void setIcon(final Folder folder) {
+ final ImageView folderIconView = (ImageView) findViewById(R.id.folder_icon);
+ Folder.setIcon(folder, folderIconView);
+ if (folderIconView.getVisibility() == View.GONE) {
+ mFolderTextView.setPadding(getContext()
+ .getResources().getDimensionPixelSize(R.dimen.folder_list_item_left_offset),
+ 0, 0, 0 /* No top, right, bottom padding needed */);
+ } else {
+ // View recycling case
+ mFolderTextView.setPadding(0, 0, 0, 0);
+ }
+ }
+
+ /**
* Sets the unread count, taking care to hide/show the textview if the count is zero/non-zero.
*/
private void setUnreadCount(int count) {