Merge "Fix missed calls not updating properly" into klp-dev
diff --git a/res/layout/phone_favorites_fragment.xml b/res/layout/phone_favorites_fragment.xml
index 6023fc8..4d3abf4 100644
--- a/res/layout/phone_favorites_fragment.xml
+++ b/res/layout/phone_favorites_fragment.xml
@@ -45,5 +45,11 @@
android:layout_marginTop="@dimen/empty_message_top_margin"
android:textColor="?android:attr/textColorSecondary"
android:textAppearance="?android:attr/textAppearanceLarge"/>
+
+ <ImageView
+ android:id="@+id/contact_tile_drag_shadow_overlay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"/>
</FrameLayout>
</LinearLayout>
diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
index f0b4d82..7d7071e 100644
--- a/res/values-nl/strings.xml
+++ b/res/values-nl/strings.xml
@@ -32,7 +32,7 @@
<string name="recentCalls_empty" msgid="247053222448663107">"Gesprekkenoverzicht is leeg"</string>
<string name="clearCallLogConfirmation_title" msgid="6427524640461816332">"Oproeplog wissen?"</string>
<string name="clearCallLogConfirmation" msgid="5043563133171583152">"Al uw oproepgegevens worden verwijderd."</string>
- <string name="clearCallLogProgress_title" msgid="8365943000154295771">"Oproeplogboek wissen..."</string>
+ <string name="clearCallLogProgress_title" msgid="8365943000154295771">"Gesprekkenlijst wissen..."</string>
<plurals name="notification_voicemail_title">
<item quantity="one" msgid="1746619685488504230">"Voicemail"</item>
<item quantity="other" msgid="5513481419205061254">"<xliff:g id="COUNT">%1$d</xliff:g> voicemails"</item>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 2717049..90ed648 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -24,12 +24,12 @@
<string name="menu_sendTextMessage" msgid="6937343460284499306">"发送短信"</string>
<string name="recentCalls_callNumber" msgid="1756372533999226126">"呼叫<xliff:g id="NAME">%s</xliff:g>"</string>
<string name="recentCalls_editNumberBeforeCall" msgid="7756171675833267857">"呼叫之前编辑号码"</string>
- <string name="recentCalls_addToContact" msgid="1429899535546487008">"添加到“联系人”"</string>
+ <string name="recentCalls_addToContact" msgid="1429899535546487008">"添加到通讯录"</string>
<string name="recentCalls_removeFromRecentList" msgid="401662244636511330">"从通话记录中删除"</string>
<string name="recentCalls_deleteAll" msgid="6352364392762163704">"清除通话记录"</string>
<string name="recentCalls_trashVoicemail" msgid="7604696960787435655">"删除语音邮件"</string>
<string name="recentCalls_shareVoicemail" msgid="1416112847592942840">"分享语音邮件"</string>
- <string name="recentCalls_empty" msgid="247053222448663107">"通话记录为空。"</string>
+ <string name="recentCalls_empty" msgid="247053222448663107">"没有通话记录。"</string>
<string name="clearCallLogConfirmation_title" msgid="6427524640461816332">"要清除通话记录吗?"</string>
<string name="clearCallLogConfirmation" msgid="5043563133171583152">"系统将删除您的所有通话记录。"</string>
<string name="clearCallLogProgress_title" msgid="8365943000154295771">"正在清除通话记录..."</string>
@@ -89,7 +89,7 @@
<string name="menu_show_missed_only" msgid="154473166059743996">"仅显示未接来电"</string>
<string name="menu_show_voicemails_only" msgid="1898421289561435703">"只显示语音邮件"</string>
<string name="menu_show_all_calls" msgid="7560347482073345885">"显示所有通话"</string>
- <string name="add_2sec_pause" msgid="9214012315201040129">"暂停时间延长 2 秒"</string>
+ <string name="add_2sec_pause" msgid="9214012315201040129">"暂停时间延长2秒"</string>
<string name="add_wait" msgid="3360818652790319634">"延长等待时间"</string>
<string name="call_settings" msgid="7666474782093693667">"设置"</string>
<string name="menu_newContact" msgid="1209922412763274638">"新建联系人"</string>
diff --git a/res/values/animation_constants.xml b/res/values/animation_constants.xml
index 77b7627..b41b316 100644
--- a/res/values/animation_constants.xml
+++ b/res/values/animation_constants.xml
@@ -15,7 +15,7 @@
~ limitations under the License
-->
<resources>
- <integer name="fade_duration">250</integer>
+ <integer name="fade_duration">300</integer>
<!-- Swipe constants -->
<integer name="swipe_escape_velocity">100</integer>
@@ -27,4 +27,4 @@
<dimen name="min_swipe">5dip</dimen>
<dimen name="min_vert">10dip</dimen>
<dimen name="min_lock">20dip</dimen>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java
index 0e8deeb..beeb320 100644
--- a/src/com/android/dialer/list/PhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -36,6 +36,7 @@
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -71,7 +72,7 @@
private static final String TAG = PhoneFavoriteFragment.class.getSimpleName();
private static final boolean DEBUG = true;
- private static final int ANIMATION_DURATION = 300;
+ private int mAnimationDuration;
/**
* Used with LoaderManager.
@@ -201,6 +202,7 @@
if (DEBUG) Log.d(TAG, "onCreate()");
super.onCreate(savedState);
+ mAnimationDuration = getResources().getInteger(R.integer.fade_duration);
mCallLogQueryHandler = new CallLogQueryHandler(getActivity().getContentResolver(),
this, 1);
final String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity());
@@ -237,6 +239,10 @@
mListView.setOnItemSwipeListener(mContactTileAdapter);
mListView.setOnDragDropListener(mContactTileAdapter);
+ final ImageView dragShadowOverlay =
+ (ImageView) listLayout.findViewById(R.id.contact_tile_drag_shadow_overlay);
+ mListView.setDragShadowOverlay(dragShadowOverlay);
+
mEmptyView = inflater.inflate(R.layout.phone_no_favorites, mListView, false);
mShowAllContactsButton = inflater.inflate(R.layout.show_all_contact_button, mListView,
@@ -403,25 +409,13 @@
final ContactEntry entry = list.get(i);
final long itemId = mContactTileAdapter.getAdjustedItemId(entry.id);
- // Skip animation for this view if the caller specified that it should be
- // kept in place
- if (containsId(idsInPlace, itemId)) continue;
-
- Integer startLeft = mItemIdLeftMap.get(itemId);
- int left = child.getLeft();
- if (DEBUG) {
- Log.d(TAG, "Found itemId: " + itemId + " for tileview child " + i +
- " Left: " + left);
+ if (containsId(idsInPlace, itemId)) {
+ child.setAlpha(0.0f);
+ child.animate().alpha(1.0f)
+ .setDuration(mAnimationDuration)
+ .start();
+ break;
}
- if (startLeft != null) {
- if (startLeft != left) {
- int delta = startLeft - left;
- child.setTranslationX(delta);
- child.animate().setDuration(ANIMATION_DURATION).translationX(0);
- }
- }
- // No need to worry about horizontal offsets of new views that come into view since
- // there is no horizontal scrolling involved.
}
}
@@ -455,33 +449,12 @@
final long itemId = mAdapter.getItemId(position);
- // Skip animation for this view if the caller specified that it should be
- // kept in place
- if (containsId(idsInPlace, itemId)) continue;
-
- Integer startTop = mItemIdTopMap.get(itemId);
- final int top = child.getTop();
- if (DEBUG) {
- Log.d(TAG, "Found itemId: " + itemId + " for listview child " + i +
- " Top: " + top);
- }
- int delta = 0;
- if (startTop != null) {
- if (startTop != top) {
- delta = startTop - top;
- }
- } else if (!mItemIdLeftMap.containsKey(itemId)) {
- // Animate new views along with the others. The catch is that they did not
- // exist in the start state, so we must calculate their starting position
- // based on neighboring views.
- int childHeight = child.getHeight() + mListView.getDividerHeight();
- startTop = top + (i > 0 ? childHeight : -childHeight);
- delta = startTop - top;
- }
-
- if (delta != 0) {
- child.setTranslationY(delta);
- child.animate().setDuration(ANIMATION_DURATION).translationY(0);
+ if (containsId(idsInPlace, itemId)) {
+ child.setAlpha(0.0f);
+ child.animate().alpha(1.0f)
+ .setDuration(mAnimationDuration)
+ .start();
+ break;
}
}
mItemIdTopMap.clear();
diff --git a/src/com/android/dialer/list/PhoneFavoriteListView.java b/src/com/android/dialer/list/PhoneFavoriteListView.java
index 4ce5df1..04bbe6b 100644
--- a/src/com/android/dialer/list/PhoneFavoriteListView.java
+++ b/src/com/android/dialer/list/PhoneFavoriteListView.java
@@ -17,11 +17,11 @@
package com.android.dialer.list;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
@@ -29,6 +29,8 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
import android.widget.ListView;
import com.android.dialer.R;
@@ -66,7 +68,10 @@
private boolean mIsDragScrollerRunning = false;
private int mTouchDownForDragStartX;
private int mTouchDownForDragStartY;
+
private Bitmap mDragShadowBitmap;
+ private ImageView mDragShadowOverlay;
+ private int mAnimationDuration;
// X and Y offsets inside the item from where the user grabbed to the
// child's left coordinate. This is used to aid in the drawing of the drag shadow.
@@ -78,8 +83,7 @@
private int mDragShadowWidth;
private int mDragShadowHeight;
- private final int DRAG_SHADOW_ALPHA = 180;
- private final Paint mPaint = new Paint();
+ private final float DRAG_SHADOW_ALPHA = 0.7f;
/**
* {@link #mTopScrollBound} and {@link mBottomScrollBound} will be
@@ -99,6 +103,28 @@
}
};
+ private final AnimatorListenerAdapter mDragShadowOverAnimatorListener =
+ new AnimatorListenerAdapter() {
+ private void recycleDragShadow() {
+ if (mDragShadowBitmap != null) {
+ mDragShadowBitmap.recycle();
+ mDragShadowBitmap = null;
+ }
+ mDragShadowOverlay.setVisibility(GONE);
+ mDragShadowOverlay.setImageBitmap(null);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ recycleDragShadow();
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ recycleDragShadow();
+ }
+ };
+
public PhoneFavoriteListView(Context context) {
this(context, null);
}
@@ -109,12 +135,12 @@
public PhoneFavoriteListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ mAnimationDuration = context.getResources().getInteger(R.integer.fade_duration);
mDensityScale = getResources().getDisplayMetrics().density;
mTouchSlop = ViewConfiguration.get(context).getScaledPagingTouchSlop();
mSwipeHelper = new SwipeHelper(context, SwipeHelper.X, this,
mDensityScale, mTouchSlop);
setItemsCanFocus(true);
- mPaint.setAlpha(DRAG_SHADOW_ALPHA);
}
@Override
@@ -251,7 +277,9 @@
ensureScrollHandler();
mScrollHandler.removeCallbacks(mDragScroller);
mIsDragScrollerRunning = false;
- if (action != DragEvent.ACTION_DRAG_EXITED) {
+ // Either it's been a successful drop or it's ended with out drop.
+ if (action == DragEvent.ACTION_DROP ||
+ (action == DragEvent.ACTION_DRAG_ENDED && !event.getResult())) {
handleDragFinished(eX, eY);
}
break;
@@ -262,13 +290,8 @@
return true;
}
- @Override
- public void dispatchDraw(Canvas canvas) {
- super.dispatchDraw(canvas);
- // Draw the drag shadow at its last known location if the drag shadow exists.
- if (mDragShadowBitmap != null) {
- canvas.drawBitmap(mDragShadowBitmap, mDragShadowLeft, mDragShadowTop, mPaint);
- }
+ public void setDragShadowOverlay(ImageView overlay) {
+ mDragShadowOverlay = overlay;
}
/**
@@ -292,6 +315,14 @@
}
}
+ private FrameLayout.LayoutParams getDragShadowLayoutParams() {
+ final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
+ mDragShadowWidth, mDragShadowHeight);
+ lp.leftMargin = mDragShadowLeft;
+ lp.topMargin = mDragShadowTop;
+ return lp;
+ }
+
/**
* @return True if the drag is started.
*/
@@ -307,6 +338,11 @@
if (itemIndex != -1 && mOnDragDropListener != null) {
final PhoneFavoriteTileView tileView =
(PhoneFavoriteTileView) tile.getViewAtPosition(x, y);
+ if (mDragShadowOverlay == null) {
+ return false;
+ }
+
+ mDragShadowOverlay.clearAnimation();
mDragShadowBitmap = createDraggedChildBitmap(tileView);
if (mDragShadowBitmap == null) {
return false;
@@ -321,9 +357,16 @@
mDragShadowLeft = tileView.getLeft() + tileView.getParentRow().getLeft();
mDragShadowTop = tileView.getTop() + tileView.getParentRow().getTop();
}
+
mDragShadowWidth = tileView.getWidth();
mDragShadowHeight = tileView.getHeight();
+ mDragShadowOverlay.setImageBitmap(mDragShadowBitmap);
+ mDragShadowOverlay.setVisibility(VISIBLE);
+ mDragShadowOverlay.setAlpha(DRAG_SHADOW_ALPHA);
+
+ mDragShadowOverlay.setLayoutParams(getDragShadowLayoutParams());
+
// x and y passed in are the coordinates of where the user has touched down, calculate
// the offset to the top left coordinate of the dragged child. This will be used for
// drawing the drag shadow.
@@ -350,8 +393,10 @@
mDragShadowLeft = x - mTouchOffsetToChildLeft;
mDragShadowTop = y - mTouchOffsetToChildTop;
- // invalidate to trigger a redraw of the drag shadow.
- invalidate();
+ // Draw the drag shadow at its last known location if the drag shadow exists.
+ if (mDragShadowOverlay != null) {
+ mDragShadowOverlay.setLayoutParams(getDragShadowLayoutParams());
+ }
final ContactTileRow tile = (ContactTileRow) child;
final int itemIndex = tile.getItemIndex(x, y);
@@ -365,9 +410,12 @@
mDragShadowLeft = x - mTouchOffsetToChildLeft;
mDragShadowTop = y - mTouchOffsetToChildTop;
- if (mDragShadowBitmap != null) {
- mDragShadowBitmap.recycle();
- mDragShadowBitmap = null;
+ if (mDragShadowOverlay != null) {
+ mDragShadowOverlay.clearAnimation();
+ mDragShadowOverlay.animate().alpha(0.0f)
+ .setDuration(mAnimationDuration)
+ .setListener(mDragShadowOverAnimatorListener)
+ .start();
}
if (mOnDragDropListener != null) {
diff --git a/src/com/android/dialer/list/PhoneFavoriteTileView.java b/src/com/android/dialer/list/PhoneFavoriteTileView.java
index 5a3f4e5..57d258f 100644
--- a/src/com/android/dialer/list/PhoneFavoriteTileView.java
+++ b/src/com/android/dialer/list/PhoneFavoriteTileView.java
@@ -31,6 +31,7 @@
import com.android.contacts.common.MoreContactUtils;
import com.android.contacts.common.list.ContactEntry;
import com.android.contacts.common.list.ContactTileView;
+import com.android.dialer.R;
import com.android.dialer.list.PhoneFavoritesTileAdapter.ContactTileRow;
import com.android.dialer.list.PhoneFavoritesTileAdapter.ViewTypes;
@@ -47,7 +48,7 @@
private static final boolean DEBUG = false;
/** Length of all animations in miniseconds. */
- private static final int ANIMATION_LENGTH = 300;
+ private int mAnimationDuration;
/** The view that holds the front layer of the favorite contact card. */
private View mFavoriteContactCard;
@@ -66,6 +67,7 @@
public PhoneFavoriteTileView(Context context, AttributeSet attrs) {
super(context, attrs);
+ mAnimationDuration = context.getResources().getInteger(R.integer.fade_duration);
}
public ContactTileRow getParentRow() {
@@ -131,7 +133,7 @@
mRemovalDialogue.setVisibility(VISIBLE);
mRemovalDialogue.setAlpha(0f);
final ObjectAnimator fadeIn = ObjectAnimator.ofFloat(mRemovalDialogue, "alpha",
- 1.f).setDuration(ANIMATION_LENGTH);
+ 1.f).setDuration(mAnimationDuration);
fadeIn.addListener(new AnimatorListenerAdapter() {
@Override
@@ -157,9 +159,9 @@
// Animates back the favorite contact card.
final ObjectAnimator fadeIn = ObjectAnimator.ofFloat(mFavoriteContactCard, "alpha", 1.f).
- setDuration(ANIMATION_LENGTH);
+ setDuration(mAnimationDuration);
final ObjectAnimator moveBack = ObjectAnimator.ofFloat(mFavoriteContactCard, "translationX",
- 0.f).setDuration(ANIMATION_LENGTH);
+ 0.f).setDuration(mAnimationDuration);
final AnimatorSet animSet = new AnimatorSet();
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 779b15d..73d3c36 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -609,7 +609,8 @@
public void handleDrop() {
boolean changed = false;
if (mDraggedEntry != null) {
- if (isIndexInBound(mDragEnteredEntryIndex)) {
+ if (isIndexInBound(mDragEnteredEntryIndex) &&
+ mDragEnteredEntryIndex != mDraggedEntryIndex) {
// Don't add the ContactEntry here (to prevent a double animation from occuring).
// When we receive a new cursor the list of contact entries will automatically be
// populated with the dragged ContactEntry at the correct spot.
@@ -634,7 +635,6 @@
PinnedPositions.STAR_WHEN_PINNING, "true").build();
// update the database here with the new pinned positions
mContext.getContentResolver().update(pinUri, cv, null, null);
- notifyDataSetChanged();
}
mDraggedEntry = null;
}