* commit 'c364c96bb07bc1cf9b2ccdce2199b7e2c970994c': Update widget colours / assets according to spec
This commit is contained in:
commit
7b2500f934
@ -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>
|
|
23
res/drawable/widget_read_conversation_selector.xml
Normal file
23
res/drawable/widget_read_conversation_selector.xml
Normal 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>
|
23
res/drawable/widget_unread_conversation_selector.xml
Normal file
23
res/drawable/widget_unread_conversation_selector.xml
Normal 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>
|
@ -22,13 +22,21 @@
|
|||||||
android:paddingLeft="16dip"
|
android:paddingLeft="16dip"
|
||||||
android:paddingRight="8dip"
|
android:paddingRight="8dip"
|
||||||
android:orientation="vertical"
|
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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8sp"
|
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
style="@style/widget_list_item"
|
||||||
>
|
>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/widget_from"
|
android:id="@+id/widget_from"
|
||||||
@ -38,6 +46,13 @@
|
|||||||
android:paddingRight="16dip"
|
android:paddingRight="16dip"
|
||||||
android:singleLine="true" />
|
android:singleLine="true" />
|
||||||
<!-- Use negative margins to align attachment icon with text -->
|
<!-- 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
|
<ImageView
|
||||||
android:id="@+id/widget_attachment"
|
android:id="@+id/widget_attachment"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -54,6 +69,7 @@
|
|||||||
android:id="@+id/widget_subject"
|
android:id="@+id/widget_subject"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
style="@style/widget_list_item"
|
||||||
android:layout_marginTop="-4sp"
|
android:layout_marginTop="-4sp"
|
||||||
android:maxLines="2"/>
|
android:maxLines="2"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -22,11 +22,4 @@
|
|||||||
<!-- Standard text colors -->
|
<!-- Standard text colors -->
|
||||||
<color name="text_primary_color">#000000</color>
|
<color name="text_primary_color">#000000</color>
|
||||||
<color name="text_secondary_color">#666666</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>
|
</resources>
|
||||||
|
@ -56,10 +56,10 @@
|
|||||||
|
|
||||||
<!-- Widget colors -->
|
<!-- Widget colors -->
|
||||||
<color name="widget_label_shadow_color">#0d0d0d</color>
|
<color name="widget_label_shadow_color">#0d0d0d</color>
|
||||||
<color name="widget_account_color">#666666</color>
|
<color name="widget_account_color">#99ffffff</color>
|
||||||
<color name="widget_unread_count_color">#4d4d4d</color>
|
<color name="widget_unread_count_color">#b2ffffff</color>
|
||||||
<color name="widget_default_text_color">#000000</color>
|
<color name="widget_default_text_color">#ff000000</color>
|
||||||
<color name="widget_light_text_color">#666666</color>
|
<color name="widget_light_text_color">#ff666666</color>
|
||||||
|
|
||||||
<color name="message_view_info_back_color">#deecfa</color>
|
<color name="message_view_info_back_color">#deecfa</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -72,6 +72,12 @@
|
|||||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||||
</style>
|
</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">
|
<style name="message_details_label">
|
||||||
<item name="android:textSize">14dip</item>
|
<item name="android:textSize">14dip</item>
|
||||||
<item name="android:textColor">@color/text_secondary_color</item>
|
<item name="android:textColor">@color/text_secondary_color</item>
|
||||||
|
@ -18,23 +18,28 @@ package com.android.email;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to load resources.
|
* Helper class to load resources.
|
||||||
*/
|
*/
|
||||||
public class ResourceHelper {
|
public class ResourceHelper {
|
||||||
|
public final static int UNDEFINED_RESOURCE_ID = -1;
|
||||||
|
|
||||||
private static ResourceHelper sInstance;
|
private static ResourceHelper sInstance;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final Resources mResources;
|
private final Resources mResources;
|
||||||
|
|
||||||
private final int[] mAccountColors;
|
private final int[] mAccountColors;
|
||||||
private final Paint[] mAccountColorPaints;
|
private final Paint[] mAccountColorPaints;
|
||||||
|
private final TypedArray mAccountColorArray;
|
||||||
|
|
||||||
private ResourceHelper(Context context) {
|
private ResourceHelper(Context context) {
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
mResources = mContext.getResources();
|
mResources = mContext.getResources();
|
||||||
|
|
||||||
|
mAccountColorArray = mResources.obtainTypedArray(R.array.combined_view_account_colors);
|
||||||
mAccountColors = mResources.getIntArray(R.array.combined_view_account_colors);
|
mAccountColors = mResources.getIntArray(R.array.combined_view_account_colors);
|
||||||
mAccountColorPaints = new Paint[mAccountColors.length];
|
mAccountColorPaints = new Paint[mAccountColors.length];
|
||||||
for (int i = 0; i < mAccountColors.length; i++) {
|
for (int i = 0; i < mAccountColors.length; i++) {
|
||||||
@ -64,6 +69,15 @@ public class ResourceHelper {
|
|||||||
return mAccountColors[getAccountColorIndex(accountId)];
|
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}.
|
* @return {@link Paint} equivalent to {@link #getAccountColor}.
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +18,7 @@ package com.android.email.provider;
|
|||||||
|
|
||||||
import com.android.email.Email;
|
import com.android.email.Email;
|
||||||
import com.android.email.R;
|
import com.android.email.R;
|
||||||
|
import com.android.email.ResourceHelper;
|
||||||
import com.android.email.Utility;
|
import com.android.email.Utility;
|
||||||
import com.android.email.activity.MessageCompose;
|
import com.android.email.activity.MessageCompose;
|
||||||
import com.android.email.activity.Welcome;
|
import com.android.email.activity.Welcome;
|
||||||
@ -161,6 +162,7 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||||||
private int mCursorCount = TOTAL_COUNT_UNKNOWN;
|
private int mCursorCount = TOTAL_COUNT_UNKNOWN;
|
||||||
// The widget's loader (derived from ThrottlingCursorLoader)
|
// The widget's loader (derived from ThrottlingCursorLoader)
|
||||||
private WidgetLoader mLoader;
|
private WidgetLoader mLoader;
|
||||||
|
private final ResourceHelper mResourceHelper;
|
||||||
|
|
||||||
// The current view type (all mail, unread, or starred for now)
|
// The current view type (all mail, unread, or starred for now)
|
||||||
/*package*/ ViewType mViewType = ViewType.STARRED;
|
/*package*/ ViewType mViewType = ViewType.STARRED;
|
||||||
@ -170,7 +172,7 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||||||
EmailContent.RECORD_ID, MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
|
EmailContent.RECORD_ID, MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
|
||||||
MessageColumns.SUBJECT, MessageColumns.FLAG_READ, MessageColumns.FLAG_FAVORITE,
|
MessageColumns.SUBJECT, MessageColumns.FLAG_READ, MessageColumns.FLAG_FAVORITE,
|
||||||
MessageColumns.FLAG_ATTACHMENT, MessageColumns.MAILBOX_KEY, MessageColumns.SNIPPET,
|
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_ID = 0;
|
||||||
public static final int WIDGET_COLUMN_DISPLAY_NAME = 1;
|
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_MAILBOX_KEY = 7;
|
||||||
public static final int WIDGET_COLUMN_SNIPPET = 8;
|
public static final int WIDGET_COLUMN_SNIPPET = 8;
|
||||||
public static final int WIDGET_COLUMN_ACCOUNT_KEY = 9;
|
public static final int WIDGET_COLUMN_ACCOUNT_KEY = 9;
|
||||||
|
public static final int WIDGET_COLUMN_FLAGS = 10;
|
||||||
|
|
||||||
public EmailWidget(int _widgetId) {
|
public EmailWidget(int _widgetId) {
|
||||||
super();
|
super();
|
||||||
@ -203,6 +206,7 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||||||
sLightTextColor = res.getColor(R.color.widget_light_text_color);
|
sLightTextColor = res.getColor(R.color.widget_light_text_color);
|
||||||
sConfigureText = res.getString(R.string.widget_other_views);
|
sConfigureText = res.getString(R.string.widget_other_views);
|
||||||
}
|
}
|
||||||
|
mResourceHelper = ResourceHelper.getInstance(sContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -471,6 +475,11 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||||||
RemoteViews views =
|
RemoteViews views =
|
||||||
new RemoteViews(sContext.getPackageName(), R.layout.widget_list_item);
|
new RemoteViews(sContext.getPackageName(), R.layout.widget_list_item);
|
||||||
boolean isUnread = mCursor.getInt(WIDGET_COLUMN_FLAG_READ) != 1;
|
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
|
// Add style to sender
|
||||||
SpannableStringBuilder from =
|
SpannableStringBuilder from =
|
||||||
@ -495,10 +504,27 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||||||
getStyledSubjectSnippet(subject, snippet, !isUnread);
|
getStyledSubjectSnippet(subject, snippet, !isUnread);
|
||||||
views.setTextViewText(R.id.widget_subject, subjectAndSnippet);
|
views.setTextViewText(R.id.widget_subject, subjectAndSnippet);
|
||||||
|
|
||||||
if (mCursor.getInt(WIDGET_COLUMN_FLAG_ATTACHMENT) != 0) {
|
int messageFlags = mCursor.getInt(WIDGET_COLUMN_FLAGS);
|
||||||
views.setViewVisibility(R.id.widget_attachment, View.VISIBLE);
|
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 {
|
} 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
|
// Set button intents for view, reply, and delete
|
||||||
|
Loading…
Reference in New Issue
Block a user