summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2013-10-10 16:46:06 -0700
committerSvetoslav <svetoslavganov@google.com>2013-10-10 16:52:54 -0700
commit3aa2e2b3ab21fda7045fbe2bb142e7a6830340e5 (patch)
tree99efaa76587ae98a51fa65e016079d9d46d31752
parente64d6a4e338739dfe482b3926bda16f885889298 (diff)
downloadframeworks_base-3aa2e2b3ab21fda7045fbe2bb142e7a6830340e5.zip
frameworks_base-3aa2e2b3ab21fda7045fbe2bb142e7a6830340e5.tar.gz
frameworks_base-3aa2e2b3ab21fda7045fbe2bb142e7a6830340e5.tar.bz2
Fixing jank when transition from print dialog to generating one.
Initially we show the print dialog and when the user presses print we show a generating dialog with an indefinite spinner and a cancel button. The transition between the two UIs which are really different layouts show in the print activity is animated. In the middle of the animation from print to generating UI there was a jump of the content and an undesired window animation kicking in. This is a side effect of changing the activity to floating so now changing the container size was causing window resize and hence animation. Fun! bug:10983508 Change-Id: I7d88e073c55863b945cdb50822401592f32d44c3
-rw-r--r--packages/PrintSpooler/res/layout/print_job_config_activity_container.xml13
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java37
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java16
3 files changed, 52 insertions, 14 deletions
diff --git a/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml b/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
index 98b5cfe..d503216 100644
--- a/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
+++ b/packages/PrintSpooler/res/layout/print_job_config_activity_container.xml
@@ -15,9 +15,12 @@
-->
<com.android.printspooler.PrintDialogFrame xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/content_container"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:background="@color/container_background">
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <FrameLayout
+ android:id="@+id/content_container"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@color/container_background">
+ </FrameLayout>
</com.android.printspooler.PrintDialogFrame>
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java b/packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java
index 6dd8aa0..c1c4d21 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintDialogFrame.java
@@ -24,6 +24,8 @@ public class PrintDialogFrame extends FrameLayout {
public final int mMaxWidth;
+ public int mHeight;
+
public PrintDialogFrame(Context context, AttributeSet attrs) {
super(context, attrs);
mMaxWidth = context.getResources().getDimensionPixelSize(
@@ -32,13 +34,36 @@ public class PrintDialogFrame extends FrameLayout {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ int measuredWidth = getMeasuredWidth();
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
- if (widthMode == MeasureSpec.AT_MOST) {
- final int receivedWidth = MeasureSpec.getSize(widthMeasureSpec);
- final int computedWidth = Math.min(mMaxWidth, receivedWidth);
- widthMeasureSpec = MeasureSpec.makeMeasureSpec(computedWidth,
- MeasureSpec.EXACTLY);
+ switch (widthMode) {
+ case MeasureSpec.UNSPECIFIED: {
+ measuredWidth = mMaxWidth;
+ } break;
+
+ case MeasureSpec.AT_MOST: {
+ final int receivedWidth = MeasureSpec.getSize(widthMeasureSpec);
+ measuredWidth = Math.min(mMaxWidth, receivedWidth);
+ } break;
}
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ mHeight = Math.max(mHeight, getMeasuredHeight());
+
+ int measuredHeight = getMeasuredHeight();
+ final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ switch (heightMode) {
+ case MeasureSpec.UNSPECIFIED: {
+ measuredHeight = mHeight;
+ } break;
+
+ case MeasureSpec.AT_MOST: {
+ final int receivedHeight = MeasureSpec.getSize(heightMeasureSpec);
+ measuredHeight = Math.min(mHeight, receivedHeight);
+ } break;
+ }
+
+ setMeasuredDimension(measuredWidth, measuredHeight);
}
}
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
index d6ebc2d..2922dd1 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
@@ -59,12 +59,14 @@ import android.text.TextWatcher;
import android.util.ArrayMap;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnAttachStateChangeListener;
import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
@@ -75,6 +77,7 @@ import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
@@ -1409,7 +1412,9 @@ public class PrintJobConfigActivity extends Activity {
postSwitchCallback.run();
}
}
- });
+ },
+ new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
} break;
}
} break;
@@ -1426,7 +1431,9 @@ public class PrintJobConfigActivity extends Activity {
postSwitchCallback.run();
}
}
- });
+ },
+ new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER));
} break;
}
} break;
@@ -1474,7 +1481,8 @@ public class PrintJobConfigActivity extends Activity {
getLayoutInflater().inflate(showLayoutId, contentContainer, true);
}
- private void animateUiSwitch(int showLayoutId, final Runnable postAnimateCommand) {
+ private void animateUiSwitch(int showLayoutId, final Runnable postAnimateCommand,
+ final LayoutParams containerParams) {
// Find everything we will shuffle around.
final ViewGroup contentContainer = (ViewGroup) findViewById(R.id.content_container);
final View hidingView = contentContainer.getChildAt(0);
@@ -1511,6 +1519,8 @@ public class PrintJobConfigActivity extends Activity {
contentContainer.setScaleY(1.0f);
contentContainer.addView(showingView);
+ contentContainer.setLayoutParams(containerParams);
+
// Third animation - show the new content.
AutoCancellingAnimator.animate(showingView).withLayer().alpha(1.0f)
.withEndAction(new Runnable() {