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

The following examples show how to use org.telegram.messenger.AndroidUtilities#hideKeyboard() . 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: DrawerLayoutContainer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void openDrawer(boolean fast) {
    if (!allowOpenDrawer) {
        return;
    }
    if (AndroidUtilities.isTablet() && parentActionBarLayout != null && parentActionBarLayout.parentActivity != null) {
        AndroidUtilities.hideKeyboard(parentActionBarLayout.parentActivity.getCurrentFocus());
    }
    cancelCurrentAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(this, "drawerPosition", drawerLayout.getMeasuredWidth()));
    animatorSet.setInterpolator(new DecelerateInterpolator());
    if (fast) {
        animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * (drawerLayout.getMeasuredWidth() - drawerPosition)), 50));
    } else {
        animatorSet.setDuration(250);
    }
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            onDrawerAnimationEnd(true);
        }
    });
    animatorSet.start();
    currentAnimation = animatorSet;
}
 
Example 2
Source File: PasscodeView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void checkRetryTextView() {
    long currentTime = SystemClock.elapsedRealtime();
    if (currentTime > SharedConfig.lastUptimeMillis) {
        SharedConfig.passcodeRetryInMs -= (currentTime - SharedConfig.lastUptimeMillis);
        if (SharedConfig.passcodeRetryInMs < 0) {
            SharedConfig.passcodeRetryInMs = 0;
        }
    }
    SharedConfig.lastUptimeMillis = currentTime;
    SharedConfig.saveConfig();
    if (SharedConfig.passcodeRetryInMs > 0) {
        int value = Math.max(1, (int) Math.ceil(SharedConfig.passcodeRetryInMs / 1000.0));
        if (value != lastValue) {
            retryTextView.setText(LocaleController.formatString("TooManyTries", R.string.TooManyTries, LocaleController.formatPluralString("Seconds", value)));
            lastValue = value;
        }
        if (retryTextView.getVisibility() != VISIBLE) {
            retryTextView.setVisibility(VISIBLE);
            passwordFrameLayout.setVisibility(INVISIBLE);
            if (numbersFrameLayout.getVisibility() == VISIBLE) {
                numbersFrameLayout.setVisibility(INVISIBLE);
            }
            AndroidUtilities.hideKeyboard(passwordEditText);
            AndroidUtilities.cancelRunOnUIThread(checkRunnable);
            AndroidUtilities.runOnUIThread(checkRunnable, 100);
        }
    } else {
        AndroidUtilities.cancelRunOnUIThread(checkRunnable);
        if (passwordFrameLayout.getVisibility() != VISIBLE) {
            retryTextView.setVisibility(INVISIBLE);
            passwordFrameLayout.setVisibility(VISIBLE);
            if (SharedConfig.passcodeType == 0) {
                numbersFrameLayout.setVisibility(VISIBLE);
            } else if (SharedConfig.passcodeType == 1) {
                AndroidUtilities.showKeyboard(passwordEditText);
            }
        }
    }
}
 
Example 3
Source File: MediaActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private boolean onItemLongClick(MessageObject item, View view, int a) {
    if (actionBar.isActionModeShowed() || getParentActivity() == null) {
        return false;
    }
    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
    selectedFiles[item.getDialogId() == dialog_id ? 0 : 1].put(item.getId(), item);
    if (!item.canDeleteMessage(null)) {
        cantDeleteMessagesCount++;
    }
    actionBar.createActionMode().getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE);
    if (gotoItem != null) {
        gotoItem.setVisibility(View.VISIBLE);
    }
    selectedMessagesCountTextView.setNumber(1, false);
    AnimatorSet animatorSet = new AnimatorSet();
    ArrayList<Animator> animators = new ArrayList<>();
    for (int i = 0; i < actionModeViews.size(); i++) {
        View view2 = actionModeViews.get(i);
        AndroidUtilities.clearDrawableAnimation(view2);
        animators.add(ObjectAnimator.ofFloat(view2, "scaleY", 0.1f, 1.0f));
    }
    animatorSet.playTogether(animators);
    animatorSet.setDuration(250);
    animatorSet.start();
    scrolling = false;
    if (view instanceof SharedDocumentCell) {
        ((SharedDocumentCell) view).setChecked(true, true);
    } else if (view instanceof SharedPhotoVideoCell) {
        ((SharedPhotoVideoCell) view).setChecked(a, true, true);
    } else if (view instanceof SharedLinkCell) {
        ((SharedLinkCell) view).setChecked(true, true);
    } else if (view instanceof SharedAudioCell) {
        ((SharedAudioCell) view).setChecked(true, true);
    }
    actionBar.showActionMode();
    return true;
}
 
