Search in sources :

Example 26 with CombinedDrawable

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

the class LoginActivity method createView.

@Override
public View createView(Context context) {
    actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == done_button) {
                onDoneButtonPressed();
            } else if (id == -1) {
                if (onBackPressed()) {
                    finishFragment();
                }
            }
        }
    });
    currentDoneType = DONE_TYPE_FLOATING;
    doneButtonVisible[DONE_TYPE_FLOATING] = true;
    doneButtonVisible[DONE_TYPE_ACTION] = false;
    ActionBarMenu menu = actionBar.createMenu();
    actionBar.setAllowOverlayTitle(true);
    doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
    doneProgressView = new ContextProgressView(context, 1);
    doneProgressView.setAlpha(0.0f);
    doneProgressView.setScaleX(0.1f);
    doneProgressView.setScaleY(0.1f);
    doneProgressView.setVisibility(View.INVISIBLE);
    doneItem.setAlpha(0.0f);
    doneItem.setScaleX(0.1f);
    doneItem.setScaleY(0.1f);
    doneItem.addView(doneProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    doneItem.setContentDescription(LocaleController.getString("Done", R.string.Done));
    doneItem.setVisibility(doneButtonVisible[DONE_TYPE_ACTION] ? View.VISIBLE : View.GONE);
    FrameLayout container = new FrameLayout(context) {

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) floatingButtonContainer.getLayoutParams();
            if (Bulletin.getVisibleBulletin() != null && Bulletin.getVisibleBulletin().isShowing()) {
                super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                marginLayoutParams.bottomMargin = AndroidUtilities.dp(14) + Bulletin.getVisibleBulletin().getLayout().getMeasuredHeight() - AndroidUtilities.dp(10);
            } else {
                marginLayoutParams.bottomMargin = AndroidUtilities.dp(14);
            }
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    };
    fragmentView = container;
    ScrollView scrollView = new ScrollView(context) {

        @Override
        public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
            if (currentViewNum == 1 || currentViewNum == 2 || currentViewNum == 4) {
                rectangle.bottom += AndroidUtilities.dp(40);
            }
            return super.requestChildRectangleOnScreen(child, rectangle, immediate);
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            scrollHeight = MeasureSpec.getSize(heightMeasureSpec) - AndroidUtilities.dp(30);
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    };
    scrollView.setFillViewport(true);
    container.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    FrameLayout frameLayout = new FrameLayout(context);
    scrollView.addView(frameLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));
    views[0] = new PhoneView(context);
    views[1] = new LoginActivitySmsView(context, 1);
    views[2] = new LoginActivitySmsView(context, 2);
    views[3] = new LoginActivitySmsView(context, 3);
    views[4] = new LoginActivitySmsView(context, 4);
    views[5] = new LoginActivityRegisterView(context);
    views[6] = new LoginActivityPasswordView(context);
    views[7] = new LoginActivityRecoverView(context);
    views[8] = new LoginActivityResetWaitView(context);
    views[9] = new LoginActivityNewPasswordView(context, 0);
    views[10] = new LoginActivityNewPasswordView(context, 1);
    views[11] = new LoginActivitySmsView(context, 11);
    for (int a = 0; a < views.length; a++) {
        views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
        frameLayout.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0));
    }
    Bundle savedInstanceState = loadCurrentState();
    if (savedInstanceState != null) {
        currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
        syncContacts = savedInstanceState.getInt("syncContacts", 1) == 1;
        if (currentViewNum >= 1 && currentViewNum <= 4) {
            int time = savedInstanceState.getInt("open");
            if (time != 0 && Math.abs(System.currentTimeMillis() / 1000 - time) >= 24 * 60 * 60) {
                currentViewNum = 0;
                savedInstanceState = null;
                clearCurrentState();
            }
        } else if (currentViewNum == 6) {
            LoginActivityPasswordView view = (LoginActivityPasswordView) views[6];
            if (view.currentPassword == null) {
                currentViewNum = 0;
                savedInstanceState = null;
                clearCurrentState();
            }
        } else if (currentViewNum == 7) {
            LoginActivityRecoverView view = (LoginActivityRecoverView) views[7];
            if (view.passwordString == null) {
                currentViewNum = 0;
                savedInstanceState = null;
                clearCurrentState();
            }
        }
    }
    floatingButtonContainer = new FrameLayout(context);
    floatingButtonContainer.setVisibility(doneButtonVisible[DONE_TYPE_FLOATING] ? View.VISIBLE : View.GONE);
    Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
        drawable = combinedDrawable;
    }
    floatingButtonContainer.setBackgroundDrawable(drawable);
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButtonIcon, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButtonIcon, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        floatingButtonContainer.setStateListAnimator(animator);
        floatingButtonContainer.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
            }
        });
    }
    VerticalPositionAutoAnimator.attach(floatingButtonContainer);
    container.addView(floatingButtonContainer, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 14, 14));
    floatingButtonContainer.setOnClickListener(view -> onDoneButtonPressed());
    floatingButtonIcon = new ImageView(context);
    floatingButtonIcon.setScaleType(ImageView.ScaleType.CENTER);
    floatingButtonIcon.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
    floatingButtonIcon.setImageResource(R.drawable.actionbtn_next);
    floatingButtonContainer.setContentDescription(LocaleController.getString("Done", R.string.Done));
    floatingButtonContainer.addView(floatingButtonIcon, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60));
    floatingProgressView = new RadialProgressView(context);
    floatingProgressView.setSize(AndroidUtilities.dp(22));
    floatingProgressView.setProgressColor(Theme.getColor(Theme.key_chats_actionIcon));
    floatingProgressView.setAlpha(0.0f);
    floatingProgressView.setScaleX(0.1f);
    floatingProgressView.setScaleY(0.1f);
    floatingProgressView.setVisibility(View.INVISIBLE);
    floatingButtonContainer.addView(floatingProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    if (savedInstanceState != null) {
        restoringState = true;
    }
    for (int a = 0; a < views.length; a++) {
        if (savedInstanceState != null) {
            if (a >= 1 && a <= 4) {
                if (a == currentViewNum) {
                    views[a].restoreStateParams(savedInstanceState);
                }
            } else {
                views[a].restoreStateParams(savedInstanceState);
            }
        }
        if (currentViewNum == a) {
            actionBar.setBackButtonImage(views[a].needBackButton() || newAccount ? R.drawable.ic_ab_back : 0);
            views[a].setVisibility(View.VISIBLE);
            views[a].onShow();
            currentDoneType = DONE_TYPE_FLOATING;
            if (a == 1 || a == 2 || a == 3 || a == 4 || a == 8) {
                showDoneButton(false, false);
            } else {
                showDoneButton(true, false);
            }
            if (a == 1 || a == 2 || a == 3 || a == 4) {
                currentDoneType = DONE_TYPE_ACTION;
            }
        } else {
            views[a].setVisibility(View.GONE);
        }
    }
    restoringState = false;
    actionBar.setTitle(views[currentViewNum].getHeaderName());
    return fragmentView;
}
Also used : ContextProgressView(org.telegram.ui.Components.ContextProgressView) StateListAnimator(android.animation.StateListAnimator) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ImageView(android.widget.ImageView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) ActionBar(org.telegram.ui.ActionBar.ActionBar) Rect(android.graphics.Rect) RadialProgressView(org.telegram.ui.Components.RadialProgressView) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) Outline(android.graphics.Outline) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) SlideView(org.telegram.ui.Components.SlideView) ScrollView(android.widget.ScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) ContextProgressView(org.telegram.ui.Components.ContextProgressView) RLottieImageView(org.telegram.ui.Components.RLottieImageView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) ViewOutlineProvider(android.view.ViewOutlineProvider) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) ScrollView(android.widget.ScrollView) FrameLayout(android.widget.FrameLayout) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) SuppressLint(android.annotation.SuppressLint)

