Java Code Examples for org.telegram.messenger.AndroidUtilities#isInMultiwindow()

The following examples show how to use org.telegram.messenger.AndroidUtilities#isInMultiwindow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void onResume()
{
    isPaused = false;
    if (showKeyboardOnResume)
    {
        showKeyboardOnResume = false;
        if (!searchingStickers)
        {
            messageEditText.requestFocus();
        }
        AndroidUtilities.showKeyboard(messageEditText);
        if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow)
        {
            waitingForKeyboardOpen = true;
            AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
            AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
        }
    }
}
 
Example 2
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void openKeyboardInternal()
{
    showPopup(AndroidUtilities.usingHardwareInput || isPaused ? 0 : 2, 0);
    messageEditText.requestFocus();
    AndroidUtilities.showKeyboard(messageEditText);
    if (isPaused)
    {
        showKeyboardOnResume = true;
    }
    else if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow)
    {
        waitingForKeyboardOpen = true;
        AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
        AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
    }
}
 
Example 3
Source File: EditTextEmoji.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void onResume() {
    isPaused = false;
    if (showKeyboardOnResume) {
        showKeyboardOnResume = false;
        editText.requestFocus();
        AndroidUtilities.showKeyboard(editText);
        if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) {
            waitingForKeyboardOpen = true;
            AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
            AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
        }
    }
}
 
Example 4
Source File: EditTextEmoji.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void onResume() {
    isPaused = false;
    if (showKeyboardOnResume) {
        showKeyboardOnResume = false;
        editText.requestFocus();
        AndroidUtilities.showKeyboard(editText);
        if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) {
            waitingForKeyboardOpen = true;
            AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
            AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
        }
    }
}
 
Example 5
Source File: EditTextEmoji.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    if (!destroyed && editText != null && waitingForKeyboardOpen && !keyboardVisible && !AndroidUtilities.usingHardwareInput && !AndroidUtilities.isInMultiwindow && AndroidUtilities.isTablet()) {
        editText.requestFocus();
        AndroidUtilities.showKeyboard(editText);
        AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
        AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
    }
}
 
Example 6
Source File: EditTextEmoji.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSizeChanged(int height, boolean isWidthGreater) {
    if (height > AndroidUtilities.dp(50) && keyboardVisible && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) {
        if (isWidthGreater) {
            keyboardHeightLand = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
        } else {
            keyboardHeight = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height", keyboardHeight).commit();
        }
    }

    if (isPopupShowing()) {
        int newHeight = isWidthGreater ? keyboardHeightLand : keyboardHeight;

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
        if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
            layoutParams.width = AndroidUtilities.displaySize.x;
            layoutParams.height = newHeight;
            emojiView.setLayoutParams(layoutParams);
            if (sizeNotifierLayout != null) {
                emojiPadding = layoutParams.height;
                sizeNotifierLayout.requestLayout();
                onWindowSizeChanged();
            }
        }
    }

    if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) {
        onWindowSizeChanged();
        return;
    }
    lastSizeChangeValue1 = height;
    lastSizeChangeValue2 = isWidthGreater;

    boolean oldValue = keyboardVisible;
    keyboardVisible = height > 0;
    if (keyboardVisible && isPopupShowing()) {
        showPopup(0);
    }
    if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) {
        emojiPadding = 0;
        sizeNotifierLayout.requestLayout();
    }
    if (keyboardVisible && waitingForKeyboardOpen) {
        waitingForKeyboardOpen = false;
        AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
    }
    onWindowSizeChanged();
}
 