Example 4
Source File: PasscodeView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void checkRetryTextView() {
    long currentTime = SystemClock.elapsedRealtime();
    if (currentTime > SharedConfig.lastUptimeMillis) {
        SharedConfig.passcodeRetryInMs -= (currentTime - SharedConfig.lastUptimeMillis);
        if (SharedConfig.passcodeRetryInMs < 0) {
            SharedConfig.passcodeRetryInMs = 0;
        }
    }
    SharedConfig.lastUptimeMillis = currentTime;
    SharedConfig.saveConfig();
    if (SharedConfig.passcodeRetryInMs > 0) {
        int value = Math.max(1, (int) Math.ceil(SharedConfig.passcodeRetryInMs / 1000.0));
        if (value != lastValue) {
            retryTextView.setText(LocaleController.formatString("TooManyTries", R.string.TooManyTries, LocaleController.formatPluralString("Seconds", value)));
            lastValue = value;
        }
        if (retryTextView.getVisibility() != VISIBLE) {
            retryTextView.setVisibility(VISIBLE);
            passwordFrameLayout.setVisibility(INVISIBLE);
            if (numbersFrameLayout.getVisibility() == VISIBLE) {
                numbersFrameLayout.setVisibility(INVISIBLE);
            }
            AndroidUtilities.hideKeyboard(passwordEditText);
            AndroidUtilities.cancelRunOnUIThread(checkRunnable);
            AndroidUtilities.runOnUIThread(checkRunnable, 100);
        }
    } else {
        AndroidUtilities.cancelRunOnUIThread(checkRunnable);
        if (passwordFrameLayout.getVisibility() != VISIBLE) {
            retryTextView.setVisibility(INVISIBLE);
            passwordFrameLayout.setVisibility(VISIBLE);
            if (SharedConfig.passcodeType == 0) {
                numbersFrameLayout.setVisibility(VISIBLE);
            } else if (SharedConfig.passcodeType == 1) {
                AndroidUtilities.showKeyboard(passwordEditText);
            }
        }
    }
}
 
Example 5
Source File: ShareAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void dismiss() {
    if (commentTextView != null) {
        AndroidUtilities.hideKeyboard(commentTextView.getEditText());
    }
    super.dismiss();
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.dialogsNeedReload);
}
 
Example 6
Source File: ActionBarMenuItem.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public boolean toggleSearch(boolean openKeyboard) {
    if (searchContainer == null) {
        return false;
    }
    if (listener != null) {
        Animator animator = listener.getCustomToggleTransition();
        if (animator != null) {
            searchField.setText("");
            animator.start();
            return true;
        }
    }
    if (searchContainer.getVisibility() == VISIBLE) {
        searchContainer.setVisibility(GONE);
        searchField.clearFocus();
        setVisibility(VISIBLE);
        if (listener != null) {
            listener.onSearchCollapse();
        }
        if (openKeyboard) {
            AndroidUtilities.hideKeyboard(searchField);
        }
        if (clearsTextOnSearchCollapse) {
            searchField.setText("");
        }
        return false;
    } else {
        if (listener != null) {
            listener.onSearchExpand();
        }
        searchContainer.setVisibility(VISIBLE);
        setVisibility(GONE);
        searchField.setText("");
        searchField.requestFocus();
        if (openKeyboard) {
            AndroidUtilities.showKeyboard(searchField);
        }
        return true;
    }
}
 
