Search in sources :

Example 1 with ResizeAnimation

use of org.thoughtcrime.securesms.animation.ResizeAnimation in project Signal-Android by WhisperSystems.

the class ImageEditorFragment method scaleViewPortForDrawing.

private void scaleViewPortForDrawing(int orientation, int protection) {
    if (resizeAnimation != null) {
        resizeAnimation.cancel();
    }
    float aspectRatio = getAspectRatioForOrientation(orientation);
    int targetWidth = getWidthForOrientation(orientation) - ViewUtil.dpToPx(32);
    int targetHeight = (int) ((1 / aspectRatio) * targetWidth);
    int maxHeight = getHeightForOrientation(orientation) - protection;
    if (targetHeight > maxHeight) {
        targetHeight = maxHeight;
        targetWidth = Math.round(targetHeight * aspectRatio);
    }
    resizeAnimation = new ResizeAnimation(imageEditorView, targetWidth, targetHeight);
    resizeAnimation.setDuration(250);
    resizeAnimation.setInterpolator(MediaAnimations.getInterpolator());
    imageEditorView.startAnimation(resizeAnimation);
}
Also used : ResizeAnimation(org.thoughtcrime.securesms.animation.ResizeAnimation) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 2 with ResizeAnimation

use of org.thoughtcrime.securesms.animation.ResizeAnimation in project Signal-Android by signalapp.

the class WebRtcCallView method animatePipToLargeRectangle.

private void animatePipToLargeRectangle(boolean isLandscape) {
    final Point dimens;
    if (isLandscape) {
        dimens = new Point(ViewUtil.dpToPx(160), ViewUtil.dpToPx(90));
    } else {
        dimens = new Point(ViewUtil.dpToPx(90), ViewUtil.dpToPx(160));
    }
    ResizeAnimation animation = new ResizeAnimation(smallLocalRenderFrame, dimens.x, dimens.y);
    animation.setDuration(PIP_RESIZE_DURATION);
    animation.setAnimationListener(new SimpleAnimationListener() {

        @Override
        public void onAnimationEnd(Animation animation) {
            pictureInPictureGestureHelper.enableCorners();
            pictureInPictureGestureHelper.adjustPip();
        }
    });
    smallLocalRenderFrame.startAnimation(animation);
}
Also used : ResizeAnimation(org.thoughtcrime.securesms.animation.ResizeAnimation) SimpleAnimationListener(org.thoughtcrime.securesms.mediasend.SimpleAnimationListener) Animation(android.view.animation.Animation) ResizeAnimation(org.thoughtcrime.securesms.animation.ResizeAnimation) Point(android.graphics.Point)

Example 3 with ResizeAnimation

use of org.thoughtcrime.securesms.animation.ResizeAnimation in project Signal-Android by signalapp.

the class ImageEditorFragment method restoreViewPortScaling.

private void restoreViewPortScaling(int orientation) {
    if (resizeAnimation != null) {
        resizeAnimation.cancel();
    }
    int maxHeight = getHeightForOrientation(orientation);
    float aspectRatio = getAspectRatioForOrientation(orientation);
    int targetWidth = getWidthForOrientation(orientation);
    int targetHeight = (int) ((1 / aspectRatio) * targetWidth);
    if (targetHeight > maxHeight) {
        targetHeight = maxHeight;
        targetWidth = Math.round(targetHeight * aspectRatio);
    }
    resizeAnimation = new ResizeAnimation(imageEditorView, targetWidth, targetHeight);
    resizeAnimation.setDuration(250);
    resizeAnimation.setInterpolator(MediaAnimations.getInterpolator());
    imageEditorView.startAnimation(resizeAnimation);
}
Also used : ResizeAnimation(org.thoughtcrime.securesms.animation.ResizeAnimation) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 4 with ResizeAnimation

use of org.thoughtcrime.securesms.animation.ResizeAnimation in project Signal-Android by signalapp.

the class ImageEditorFragment method scaleViewPortForDrawing.

private void scaleViewPortForDrawing(int orientation, int protection) {
    if (resizeAnimation != null) {
        resizeAnimation.cancel();
    }
    float aspectRatio = getAspectRatioForOrientation(orientation);
    int targetWidth = getWidthForOrientation(orientation) - ViewUtil.dpToPx(32);
    int targetHeight = (int) ((1 / aspectRatio) * targetWidth);
    int maxHeight = getHeightForOrientation(orientation) - protection;
    if (targetHeight > maxHeight) {
        targetHeight = maxHeight;
        targetWidth = Math.round(targetHeight * aspectRatio);
    }
    resizeAnimation = new ResizeAnimation(imageEditorView, targetWidth, targetHeight);
    resizeAnimation.setDuration(250);
    resizeAnimation.setInterpolator(MediaAnimations.getInterpolator());
    imageEditorView.startAnimation(resizeAnimation);
}
Also used : ResizeAnimation(org.thoughtcrime.securesms.animation.ResizeAnimation) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 5 with ResizeAnimation

use of org.thoughtcrime.securesms.animation.ResizeAnimation in project Signal-Android by WhisperSystems.

the class WebRtcCallView method animatePipToLargeRectangle.

private void animatePipToLargeRectangle(boolean isLandscape) {
    final Point dimens;
    if (isLandscape) {
        dimens = new Point(ViewUtil.dpToPx(160), ViewUtil.dpToPx(90));
    } else {
        dimens = new Point(ViewUtil.dpToPx(90), ViewUtil.dpToPx(160));
    }
    ResizeAnimation animation = new ResizeAnimation(smallLocalRenderFrame, dimens.x, dimens.y);
    animation.setDuration(PIP_RESIZE_DURATION);
    animation.setAnimationListener(new SimpleAnimationListener() {

        @Override
        public void onAnimationEnd(Animation animation) {
            pictureInPictureGestureHelper.enableCorners();
            pictureInPictureGestureHelper.adjustPip();
        }
    });
    smallLocalRenderFrame.startAnimation(animation);
}
Also used : ResizeAnimation(org.thoughtcrime.securesms.animation.ResizeAnimation) SimpleAnimationListener(org.thoughtcrime.securesms.mediasend.SimpleAnimationListener) Animation(android.view.animation.Animation) ResizeAnimation(org.thoughtcrime.securesms.animation.ResizeAnimation) Point(android.graphics.Point)

Aggregations

ResizeAnimation (org.thoughtcrime.securesms.animation.ResizeAnimation)8 Point (android.graphics.Point)6 Paint (android.graphics.Paint)4 Animation (android.view.animation.Animation)4 SimpleAnimationListener (org.thoughtcrime.securesms.mediasend.SimpleAnimationListener)4