Search in sources :

Example 1 with PhotoPaintView

use of org.telegram.ui.Components.PhotoPaintView in project Telegram-FOSS by Telegram-FOSS-Team.

the class PhotoViewer method createPaintView.

private void createPaintView() {
    if (photoPaintView == null) {
        int w;
        int h;
        if (videoTextureView != null) {
            VideoEditTextureView textureView = (VideoEditTextureView) videoTextureView;
            w = textureView.getVideoWidth();
            h = textureView.getVideoHeight();
            while (w > 1280 || h > 1280) {
                w /= 2;
                h /= 2;
            }
        } else {
            w = centerImage.getBitmapWidth();
            h = centerImage.getBitmapHeight();
        }
        Bitmap bitmap = paintingOverlay.getBitmap();
        if (bitmap == null) {
            bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
        }
        MediaController.CropState state;
        if (sendPhotoType == SELECT_TYPE_AVATAR) {
            state = new MediaController.CropState();
            state.transformRotation = cropTransform.getOrientation();
        } else {
            state = editState.cropState;
        }
        photoPaintView = new PhotoPaintView(parentActivity, bitmap, isCurrentVideo ? null : centerImage.getBitmap(), centerImage.getOrientation(), editState.mediaEntities, state, () -> paintingOverlay.hideBitmap(), resourcesProvider) {

            @Override
            protected void onOpenCloseStickersAlert(boolean open) {
                if (videoPlayer == null) {
                    return;
                }
                manuallyPaused = false;
                cancelVideoPlayRunnable();
                if (open) {
                    videoPlayer.pause();
                } else {
                    videoPlayer.play();
                }
            }

            @Override
            protected void didSetAnimatedSticker(RLottieDrawable drawable) {
                if (videoPlayer == null) {
                    return;
                }
                drawable.setProgressMs(videoPlayer.getCurrentPosition() - (startTime > 0 ? startTime / 1000 : 0));
            }

            @Override
            protected void onTextAdd() {
                if (!windowView.isFocusable()) {
                    makeFocusable();
                }
            }
        };
        containerView.addView(photoPaintView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        photoPaintView.getDoneTextView().setOnClickListener(v -> {
            savedState = null;
            applyCurrentEditMode();
            switchToEditMode(0);
        });
        photoPaintView.getCancelTextView().setOnClickListener(v -> closePaintMode());
        photoPaintView.getColorPicker().setTranslationY(AndroidUtilities.dp(126));
        photoPaintView.getToolsView().setTranslationY(AndroidUtilities.dp(126));
    }
}
Also used : Bitmap(android.graphics.Bitmap) MediaController(org.telegram.messenger.MediaController) VideoEditTextureView(org.telegram.ui.Components.VideoEditTextureView) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) PhotoPaintView(org.telegram.ui.Components.PhotoPaintView) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint)

Example 2 with PhotoPaintView

use of org.telegram.ui.Components.PhotoPaintView in project Telegram-FOSS by Telegram-FOSS-Team.

the class PhotoViewer method updateColors.

public void updateColors() {
    int color = getThemedColor(Theme.key_dialogFloatingButton);
    if (pickerViewSendButton != null) {
        Drawable drawable = pickerViewSendButton.getBackground();
        Theme.setSelectorDrawableColor(drawable, color, false);
        Theme.setSelectorDrawableColor(drawable, getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton), true);
        pickerViewSendButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));
    }
    if (checkImageView != null) {
        checkImageView.setColor(getThemedColor(Theme.key_dialogFloatingButton), 0xffffffff);
    }
    PorterDuffColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY);
    if (timeItem != null && timeItem.getColorFilter() != null) {
        timeItem.setColorFilter(filter);
    }
    if (paintItem != null && paintItem.getColorFilter() != null) {
        paintItem.setColorFilter(filter);
    }
    if (cropItem != null && cropItem.getColorFilter() != null) {
        cropItem.setColorFilter(filter);
    }
    if (tuneItem != null && tuneItem.getColorFilter() != null) {
        tuneItem.setColorFilter(filter);
    }
    if (rotateItem != null && rotateItem.getColorFilter() != null) {
        rotateItem.setColorFilter(filter);
    }
    if (mirrorItem != null && mirrorItem.getColorFilter() != null) {
        mirrorItem.setColorFilter(filter);
    }
    if (editorDoneLayout != null) {
        editorDoneLayout.doneButton.setTextColor(color);
    }
    if (qualityPicker != null) {
        qualityPicker.doneButton.setTextColor(color);
    }
    if (photoPaintView != null) {
        photoPaintView.updateColors();
    }
    if (photoFilterView != null) {
        photoFilterView.updateColors();
    }
    if (captionEditText != null) {
        captionEditText.updateColors();
    }
    if (videoTimelineView != null) {
        videoTimelineView.invalidate();
    }
    if (selectedPhotosListView != null) {
        int count = selectedPhotosListView.getChildCount();
        for (int a = 0; a < count; a++) {
            View view = selectedPhotosListView.getChildAt(a);
            if (view instanceof PhotoPickerPhotoCell) {
                ((PhotoPickerPhotoCell) view).updateColors();
            }
        }
    }
    if (masksAlert != null) {
        masksAlert.updateColors(true);
    }
}
Also used : PhotoPickerPhotoCell(org.telegram.ui.Cells.PhotoPickerPhotoCell) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) VideoForwardDrawable(org.telegram.ui.Components.VideoForwardDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) OtherDocumentPlaceholderDrawable(org.telegram.ui.Components.OtherDocumentPlaceholderDrawable) PlayPauseDrawable(org.telegram.ui.Components.PlayPauseDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) PhotoCropView(org.telegram.ui.Components.PhotoCropView) PhotoViewerWebView(org.telegram.ui.Components.PhotoViewerWebView) CropView(org.telegram.ui.Components.Crop.CropView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) SpoilersTextView(org.telegram.ui.Components.spoilers.SpoilersTextView) NestedScrollView(androidx.core.widget.NestedScrollView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PipVideoView(org.telegram.ui.Components.PipVideoView) BackupImageView(org.telegram.ui.Components.BackupImageView) TextureView(android.view.TextureView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) PhotoViewerCaptionEnterView(org.telegram.ui.Components.PhotoViewerCaptionEnterView) UndoView(org.telegram.ui.Components.UndoView) VideoEditTextureView(org.telegram.ui.Components.VideoEditTextureView) GroupedPhotosListView(org.telegram.ui.Components.GroupedPhotosListView) PhotoPaintView(org.telegram.ui.Components.PhotoPaintView) ClippingImageView(org.telegram.ui.Components.ClippingImageView) View(android.view.View) TextView(android.widget.TextView) VideoTimelinePlayView(org.telegram.ui.Components.VideoTimelinePlayView) PhotoFilterView(org.telegram.ui.Components.PhotoFilterView) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)2 Paint (android.graphics.Paint)2 TextPaint (android.text.TextPaint)2 PhotoPaintView (org.telegram.ui.Components.PhotoPaintView)2 RLottieDrawable (org.telegram.ui.Components.RLottieDrawable)2 VideoEditTextureView (org.telegram.ui.Components.VideoEditTextureView)2 Bitmap (android.graphics.Bitmap)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 TextureView (android.view.TextureView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 NestedScrollView (androidx.core.widget.NestedScrollView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 MediaController (org.telegram.messenger.MediaController)1 SimpleTextView (org.telegram.ui.ActionBar.SimpleTextView)1