Example 7
Source File: ChatAttachAlertPollLayout.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
    if (holder.getItemViewType() == 4) {
        PollEditTextCell editTextCell = (PollEditTextCell) holder.itemView;
        EditTextBoldCursor editText = editTextCell.getTextView();
        if (editText.isFocused()) {
            editText.clearFocus();
            AndroidUtilities.hideKeyboard(editText);
        }
    }
}
 
Example 8
Source File: PollCreateActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
    if (holder.getItemViewType() == 4) {
        PollEditTextCell editTextCell = (PollEditTextCell) holder.itemView;
        EditTextBoldCursor editText = editTextCell.getTextView();
        if (editText.isFocused()) {
            editText.clearFocus();
            AndroidUtilities.hideKeyboard(editText);
        }
    }
}
 
Example 9
Source File: PasscodeView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void checkRetryTextView() {
    long currentTime = SystemClock.elapsedRealtime();
    if (currentTime > SharedConfig.lastUptimeMillis) {
        SharedConfig.passcodeRetryInMs -= (currentTime - SharedConfig.lastUptimeMillis);
        if (SharedConfig.passcodeRetryInMs < 0) {
            SharedConfig.passcodeRetryInMs = 0;
        }
    }
    SharedConfig.lastUptimeMillis = currentTime;
    SharedConfig.saveConfig();
    if (SharedConfig.passcodeRetryInMs > 0) {
        int value = Math.max(1, (int) Math.ceil(SharedConfig.passcodeRetryInMs / 1000.0));
        if (value != lastValue) {
            retryTextView.setText(LocaleController.formatString("TooManyTries", R.string.TooManyTries, LocaleController.formatPluralString("Seconds", value)));
            lastValue = value;
        }
        if (retryTextView.getVisibility() != VISIBLE) {
            retryTextView.setVisibility(VISIBLE);
            passwordFrameLayout.setVisibility(INVISIBLE);
            if (numbersFrameLayout.getVisibility() == VISIBLE) {
                numbersFrameLayout.setVisibility(INVISIBLE);
            }
            AndroidUtilities.hideKeyboard(passwordEditText);
            AndroidUtilities.cancelRunOnUIThread(checkRunnable);
            AndroidUtilities.runOnUIThread(checkRunnable, 100);
        }
    } else {
        AndroidUtilities.cancelRunOnUIThread(checkRunnable);
        if (passwordFrameLayout.getVisibility() != VISIBLE) {
            retryTextView.setVisibility(INVISIBLE);
            passwordFrameLayout.setVisibility(VISIBLE);
            if (SharedConfig.passcodeType == 0) {
                numbersFrameLayout.setVisibility(VISIBLE);
            } else if (SharedConfig.passcodeType == 1) {
                AndroidUtilities.showKeyboard(passwordEditText);
            }
        }
    }
}
 
Example 10
Source File: PhotoPaintView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void closeTextEnter(boolean apply) {
    if (!editingText || !(currentEntityView instanceof TextPaintView)) {
        return;
    }

    TextPaintView textPaintView = (TextPaintView) currentEntityView;

    toolsView.setVisibility(VISIBLE);

    AndroidUtilities.hideKeyboard(textPaintView.getFocusedView());

    textPaintView.getFocusedView().clearFocus();
    textPaintView.endEditing();

    if (!apply) {
        textPaintView.setText(initialText);
    }

    if (textPaintView.getText().trim().length() == 0) {
        entitiesView.removeView(textPaintView);
        selectEntity(null);
    } else {
        textPaintView.setPosition(editedTextPosition);
        textPaintView.setRotation(editedTextRotation);
        textPaintView.setScale(editedTextScale);

        editedTextPosition = null;
        editedTextRotation = 0.0f;
        editedTextScale = 0.0f;
    }

    setTextDimVisibility(false, textPaintView);

    editingText = false;
    initialText = null;

    curtainView.setVisibility(View.GONE);
}
 
Example 11
Source File: SearchField.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void hideKeyboard() {
    AndroidUtilities.hideKeyboard(searchEditText);
}
 
Example 12
Source File: EditTextEmoji.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void closeKeyboard() {
    AndroidUtilities.hideKeyboard(editText);
}
 