Example 7
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void updateUIColors() {
    if (AndroidUtilities.isInMultiwindow) {
        getBackground().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_emojiPanelBackground), PorterDuff.Mode.MULTIPLY));
    } else {
        setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
        emojiTab.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }

    if (searchEditTextContainer != null) {
        searchEditTextContainer.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }
    if (dotPaint != null) {
        dotPaint.setColor(Theme.getColor(Theme.key_chat_emojiPanelNewTrending));
    }
    if (stickersGridView != null) {
        stickersGridView.setGlowColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }
    if (trendingGridView != null) {
        trendingGridView.setGlowColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }
    if (stickersEmptyView != null) {
        stickersEmptyView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelEmptyText));
    }
    if (stickersTab != null) {
        stickersTab.setIndicatorColor(Theme.getColor(Theme.key_chat_emojiPanelStickerPackSelector));
        stickersTab.setUnderlineColor(Theme.getColor(Theme.key_chat_emojiPanelStickerPackSelector));
        stickersTab.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }
    if (pagerSlidingTabStrip != null) {
        pagerSlidingTabStrip.setIndicatorColor(Theme.getColor(Theme.key_chat_emojiPanelIconSelector));
        pagerSlidingTabStrip.setUnderlineColor(Theme.getColor(Theme.key_chat_emojiPanelShadowLine));
    }
    if (backspaceButton != null) {
        backspaceButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_emojiPanelBackspace), PorterDuff.Mode.MULTIPLY));
    }
    if (searchIconImageView != null) {
        clearSearchImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_emojiPanelIcon), PorterDuff.Mode.MULTIPLY));
    }
    if (shadowLine != null) {
        shadowLine.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelShadowLine));
    }
    if (noRecentTextView != null) {
        noRecentTextView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelEmptyText));
    }
    if (mediaBanTooltip != null) {
        ((ShapeDrawable) mediaBanTooltip.getBackground()).getPaint().setColor(Theme.getColor(Theme.key_chat_gifSaveHintBackground));
        mediaBanTooltip.setTextColor(Theme.getColor(Theme.key_chat_gifSaveHintText));
    }
    if (stickersCounter != null) {
        stickersCounter.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelBadgeText));
        Theme.setDrawableColor(stickersCounter.getBackground(), Theme.getColor(Theme.key_chat_emojiPanelBadgeBackground));
        stickersCounter.invalidate();
    }

    Theme.setDrawableColorByKey(stickersDrawable, Theme.key_chat_emojiPanelIcon);
    for (int a = 0; a < icons.length - 1; a++) {
        Theme.setEmojiDrawableColor(icons[a], Theme.getColor(Theme.key_chat_emojiPanelIcon), false);
        Theme.setEmojiDrawableColor(icons[a], Theme.getColor(Theme.key_chat_emojiPanelIconSelected), true);
    }
    if (searchBackground != null) {
        Theme.setDrawableColorByKey(searchBackground.getBackground(), Theme.key_chat_emojiSearchBackground);
        searchBackground.invalidate();
    }
}
 
Example 8
Source File: EditTextEmoji.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void showPopup(int show) {
    if (show == 1) {
        if (emojiView == null) {
            createEmojiView();
        }

        emojiView.setVisibility(VISIBLE);
        emojiViewVisible = true;
        View currentView = emojiView;

        if (keyboardHeight <= 0) {
            if (AndroidUtilities.isTablet()) {
                keyboardHeight = AndroidUtilities.dp(150);
            } else {
                keyboardHeight = MessagesController.getGlobalEmojiSettings().getInt("kbd_height", AndroidUtilities.dp(200));
            }
        }
        if (keyboardHeightLand <= 0) {
            if (AndroidUtilities.isTablet()) {
                keyboardHeightLand = AndroidUtilities.dp(150);
            } else {
                keyboardHeightLand = MessagesController.getGlobalEmojiSettings().getInt("kbd_height_land3", AndroidUtilities.dp(200));
            }
        }
        int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) currentView.getLayoutParams();
        layoutParams.height = currentHeight;
        currentView.setLayoutParams(layoutParams);
        if (!AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) {
            AndroidUtilities.hideKeyboard(editText);
        }
        if (sizeNotifierLayout != null) {
            emojiPadding = currentHeight;
            sizeNotifierLayout.requestLayout();
            emojiButton.setImageResource(R.drawable.input_keyboard);
            onWindowSizeChanged();
        }
    } else {
        if (emojiButton != null) {
            if (currentStyle == STYLE_FRAGMENT) {
                emojiButton.setImageResource(R.drawable.smiles_tab_smiles);
            } else {
                emojiButton.setImageResource(R.drawable.input_smile);
            }
        }
        if (emojiView != null) {
            emojiViewVisible = false;
            if (AndroidUtilities.usingHardwareInput || AndroidUtilities.isInMultiwindow) {
                emojiView.setVisibility(GONE);
            }
        }
        if (sizeNotifierLayout != null) {
            if (show == 0) {
                emojiPadding = 0;
            }
            sizeNotifierLayout.requestLayout();
            onWindowSizeChanged();
        }
    }
}
 
