am c364c96b: am a5de96be: Merge "Update widget colours / assets according to spec" into honeycomb

* commit 'c364c96bb07bc1cf9b2ccdce2199b7e2c970994c':
  Update widget colours / assets according to spec
This commit is contained in:
Todd Kennedy 2011-01-19 11:07:43 -08:00 committed by Android Git Automerger
commit 7b2500f934
9 changed files with 118 additions and 27 deletions

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2010, Google Inc. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:drawable="@drawable/header_row_focused_email_widget_holo" />
<item android:state_pressed="true"
android:drawable="@drawable/header_row_press_email_widget_holo" />
<item android:drawable="@drawable/bg_row_email_widget_holo" />
</selector>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:drawable="@drawable/header_row_focused_email_widget_holo" />
<item android:state_pressed="true"
android:drawable="@drawable/header_row_press_email_widget_holo" />
<item android:drawable="@drawable/bg_row_read_email_widget_holo" />
</selector>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:drawable="@drawable/header_row_focused_email_widget_holo" />
<item android:state_pressed="true"
android:drawable="@drawable/header_row_press_email_widget_holo" />
<item android:drawable="@drawable/bg_row_email_widget_holo" />
</selector>

View File

@ -22,13 +22,21 @@
android:paddingLeft="16dip"
android:paddingRight="8dip"
android:orientation="vertical"
android:background="@drawable/widget_conversation_selector"
android:background="@drawable/widget_unread_conversation_selector"
>
<ImageView
android:id="@+id/color_chip"
android:layout_width="32dip"
android:layout_height="8dip"
style="@style/widget_list_item"
android:layout_gravity="right|top"
android:visibility="visible"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8sp"
android:orientation="horizontal"
style="@style/widget_list_item"
>
<TextView
android:id="@+id/widget_from"
@ -38,6 +46,13 @@
android:paddingRight="16dip"
android:singleLine="true" />
<!-- Use negative margins to align attachment icon with text -->
<ImageView
android:id="@+id/widget_invite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10sp"
android:layout_marginRight="-4dip"
android:src="@drawable/ic_badge_invite" />
<ImageView
android:id="@+id/widget_attachment"
android:layout_width="wrap_content"
@ -54,6 +69,7 @@
android:id="@+id/widget_subject"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/widget_list_item"
android:layout_marginTop="-4sp"
android:maxLines="2"/>
</LinearLayout>

View File

@ -22,11 +22,4 @@
<!-- Standard text colors -->
<color name="text_primary_color">#000000</color>
<color name="text_secondary_color">#666666</color>
<!-- Widget colors -->
<color name="widget_label_shadow_color">#0d0d0d</color>
<color name="widget_account_color">#666666</color>
<color name="widget_unread_count_color">#4d4d4d</color>
<color name="widget_default_text_color">#000000</color>
<color name="widget_light_text_color">#666666</color>
</resources>

View File

@ -56,10 +56,10 @@
<!-- Widget colors -->
<color name="widget_label_shadow_color">#0d0d0d</color>
<color name="widget_account_color">#666666</color>
<color name="widget_unread_count_color">#4d4d4d</color>
<color name="widget_default_text_color">#000000</color>
<color name="widget_light_text_color">#666666</color>
<color name="widget_account_color">#99ffffff</color>
<color name="widget_unread_count_color">#b2ffffff</color>
<color name="widget_default_text_color">#ff000000</color>
<color name="widget_light_text_color">#ff666666</color>
<color name="message_view_info_back_color">#deecfa</color>
</resources>

View File

@ -72,6 +72,12 @@
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="widget_list_item">
<item name="android:textColor">?android:attr/textColorSecondary</item>
<item name="android:layout_marginLeft">16dip</item>
<item name="android:layout_marginRight">8dip</item>
</style>
<style name="message_details_label">
<item name="android:textSize">14dip</item>
<item name="android:textColor">@color/text_secondary_color</item>

View File