Example 13
Source File: ThemeEditorView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void hideKeyboard() {
    AndroidUtilities.hideKeyboard(searchEditText);
}
 
Example 14
Source File: PhotoViewerCaptionEnterView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void closeKeyboard() {
    AndroidUtilities.hideKeyboard(messageEditText);
    messageEditText.clearFocus();
}
 
Example 15
Source File: PhotoViewerCaptionEnterView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void closeKeyboard() {
    AndroidUtilities.hideKeyboard(messageEditText);
    messageEditText.clearFocus();
}
 
Example 16
Source File: SearchField.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void hideKeyboard() {
    AndroidUtilities.hideKeyboard(searchEditText);
}
 
Example 17
Source File: ActionBarMenuItem.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public boolean toggleSearch(boolean openKeyboard)
{
    if (searchContainer == null)
    {
        return false;
    }
    if (searchContainer.getVisibility() == VISIBLE)
    {
        if (listener == null || listener != null && listener.canCollapseSearch())
        {
            searchContainer.setVisibility(GONE);
            searchField.clearFocus();
            setVisibility(VISIBLE);
            if (openKeyboard)
            {
                AndroidUtilities.hideKeyboard(searchField);
            }
            if (listener != null)
            {
                listener.onSearchCollapse();
            }
        }
        return false;
    }
    else
    {
        searchContainer.setVisibility(VISIBLE);
        setVisibility(GONE);
        searchField.setText("");
        searchField.requestFocus();
        if (openKeyboard)
        {
            AndroidUtilities.showKeyboard(searchField);
        }
        if (listener != null)
        {
            listener.onSearchExpand();
        }
        return true;
    }
}
 
Example 18
Source File: ChatRightsEditActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
    if (holder.getAdapterPosition() == rankRow && getParentActivity() != null) {
        AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
    }
}
 
Example 19
Source File: PaymentFormActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void updatePasswordFields() {
    if (currentStep != 6 || bottomCell[2] == null) {
        return;
    }
    if (currentPassword == null) {
        doneItem.setVisibility(View.VISIBLE);
        showEditDoneProgress(true, true);
        bottomCell[2].setVisibility(View.GONE);
        settingsCell1.setVisibility(View.GONE);
        headerCell[0].setVisibility(View.GONE);
        headerCell[1].setVisibility(View.GONE);
        bottomCell[0].setVisibility(View.GONE);
        for (int a = 0; a < FIELDS_COUNT_PASSWORD; a++) {
            ((View) inputFields[a].getParent()).setVisibility(View.GONE);
        }
        for (int a = 0; a < dividers.size(); a++) {
            dividers.get(a).setVisibility(View.GONE);
        }
    } else {
        showEditDoneProgress(true, false);
        if (waitingForEmail) {
            if (getParentActivity() != null) {
                AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
            }
            doneItem.setVisibility(View.GONE);
            bottomCell[2].setText(LocaleController.formatString("EmailPasswordConfirmText", R.string.EmailPasswordConfirmText, currentPassword.email_unconfirmed_pattern != null ? currentPassword.email_unconfirmed_pattern : ""));
            bottomCell[2].setVisibility(View.VISIBLE);
            settingsCell1.setVisibility(View.VISIBLE);
            bottomCell[1].setText("");

            headerCell[0].setVisibility(View.GONE);
            headerCell[1].setVisibility(View.GONE);
            bottomCell[0].setVisibility(View.GONE);
            for (int a = 0; a < FIELDS_COUNT_PASSWORD; a++) {
                ((View) inputFields[a].getParent()).setVisibility(View.GONE);
            }
            for (int a = 0; a < dividers.size(); a++) {
                dividers.get(a).setVisibility(View.GONE);
            }
        } else {
            doneItem.setVisibility(View.VISIBLE);
            bottomCell[2].setVisibility(View.GONE);
            settingsCell1.setVisibility(View.GONE);
            bottomCell[1].setText(LocaleController.getString("PaymentPasswordEmailInfo", R.string.PaymentPasswordEmailInfo));

            headerCell[0].setVisibility(View.VISIBLE);
            headerCell[1].setVisibility(View.VISIBLE);
            bottomCell[0].setVisibility(View.VISIBLE);
            for (int a = 0; a < FIELDS_COUNT_PASSWORD; a++) {
                ((View) inputFields[a].getParent()).setVisibility(View.VISIBLE);
            }
            for (int a = 0; a < dividers.size(); a++) {
                dividers.get(a).setVisibility(View.VISIBLE);
            }
        }
    }
}
 