Example 9
Source File: EditTextEmoji.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void showPopup(int show) {
    if (show == 1) {
        if (emojiView == null) {
            createEmojiView();
        }

        emojiView.setVisibility(VISIBLE);
        emojiViewVisible = true;
        View currentView = emojiView;

        if (keyboardHeight <= 0) {
            if (AndroidUtilities.isTablet()) {
                keyboardHeight = AndroidUtilities.dp(150);
            } else {
                keyboardHeight = MessagesController.getGlobalEmojiSettings().getInt("kbd_height", AndroidUtilities.dp(200));
            }
        }
        if (keyboardHeightLand <= 0) {
            if (AndroidUtilities.isTablet()) {
                keyboardHeightLand = AndroidUtilities.dp(150);
            } else {
                keyboardHeightLand = MessagesController.getGlobalEmojiSettings().getInt("kbd_height_land3", AndroidUtilities.dp(200));
            }
        }
        int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) currentView.getLayoutParams();
        layoutParams.height = currentHeight;
        currentView.setLayoutParams(layoutParams);
        if (!AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) {
            AndroidUtilities.hideKeyboard(editText);
        }
        if (sizeNotifierLayout != null) {
            emojiPadding = currentHeight;
            sizeNotifierLayout.requestLayout();
            emojiButton.setImageResource(R.drawable.input_keyboard);
            onWindowSizeChanged();
        }
    } else {
        if (emojiButton != null) {
            if (currentStyle == STYLE_FRAGMENT) {
                emojiButton.setImageResource(R.drawable.smiles_tab_smiles);
            } else {
                emojiButton.setImageResource(R.drawable.input_smile);
            }
        }
        if (emojiView != null) {
            emojiViewVisible = false;
            if (AndroidUtilities.usingHardwareInput || AndroidUtilities.isInMultiwindow) {
                emojiView.setVisibility(GONE);
            }
        }
        if (sizeNotifierLayout != null) {
            if (show == 0) {
                emojiPadding = 0;
            }
            sizeNotifierLayout.requestLayout();
            onWindowSizeChanged();
        }
    }
}
 
Example 10
Source File: PhotoViewerCaptionEnterView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void showPopup(int show) {
    if (show == 1) {
        if (emojiView == null) {
            createEmojiView();
        }

        emojiView.setVisibility(VISIBLE);

        if (keyboardHeight <= 0) {
            keyboardHeight = MessagesController.getGlobalEmojiSettings().getInt("kbd_height", AndroidUtilities.dp(200));
        }
        if (keyboardHeightLand <= 0) {
            keyboardHeightLand = MessagesController.getGlobalEmojiSettings().getInt("kbd_height_land3", AndroidUtilities.dp(200));
        }
        int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
        layoutParams.width = AndroidUtilities.displaySize.x;
        layoutParams.height = currentHeight;
        emojiView.setLayoutParams(layoutParams);
        if (!AndroidUtilities.isInMultiwindow && !forceFloatingEmoji) {
            AndroidUtilities.hideKeyboard(messageEditText);
        }
        if (sizeNotifierLayout != null) {
            emojiPadding = currentHeight;
            sizeNotifierLayout.requestLayout();
            emojiButton.setImageResource(R.drawable.input_keyboard);
            onWindowSizeChanged();
        }
    } else {
        if (emojiButton != null) {
            emojiButton.setImageResource(R.drawable.input_smile);
        }
        if (emojiView != null) {
            emojiView.setVisibility(GONE);
        }
        if (sizeNotifierLayout != null) {
            if (show == 0) {
                emojiPadding = 0;
            }
            sizeNotifierLayout.requestLayout();
            onWindowSizeChanged();
        }
    }
}
 