@ -18,23 +18,28 @@ package com.android.email;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Paint;
/**
* Helper class to load resources.
*/
public class ResourceHelper {
public final static int UNDEFINED_RESOURCE_ID = -1;
private static ResourceHelper sInstance;
private final Context mContext;
private final Resources mResources;
private final int[] mAccountColors;
private final Paint[] mAccountColorPaints;
private final TypedArray mAccountColorArray;
private ResourceHelper(Context context) {
mContext = context.getApplicationContext();
mResources = mContext.getResources();
mAccountColorArray = mResources.obtainTypedArray(R.array.combined_view_account_colors);
mAccountColors = mResources.getIntArray(R.array.combined_view_account_colors);
mAccountColorPaints = new Paint[mAccountColors.length];
for (int i = 0; i < mAccountColors.length; i++) {
@ -64,6 +69,15 @@ public class ResourceHelper {
return mAccountColors[getAccountColorIndex(accountId)];
}
/**
* @return The resource ID for an account color.
* Otherwise, {@value #UNDEFINED_RESOURCE_ID} if color was not specified via ID.
*/
public int getAccountColorId(long accountId) {
return mAccountColorArray.getResourceId(getAccountColorIndex(accountId),
UNDEFINED_RESOURCE_ID);
}
/**
* @return {@link Paint} equivalent to {@link #getAccountColor}.
*/

View File

@ -18,6 +18,7 @@ package com.android.email.provider;
import com.android.email.Email;
import com.android.email.R;
import com.android.email.ResourceHelper;
import com.android.email.Utility;
import com.android.email.activity.MessageCompose;
import com.android.email.activity.Welcome;
@ -161,6 +162,7 @@ public class WidgetProvider extends AppWidgetProvider {
private int mCursorCount = TOTAL_COUNT_UNKNOWN;
// The widget's loader (derived from ThrottlingCursorLoader)
private WidgetLoader mLoader;
private final ResourceHelper mResourceHelper;
// The current view type (all mail, unread, or starred for now)
/*package*/ ViewType mViewType = ViewType.STARRED;
@ -170,7 +172,7 @@ public class WidgetProvider extends AppWidgetProvider {
EmailContent.RECORD_ID, MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
MessageColumns.SUBJECT, MessageColumns.FLAG_READ, MessageColumns.FLAG_FAVORITE,
MessageColumns.FLAG_ATTACHMENT, MessageColumns.MAILBOX_KEY, MessageColumns.SNIPPET,
MessageColumns.ACCOUNT_KEY
MessageColumns.ACCOUNT_KEY, MessageColumns.FLAGS
};
public static final int WIDGET_COLUMN_ID = 0;
public static final int WIDGET_COLUMN_DISPLAY_NAME = 1;
@ -182,6 +184,7 @@ public class WidgetProvider extends AppWidgetProvider {
public static final int WIDGET_COLUMN_MAILBOX_KEY = 7;
public static final int WIDGET_COLUMN_SNIPPET = 8;
public static final int WIDGET_COLUMN_ACCOUNT_KEY = 9;
public static final int WIDGET_COLUMN_FLAGS = 10;
public EmailWidget(int _widgetId) {
super();
@ -203,6 +206,7 @@ public class WidgetProvider extends AppWidgetProvider {
sLightTextColor = res.getColor(R.color.widget_light_text_color);
sConfigureText = res.getString(R.string.widget_other_views);
}
mResourceHelper = ResourceHelper.getInstance(sContext);
}
/**
@ -471,6 +475,11 @@ public class WidgetProvider extends AppWidgetProvider {
RemoteViews views =
new RemoteViews(sContext.getPackageName(), R.layout.widget_list_item);
boolean isUnread = mCursor.getInt(WIDGET_COLUMN_FLAG_READ) != 1;
int drawableId = R.drawable.widget_read_conversation_selector;
if (isUnread) {
drawableId = R.drawable.widget_unread_conversation_selector;
}
views.setInt(R.id.widget_message, "setBackgroundResource", drawableId);
// Add style to sender
SpannableStringBuilder from =
@ -495,10 +504,27 @@ public class WidgetProvider extends AppWidgetProvider {
getStyledSubjectSnippet(subject, snippet, !isUnread);
views.setTextViewText(R.id.widget_subject, subjectAndSnippet);
if (mCursor.getInt(WIDGET_COLUMN_FLAG_ATTACHMENT) != 0) {
views.setViewVisibility(R.id.widget_attachment, View.VISIBLE);
int messageFlags = mCursor.getInt(WIDGET_COLUMN_FLAGS);
boolean hasInvite = (messageFlags & Message.FLAG_INCOMING_MEETING_INVITE) != 0;
views.setViewVisibility(R.id.widget_invite, hasInvite ? View.VISIBLE : View.GONE);
boolean hasAttachment = mCursor.getInt(WIDGET_COLUMN_FLAG_ATTACHMENT) != 0;
views.setViewVisibility(R.id.widget_attachment,
hasAttachment ? View.VISIBLE : View.GONE);
if (mViewType == ViewType.ACCOUNT) {
views.setViewVisibility(R.id.color_chip, View.INVISIBLE);
} else {
views.setViewVisibility(R.id.widget_attachment, View.GONE);
long accountId = mCursor.getLong(WIDGET_COLUMN_ACCOUNT_KEY);
int colorId = mResourceHelper.getAccountColorId(accountId);
if (colorId != ResourceHelper.UNDEFINED_RESOURCE_ID) {
// Color defined by resource ID, so, use it
views.setViewVisibility(R.id.color_chip, View.VISIBLE);
views.setImageViewResource(R.id.color_chip, colorId);
} else {
// Color not defined by resource ID, nothing we can do, so, hide the chip
views.setViewVisibility(R.id.color_chip, View.INVISIBLE);
}
}
// Set button intents for view, reply, and delete