Updating Recents to make the cards slightly more visible.

Change-Id: I876d39f4aac4007a3fe0c509ccb7db130f27a737
This commit is contained in:
Winson Chung
2014-06-09 18:33:08 -07:00
parent d478a3a0d8
commit b13c46e8b7
14 changed files with 48 additions and 21 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -20,4 +20,4 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:scaleType="fitXY"
android:src="@drawable/recents_nav_bar_background" />
android:src="@drawable/recents_lower_gradient" />

View File

@ -106,7 +106,7 @@ public class Constants {
// The height of the peek space relative to the stack height
public static final float StackPeekHeightPct = 0.1f;
// The min scale of the last card in the peek area
public static final float StackPeekMinScale = 0.9f;
public static final float StackPeekMinScale = 0.8f;
// The number of cards we see in the peek space
public static final int StackPeekNumCards = 3;
}

View File

@ -41,6 +41,8 @@ import com.android.systemui.recents.model.SpaceNode;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.RecentsView;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Set;
@ -79,6 +81,19 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
boolean mVisible;
boolean mTaskLaunched;
private static Method sPropertyMethod;
static {
try {
Class<?> c = Class.forName("android.view.GLES20Canvas");
sPropertyMethod = c.getDeclaredMethod("setProperty", String.class, String.class);
if (!sPropertyMethod.isAccessible()) sPropertyMethod.setAccessible(true);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
// Broadcast receiver to handle messages from our RecentsService
BroadcastReceiver mServiceBroadcastReceiver = new BroadcastReceiver() {
@Override
@ -139,21 +154,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
// Add the default no-recents layout
if (stacks.size() == 1 && stacks.get(0).getTaskCount() == 0) {
mEmptyView.setVisibility(View.VISIBLE);
// Dim the background even more
WindowManager.LayoutParams wlp = getWindow().getAttributes();
wlp.dimAmount = Constants.Values.Window.DarkBackgroundDim;
getWindow().setAttributes(wlp);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
} else {
mEmptyView.setVisibility(View.GONE);
// Un-dim the background
WindowManager.LayoutParams wlp = getWindow().getAttributes();
wlp.dimAmount = 0f;
getWindow().setAttributes(wlp);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}
// Dim the background
mRecentsView.setBackgroundColor(0x80000000);
}
/** Attempts to allocate and bind the search bar app widget */
@ -277,6 +283,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
LayoutInflater inflater = LayoutInflater.from(this);
mEmptyView = inflater.inflate(R.layout.recents_empty, mContainerView, false);
mNavBarScrimView = inflater.inflate(R.layout.recents_nav_bar_scrim, mContainerView, false);
mNavBarScrimView.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
mContainerView = new FrameLayout(this);
mContainerView.addView(mRecentsView);
@ -296,6 +305,16 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
if (savedInstanceState != null) {
onConfigurationChange();
}
// XXX: Update the shadows
try {
sPropertyMethod.invoke(null, "ambientShadowStrength", String.valueOf(35f));
sPropertyMethod.invoke(null, "ambientRatio", String.valueOf(0.5f));
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
void onConfigurationChange() {

View File

@ -156,10 +156,12 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
float boundedT = Math.max(t, -(numPeekCards + 1));
// Set the scale relative to its position
int numFrontScaledCards = 3;
float minScale = Constants.Values.TaskStackView.StackPeekMinScale;
float scaleRange = 1f - minScale;
float scaleInc = scaleRange / numPeekCards;
float scale = Math.max(minScale, Math.min(1f, 1f + (boundedT * scaleInc)));
float scaleInc = scaleRange / (numPeekCards + numFrontScaledCards);
float scale = Math.max(minScale, Math.min(1f, minScale +
((boundedT + (numPeekCards + 1)) * scaleInc)));
float scaleYOffset = ((1f - scale) * mTaskRect.height()) / 2;
transform.scale = scale;
@ -171,6 +173,12 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
transform.translationY = (int) (boundedT * overlapHeight - scaleYOffset);
}
// Set the z translation
RecentsConfiguration config = RecentsConfiguration.getInstance();
int minZ = config.taskViewTranslationZMinPx;
int incZ = config.taskViewTranslationZIncrementPx;
transform.translationZ = (int) Math.max(minZ, minZ + ((boundedT + numPeekCards) * incZ));
// Set the alphas
transform.dismissAlpha = Math.max(-1f, Math.min(0f, t + 1)) + 1f;

View File

@ -142,8 +142,6 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
void updateViewPropertiesToTaskTransform(TaskViewTransform animateFromTransform,
TaskViewTransform toTransform, int duration) {
RecentsConfiguration config = RecentsConfiguration.getInstance();
int minZ = config.taskViewTranslationZMinPx;
int incZ = config.taskViewTranslationZIncrementPx;
// Update the bar view
mBarView.updateViewPropertiesToTaskTransform(animateFromTransform, toTransform, duration);
@ -153,14 +151,14 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
if (animateFromTransform != null) {
setTranslationY(animateFromTransform.translationY);
if (Constants.DebugFlags.App.EnableShadows) {
setTranslationZ(Math.max(minZ, minZ + (animateFromTransform.t * incZ)));
setTranslationZ(animateFromTransform.translationZ);
}
setScaleX(animateFromTransform.scale);
setScaleY(animateFromTransform.scale);
setAlpha(animateFromTransform.alpha);
}
if (Constants.DebugFlags.App.EnableShadows) {
animate().translationZ(Math.max(minZ, minZ + (toTransform.t * incZ)));
animate().translationZ(toTransform.translationZ);
}
animate().translationY(toTransform.translationY)
.scaleX(toTransform.scale)
@ -179,7 +177,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, View.On
} else {
setTranslationY(toTransform.translationY);
if (Constants.DebugFlags.App.EnableShadows) {
setTranslationZ(Math.max(minZ, minZ + (toTransform.t * incZ)));
setTranslationZ(toTransform.translationZ);
}
setScaleX(toTransform.scale);
setScaleY(toTransform.scale);

View File

@ -22,6 +22,7 @@ import android.graphics.Rect;
/* The transform state for a task view */
public class TaskViewTransform {
public int translationY = 0;
public int translationZ = 0;
public float scale = 1f;
public float alpha = 1f;
public float dismissAlpha = 1f;
@ -35,6 +36,7 @@ public class TaskViewTransform {
public TaskViewTransform(TaskViewTransform o) {
translationY = o.translationY;
translationZ = o.translationZ;
scale = o.scale;
alpha = o.alpha;
dismissAlpha = o.dismissAlpha;