Example 11
Source File: PhotoViewerCaptionEnterView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSizeChanged(int height, boolean isWidthGreater) {
    if (height > AndroidUtilities.dp(50) && keyboardVisible && !AndroidUtilities.isInMultiwindow && !forceFloatingEmoji) {
        if (isWidthGreater) {
            keyboardHeightLand = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
        } else {
            keyboardHeight = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height", keyboardHeight).commit();
        }
    }

    if (isPopupShowing()) {
        int newHeight;
        if (isWidthGreater) {
            newHeight = keyboardHeightLand;
        } else {
            newHeight = keyboardHeight;
        }

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
        if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
            layoutParams.width = AndroidUtilities.displaySize.x;
            layoutParams.height = newHeight;
            emojiView.setLayoutParams(layoutParams);
            if (sizeNotifierLayout != null) {
                emojiPadding = layoutParams.height;
                sizeNotifierLayout.requestLayout();
                onWindowSizeChanged();
            }
        }
    }

    if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) {
        onWindowSizeChanged();
        return;
    }
    lastSizeChangeValue1 = height;
    lastSizeChangeValue2 = isWidthGreater;

    boolean oldValue = keyboardVisible;
    keyboardVisible = height > 0;
    if (keyboardVisible && isPopupShowing()) {
        showPopup(0);
    }
    if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) {
        emojiPadding = 0;
        sizeNotifierLayout.requestLayout();
    }
    onWindowSizeChanged();
}
 
Example 12
Source File: EditTextEmoji.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSizeChanged(int height, boolean isWidthGreater) {
    if (height > AndroidUtilities.dp(50) && keyboardVisible && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) {
        if (isWidthGreater) {
            keyboardHeightLand = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
        } else {
            keyboardHeight = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height", keyboardHeight).commit();
        }
    }

    if (isPopupShowing()) {
        int newHeight = isWidthGreater ? keyboardHeightLand : keyboardHeight;

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
        if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
            layoutParams.width = AndroidUtilities.displaySize.x;
            layoutParams.height = newHeight;
            emojiView.setLayoutParams(layoutParams);
            if (sizeNotifierLayout != null) {
                emojiPadding = layoutParams.height;
                sizeNotifierLayout.requestLayout();
                onWindowSizeChanged();
            }
        }
    }

    if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) {
        onWindowSizeChanged();
        return;
    }
    lastSizeChangeValue1 = height;
    lastSizeChangeValue2 = isWidthGreater;

    boolean oldValue = keyboardVisible;
    keyboardVisible = height > 0;
    if (keyboardVisible && isPopupShowing()) {
        showPopup(0);
    }
    if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) {
        emojiPadding = 0;
        sizeNotifierLayout.requestLayout();
    }
    if (keyboardVisible && waitingForKeyboardOpen) {
        waitingForKeyboardOpen = false;
        AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
    }
    onWindowSizeChanged();
}
 