Example 27 with CombinedDrawable

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

the class ProfileActivity method onBecomeFullyVisible.

@Override
protected void onBecomeFullyVisible() {
    super.onBecomeFullyVisible();
    try {
        Drawable shadowDrawable = fragmentView.getContext().getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(Color.BLACK, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_profile_actionBackground), Theme.getColor(Theme.key_profile_actionPressedBackground)), 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
        writeButton.setBackground(combinedDrawable);
    } catch (Exception e) {
    }
}
Also used : CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) TimerDrawable(org.telegram.ui.Components.TimerDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) IdenticonDrawable(org.telegram.ui.Components.IdenticonDrawable) CrossfadeDrawable(org.telegram.ui.Components.CrossfadeDrawable) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ScamDrawable(org.telegram.ui.Components.ScamDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter)

Example 28 with CombinedDrawable

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

the class PhotoAlbumPickerActivity method createView.

@Override
public View createView(Context context) {
    actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack));
    actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false);
    actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == 1) {
                if (delegate != null) {
                    finishFragment(false);
                    delegate.startPhotoSelectActivity();
                }
            } else if (id == 2) {
                openPhotoPicker(null, 0);
            }
        }
    });
    ActionBarMenu menu = actionBar.createMenu();
    if (allowSearchImages) {
        menu.addItem(2, R.drawable.ic_ab_search).setContentDescription(LocaleController.getString("Search", R.string.Search));
    }
    ActionBarMenuItem menuItem = menu.addItem(0, R.drawable.ic_ab_other);
    menuItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
    menuItem.addSubItem(1, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
    sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {

        private int lastNotifyWidth;

        private boolean ignoreLayout;

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int widthSize = MeasureSpec.getSize(widthMeasureSpec);
            int heightSize = MeasureSpec.getSize(heightMeasureSpec);
            setMeasuredDimension(widthSize, heightSize);
            int keyboardSize = SharedConfig.smoothKeyboard ? 0 : measureKeyboardHeight();
            if (keyboardSize <= AndroidUtilities.dp(20)) {
                if (!AndroidUtilities.isInMultiwindow) {
                    heightSize -= commentTextView.getEmojiPadding();
                    heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
                }
            } else {
                ignoreLayout = true;
                commentTextView.hideEmojiView();
                ignoreLayout = false;
            }
            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
                View child = getChildAt(i);
                if (child == null || child.getVisibility() == GONE) {
                    continue;
                }
                if (commentTextView != null && commentTextView.isPopupView(child)) {
                    if (AndroidUtilities.isInMultiwindow || AndroidUtilities.isTablet()) {
                        if (AndroidUtilities.isTablet()) {
                            child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(AndroidUtilities.isTablet() ? 200 : 320), heightSize - AndroidUtilities.statusBarHeight + getPaddingTop()), MeasureSpec.EXACTLY));
                        } else {
                            child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize - AndroidUtilities.statusBarHeight + getPaddingTop(), MeasureSpec.EXACTLY));
                        }
                    } else {
                        child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
                    }
                } else {
                    measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
                }
            }
        }

        @Override
        protected void onLayout(boolean changed, int l, int t, int r, int b) {
            if (lastNotifyWidth != r - l) {
                lastNotifyWidth = r - l;
                if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
                    sendPopupWindow.dismiss();
                }
            }
            final int count = getChildCount();
            int keyboardSize = SharedConfig.smoothKeyboard ? 0 : measureKeyboardHeight();
            int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
            setBottomClip(paddingBottom);
            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);
                if (child.getVisibility() == GONE) {
                    continue;
                }
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                final int width = child.getMeasuredWidth();
                final int height = child.getMeasuredHeight();
                int childLeft;
                int childTop;
                int gravity = lp.gravity;
                if (gravity == -1) {
                    gravity = Gravity.TOP | Gravity.LEFT;
                }
                final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
                final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
                switch(absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                    case Gravity.CENTER_HORIZONTAL:
                        childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
                        break;
                    case Gravity.RIGHT:
                        childLeft = (r - l) - width - lp.rightMargin - getPaddingRight();
                        break;
                    case Gravity.LEFT:
                    default:
                        childLeft = lp.leftMargin + getPaddingLeft();
                }
                switch(verticalGravity) {
                    case Gravity.TOP:
                        childTop = lp.topMargin + getPaddingTop();
                        break;
                    case Gravity.CENTER_VERTICAL:
                        childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
                        break;
                    case Gravity.BOTTOM:
                        childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
                        break;
                    default:
                        childTop = lp.topMargin;
                }
                if (commentTextView != null && commentTextView.isPopupView(child)) {
                    if (AndroidUtilities.isTablet()) {
                        childTop = getMeasuredHeight() - child.getMeasuredHeight();
                    } else {
                        childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
                    }
                }
                child.layout(childLeft, childTop, childLeft + width, childTop + height);
            }
            notifyHeightChanged();
        }

        @Override
        public void requestLayout() {
            if (ignoreLayout) {
                return;
            }
            super.requestLayout();
        }
    };
    sizeNotifierFrameLayout.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    fragmentView = sizeNotifierFrameLayout;
    actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery));
    listView = new RecyclerListView(context);
    listView.setPadding(AndroidUtilities.dp(6), AndroidUtilities.dp(4), AndroidUtilities.dp(6), AndroidUtilities.dp(54));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    listView.setDrawingCacheEnabled(false);
    sizeNotifierFrameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
    listView.setAdapter(listAdapter = new ListAdapter(context));
    listView.setGlowColor(Theme.getColor(Theme.key_dialogBackground));
    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
    sizeNotifierFrameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 48));
    emptyView.setOnTouchListener((v, event) -> true);
    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    sizeNotifierFrameLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 48));
    RadialProgressView progressBar = new RadialProgressView(context);
    progressBar.setProgressColor(0xff527da3);
    progressView.addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
    shadow = new View(context);
    shadow.setBackgroundResource(R.drawable.header_shadow_reverse);
    shadow.setTranslationY(AndroidUtilities.dp(48));
    sizeNotifierFrameLayout.addView(shadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48));
    frameLayout2 = new FrameLayout(context);
    frameLayout2.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    frameLayout2.setVisibility(View.INVISIBLE);
    frameLayout2.setTranslationY(AndroidUtilities.dp(48));
    sizeNotifierFrameLayout.addView(frameLayout2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));
    frameLayout2.setOnTouchListener((v, event) -> true);
    if (commentTextView != null) {
        commentTextView.onDestroy();
    }
    commentTextView = new EditTextEmoji(context, sizeNotifierFrameLayout, null, EditTextEmoji.STYLE_DIALOG);
    InputFilter[] inputFilters = new InputFilter[1];
    inputFilters[0] = new InputFilter.LengthFilter(MessagesController.getInstance(UserConfig.selectedAccount).maxCaptionLength);
    commentTextView.setFilters(inputFilters);
    commentTextView.setHint(LocaleController.getString("AddCaption", R.string.AddCaption));
    EditTextBoldCursor editText = commentTextView.getEditText();
    editText.setMaxLines(1);
    editText.setSingleLine(true);
    frameLayout2.addView(commentTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 84, 0));
    if (caption != null) {
        commentTextView.setText(caption);
    }
    writeButtonContainer = new FrameLayout(context) {

        @Override
        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
            super.onInitializeAccessibilityNodeInfo(info);
            info.setText(LocaleController.formatPluralString("AccDescrSendPhotos", selectedPhotos.size()));
            info.setClassName(Button.class.getName());
            info.setLongClickable(true);
            info.setClickable(true);
        }
    };
    writeButtonContainer.setFocusable(true);
    writeButtonContainer.setFocusableInTouchMode(true);
    writeButtonContainer.setVisibility(View.INVISIBLE);
    writeButtonContainer.setScaleX(0.2f);
    writeButtonContainer.setScaleY(0.2f);
    writeButtonContainer.setAlpha(0.0f);
    sizeNotifierFrameLayout.addView(writeButtonContainer, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 12, 10));
    writeButton = new ImageView(context);
    writeButtonDrawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_dialogFloatingButton), Theme.getColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, writeButtonDrawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
        writeButtonDrawable = combinedDrawable;
    }
    writeButton.setBackgroundDrawable(writeButtonDrawable);
    writeButton.setImageResource(R.drawable.attach_send);
    writeButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));
    writeButton.setScaleType(ImageView.ScaleType.CENTER);
    if (Build.VERSION.SDK_INT >= 21) {
        writeButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
            }
        });
    }
    writeButtonContainer.addView(writeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.LEFT | Gravity.TOP, Build.VERSION.SDK_INT >= 21 ? 2 : 0, 0, 0, 0));
    writeButton.setOnClickListener(v -> {
        if (chatActivity != null && chatActivity.isInScheduleMode()) {
            AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), chatActivity.getDialogId(), (notify, scheduleDate) -> {
                sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, notify, scheduleDate);
                finishFragment();
            });
        } else {
            sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, true, 0);
            finishFragment();
        }
    });
    writeButton.setOnLongClickListener(view -> {
        if (chatActivity == null || maxSelectedPhotos == 1) {
            return false;
        }
        TLRPC.Chat chat = chatActivity.getCurrentChat();
        TLRPC.User user = chatActivity.getCurrentUser();
        if (sendPopupLayout == null) {
            sendPopupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity());
            sendPopupLayout.setAnimationEnabled(false);
            sendPopupLayout.setOnTouchListener(new View.OnTouchListener() {

                private android.graphics.Rect popupRect = new android.graphics.Rect();

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                        if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
                            v.getHitRect(popupRect);
                            if (!popupRect.contains((int) event.getX(), (int) event.getY())) {
                                sendPopupWindow.dismiss();
                            }
                        }
                    }
                    return false;
                }
            });
            sendPopupLayout.setDispatchKeyEventListener(keyEvent -> {
                if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && sendPopupWindow != null && sendPopupWindow.isShowing()) {
                    sendPopupWindow.dismiss();
                }
            });
            sendPopupLayout.setShownFromBotton(false);
            itemCells = new ActionBarMenuSubItem[2];
            for (int a = 0; a < 2; a++) {
                if (a == 0 && !chatActivity.canScheduleMessage() || a == 1 && UserObject.isUserSelf(user)) {
                    continue;
                }
                int num = a;
                itemCells[a] = new ActionBarMenuSubItem(getParentActivity(), a == 0, a == 1);
                if (num == 0) {
                    if (UserObject.isUserSelf(user)) {
                        itemCells[a].setTextAndIcon(LocaleController.getString("SetReminder", R.string.SetReminder), R.drawable.msg_schedule);
                    } else {
                        itemCells[a].setTextAndIcon(LocaleController.getString("ScheduleMessage", R.string.ScheduleMessage), R.drawable.msg_schedule);
                    }
                } else {
                    itemCells[a].setTextAndIcon(LocaleController.getString("SendWithoutSound", R.string.SendWithoutSound), R.drawable.input_notify_off);
                }
                itemCells[a].setMinimumWidth(AndroidUtilities.dp(196));
                sendPopupLayout.addView(itemCells[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
                itemCells[a].setOnClickListener(v -> {
                    if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
                        sendPopupWindow.dismiss();
                    }
                    if (num == 0) {
                        AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), chatActivity.getDialogId(), (notify, scheduleDate) -> {
                            sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, notify, scheduleDate);
                            finishFragment();
                        });
                    } else {
                        sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, true, 0);
                        finishFragment();
                    }
                });
            }
            sendPopupLayout.setupRadialSelectors(Theme.getColor(Theme.key_dialogButtonSelector));
            sendPopupWindow = new ActionBarPopupWindow(sendPopupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT);
            sendPopupWindow.setAnimationEnabled(false);
            sendPopupWindow.setAnimationStyle(R.style.PopupContextAnimation2);
            sendPopupWindow.setOutsideTouchable(true);
            sendPopupWindow.setClippingEnabled(true);
            sendPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
            sendPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
            sendPopupWindow.getContentView().setFocusableInTouchMode(true);
        }
        sendPopupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
        sendPopupWindow.setFocusable(true);
        int[] location = new int[2];
        view.getLocationInWindow(location);
        sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(2));
        sendPopupWindow.dimBehind();
        view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
        return false;
    });
    textPaint.setTextSize(AndroidUtilities.dp(12));
    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    selectedCountView = new View(context) {

        @Override
        protected void onDraw(Canvas canvas) {
            String text = String.format("%d", Math.max(1, selectedPhotosOrder.size()));
            int textSize = (int) Math.ceil(textPaint.measureText(text));
            int size = Math.max(AndroidUtilities.dp(16) + textSize, AndroidUtilities.dp(24));
            int cx = getMeasuredWidth() / 2;
            int cy = getMeasuredHeight() / 2;
            textPaint.setColor(Theme.getColor(Theme.key_dialogRoundCheckBoxCheck));
            paint.setColor(Theme.getColor(Theme.key_dialogBackground));
            rect.set(cx - size / 2, 0, cx + size / 2, getMeasuredHeight());
            canvas.drawRoundRect(rect, AndroidUtilities.dp(12), AndroidUtilities.dp(12), paint);
            paint.setColor(Theme.getColor(Theme.key_dialogRoundCheckBox));
            rect.set(cx - size / 2 + AndroidUtilities.dp(2), AndroidUtilities.dp(2), cx + size / 2 - AndroidUtilities.dp(2), getMeasuredHeight() - AndroidUtilities.dp(2));
            canvas.drawRoundRect(rect, AndroidUtilities.dp(10), AndroidUtilities.dp(10), paint);
            canvas.drawText(text, cx - textSize / 2, AndroidUtilities.dp(16.2f), textPaint);
        }
    };
    selectedCountView.setAlpha(0.0f);
    selectedCountView.setScaleX(0.2f);
    selectedCountView.setScaleY(0.2f);
    sizeNotifierFrameLayout.addView(selectedCountView, LayoutHelper.createFrame(42, 24, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, -2, 9));
    if (selectPhotoType != SELECT_TYPE_ALL) {
        commentTextView.setVisibility(View.GONE);
    }
    if (loading && (albumsSorted == null || albumsSorted.isEmpty())) {
        progressView.setVisibility(View.VISIBLE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    return fragmentView;
}
Also used : PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TLRPC(org.telegram.tgnet.TLRPC) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) TextView(android.widget.TextView) ImageView(android.widget.ImageView) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) ActionBar(org.telegram.ui.ActionBar.ActionBar) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) InputFilter(android.text.InputFilter) RadialProgressView(org.telegram.ui.Components.RadialProgressView) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) Outline(android.graphics.Outline) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ViewOutlineProvider(android.view.ViewOutlineProvider) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) FrameLayout(android.widget.FrameLayout) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) SuppressLint(android.annotation.SuppressLint) EditTextEmoji(org.telegram.ui.Components.EditTextEmoji)

