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));
}
}
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);
}
}
Aggregations