Merge "Disable activity's translucency until it starts being swiped away." into lmp-sprout-dev

This commit is contained in:
Filip Gruszczynski
2014-10-21 22:14:39 +00:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
package com.android.internal.widget;
import android.animation.TimeInterpolator;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
@@ -102,6 +103,11 @@ public class SwipeDismissLayout extends FrameLayout {
android.R.integer.config_shortAnimTime);
mCancelInterpolator = new DecelerateInterpolator(1.5f);
mDismissInterpolator = new AccelerateInterpolator(1.5f);
// SwipeDismissLayout assumes that the host Activity is translucent
// and temporarily disables translucency when it is fully visible.
// As soon as the user starts swiping, we will re-enable
// translucency.
((Activity) context).convertFromTranslucent();
}
public void setOnDismissedListener(OnDismissedListener listener) {
@@ -197,6 +203,7 @@ public class SwipeDismissLayout extends FrameLayout {
mLastX = ev.getRawX();
updateSwiping(ev);
if (mSwiping) {
((Activity) getContext()).convertToTranslucent(null, null);
setProgress(ev.getRawX() - mDownX);
break;
}
@@ -218,6 +225,7 @@ public class SwipeDismissLayout extends FrameLayout {
}
protected void cancel() {
((Activity) getContext()).convertFromTranslucent();
if (mProgressListener != null) {
mProgressListener.onSwipeCancelled(this);
}

View File

@@ -24,6 +24,8 @@
<item name="windowBackground">@color/black</item>
<item name="windowContentOverlay">@null</item>
<item name="windowIsFloating">false</item>
<!-- We need the windows to be translucent for SwipeToDismiss layout
to work properly. -->
<item name="windowIsTranslucent">true</item>
<item name="windowSwipeToDismiss">true</item>
</style>
@@ -38,6 +40,8 @@
<item name="windowBackground">@color/white</item>
<item name="windowContentOverlay">@null</item>
<item name="windowIsFloating">false</item>
<!-- We need the windows to be translucent for SwipeToDismiss layout
to work properly. -->
<item name="windowIsTranslucent">true</item>
<item name="windowSwipeToDismiss">true</item>
</style>