Search in sources :

Example 1 with PhotoAttachCameraCell

use of org.telegram.ui.Cells.PhotoAttachCameraCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatAttachAlertPhotoLayout method onHide.

@Override
public void onHide() {
    isHidden = true;
    dropDownContainer.setVisibility(GONE);
    int count = gridView.getChildCount();
    for (int a = 0; a < count; a++) {
        View child = gridView.getChildAt(a);
        if (child instanceof PhotoAttachCameraCell) {
            PhotoAttachCameraCell cell = (PhotoAttachCameraCell) child;
            child.setVisibility(View.VISIBLE);
            saveLastCameraBitmap();
            cell.updateBitmap();
            break;
        }
    }
}
Also used : PhotoAttachCameraCell(org.telegram.ui.Cells.PhotoAttachCameraCell) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) TextureView(android.view.TextureView) CameraView(org.telegram.messenger.camera.CameraView) Paint(android.graphics.Paint)

Example 2 with PhotoAttachCameraCell

use of org.telegram.ui.Cells.PhotoAttachCameraCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatAttachAlertPhotoLayout method checkColors.

@Override
void checkColors() {
    if (cameraIcon != null) {
        cameraIcon.invalidate();
    }
    String textColor = forceDarkTheme ? Theme.key_voipgroup_actionBarItems : Theme.key_dialogTextBlack;
    Theme.setDrawableColor(cameraDrawable, getThemedColor(Theme.key_dialogCameraIcon));
    progressView.setTextColor(getThemedColor(Theme.key_emptyListPlaceholder));
    gridView.setGlowColor(getThemedColor(Theme.key_dialogScrollGlow));
    RecyclerView.ViewHolder holder = gridView.findViewHolderForAdapterPosition(0);
    if (holder != null && holder.itemView instanceof PhotoAttachCameraCell) {
        ((PhotoAttachCameraCell) holder.itemView).getImageView().setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogCameraIcon), PorterDuff.Mode.MULTIPLY));
    }
    dropDown.setTextColor(getThemedColor(textColor));
    dropDownContainer.setPopupItemsColor(getThemedColor(forceDarkTheme ? Theme.key_voipgroup_actionBarItems : Theme.key_actionBarDefaultSubmenuItem), false);
    dropDownContainer.setPopupItemsColor(getThemedColor(forceDarkTheme ? Theme.key_voipgroup_actionBarItems : Theme.key_actionBarDefaultSubmenuItem), true);
    dropDownContainer.redrawPopup(getThemedColor(forceDarkTheme ? Theme.key_voipgroup_actionBarUnscrolled : Theme.key_actionBarDefaultSubmenuBackground));
    Theme.setDrawableColor(dropDownDrawable, getThemedColor(textColor));
}
Also used : PhotoAttachCameraCell(org.telegram.ui.Cells.PhotoAttachCameraCell) RecyclerView(androidx.recyclerview.widget.RecyclerView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter)

Example 3 with PhotoAttachCameraCell

use of org.telegram.ui.Cells.PhotoAttachCameraCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatAttachAlertPhotoLayout method onShown.

@Override
void onShown() {
    isHidden = false;
    if (cameraView != null) {
        cameraView.setVisibility(VISIBLE);
    }
    if (cameraIcon != null) {
        cameraIcon.setVisibility(VISIBLE);
    }
    if (cameraView != null) {
        int count = gridView.getChildCount();
        for (int a = 0; a < count; a++) {
            View child = gridView.getChildAt(a);
            if (child instanceof PhotoAttachCameraCell) {
                child.setVisibility(View.INVISIBLE);
                break;
            }
        }
    }
    if (checkCameraWhenShown) {
        checkCameraWhenShown = false;
        checkCamera(true);
    }
}
Also used : PhotoAttachCameraCell(org.telegram.ui.Cells.PhotoAttachCameraCell) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) TextureView(android.view.TextureView) CameraView(org.telegram.messenger.camera.CameraView) Paint(android.graphics.Paint)

Example 4 with PhotoAttachCameraCell

use of org.telegram.ui.Cells.PhotoAttachCameraCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatAttachAlertPhotoLayout method checkCameraViewPosition.