Example 13
Source File: ChatAttachAlertPhotoLayout.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
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 (!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;
                }
            }
            child.getLocationInWindow(cameraViewLocation);
            cameraViewLocation[0] -= parentAlert.getLeftInset();
            float listViewX = gridView.getX() - parentAlert.getLeftInset();
            if (cameraViewLocation[0] < listViewX) {
                cameraViewOffsetX = (int) (listViewX - cameraViewLocation[0]);
                if (cameraViewOffsetX >= itemSize) {
                    cameraViewOffsetX = 0;
                    cameraViewLocation[0] = AndroidUtilities.dp(-400);
                    cameraViewLocation[1] = 0;
                } else {
                    cameraViewLocation[0] += cameraViewOffsetX;
                }
            } else {
                cameraViewOffsetX = 0;
            }
            int maxY = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight();
            if (cameraViewLocation[1] < maxY) {
                cameraViewOffsetY = maxY - cameraViewLocation[1];
                if (cameraViewOffsetY >= itemSize) {
                    cameraViewOffsetY = 0;
                    cameraViewLocation[0] = AndroidUtilities.dp(-400);
                    cameraViewLocation[1] = 0;
                } else {
                    cameraViewLocation[1] += cameraViewOffsetY;
                }
            } else {
                cameraViewOffsetY = 0;
            }
            int containerHeight = parentAlert.getSheetContainer().getMeasuredHeight();
            int keyboardSize = parentAlert.sizeNotifierFrameLayout.getKeyboardHeight();
            if (!AndroidUtilities.isInMultiwindow && keyboardSize <= AndroidUtilities.dp(20)) {
                containerHeight -= parentAlert.commentTextView.getEmojiPadding();
            }
            maxY = (int) (containerHeight - parentAlert.buttonsRecyclerView.getMeasuredHeight() + parentAlert.buttonsRecyclerView.getTranslationY() + parentAlert.getSheetContainer().getTranslationY());
            if (cameraViewLocation[1] + itemSize > maxY) {
                cameraViewOffsetBottomY = cameraViewLocation[1] + itemSize - maxY;
                if (cameraViewOffsetBottomY >= itemSize) {
                    cameraViewOffsetBottomY = 0;
                    cameraViewLocation[0] = AndroidUtilities.dp(-400);
                    cameraViewLocation[1] = 0;
                }
            } else {
                cameraViewOffsetBottomY = 0;
            }
            applyCameraViewPosition();
            return;
        }
    }
    cameraViewOffsetX = 0;
    cameraViewOffsetY = 0;
    cameraViewLocation[0] = AndroidUtilities.dp(-400);
    cameraViewLocation[1] = 0;
    applyCameraViewPosition();
}
 
Example 14
Source File: PhotoViewerCaptionEnterView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSizeChanged(int height, boolean isWidthGreater) {
    if (height > AndroidUtilities.dp(50) && keyboardVisible && !AndroidUtilities.isInMultiwindow && !forceFloatingEmoji) {
        if (isWidthGreater) {
            keyboardHeightLand = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
        } else {
            keyboardHeight = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height", keyboardHeight).commit();
        }
    }

    if (isPopupShowing()) {
        int newHeight;
        if (isWidthGreater) {
            newHeight = keyboardHeightLand;
        } else {
            newHeight = keyboardHeight;
        }

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
        if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
            layoutParams.width = AndroidUtilities.displaySize.x;
            layoutParams.height = newHeight;
            emojiView.setLayoutParams(layoutParams);
            if (sizeNotifierLayout != null) {
                emojiPadding = layoutParams.height;
                sizeNotifierLayout.requestLayout();
                onWindowSizeChanged();
            }
        }
    }

    if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) {
        onWindowSizeChanged();
        return;
    }
    lastSizeChangeValue1 = height;
    lastSizeChangeValue2 = isWidthGreater;

    boolean oldValue = keyboardVisible;
    keyboardVisible = height > 0;
    if (keyboardVisible && isPopupShowing()) {
        showPopup(0);
    }
    if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) {
        emojiPadding = 0;
        sizeNotifierLayout.requestLayout();
    }
    onWindowSizeChanged();
}
 