Example 20
Source File: ChannelEditInfoActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void updatePrivatePublic() {
    if (sectionCell2 == null) {
        return;
    }
    if (!isPrivate && !canCreatePublic) {
        typeInfoCell.setText(LocaleController.getString("ChangePublicLimitReached", R.string.ChangePublicLimitReached));
        typeInfoCell.setTag(Theme.key_windowBackgroundWhiteRedText4);
        typeInfoCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
        linkContainer.setVisibility(View.GONE);
        sectionCell2.setVisibility(View.GONE);
        adminedInfoCell.setVisibility(View.VISIBLE);
        if (loadingAdminedChannels) {
            loadingAdminedCell.setVisibility(View.VISIBLE);
            adminnedChannelsLayout.setVisibility(View.GONE);
            typeInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(typeInfoCell.getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            adminedInfoCell.setBackgroundDrawable(null);
        } else {
            adminedInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(adminedInfoCell.getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            typeInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(typeInfoCell.getContext(), R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            loadingAdminedCell.setVisibility(View.GONE);
            adminnedChannelsLayout.setVisibility(View.VISIBLE);
        }
        if (headerCell2 != null) {
            headerCell2.setVisibility(View.GONE);
            linearLayoutInviteContainer.setVisibility(View.GONE);
            sectionCell3.setVisibility(View.GONE);
        }
    } else {
        typeInfoCell.setTag(Theme.key_windowBackgroundWhiteGrayText4);
        typeInfoCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText4));
        sectionCell2.setVisibility(View.VISIBLE);
        adminedInfoCell.setVisibility(View.GONE);
        typeInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(typeInfoCell.getContext(), R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
        adminnedChannelsLayout.setVisibility(View.GONE);
        linkContainer.setVisibility(View.VISIBLE);
        loadingAdminedCell.setVisibility(View.GONE);
        if (currentChat.megagroup) {
            typeInfoCell.setText(isPrivate ? LocaleController.getString("MegaPrivateLinkHelp", R.string.MegaPrivateLinkHelp) : LocaleController.getString("MegaUsernameHelp", R.string.MegaUsernameHelp));
            headerCell.setText(isPrivate ? LocaleController.getString("ChannelInviteLinkTitle", R.string.ChannelInviteLinkTitle) : LocaleController.getString("ChannelLinkTitle", R.string.ChannelLinkTitle));
        } else {
            typeInfoCell.setText(isPrivate ? LocaleController.getString("ChannelPrivateLinkHelp", R.string.ChannelPrivateLinkHelp) : LocaleController.getString("ChannelUsernameHelp", R.string.ChannelUsernameHelp));
            headerCell.setText(isPrivate ? LocaleController.getString("ChannelInviteLinkTitle", R.string.ChannelInviteLinkTitle) : LocaleController.getString("ChannelLinkTitle", R.string.ChannelLinkTitle));
        }
        publicContainer.setVisibility(isPrivate ? View.GONE : View.VISIBLE);
        privateContainer.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
        linkContainer.setPadding(0, 0, 0, isPrivate ? 0 : AndroidUtilities.dp(7));
        privateContainer.setText(invite != null ? invite.link : LocaleController.getString("Loading", R.string.Loading), false);
        checkTextView.setVisibility(!isPrivate && checkTextView.length() != 0 ? View.VISIBLE : View.GONE);
        if (headerCell2 != null) {
            headerCell2.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
            linearLayoutInviteContainer.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
            sectionCell3.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
        }
    }
    radioButtonCell1.setChecked(!isPrivate, true);
    radioButtonCell2.setChecked(isPrivate, true);
    usernameTextView.clearFocus();
    AndroidUtilities.hideKeyboard(nameTextView);
}