Example 29 with CombinedDrawable

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

the class SessionCell method showStub.

public void showStub(FlickerLoadingView globalGradient) {
    this.globalGradient = globalGradient;
    showStub = true;
    Drawable iconDrawable = ContextCompat.getDrawable(ApplicationLoader.applicationContext, AndroidUtilities.isTablet() ? R.drawable.device_tablet_android : R.drawable.device_phone_android).mutate();
    iconDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_avatar_text), PorterDuff.Mode.SRC_IN));
    CombinedDrawable combinedDrawable = new CombinedDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(42), Theme.getColor(Theme.key_avatar_backgroundGreen)), iconDrawable);
    imageView.setImageDrawable(combinedDrawable);
    invalidate();
}
Also used : CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter)

Aggregations

CombinedDrawable (org.telegram.ui.Components.CombinedDrawable)29 Drawable (android.graphics.drawable.Drawable)26 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)21 View (android.view.View)20 RecyclerListView (org.telegram.ui.Components.RecyclerListView)18 ImageView (android.widget.ImageView)16 RecyclerView (androidx.recyclerview.widget.RecyclerView)16 ActionBar (org.telegram.ui.ActionBar.ActionBar)16 ViewGroup (android.view.ViewGroup)15 FrameLayout (android.widget.FrameLayout)15 TLRPC (org.telegram.tgnet.TLRPC)15 Paint (android.graphics.Paint)14 TextView (android.widget.TextView)14 SuppressLint (android.annotation.SuppressLint)12 Context (android.content.Context)12 Outline (android.graphics.Outline)12 Build (android.os.Build)12 ViewOutlineProvider (android.view.ViewOutlineProvider)12 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)12 ArrayList (java.util.ArrayList)12