Loading packages/SystemUI/res/drawable/heads_up_scrim.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2014 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 --> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:type="linear" android:angle="-90" android:startColor="#55000000" android:endColor="#00000000" /> </shape> No newline at end of file packages/SystemUI/res/layout/heads_up.xml +5 −4 Original line number Diff line number Diff line Loading @@ -17,13 +17,14 @@ <com.android.systemui.statusbar.policy.HeadsUpNotificationView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent"> android:layout_width="match_parent" android:background="@drawable/heads_up_scrim"> <FrameLayout android:layout_height="wrap_content" android:layout_marginStart="@dimen/notification_side_padding" android:layout_marginEnd="@dimen/notification_side_padding" android:elevation="16dp" android:paddingStart="@dimen/notification_side_padding" android:paddingEnd="@dimen/notification_side_padding" android:elevation="8dp" android:id="@+id/content_holder" style="@style/NotificationsQuickSettings" /> Loading packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,7 @@ keyguard_clock_height_fraction_* for the difference between min and max.--> <dimen name="keyguard_clock_notifications_margin_min">22dp</dimen> <dimen name="keyguard_clock_notifications_margin_max">36dp</dimen> <dimen name="heads_up_window_height">250dp</dimen> <!-- The minimum amount the user needs to swipe to go to the camera / phone. --> <dimen name="keyguard_min_swipe_amount">75dp</dimen> Loading packages/SystemUI/src/com/android/systemui/SwipeHelper.java +38 −28 Original line number Diff line number Diff line Loading @@ -51,12 +51,12 @@ public class SwipeHelper implements Gefingerpoken { private int MAX_DISMISS_VELOCITY = 2000; // dp/sec private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 150; // ms public static float ALPHA_FADE_START = 0f; // fraction of thumbnail width public static float SWIPE_PROGRESS_FADE_START = 0f; // fraction of thumbnail width // where fade starts static final float ALPHA_FADE_END = 0.5f; // fraction of thumbnail width // beyond which alpha->0 private float mMinAlpha = 0f; private float mMaxAlpha = 1f; static final float SWIPE_PROGRESS_FADE_END = 0.5f; // fraction of thumbnail width // beyond which swipe progress->0 private float mMinSwipeProgress = 0f; private float mMaxSwipeProgress = 1f; private float mPagingTouchSlop; private Callback mCallback; Loading Loading @@ -137,36 +137,39 @@ public class SwipeHelper implements Gefingerpoken { v.getMeasuredHeight(); } public void setMinAlpha(float minAlpha) { mMinAlpha = minAlpha; public void setMinSwipeProgress(float minSwipeProgress) { mMinSwipeProgress = minSwipeProgress; } public void setMaxAlpha(float maxAlpha) { mMaxAlpha = maxAlpha; public void setMaxSwipeProgress(float maxSwipeProgress) { mMaxSwipeProgress = maxSwipeProgress; } private float getAlphaForOffset(View view) { private float getSwipeProgressForOffset(View view) { float viewSize = getSize(view); final float fadeSize = ALPHA_FADE_END * viewSize; final float fadeSize = SWIPE_PROGRESS_FADE_END * viewSize; float result = 1.0f; float pos = getTranslation(view); if (pos >= viewSize * ALPHA_FADE_START) { result = 1.0f - (pos - viewSize * ALPHA_FADE_START) / fadeSize; } else if (pos < viewSize * (1.0f - ALPHA_FADE_START)) { result = 1.0f + (viewSize * ALPHA_FADE_START + pos) / fadeSize; if (pos >= viewSize * SWIPE_PROGRESS_FADE_START) { result = 1.0f - (pos - viewSize * SWIPE_PROGRESS_FADE_START) / fadeSize; } else if (pos < viewSize * (1.0f - SWIPE_PROGRESS_FADE_START)) { result = 1.0f + (viewSize * SWIPE_PROGRESS_FADE_START + pos) / fadeSize; } return Math.min(Math.max(mMinAlpha, result), mMaxAlpha); return Math.min(Math.max(mMinSwipeProgress, result), mMaxSwipeProgress); } private void updateAlphaFromOffset(View animView, boolean dismissable) { private void updateSwipeProgressFromOffset(View animView, boolean dismissable) { float swipeProgress = getSwipeProgressForOffset(animView); if (!mCallback.updateSwipeProgress(animView, dismissable, swipeProgress)) { if (FADE_OUT_DURING_SWIPE && dismissable) { float alpha = getAlphaForOffset(animView); float alpha = swipeProgress; if (alpha != 0f && alpha != 1f) { animView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else { animView.setLayerType(View.LAYER_TYPE_NONE, null); } animView.setAlpha(getAlphaForOffset(animView)); animView.setAlpha(getSwipeProgressForOffset(animView)); } } invalidateGlobalRegion(animView); } Loading Loading @@ -307,7 +310,7 @@ public class SwipeHelper implements Gefingerpoken { }); anim.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { updateAlphaFromOffset(animView, canAnimViewBeDismissed); updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed); } }); anim.start(); Loading @@ -321,12 +324,12 @@ public class SwipeHelper implements Gefingerpoken { anim.setDuration(duration); anim.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { updateAlphaFromOffset(animView, canAnimViewBeDismissed); updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed); } }); anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animator) { updateAlphaFromOffset(animView, canAnimViewBeDismissed); updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed); mCallback.onChildSnappedBack(animView); } }); Loading Loading @@ -365,7 +368,7 @@ public class SwipeHelper implements Gefingerpoken { } setTranslation(mCurrAnimView, delta); updateAlphaFromOffset(mCurrAnimView, mCanCurrViewBeDimissed); updateSwipeProgressFromOffset(mCurrAnimView, mCanCurrViewBeDimissed); } break; case MotionEvent.ACTION_UP: Loading Loading @@ -415,5 +418,12 @@ public class SwipeHelper implements Gefingerpoken { void onDragCancelled(View v); void onChildSnappedBack(View animView); /** * Updates the swipe progress on a child. * * @return if true, prevents the default alpha fading. */ boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress); } } packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java +6 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView } public void setMinSwipeAlpha(float minAlpha) { mSwipeHelper.setMinAlpha(minAlpha); mSwipeHelper.setMinSwipeProgress(minAlpha); } private int scrollPositionOfMostRecent() { Loading Loading @@ -221,6 +221,11 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView public void onChildSnappedBack(View animView) { } @Override public boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress) { return false; } public View getChildAtPosition(MotionEvent ev) { final float x = ev.getX() + getScrollX(); final float y = ev.getY() + getScrollY(); Loading Loading
packages/SystemUI/res/drawable/heads_up_scrim.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2014 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 --> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:type="linear" android:angle="-90" android:startColor="#55000000" android:endColor="#00000000" /> </shape> No newline at end of file
packages/SystemUI/res/layout/heads_up.xml +5 −4 Original line number Diff line number Diff line Loading @@ -17,13 +17,14 @@ <com.android.systemui.statusbar.policy.HeadsUpNotificationView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent"> android:layout_width="match_parent" android:background="@drawable/heads_up_scrim"> <FrameLayout android:layout_height="wrap_content" android:layout_marginStart="@dimen/notification_side_padding" android:layout_marginEnd="@dimen/notification_side_padding" android:elevation="16dp" android:paddingStart="@dimen/notification_side_padding" android:paddingEnd="@dimen/notification_side_padding" android:elevation="8dp" android:id="@+id/content_holder" style="@style/NotificationsQuickSettings" /> Loading
packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,7 @@ keyguard_clock_height_fraction_* for the difference between min and max.--> <dimen name="keyguard_clock_notifications_margin_min">22dp</dimen> <dimen name="keyguard_clock_notifications_margin_max">36dp</dimen> <dimen name="heads_up_window_height">250dp</dimen> <!-- The minimum amount the user needs to swipe to go to the camera / phone. --> <dimen name="keyguard_min_swipe_amount">75dp</dimen> Loading
packages/SystemUI/src/com/android/systemui/SwipeHelper.java +38 −28 Original line number Diff line number Diff line Loading @@ -51,12 +51,12 @@ public class SwipeHelper implements Gefingerpoken { private int MAX_DISMISS_VELOCITY = 2000; // dp/sec private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 150; // ms public static float ALPHA_FADE_START = 0f; // fraction of thumbnail width public static float SWIPE_PROGRESS_FADE_START = 0f; // fraction of thumbnail width // where fade starts static final float ALPHA_FADE_END = 0.5f; // fraction of thumbnail width // beyond which alpha->0 private float mMinAlpha = 0f; private float mMaxAlpha = 1f; static final float SWIPE_PROGRESS_FADE_END = 0.5f; // fraction of thumbnail width // beyond which swipe progress->0 private float mMinSwipeProgress = 0f; private float mMaxSwipeProgress = 1f; private float mPagingTouchSlop; private Callback mCallback; Loading Loading @@ -137,36 +137,39 @@ public class SwipeHelper implements Gefingerpoken { v.getMeasuredHeight(); } public void setMinAlpha(float minAlpha) { mMinAlpha = minAlpha; public void setMinSwipeProgress(float minSwipeProgress) { mMinSwipeProgress = minSwipeProgress; } public void setMaxAlpha(float maxAlpha) { mMaxAlpha = maxAlpha; public void setMaxSwipeProgress(float maxSwipeProgress) { mMaxSwipeProgress = maxSwipeProgress; } private float getAlphaForOffset(View view) { private float getSwipeProgressForOffset(View view) { float viewSize = getSize(view); final float fadeSize = ALPHA_FADE_END * viewSize; final float fadeSize = SWIPE_PROGRESS_FADE_END * viewSize; float result = 1.0f; float pos = getTranslation(view); if (pos >= viewSize * ALPHA_FADE_START) { result = 1.0f - (pos - viewSize * ALPHA_FADE_START) / fadeSize; } else if (pos < viewSize * (1.0f - ALPHA_FADE_START)) { result = 1.0f + (viewSize * ALPHA_FADE_START + pos) / fadeSize; if (pos >= viewSize * SWIPE_PROGRESS_FADE_START) { result = 1.0f - (pos - viewSize * SWIPE_PROGRESS_FADE_START) / fadeSize; } else if (pos < viewSize * (1.0f - SWIPE_PROGRESS_FADE_START)) { result = 1.0f + (viewSize * SWIPE_PROGRESS_FADE_START + pos) / fadeSize; } return Math.min(Math.max(mMinAlpha, result), mMaxAlpha); return Math.min(Math.max(mMinSwipeProgress, result), mMaxSwipeProgress); } private void updateAlphaFromOffset(View animView, boolean dismissable) { private void updateSwipeProgressFromOffset(View animView, boolean dismissable) { float swipeProgress = getSwipeProgressForOffset(animView); if (!mCallback.updateSwipeProgress(animView, dismissable, swipeProgress)) { if (FADE_OUT_DURING_SWIPE && dismissable) { float alpha = getAlphaForOffset(animView); float alpha = swipeProgress; if (alpha != 0f && alpha != 1f) { animView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else { animView.setLayerType(View.LAYER_TYPE_NONE, null); } animView.setAlpha(getAlphaForOffset(animView)); animView.setAlpha(getSwipeProgressForOffset(animView)); } } invalidateGlobalRegion(animView); } Loading Loading @@ -307,7 +310,7 @@ public class SwipeHelper implements Gefingerpoken { }); anim.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { updateAlphaFromOffset(animView, canAnimViewBeDismissed); updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed); } }); anim.start(); Loading @@ -321,12 +324,12 @@ public class SwipeHelper implements Gefingerpoken { anim.setDuration(duration); anim.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { updateAlphaFromOffset(animView, canAnimViewBeDismissed); updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed); } }); anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animator) { updateAlphaFromOffset(animView, canAnimViewBeDismissed); updateSwipeProgressFromOffset(animView, canAnimViewBeDismissed); mCallback.onChildSnappedBack(animView); } }); Loading Loading @@ -365,7 +368,7 @@ public class SwipeHelper implements Gefingerpoken { } setTranslation(mCurrAnimView, delta); updateAlphaFromOffset(mCurrAnimView, mCanCurrViewBeDimissed); updateSwipeProgressFromOffset(mCurrAnimView, mCanCurrViewBeDimissed); } break; case MotionEvent.ACTION_UP: Loading Loading @@ -415,5 +418,12 @@ public class SwipeHelper implements Gefingerpoken { void onDragCancelled(View v); void onChildSnappedBack(View animView); /** * Updates the swipe progress on a child. * * @return if true, prevents the default alpha fading. */ boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress); } }
packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java +6 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView } public void setMinSwipeAlpha(float minAlpha) { mSwipeHelper.setMinAlpha(minAlpha); mSwipeHelper.setMinSwipeProgress(minAlpha); } private int scrollPositionOfMostRecent() { Loading Loading @@ -221,6 +221,11 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView public void onChildSnappedBack(View animView) { } @Override public boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress) { return false; } public View getChildAtPosition(MotionEvent ev) { final float x = ev.getX() + getScrollX(); final float y = ev.getY() + getScrollY(); Loading