Example 15
Source File: PhotoViewerCaptionEnterView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void showPopup(int show) {
    if (show == 1) {
        if (emojiView == null) {
            createEmojiView();
        }

        emojiView.setVisibility(VISIBLE);

        if (keyboardHeight <= 0) {
            keyboardHeight = MessagesController.getGlobalEmojiSettings().getInt("kbd_height", AndroidUtilities.dp(200));
        }
        if (keyboardHeightLand <= 0) {
            keyboardHeightLand = MessagesController.getGlobalEmojiSettings().getInt("kbd_height_land3", AndroidUtilities.dp(200));
        }
        int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
        layoutParams.width = AndroidUtilities.displaySize.x;
        layoutParams.height = currentHeight;
        emojiView.setLayoutParams(layoutParams);
        if (!AndroidUtilities.isInMultiwindow && !forceFloatingEmoji) {
            AndroidUtilities.hideKeyboard(messageEditText);
        }
        if (sizeNotifierLayout != null) {
            emojiPadding = currentHeight;
            sizeNotifierLayout.requestLayout();
            emojiButton.setImageResource(R.drawable.input_keyboard);
            onWindowSizeChanged();
        }
    } else {
        if (emojiButton != null) {
            emojiButton.setImageResource(R.drawable.input_smile);
        }
        if (emojiView != null) {
            emojiView.setVisibility(GONE);
        }
        if (sizeNotifierLayout != null) {
            if (show == 0) {
                emojiPadding = 0;
            }
            sizeNotifierLayout.requestLayout();
            onWindowSizeChanged();
        }
    }
}
 
Example 16
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    isLayout = true;
    if (AndroidUtilities.isInMultiwindow) {
        if (currentBackgroundType != 1) {
            if (Build.VERSION.SDK_INT >= 21) {
                setOutlineProvider((ViewOutlineProvider) outlineProvider);
                setClipToOutline(true);
                setElevation(AndroidUtilities.dp(2));
            }
            setBackgroundResource(R.drawable.smiles_popup);
            getBackground().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_emojiPanelBackground), PorterDuff.Mode.MULTIPLY));
            emojiTab.setBackgroundDrawable(null);
            currentBackgroundType = 1;
        }
    } else {
        if (currentBackgroundType != 0) {
            if (Build.VERSION.SDK_INT >= 21) {
                setOutlineProvider(null);
                setClipToOutline(false);
                setElevation(0);
            }
            setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
            emojiTab.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
            currentBackgroundType = 0;
        }
    }

    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiTab.getLayoutParams();
    FrameLayout.LayoutParams layoutParams1 = null;
    layoutParams.width = View.MeasureSpec.getSize(widthMeasureSpec);
    if (stickersTab != null) {
        layoutParams1 = (FrameLayout.LayoutParams) stickersTab.getLayoutParams();
        if (layoutParams1 != null) {
            layoutParams1.width = layoutParams.width;
        }
    }
    if (layoutParams.width != oldWidth) {
        if (stickersTab != null && layoutParams1 != null) {
            onPageScrolled(pager.getCurrentItem(), layoutParams.width - getPaddingLeft() - getPaddingRight(), 0);
            stickersTab.setLayoutParams(layoutParams1);
        }
        emojiTab.setLayoutParams(layoutParams);
        oldWidth = layoutParams.width;
    }
    super.onMeasure(View.MeasureSpec.makeMeasureSpec(layoutParams.width, MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY));
    isLayout = false;
}
 