private void checkCameraViewPosition() {
    if (Build.VERSION.SDK_INT >= 21) {
        if (cameraView != null) {
            cameraView.invalidateOutline();
        }
        RecyclerView.ViewHolder holder = gridView.findViewHolderForAdapterPosition(itemsPerRow - 1);
        if (holder != null) {
            holder.itemView.invalidateOutline();
        }
        if (!adapter.needCamera || !deviceHasGoodCamera || selectedAlbumEntry != galleryAlbumEntry) {
            holder = gridView.findViewHolderForAdapterPosition(0);
            if (holder != null) {
                holder.itemView.invalidateOutline();
            }
        }
    }
    if (cameraView != null) {
        cameraView.invalidate();
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && recordTime != null) {
        MarginLayoutParams params = (MarginLayoutParams) recordTime.getLayoutParams();
        params.topMargin = (getRootWindowInsets() == null ? AndroidUtilities.dp(16) : getRootWindowInsets().getSystemWindowInsetTop() + AndroidUtilities.dp(2));
    }
    if (!deviceHasGoodCamera) {
        return;
    }
    int count = gridView.getChildCount();
    for (int a = 0; a < count; a++) {
        View child = gridView.getChildAt(a);
        if (child instanceof PhotoAttachCameraCell) {
            if (Build.VERSION.SDK_INT >= 19) {
                if (!child.isAttachedToWindow()) {
                    break;
                }
            }
            float topLocal = child.getY() + gridView.getY() + getY();
            float top = topLocal + parentAlert.getSheetContainer().getY();
            float left = child.getX() + gridView.getX() + getX() + parentAlert.getSheetContainer().getX();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                left -= getRootWindowInsets().getSystemWindowInsetLeft();
            }
            float maxY = (Build.VERSION.SDK_INT >= 21 && !parentAlert.inBubbleMode ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight();
            float newCameraViewOffsetY;
            if (topLocal < maxY) {
                newCameraViewOffsetY = maxY - topLocal;
            } else {
                newCameraViewOffsetY = 0;
            }
            if (newCameraViewOffsetY != cameraViewOffsetY) {
                cameraViewOffsetY = newCameraViewOffsetY;
                if (cameraView != null) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        cameraView.invalidateOutline();
                    } else {
                        cameraView.invalidate();
                    }
                }
                if (cameraIcon != null) {
                    cameraIcon.invalidate();
                }
            }
            int containerHeight = parentAlert.getSheetContainer().getMeasuredHeight();
            maxY = (int) (containerHeight - parentAlert.buttonsRecyclerView.getMeasuredHeight() + parentAlert.buttonsRecyclerView.getTranslationY());
            if (topLocal + child.getMeasuredHeight() > maxY) {
                cameraViewOffsetBottomY = topLocal + child.getMeasuredHeight() - maxY;
            } else {
                cameraViewOffsetBottomY = 0;
            }
            cameraViewLocation[0] = left;
            cameraViewLocation[1] = top;
            applyCameraViewPosition();
            return;
        }
    }
    if (cameraViewOffsetY != 0 || cameraViewOffsetX != 0) {
        cameraViewOffsetX = 0;
        cameraViewOffsetY = 0;
        if (cameraView != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                cameraView.invalidateOutline();
            } else {
                cameraView.invalidate();
            }
        }
        if (cameraIcon != null) {
            cameraIcon.invalidate();
        }
    }
    cameraViewLocation[0] = AndroidUtilities.dp(-400);
    cameraViewLocation[1] = 0;
    applyCameraViewPosition();
}
Also used : PhotoAttachCameraCell(org.telegram.ui.Cells.PhotoAttachCameraCell) RecyclerView(androidx.recyclerview.widget.RecyclerView) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) TextureView(android.view.TextureView) CameraView(org.telegram.messenger.camera.CameraView) Paint(android.graphics.Paint)

Example 5 with PhotoAttachCameraCell

use of org.telegram.ui.Cells.PhotoAttachCameraCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatAttachAlertPhotoLayout method setTranslationY.

@Override
public void setTranslationY(float translationY) {
    if (parentAlert.getSheetAnimationType() == 1) {
        float scale = -0.1f * (translationY / 40.0f);
        for (int a = 0, N = gridView.getChildCount(); a < N; a++) {
            View child = gridView.getChildAt(a);
            if (child instanceof PhotoAttachCameraCell) {
                PhotoAttachCameraCell cell = (PhotoAttachCameraCell) child;
                cell.getImageView().setScaleX(1.0f + scale);
                cell.getImageView().setScaleY(1.0f + scale);
            } else if (child instanceof PhotoAttachPhotoCell) {
                PhotoAttachPhotoCell cell = (PhotoAttachPhotoCell) child;
                cell.getCheckBox().setScaleX(1.0f + scale);
                cell.getCheckBox().setScaleY(1.0f + scale);
            }
        }
    }
    super.setTranslationY(translationY);
    parentAlert.getSheetContainer().invalidate();
    invalidate();
}
Also used : PhotoAttachPhotoCell(org.telegram.ui.Cells.PhotoAttachPhotoCell) PhotoAttachCameraCell(org.telegram.ui.Cells.PhotoAttachCameraCell) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) TextureView(android.view.TextureView) CameraView(org.telegram.messenger.camera.CameraView) Paint(android.graphics.Paint)

Aggregations

RecyclerView (androidx.recyclerview.widget.RecyclerView)7 PhotoAttachCameraCell (org.telegram.ui.Cells.PhotoAttachCameraCell)7 Paint (android.graphics.Paint)6 TextureView (android.view.TextureView)6 View (android.view.View)6 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 CameraView (org.telegram.messenger.camera.CameraView)6 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 Canvas (android.graphics.Canvas)1 Outline (android.graphics.Outline)1 Path (android.graphics.Path)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 Camera (android.hardware.Camera)1 ViewOutlineProvider (android.view.ViewOutlineProvider)1 FrameLayout (android.widget.FrameLayout)1