Merge "Fix LongScreenshotActivity rotation" into sc-dev

This commit is contained in:
Matt Casey
2021-06-16 19:32:14 +00:00
committed by Android (Google) Code Review

View File

@@ -250,6 +250,7 @@ public class LongScreenshotActivity extends Activity {
Log.d(TAG, "onCachedImageLoaded(imageResult=" + imageResult + ")"); Log.d(TAG, "onCachedImageLoaded(imageResult=" + imageResult + ")");
BitmapDrawable drawable = new BitmapDrawable(getResources(), imageResult.bitmap); BitmapDrawable drawable = new BitmapDrawable(getResources(), imageResult.bitmap);
mPreview.setImageDrawable(drawable); mPreview.setImageDrawable(drawable);
mPreview.setAlpha(1f);
mMagnifierView.setDrawable(drawable, imageResult.bitmap.getWidth(), mMagnifierView.setDrawable(drawable, imageResult.bitmap.getWidth(),
imageResult.bitmap.getHeight()); imageResult.bitmap.getHeight());
mCropView.setVisibility(View.VISIBLE); mCropView.setVisibility(View.VISIBLE);
@@ -476,19 +477,21 @@ public class LongScreenshotActivity extends Activity {
params.height = boundaries.height(); params.height = boundaries.height();
mTransitionView.setLayoutParams(params); mTransitionView.setLayoutParams(params);
ConstraintLayout.LayoutParams enterTransitionParams = if (mLongScreenshot != null) {
(ConstraintLayout.LayoutParams) mEnterTransitionView.getLayoutParams(); ConstraintLayout.LayoutParams enterTransitionParams =
float topFraction = Math.max(0, (ConstraintLayout.LayoutParams) mEnterTransitionView.getLayoutParams();
-mLongScreenshot.getTop() / (float) mLongScreenshot.getHeight()); float topFraction = Math.max(0,
enterTransitionParams.width = (int) (scale * drawable.getIntrinsicWidth()); -mLongScreenshot.getTop() / (float) mLongScreenshot.getHeight());
enterTransitionParams.height = (int) (scale * mLongScreenshot.getPageHeight()); enterTransitionParams.width = (int) (scale * drawable.getIntrinsicWidth());
mEnterTransitionView.setLayoutParams(enterTransitionParams); enterTransitionParams.height = (int) (scale * mLongScreenshot.getPageHeight());
mEnterTransitionView.setLayoutParams(enterTransitionParams);
Matrix matrix = new Matrix(); Matrix matrix = new Matrix();
matrix.setScale(scale, scale); matrix.setScale(scale, scale);
matrix.postTranslate(0, -scale * drawable.getIntrinsicHeight() * topFraction); matrix.postTranslate(0, -scale * drawable.getIntrinsicHeight() * topFraction);
mEnterTransitionView.setImageMatrix(matrix); mEnterTransitionView.setImageMatrix(matrix);
mEnterTransitionView.setTranslationY( mEnterTransitionView.setTranslationY(
topFraction * previewHeight + mPreview.getPaddingTop() + extraPadding); topFraction * previewHeight + mPreview.getPaddingTop() + extraPadding);
}
} }
} }