Example 17
Source File: EmojiView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void updateUIColors() {
    if (AndroidUtilities.isInMultiwindow) {
        getBackground().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_emojiPanelBackground), PorterDuff.Mode.MULTIPLY));
    } else {
        setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
        emojiTab.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }

    if (searchEditTextContainer != null) {
        searchEditTextContainer.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }
    if (dotPaint != null) {
        dotPaint.setColor(Theme.getColor(Theme.key_chat_emojiPanelNewTrending));
    }
    if (stickersGridView != null) {
        stickersGridView.setGlowColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }
    if (trendingGridView != null) {
        trendingGridView.setGlowColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }
    if (stickersEmptyView != null) {
        stickersEmptyView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelEmptyText));
    }
    if (stickersTab != null) {
        stickersTab.setIndicatorColor(Theme.getColor(Theme.key_chat_emojiPanelStickerPackSelector));
        stickersTab.setUnderlineColor(Theme.getColor(Theme.key_chat_emojiPanelStickerPackSelector));
        stickersTab.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
    }
    if (pagerSlidingTabStrip != null) {
        pagerSlidingTabStrip.setIndicatorColor(Theme.getColor(Theme.key_chat_emojiPanelIconSelector));
        pagerSlidingTabStrip.setUnderlineColor(Theme.getColor(Theme.key_chat_emojiPanelShadowLine));
    }
    if (backspaceButton != null) {
        backspaceButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_emojiPanelBackspace), PorterDuff.Mode.MULTIPLY));
    }
    if (searchIconImageView != null) {
        clearSearchImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_emojiPanelIcon), PorterDuff.Mode.MULTIPLY));
    }
    if (shadowLine != null) {
        shadowLine.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelShadowLine));
    }
    if (noRecentTextView != null) {
        noRecentTextView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelEmptyText));
    }
    if (mediaBanTooltip != null) {
        ((ShapeDrawable) mediaBanTooltip.getBackground()).getPaint().setColor(Theme.getColor(Theme.key_chat_gifSaveHintBackground));
        mediaBanTooltip.setTextColor(Theme.getColor(Theme.key_chat_gifSaveHintText));
    }
    if (stickersCounter != null) {
        stickersCounter.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelBadgeText));
        Theme.setDrawableColor(stickersCounter.getBackground(), Theme.getColor(Theme.key_chat_emojiPanelBadgeBackground));
        stickersCounter.invalidate();
    }

    Theme.setDrawableColorByKey(stickersDrawable, Theme.key_chat_emojiPanelIcon);
    for (int a = 0; a < icons.length - 1; a++) {
        Theme.setEmojiDrawableColor(icons[a], Theme.getColor(Theme.key_chat_emojiPanelIcon), false);
        Theme.setEmojiDrawableColor(icons[a], Theme.getColor(Theme.key_chat_emojiPanelIconSelected), true);
    }
    if (searchBackground != null) {
        Theme.setDrawableColorByKey(searchBackground.getBackground(), Theme.key_chat_emojiSearchBackground);
        searchBackground.invalidate();
    }
}
 
Example 18
Source File: PhotoViewerCaptionEnterView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSizeChanged(int height, boolean isWidthGreater) {
    if (height > AndroidUtilities.dp(50) && keyboardVisible && !AndroidUtilities.isInMultiwindow && !forceFloatingEmoji) {
        if (isWidthGreater) {
            keyboardHeightLand = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
        } else {
            keyboardHeight = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height", keyboardHeight).commit();
        }
    }

    if (isPopupShowing()) {
        int newHeight;
        if (isWidthGreater) {
            newHeight = keyboardHeightLand;
        } else {
            newHeight = keyboardHeight;
        }

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
        if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
            layoutParams.width = AndroidUtilities.displaySize.x;
            layoutParams.height = newHeight;
            emojiView.setLayoutParams(layoutParams);
            if (sizeNotifierLayout != null) {
                emojiPadding = layoutParams.height;
                sizeNotifierLayout.requestLayout();
                onWindowSizeChanged();
            }
        }
    }

    if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) {
        onWindowSizeChanged();
        return;
    }
    lastSizeChangeValue1 = height;
    lastSizeChangeValue2 = isWidthGreater;

    boolean oldValue = keyboardVisible;
    keyboardVisible = height > 0;
    if (keyboardVisible && isPopupShowing()) {
        showPopup(0);
    }
    if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) {
        emojiPadding = 0;
        sizeNotifierLayout.requestLayout();
    }
    onWindowSizeChanged();
}
 
