Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2a4703c authored by Matt Casey's avatar Matt Casey Committed by Automerger Merge Worker
Browse files

Merge "Update long screenshot crop per mocks" into sc-dev am: abe60b35

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13938665

Change-Id: I2af62bc363d688da8ddee2a872246e0719dd39e4
parents 2b4b931e abe60b35
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@
    <color name="global_screenshot_background_protection_start">#40000000</color> <!-- 25% black -->

    <!-- Long screenshot UI -->
    <color name="screenshot_crop_scrim">#9444</color>
    <color name="screenshot_crop_scrim">#6444</color>

    <!-- GM2 colors -->
    <color name="GM2_grey_50">#F8F9FA</color>
+161 −107

File changed.

Preview size limit exceeded, changes collapsed.

+8 −7
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class LongScreenshotActivity extends Activity {

        mPreview.addOnLayoutChangeListener(
                (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
                        updateCropLocation());
                        updateImageDimensions());

        Intent intent = getIntent();
        mScrollCaptureResponse = intent.getParcelableExtra(EXTRA_CAPTURE_RESPONSE);
@@ -206,7 +206,7 @@ public class LongScreenshotActivity extends Activity {
        Log.d(TAG, "onCaptureCompleted(longScreenshot=" + longScreenshot + ")");
        mLongScreenshot = longScreenshot;
        mPreview.setImageDrawable(mLongScreenshot.getDrawable());
        updateCropLocation();
        updateImageDimensions();
        mMagnifierView.setDrawable(mLongScreenshot.getDrawable(),
                mLongScreenshot.getWidth(), mLongScreenshot.getHeight());
        // Original boundaries go from the image tile set's y=0 to y=pageSize, so
@@ -363,10 +363,8 @@ public class LongScreenshotActivity extends Activity {
            return;
        }

        Rect bounds = new Rect(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        int height = bounds.height();
        bounds.top = (int) (height * mCropView.getTopBoundary());
        bounds.bottom = (int) (height * mCropView.getBottomBoundary());
        Rect bounds = mCropView.getCropBoundaries(drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());

        if (bounds.isEmpty()) {
            Log.w(TAG, "Crop bounds empty, skipping export.");
@@ -404,7 +402,7 @@ public class LongScreenshotActivity extends Activity {
        }
    }

    private void updateCropLocation() {
    private void updateImageDimensions() {
        Drawable drawable = mPreview.getDrawable();
        if (drawable == null) {
            return;
@@ -419,9 +417,12 @@ public class LongScreenshotActivity extends Activity {
            float imageHeight = mPreview.getHeight() * viewRatio / imageRatio;
            int extraPadding = (int) (mPreview.getHeight() - imageHeight) / 2;
            mCropView.setExtraPadding(extraPadding, extraPadding);
            mCropView.setImageWidth(mPreview.getWidth());
        } else {
            // Image is full height
            mCropView.setExtraPadding(0, 0);
            mCropView.setImageWidth((int) (mPreview.getHeight() * imageRatio));
        }

    }
}
+4 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public class MagnifierView extends View implements CropView.CropInteractionListe
    private float mCheckerboardBoxSize = 40;

    private float mLastCropPosition;
    private float mLastCenter = 0.5f;
    private CropView.CropBoundary mCropBoundary;

    private ViewPropertyAnimator mTranslationAnimator;
@@ -131,7 +132,7 @@ public class MagnifierView extends View implements CropView.CropInteractionListe
            canvas.save();
            // Translate such that the center of this view represents the center of the crop
            // boundary.
            canvas.translate(-mDrawable.getBounds().width() / 2 + getWidth() / 2,
            canvas.translate(-mDrawable.getBounds().width() * mLastCenter + getWidth() / 2,
                    -mDrawable.getBounds().height() * mLastCropPosition + getHeight() / 2);
            mDrawable.draw(canvas);
            canvas.restore();
@@ -148,8 +149,9 @@ public class MagnifierView extends View implements CropView.CropInteractionListe

    @Override
    public void onCropMotionEvent(MotionEvent event, CropView.CropBoundary boundary,
            float cropPosition, int cropPositionPx) {
            float cropPosition, int cropPositionPx, float horizontalCenter) {
        mCropBoundary = boundary;
        mLastCenter = horizontalCenter;
        boolean touchOnRight = event.getX() > getParentWidth() / 2;
        float translateXTarget = touchOnRight ? 0 : getParentWidth() - getWidth();
        switch (event.getAction()) {