Widget refresh.
Different fonts and alignments. Different header background.
Todo: remove unread count and decide if we want to cycle between account name
and unread text.
Bug: 10074523
Change-Id: I85968446e135cc896c9f20dc049466cb8811e4fa
diff --git a/res/drawable-hdpi/header_bg_widget_holo.9.png b/res/drawable-hdpi/header_bg_widget_holo.9.png
index 6216ba3..af917e5 100644
--- a/res/drawable-hdpi/header_bg_widget_holo.9.png
+++ b/res/drawable-hdpi/header_bg_widget_holo.9.png
Binary files differ
diff --git a/res/drawable-mdpi/header_bg_widget_holo.9.png b/res/drawable-mdpi/header_bg_widget_holo.9.png
index 500cc4c..17c1fb9 100644
--- a/res/drawable-mdpi/header_bg_widget_holo.9.png
+++ b/res/drawable-mdpi/header_bg_widget_holo.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/header_bg_widget_holo.9.png b/res/drawable-xhdpi/header_bg_widget_holo.9.png
index fa41141..c427297 100644
--- a/res/drawable-xhdpi/header_bg_widget_holo.9.png
+++ b/res/drawable-xhdpi/header_bg_widget_holo.9.png
Binary files differ
diff --git a/res/layout/widget.xml b/res/layout/widget.xml
index aebc6c9..a23d98c 100644
--- a/res/layout/widget.xml
+++ b/res/layout/widget.xml
@@ -106,7 +106,8 @@
android:layout_height="0dip"
android:layout_weight="1"
android:cacheColorHint="#00000000"
- android:background="@drawable/gradient_bg_widget_holo" />
+ android:background="@drawable/gradient_bg_widget_holo"
+ style="@style/ConversationListFade" />
<TextView
android:id="@+id/empty_conversation_list"
android:layout_width="match_parent"
@@ -148,8 +149,4 @@
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/list_div_top_btm_widget_holo" />
</LinearLayout>
diff --git a/res/layout/widget_conversation.xml b/res/layout/widget_conversation_list_item.xml
similarity index 93%
rename from res/layout/widget_conversation.xml
rename to res/layout/widget_conversation_list_item.xml
index 77a13c3..457ca2d 100644
--- a/res/layout/widget_conversation.xml
+++ b/res/layout/widget_conversation_list_item.xml
@@ -18,9 +18,9 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/widget_conversation"
+ android:id="@+id/widget_conversation_list_item"
android:layout_width="match_parent"
- android:layout_height="70sp">
+ android:layout_height="72sp">
<!--
Remote view doesn't allow changing background so we have to work around
by having 2 image views here.
@@ -36,12 +36,13 @@
android:layout_height="match_parent"
android:background="@drawable/widget_conversation_read_selector" />
<RelativeLayout
+ android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dip"
- android:paddingRight="8dip"
- android:orientation="vertical">
+ android:paddingRight="16dip">
<RelativeLayout
+ android:id="@+id/labels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
@@ -91,11 +92,12 @@
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/widget_attachment_and_date"
- android:layout_marginTop="6sp"
+ android:layout_marginTop="10sp"
android:paddingRight="16dip"
android:singleLine="true"
android:ellipsize="end"
android:textSize="@dimen/senders_font_size"
+ android:textColor="#58585b"
android:includeFontPadding="false" />
<TextView
android:id="@+id/widget_subject"
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index c309428..3f822b7 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -86,7 +86,7 @@
<dimen name="account_item_folder_color_width">36dip</dimen>
<dimen name="account_radio_button_length">16dp</dimen>
<dimen name="widget_senders_font_size">18sp</dimen>
- <dimen name="widget_subject_font_size">14sp</dimen>
+ <dimen name="widget_subject_font_size">13sp</dimen>
<dimen name="widget_date_font_size">12sp</dimen>
<dimen name="widget_margin_top">0dip</dimen>
<dimen name="widget_margin_left">0dip</dimen>
diff --git a/src/com/android/mail/ui/ConversationListView.java b/src/com/android/mail/ui/ConversationListView.java
index 25ac4a6..5c1e691 100644
--- a/src/com/android/mail/ui/ConversationListView.java
+++ b/src/com/android/mail/ui/ConversationListView.java
@@ -26,6 +26,7 @@
import com.android.mail.R;
import com.android.mail.utils.LogTag;
import com.android.mail.utils.LogUtils;
+import com.android.mail.utils.Utils;
/**
* Conversation list view contains a {@link SwipeableListView} and a sync status bar above it.
@@ -382,7 +383,6 @@
setVisibility(View.GONE);
}
};
- private static final int[] STYLE_ATTR = new int[] {android.R.attr.background};
public HintText(final Context context) {
this(context, null);
@@ -404,20 +404,8 @@
setVisibility(View.GONE);
// Set background color to be same as action bar color
- TypedValue actionBarStyle = new TypedValue();
- if (context.getTheme().resolveAttribute(
- android.R.attr.actionBarStyle, actionBarStyle, true) &&
- actionBarStyle.type == TypedValue.TYPE_REFERENCE) {
- TypedValue backgroundValue = new TypedValue();
- TypedArray attr = context.obtainStyledAttributes(actionBarStyle.resourceId,
- STYLE_ATTR);
- attr.getValue(0, backgroundValue);
- setBackgroundResource(backgroundValue.resourceId);
- attr.recycle();
- } else {
- // Default color
- setBackgroundColor(getResources().getColor(R.color.list_background_color));
- }
+ final int actionBarRes = Utils.getActionBarBackgroundResource(context);
+ setBackgroundResource(actionBarRes);
}
private void displaySwipeToRefresh() {
diff --git a/src/com/android/mail/utils/Utils.java b/src/com/android/mail/utils/Utils.java
index 251e95e..b15439b 100644
--- a/src/com/android/mail/utils/Utils.java
+++ b/src/com/android/mail/utils/Utils.java
@@ -29,6 +29,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Typeface;
@@ -46,6 +47,7 @@
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
+import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -130,6 +132,8 @@
public static final SimpleTimer sConvLoadTimer =
new SimpleTimer(ENABLE_CONV_LOAD_TIMER).withSessionName("ConvLoadTimer");
+ private static final int[] STYLE_ATTR = new int[] {android.R.attr.background};
+
public static boolean isRunningJellybeanOrLater() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
}
@@ -1354,4 +1358,22 @@
}
}
+ /**
+ * Get the background color of Gmail's action bar.
+ */
+ public static int getActionBarBackgroundResource(final Context context) {
+ final TypedValue actionBarStyle = new TypedValue();
+ if (context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, actionBarStyle, true)
+ && actionBarStyle.type == TypedValue.TYPE_REFERENCE) {
+ final TypedValue backgroundValue = new TypedValue();
+ final TypedArray attr = context.obtainStyledAttributes(actionBarStyle.resourceId,
+ STYLE_ATTR);
+ attr.getValue(0, backgroundValue);
+ attr.recycle();
+ return backgroundValue.resourceId;
+ } else {
+ // Default color
+ return context.getResources().getColor(R.color.list_background_color);
+ }
+ }
}
diff --git a/src/com/android/mail/widget/BaseWidgetProvider.java b/src/com/android/mail/widget/BaseWidgetProvider.java
index 763740c..6743615 100644
--- a/src/com/android/mail/widget/BaseWidgetProvider.java
+++ b/src/com/android/mail/widget/BaseWidgetProvider.java
@@ -312,9 +312,9 @@
protected void updateWidgetInternal(Context context, int appWidgetId, Account account,
final int folderType, final Uri folderUri, final Uri folderConversationListUri,
final String folderDisplayName) {
- RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
- final boolean isAccountValid = isAccountValid(context, account);
+ final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
+ final boolean isAccountValid = isAccountValid(context, account);
if (!isAccountValid || Utils.isEmpty(folderUri)) {
// Widget has not been configured yet
remoteViews.setViewVisibility(R.id.widget_folder, View.GONE);
diff --git a/src/com/android/mail/widget/WidgetConversationViewBuilder.java b/src/com/android/mail/widget/WidgetConversationListItemViewBuilder.java
similarity index 89%
rename from src/com/android/mail/widget/WidgetConversationViewBuilder.java
rename to src/com/android/mail/widget/WidgetConversationListItemViewBuilder.java
index 77c1992..585eddf 100644
--- a/src/com/android/mail/widget/WidgetConversationViewBuilder.java
+++ b/src/com/android/mail/widget/WidgetConversationListItemViewBuilder.java
@@ -35,7 +35,7 @@
import android.view.View;
import android.widget.RemoteViews;
-public class WidgetConversationViewBuilder {
+public class WidgetConversationListItemViewBuilder {
// Static font sizes
private static int DATE_FONT_SIZE;
private static int SUBJECT_FONT_SIZE;
@@ -112,7 +112,7 @@
/*
* Get font sizes and bitmaps from Resources
*/
- public WidgetConversationViewBuilder(Context context) {
+ public WidgetConversationListItemViewBuilder(Context context) {
mContext = context;
Resources res = context.getResources();
@@ -146,20 +146,20 @@
/*
* Return the full View
*/
- public RemoteViews getStyledView(CharSequence date, Conversation conversation,
+ public RemoteViews getStyledView(final CharSequence date, final Conversation conversation,
final FolderUri folderUri, final int ignoreFolderType,
- SpannableStringBuilder senders, String filteredSubject) {
+ final SpannableStringBuilder senders, final String filteredSubject) {
final boolean isUnread = !conversation.read;
- String snippet = conversation.getSnippet();
- boolean hasAttachments = conversation.hasAttachments;
+ final String snippet = conversation.getSnippet();
+ final boolean hasAttachments = conversation.hasAttachments;
// Add style to date
- CharSequence styledDate = addStyle(date, DATE_FONT_SIZE, DATE_TEXT_COLOR);
+ final CharSequence styledDate = addStyle(date, DATE_FONT_SIZE, DATE_TEXT_COLOR);
// Add style to subject
- int subjectColor = isUnread ? SUBJECT_TEXT_COLOR_UNREAD : SUBJECT_TEXT_COLOR_READ;
- SpannableStringBuilder subjectAndSnippet = new SpannableStringBuilder(
+ final int subjectColor = isUnread ? SUBJECT_TEXT_COLOR_UNREAD : SUBJECT_TEXT_COLOR_READ;
+ final SpannableStringBuilder subjectAndSnippet = new SpannableStringBuilder(
Conversation.getSubjectAndSnippetForDisplay(mContext, filteredSubject, snippet));
if (isUnread) {
subjectAndSnippet.setSpan(new StyleSpan(Typeface.BOLD), 0, filteredSubject.length(),
@@ -167,7 +167,7 @@
}
subjectAndSnippet.setSpan(new ForegroundColorSpan(subjectColor), 0, subjectAndSnippet
.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- CharSequence styledSubject = addStyle(subjectAndSnippet, SUBJECT_FONT_SIZE, 0);
+ final CharSequence styledSubject = addStyle(subjectAndSnippet, SUBJECT_FONT_SIZE, 0);
// Paper clip for attachment
Bitmap paperclipBitmap = null;
@@ -176,8 +176,8 @@
}
// Inflate and fill out the remote view
- RemoteViews remoteViews = new RemoteViews(
- mContext.getPackageName(), R.layout.widget_conversation);
+ final RemoteViews remoteViews = new RemoteViews(
+ mContext.getPackageName(), R.layout.widget_conversation_list_item);
remoteViews.setTextViewText(R.id.widget_senders, senders);
remoteViews.setTextViewText(R.id.widget_date, styledDate);
remoteViews.setTextViewText(R.id.widget_subject, styledSubject);
diff --git a/src/com/android/mail/widget/WidgetService.java b/src/com/android/mail/widget/WidgetService.java
index a8a45f3..c49eb7d 100644
--- a/src/com/android/mail/widget/WidgetService.java
+++ b/src/com/android/mail/widget/WidgetService.java
@@ -209,7 +209,7 @@
private final Uri mFolderUri;
private final Uri mFolderConversationListUri;
private final String mFolderDisplayName;
- private final WidgetConversationViewBuilder mWidgetConversationViewBuilder;
+ private final WidgetConversationListItemViewBuilder mWidgetConversationListItemViewBuilder;
private CursorLoader mConversationCursorLoader;
private Cursor mConversationCursor;
private CursorLoader mFolderLoader;
@@ -253,7 +253,8 @@
}
}
- mWidgetConversationViewBuilder = new WidgetConversationViewBuilder(context);
+ mWidgetConversationListItemViewBuilder = new WidgetConversationListItemViewBuilder(
+ context);
mService = service;
}
@@ -414,12 +415,12 @@
}
// Load up our remote view.
- RemoteViews remoteViews = mWidgetConversationViewBuilder.getStyledView(date,
+ RemoteViews remoteViews = mWidgetConversationListItemViewBuilder.getStyledView(date,
conversation, new FolderUri(mFolderUri), ignoreFolderType,
senderBuilder, filterTag(conversation.subject));
// On click intent.
- remoteViews.setOnClickFillInIntent(R.id.widget_conversation,
+ remoteViews.setOnClickFillInIntent(R.id.widget_conversation_list_item,
Utils.createViewConversationIntent(mContext, conversation, mFolderUri,
mAccount));