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

The following examples show how to use org.telegram.messenger.AndroidUtilities#usingHardwareInput() . 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: 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 4
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 5
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void removeGifFromInputField()
{
    if (!AndroidUtilities.usingHardwareInput)
    {
        if (messageEditText.getText().toString().equals("@gif "))
        {
            messageEditText.setText("");
        }
    }
}
 
Example 6
Source File: EditTextEmoji.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void openKeyboardInternal() {
    showPopup(AndroidUtilities.usingHardwareInput || isPaused ? 0 : 2);
    editText.requestFocus();
    AndroidUtilities.showKeyboard(editText);
    if (isPaused) {
        showKeyboardOnResume = true;
    } else if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) {
        waitingForKeyboardOpen = true;
        AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
        AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
    }
}
 
Example 7
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 8
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 9
Source File: AdjustPanLayoutHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void update() {
    if (parentView.getVisibility() != View.VISIBLE || parentView.getParent() == null) {
        return;
    }
    if (!AndroidUtilities.usingHardwareInput && SharedConfig.smoothKeyboard) {
        parentView.getLocationInWindow(loc);
        if (loc[1] <= 0) {
            loc[1] -= parentView.getTranslationY();
            if (Build.VERSION.SDK_INT < 21) {
                loc[1] -= AndroidUtilities.statusBarHeight;
            }
        } else {
            loc[1] = 0;
        }
        if (loc[1] != prevMovement) {
            if (!wasMovement) {
                onTransitionStart();
            }
            wasMovement = true;
            onPanTranslationUpdate(-loc[1]);
            framesWithoutMovement = 0;
            prevMovement = loc[1];
        } else {
            framesWithoutMovement++;
        }
        if (framesWithoutMovement < FRAMES_WITHOUT_MOVE_LIMIT) {
            parentView.invalidate();
        } else if (wasMovement) {
            onTransitionEnd();
        }
    }
}
 
Example 10
Source File: EditTextEmoji.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void openKeyboardInternal() {
    showPopup(AndroidUtilities.usingHardwareInput || isPaused ? 0 : 2);
    editText.requestFocus();
    AndroidUtilities.showKeyboard(editText);
    if (isPaused) {
        showKeyboardOnResume = true;
    } else if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet()) {
        waitingForKeyboardOpen = true;
        AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
        AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
    }
}
 
Example 11
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 12
Source File: EditTextEmoji.java    From Telegram-FOSS 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 13
Source File: AdjustPanLayoutHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void update() {
    if (parentView.getVisibility() != View.VISIBLE || parentView.getParent() == null) {
        return;
    }
    if (!AndroidUtilities.usingHardwareInput && SharedConfig.smoothKeyboard) {
        parentView.getLocationInWindow(loc);
        if (loc[1] <= 0) {
            loc[1] -= parentView.getTranslationY();
            if (Build.VERSION.SDK_INT < 21) {
                loc[1] -= AndroidUtilities.statusBarHeight;
            }
        } else {
            loc[1] = 0;
        }
        if (loc[1] != prevMovement) {
            if (!wasMovement) {
                onTransitionStart();
            }
            wasMovement = true;
            onPanTranslationUpdate(-loc[1]);
            framesWithoutMovement = 0;
            prevMovement = loc[1];
        } else {
            framesWithoutMovement++;
        }
        if (framesWithoutMovement < FRAMES_WITHOUT_MOVE_LIMIT) {
            parentView.invalidate();
        } else if (wasMovement) {
            onTransitionEnd();
        }
    }
}
 
Example 14
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void removeGifFromInputField()
{
    if (!AndroidUtilities.usingHardwareInput)
    {
        if (messageEditText.getText().toString().equals("@gif "))
        {
            messageEditText.setText("");
        }
    }
}
 
Example 15
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 16
Source File: PhotoViewerCaptionEnterView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public boolean isKeyboardVisible() {
    return AndroidUtilities.usingHardwareInput && getTag() != null || keyboardVisible;
}
 
Example 17
Source File: PhotoViewerCaptionEnterView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean isKeyboardVisible() {
    return AndroidUtilities.usingHardwareInput && getTag() != null || keyboardVisible;
}
 
Example 18
Source File: PhotoViewerCaptionEnterView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean isKeyboardVisible() {
    return AndroidUtilities.usingHardwareInput && getTag() != null || keyboardVisible;
}
 
Example 19
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 20
Source File: PhotoViewerCaptionEnterView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public boolean isKeyboardVisible() {
    return AndroidUtilities.usingHardwareInput && getTag() != null || keyboardVisible;
}