Example 19
Source File: PhotoViewerCaptionEnterView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void showPopup(int show) {
    if (show == 1) {
        if (emojiView == null) {
            createEmojiView();
        }

        emojiView.setVisibility(VISIBLE);

        if (keyboardHeight <= 0) {
            keyboardHeight = MessagesController.getGlobalEmojiSettings().getInt("kbd_height", AndroidUtilities.dp(200));
        }
        if (keyboardHeightLand <= 0) {
            keyboardHeightLand = MessagesController.getGlobalEmojiSettings().getInt("kbd_height_land3", AndroidUtilities.dp(200));
        }
        int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
        layoutParams.width = AndroidUtilities.displaySize.x;
        layoutParams.height = currentHeight;
        emojiView.setLayoutParams(layoutParams);
        if (!AndroidUtilities.isInMultiwindow && !forceFloatingEmoji) {
            AndroidUtilities.hideKeyboard(messageEditText);
        }
        if (sizeNotifierLayout != null) {
            emojiPadding = currentHeight;
            sizeNotifierLayout.requestLayout();
            emojiButton.setImageResource(R.drawable.ic_keyboard_w);
            onWindowSizeChanged();
        }
    } else {
        if (emojiButton != null) {
            emojiButton.setImageResource(R.drawable.ic_smile_w);
        }
        if (emojiView != null) {
            emojiView.setVisibility(GONE);
        }
        if (sizeNotifierLayout != null) {
            if (show == 0) {
                emojiPadding = 0;
            }
            sizeNotifierLayout.requestLayout();
            onWindowSizeChanged();
        }
    }
}
 
Example 20
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSizeChanged(int height, boolean isWidthGreater)
{
    if (searchingStickers)
    {
        lastSizeChangeValue1 = height;
        lastSizeChangeValue2 = isWidthGreater;
        keyboardVisible = height > 0;
        return;
    }
    if (height > AndroidUtilities.dp(50) && keyboardVisible && !AndroidUtilities.isInMultiwindow)
    {
        if (isWidthGreater)
        {
            keyboardHeightLand = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
        }
        else
        {
            keyboardHeight = height;
            MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height", keyboardHeight).commit();
        }
    }

    if (isPopupShowing())
    {
        int newHeight = isWidthGreater ? keyboardHeightLand : keyboardHeight;
        if (currentPopupContentType == 1 && !botKeyboardView.isFullSize())
        {
            newHeight = Math.min(botKeyboardView.getKeyboardHeight(), newHeight);
        }

        View currentView = null;
        if (currentPopupContentType == 0)
        {
            currentView = emojiView;
        }
        else if (currentPopupContentType == 1)
        {
            currentView = botKeyboardView;
        }
        if (botKeyboardView != null)
        {
            botKeyboardView.setPanelHeight(newHeight);
        }

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) currentView.getLayoutParams();
        if (!closeAnimationInProgress && (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) && !stickersExpanded)
        {
            layoutParams.width = AndroidUtilities.displaySize.x;
            layoutParams.height = newHeight;
            currentView.setLayoutParams(layoutParams);
            if (sizeNotifierLayout != null)
            {
                emojiPadding = layoutParams.height;
                sizeNotifierLayout.requestLayout();
                onWindowSizeChanged();
            }
        }
    }

    if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater)
    {
        onWindowSizeChanged();
        return;
    }
    lastSizeChangeValue1 = height;
    lastSizeChangeValue2 = isWidthGreater;

    boolean oldValue = keyboardVisible;
    keyboardVisible = height > 0;
    if (keyboardVisible && isPopupShowing())
    {
        showPopup(0, currentPopupContentType);
    }
    if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing())
    {
        emojiPadding = 0;
        sizeNotifierLayout.requestLayout();
    }
    if (keyboardVisible && waitingForKeyboardOpen)
    {
        waitingForKeyboardOpen = false;
        AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
    }
    onWindowSizeChanged();
}