am ea1d5014: fix refresh ProgressBar halo
* commit 'ea1d5014bead3dcb1c9653d5a2dcc58442670be7':
fix refresh ProgressBar halo
diff --git a/Android.mk b/Android.mk
index a1c9cb6..1cf0bb6 100644
--- a/Android.mk
+++ b/Android.mk
@@ -39,7 +39,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs)) \
$(call all-logtags-files-under, $(src_dirs))
-LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs)) $(LOCAL_PATH)/res
+LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs))
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages com.android.ex.chips:com.android.ex.photo
diff --git a/res/color/folder_item_text_color.xml b/res/color/folder_item_text_color.xml
index ab79a8d..47e27f0 100644
--- a/res/color/folder_item_text_color.xml
+++ b/res/color/folder_item_text_color.xml
@@ -16,7 +16,10 @@
limitations under the License.
-->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item app:state_drag_mode="true" android:state_drag_can_accept="false"
+ android:color="@color/folder_disabled_drop_target_text_color" />
<item android:state_activated="true" android:color="@android:color/white" />
<item android:color="@color/dark_gray_text_color" />
</selector>
diff --git a/res/drawable/folder_item.xml b/res/drawable/folder_item.xml
index c28ae55..4fd24d0 100644
--- a/res/drawable/folder_item.xml
+++ b/res/drawable/folder_item.xml
@@ -16,7 +16,13 @@
limitations under the License.
-->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item app:state_drag_mode="true"
+ android:state_drag_can_accept="true" android:state_drag_hovered="true"
+ android:drawable="@drawable/list_pressed_holo" />
+ <item app:state_drag_mode="true"
+ android:drawable="@drawable/ic_drawer_divider" />
<item android:state_pressed="true" android:drawable="@drawable/list_pressed_holo" />
<item android:state_activated="true" android:drawable="@color/mail_app_blue" />
<item android:state_focused="true" android:drawable="@drawable/list_focused_holo" />
diff --git a/res/layout/folder_item.xml b/res/layout/folder_item.xml
index c36d272..334c312 100644
--- a/res/layout/folder_item.xml
+++ b/res/layout/folder_item.xml
@@ -44,10 +44,12 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/folder_list_item_right_margin"
- android:layout_alignParentRight="true">
+ android:layout_alignParentRight="true"
+ android:duplicateParentState="true">
<TextView
android:id="@+id/unread"
+ android:duplicateParentState="true"
style="@style/UnreadCount" />
<TextView
@@ -63,6 +65,7 @@
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/folder_list_item_left_margin"
android:layout_alignParentLeft="true"
+ android:duplicateParentState="true"
android:visibility="gone" />
<TextView
@@ -75,6 +78,7 @@
android:layout_alignWithParentIfMissing="true"
android:layout_marginLeft="@dimen/folder_list_item_left_margin"
android:layout_marginRight="@dimen/folder_list_item_right_margin"
+ android:duplicateParentState="true"
android:includeFontPadding="false"
android:maxLines="2"
android:ellipsize="end"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 70fc10a..0a2d767 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -27,4 +27,7 @@
<add-resource name="RecipientComposeFieldLayout" type="style" />
<add-resource name="ComposeBodyStyle" type="style" />
<add-resource name="ComposeSubjectStyle" type="style" />
+ <declare-styleable name="FolderItemViewDrawableState">
+ <attr name="state_drag_mode" format="boolean" />
+ </declare-styleable>
</resources>
diff --git a/src/com/android/mail/MailIntentService.java b/src/com/android/mail/MailIntentService.java
index 065e5fd..2fa0717 100644
--- a/src/com/android/mail/MailIntentService.java
+++ b/src/com/android/mail/MailIntentService.java
@@ -66,7 +66,7 @@
final Account account = intent.getParcelableExtra(Utils.EXTRA_ACCOUNT);
final Folder folder = intent.getParcelableExtra(Utils.EXTRA_FOLDER);
- NotificationUtils.clearFolderNotification(this, account, folder);
+ NotificationUtils.clearFolderNotification(this, account, folder, true /* markSeen */);
} else if (ACTION_RESEND_NOTIFICATIONS.equals(action)) {
final Uri accountUri = intent.getParcelableExtra(Utils.EXTRA_ACCOUNT_URI);
final Uri folderUri = intent.getParcelableExtra(Utils.EXTRA_FOLDER_URI);
diff --git a/src/com/android/mail/providers/UIProvider.java b/src/com/android/mail/providers/UIProvider.java
index 8c6ca86..731e356 100644
--- a/src/com/android/mail/providers/UIProvider.java
+++ b/src/com/android/mail/providers/UIProvider.java
@@ -577,11 +577,6 @@
*/
public static final String QUERY = "query";
- /**
- * If specified, the query results will be limited to this folder.
- */
- public static final String FOLDER = "folder";
-
private SearchQueryParameters() {}
}
diff --git a/src/com/android/mail/ui/AbstractMailActivity.java b/src/com/android/mail/ui/AbstractMailActivity.java
index 33a7da2..43f3b23 100644
--- a/src/com/android/mail/ui/AbstractMailActivity.java
+++ b/src/com/android/mail/ui/AbstractMailActivity.java
@@ -39,7 +39,7 @@
private final UiHandler mUiHandler = new UiHandler();
- private static final boolean STRICT_MODE = false;
+ private static final boolean STRICT_MODE = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/src/com/android/mail/ui/ConversationViewFragment.java b/src/com/android/mail/ui/ConversationViewFragment.java
index c119861..2220f2f 100644
--- a/src/com/android/mail/ui/ConversationViewFragment.java
+++ b/src/com/android/mail/ui/ConversationViewFragment.java
@@ -677,6 +677,10 @@
}
prevCollapsedMsg = msg;
prevSafeForImages = safeForImages;
+
+ // This line puts the from address in the address cache so that
+ // we get the sender image for it if it's in a super-collapsed block.
+ getAddress(msg.getFrom());
continue;
}
diff --git a/src/com/android/mail/ui/FolderDisplayer.java b/src/com/android/mail/ui/FolderDisplayer.java
index 4c4a68c..71c6c38 100644
--- a/src/com/android/mail/ui/FolderDisplayer.java
+++ b/src/com/android/mail/ui/FolderDisplayer.java
@@ -53,7 +53,7 @@
/**
* Configure the FolderDisplayer object by parsing the rawFolders string.
*
- * @param foldersString string containing serialized folders to display.
+ * @param conv {@link Conversation} containing the folders to display.
* @param ignoreFolderUri (optional) folder to omit from the displayed set
* @param ignoreFolderType -1, or the {@link FolderType} to omit from the displayed set
*/
diff --git a/src/com/android/mail/ui/FolderItemView.java b/src/com/android/mail/ui/FolderItemView.java
index 329f59f..9e3b1c3 100644
--- a/src/com/android/mail/ui/FolderItemView.java
+++ b/src/com/android/mail/ui/FolderItemView.java
@@ -43,19 +43,8 @@
*/
public class FolderItemView extends RelativeLayout {
private final String LOG_TAG = LogTag.getLogTag();
- // Static colors
- private static int NON_DROPPABLE_TARGET_TEXT_COLOR;
- // Static bitmap
- private static Bitmap SHORTCUT_ICON;
-
- // These are fine to be static, as these Drawables only have one state
- private static Drawable DROPPABLE_HOVER_BACKGROUND;
- private static Drawable DRAG_STEADY_STATE_BACKGROUND;
-
- private Drawable mBackground;
- private ColorStateList mInitialFolderTextColor;
- private ColorStateList mInitialUnreadCountTextColor;
+ private static final int[] STATE_DRAG_MODE = {R.attr.state_drag_mode};
private Folder mFolder;
private TextView mFolderTextView;
@@ -64,6 +53,8 @@
private DropHandler mDropHandler;
private ImageView mFolderParentIcon;
+ private boolean mIsDragMode;
+
/**
* A delegate for a handler to handle a drop of an item.
*/
@@ -91,28 +82,17 @@
public FolderItemView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+
+ mIsDragMode = false;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- if (SHORTCUT_ICON == null) {
- final Resources res = getResources();
- SHORTCUT_ICON = BitmapFactory.decodeResource(
- res, R.mipmap.ic_launcher_shortcut_folder);
- DROPPABLE_HOVER_BACKGROUND =
- res.getDrawable(R.drawable.folder_drag_target);
- DRAG_STEADY_STATE_BACKGROUND =
- res.getDrawable(R.drawable.folder_no_hover);
- NON_DROPPABLE_TARGET_TEXT_COLOR =
- res.getColor(R.color.folder_disabled_drop_target_text_color);
- }
+
mFolderTextView = (TextView)findViewById(R.id.name);
mUnreadCountTextView = (TextView)findViewById(R.id.unread);
mUnseenCountTextView = (TextView)findViewById(R.id.unseen);
- mBackground = getBackground();
- mInitialFolderTextColor = mFolderTextView.getTextColors();
- mInitialUnreadCountTextColor = mUnreadCountTextView.getTextColors();
mFolderParentIcon = (ImageView) findViewById(R.id.folder_parent_icon);
}
@@ -221,43 +201,20 @@
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
- // If this folder is not a drop target, dim the text.
- if (!isDroppableTarget(event)) {
- // Make sure we update this at the time we drop on the target.
- mInitialFolderTextColor = mFolderTextView.getTextColors();
- mInitialUnreadCountTextColor = mUnreadCountTextView.getTextColors();
- mFolderTextView.setTextColor(NON_DROPPABLE_TARGET_TEXT_COLOR);
- mUnreadCountTextView.setTextColor(NON_DROPPABLE_TARGET_TEXT_COLOR);
- }
- // Set the background to a steady state background.
- setBackgroundDrawable(DRAG_STEADY_STATE_BACKGROUND);
- return true;
-
+ // Set drag mode state to true now that we have entered drag mode.
+ // This change updates the states of icons and text colors.
+ // Additional drawable states are updated by the framework
+ // based on the DragEvent.
+ setDragMode(true);
case DragEvent.ACTION_DRAG_ENTERED:
- // Change background color to indicate this folder is the drop target.
- if (isDroppableTarget(event)) {
- setBackgroundDrawable(DROPPABLE_HOVER_BACKGROUND);
- return true;
- }
- break;
-
case DragEvent.ACTION_DRAG_EXITED:
- // If this is a droppable target, make sure that it is set back to steady state,
- // when the drag leaves the view.
- if (isDroppableTarget(event)) {
- setBackgroundDrawable(DRAG_STEADY_STATE_BACKGROUND);
- return true;
- }
- break;
-
+ // All of these states return based on isDroppableTarget's return value.
+ // If modifying, watch the switch's drop-through effects.
+ return isDroppableTarget(event);
case DragEvent.ACTION_DRAG_ENDED:
- // Reset the text of the non draggable views back to the color it had been..
- if (!isDroppableTarget(event)) {
- mFolderTextView.setTextColor(mInitialFolderTextColor);
- mUnreadCountTextView.setTextColor(mInitialUnreadCountTextColor);
- }
- // Restore the background of the view.
- setBackgroundDrawable(mBackground);
+ // Set drag mode to false since we're leaving drag mode.
+ // Updates all the states of icons and text colors back to non-drag values.
+ setDragMode(false);
return true;
case DragEvent.ACTION_DRAG_LOCATION:
@@ -273,4 +230,18 @@
}
return false;
}
+
+ @Override
+ protected int[] onCreateDrawableState(int extraSpace) {
+ final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
+ if (mIsDragMode) {
+ mergeDrawableStates(drawableState, STATE_DRAG_MODE);
+ }
+ return drawableState;
+ }
+
+ private void setDragMode(boolean isDragMode) {
+ mIsDragMode = isDragMode;
+ refreshDrawableState();
+ }
}
diff --git a/src/com/android/mail/ui/SecureConversationViewFragment.java b/src/com/android/mail/ui/SecureConversationViewFragment.java
index 3a74d35..13612ae 100644
--- a/src/com/android/mail/ui/SecureConversationViewFragment.java
+++ b/src/com/android/mail/ui/SecureConversationViewFragment.java
@@ -96,7 +96,7 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mConversationHeaderView.setCallbacks(this, this);
- mConversationHeaderView.setFoldersVisible(false);
+ mConversationHeaderView.setFolders(mConversation);
mConversationHeaderView.setSubject(mConversation.subject);
mMessageHeaderView.initialize(mDateBuilder, this, mAddressCache);
mMessageHeaderView.setExpandMode(MessageHeaderView.POPUP_MODE);
diff --git a/src/com/android/mail/utils/LogUtils.java b/src/com/android/mail/utils/LogUtils.java
index f4fb230..585bc22 100644
--- a/src/com/android/mail/utils/LogUtils.java
+++ b/src/com/android/mail/utils/LogUtils.java
@@ -61,7 +61,7 @@
* production releases. This should be set to DEBUG for production releases, and VERBOSE for
* internal builds.
*/
- private static final int MAX_ENABLED_LOG_LEVEL = DEBUG;
+ private static final int MAX_ENABLED_LOG_LEVEL = VERBOSE;
private static Boolean sDebugLoggingEnabledForTests = null;
diff --git a/src/com/android/mail/utils/NotificationUtils.java b/src/com/android/mail/utils/NotificationUtils.java
index de4d887..b91ee77 100644
--- a/src/com/android/mail/utils/NotificationUtils.java
+++ b/src/com/android/mail/utils/NotificationUtils.java
@@ -32,13 +32,9 @@
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.Contacts.Photo;
import android.support.v4.app.NotificationCompat;
-import android.text.Html;
-import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
-import android.text.Spanned;
import android.text.TextUtils;
-import android.text.TextUtils.SimpleStringSplitter;
import android.text.style.CharacterStyle;
import android.text.style.TextAppearanceSpan;
import android.util.Pair;
@@ -63,8 +59,8 @@
import com.google.android.common.html.parser.HtmlDocument;
import com.google.android.common.html.parser.HtmlTree;
import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.io.ByteArrayInputStream;
@@ -73,7 +69,6 @@
import java.util.Collection;
import java.util.Deque;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -88,11 +83,6 @@
private static TextAppearanceSpan sNotificationUnreadStyleSpan;
private static CharacterStyle sNotificationReadStyleSpan;
- private static final Map<Integer, Integer> sPriorityToLength = Maps.newHashMap();
- private static final SimpleStringSplitter SENDER_LIST_SPLITTER =
- new SimpleStringSplitter(Utils.SENDER_LIST_SEPARATOR);
- private static String[] sSenderFragments = new String[8];
-
/** A factory that produces a plain text converter that removes elided text. */
private static final HtmlTree.PlainTextConverterFactory MESSAGE_CONVERTER_FACTORY =
new HtmlTree.PlainTextConverterFactory() {
@@ -1205,47 +1195,10 @@
}
/**
- * Adds a fragment with given style to a string builder.
- *
- * @param builder the current string builder
- * @param fragment the fragment to be added
- * @param style the style of the fragment
- * @param withSpaces whether to add the whole fragment or to divide it into
- * smaller ones
+ * Clears the notifications for the specified account/folder.
*/
- private static void addStyledFragment(SpannableStringBuilder builder, String fragment,
- CharacterStyle style, boolean withSpaces) {
- if (withSpaces) {
- int pos = builder.length();
- builder.append(fragment);
- builder.setSpan(CharacterStyle.wrap(style), pos, builder.length(),
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- } else {
- int start = 0;
- while (true) {
- int pos = fragment.substring(start).indexOf(' ');
- if (pos == -1) {
- addStyledFragment(builder, fragment.substring(start), style, true);
- break;
- } else {
- pos += start;
- if (start < pos) {
- addStyledFragment(builder, fragment.substring(start, pos), style, true);
- builder.append(' ');
- }
- start = pos + 1;
- if (start >= fragment.length()) {
- break;
- }
- }
- }
- }
- }
-
- /**
- * Clears the notifications for the specified account/folder/conversation.
- */
- public static void clearFolderNotification(Context context, Account account, Folder folder) {
+ public static void clearFolderNotification(Context context, Account account, Folder folder,
+ final boolean markSeen) {
LogUtils.v(LOG_TAG, "NotificationUtils: Clearing all notifications for %s/%s", account.name,
folder.name);
final NotificationMap notificationMap = getNotificationMap(context);
@@ -1253,7 +1206,43 @@
notificationMap.remove(key);
notificationMap.saveNotificationMap(context);
- markSeen(context, folder);
+ final NotificationManager notificationManager =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancel(getNotificationId(account.name, folder));
+
+ if (markSeen) {
+ markSeen(context, folder);
+ }
+ }
+
+ /**
+ * Clears all notifications for the specified account.
+ */
+ public static void clearAccountNotifications(final Context context, final String account) {
+ LogUtils.v(LOG_TAG, "NotificationUtils: Clearing all notifications for %s", account);
+ final NotificationMap notificationMap = getNotificationMap(context);
+
+ // Find all NotificationKeys for this account
+ final ImmutableList.Builder<NotificationKey> keyBuilder = ImmutableList.builder();
+
+ for (final NotificationKey key : notificationMap.keySet()) {
+ if (account.equals(key.account.name)) {
+ keyBuilder.add(key);
+ }
+ }
+
+ final List<NotificationKey> notificationKeys = keyBuilder.build();
+
+ final NotificationManager notificationManager =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+
+ for (final NotificationKey notificationKey : notificationKeys) {
+ final Folder folder = notificationKey.folder;
+ notificationManager.cancel(getNotificationId(account, folder));
+ notificationMap.remove(notificationKey);
+ }
+
+ notificationMap.saveNotificationMap(context);
}
private static ArrayList<Long> findContacts(Context context, Collection<String> addresses) {