Skip to content

Commit

Permalink
Keyboard Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Arseny271 committed Oct 24, 2023
1 parent 194cc1c commit 8f21745
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
Expand Up @@ -8523,7 +8523,7 @@ private void setTextFormattingLayoutVisible (boolean visible) {
textFormattingVisible = visible;
if (emojiLayout != null && textFormattingLayout != null) {
textFormattingLayout.setVisibility(visible ? View.VISIBLE : View.GONE);
emojiLayout.optimizeForDisplayTextFormattingLayout(!visible);
emojiLayout.optimizeForDisplayTextFormattingLayout(visible);
if (visible) {
textFormattingLayout.checkButtonsActive(false);
}
Expand Down
Expand Up @@ -4402,11 +4402,32 @@ public void showMessageAddedReactions (TGMessage message, TdApi.ReactionType rea
showMessageOptions(null, message, reactionType, newMessageOptionDelegate(message, null, null));
}

private boolean isMessageOptionsVisible;

private void showMessageOptions (Options options, TGMessage message, @Nullable TdApi.ReactionType reactionType, OptionDelegate optionsDelegate) {
MessageOptionsPagerController r = new MessageOptionsPagerController(context, tdlib, options, message, reactionType, optionsDelegate);
if (isMessageOptionsVisible) {
return;
}
isMessageOptionsVisible = true;

MessageOptionsPagerController r = new MessageOptionsPagerController(context, tdlib, options, message, reactionType, optionsDelegate) {
@Override
protected void onCustomShowComplete () {
super.onCustomShowComplete();
prepareToShowMessageOptions2();
}
};
r.show();
r.setDismissListener(p -> {
onHideMessageOptions();
r.setDismissListener(new PopupLayout.DismissListener() {
@Override
public void onPopupDismiss (PopupLayout popup) {
isMessageOptionsVisible = false;
}

@Override
public void onPopupDismissPrepare (PopupLayout popup) {
onHideMessageOptions();
}
});
prepareToShowMessageOptions();
hideCursorsForInputView();
Expand All @@ -4421,15 +4442,18 @@ private void prepareToShowMessageOptions () {
if (needShowKeyboardAfterHideMessageOptions) { // показываем emoji-клавиатуру, чтобы скрыть системную
openEmojiKeyboard(); // делаем emojiLayout невидимым для оптимизации
} // todo: если меню сообщения ниже EmojiLayout, то не скрывать?
}

private void prepareToShowMessageOptions2 () {
if (needShowKeyboardAfterHideMessageOptions || needShowEmojiKeyboardAfterHideMessageOptions) {
emojiLayout.setVisibility(View.INVISIBLE);
emojiLayout.optimizeForDisplayTextFormattingLayout(true);
}
}

private void onHideMessageOptions () {
if (needShowEmojiKeyboardAfterHideMessageOptions) {
if (emojiShown) {
emojiLayout.setVisibility(View.VISIBLE);
emojiLayout.optimizeForDisplayTextFormattingLayout(false);
} else {
openEmojiKeyboard();
}
Expand Down Expand Up @@ -11382,7 +11406,7 @@ private void setTextFormattingLayoutVisible (boolean visible) {
textFormattingVisible = visible;
if (emojiLayout != null && textFormattingLayout != null) {
textFormattingLayout.setVisibility(visible ? View.VISIBLE : View.GONE);
emojiLayout.optimizeForDisplayTextFormattingLayout(!visible);
emojiLayout.optimizeForDisplayTextFormattingLayout(visible);
if (visible) {
textFormattingLayout.checkButtonsActive(false);
}
Expand Down
Expand Up @@ -3311,7 +3311,7 @@ private void setTextFormattingLayoutVisible (boolean visible) {
textFormattingVisible = visible;
if (emojiLayout != null && textFormattingLayout != null) {
textFormattingLayout.setVisibility(visible ? View.VISIBLE : View.GONE);
emojiLayout.optimizeForDisplayTextFormattingLayout(!visible);
emojiLayout.optimizeForDisplayTextFormattingLayout(visible);
if (visible) {
textFormattingLayout.checkButtonsActive(false);
}
Expand Down
Expand Up @@ -474,7 +474,7 @@ public void setCircleVisible (boolean isVisible, boolean isSearch) {
}

public void optimizeForDisplayTextFormattingLayout (boolean needOptimize) {
int visibility = needOptimize ? VISIBLE : GONE;
int visibility = needOptimize ? GONE : VISIBLE;
// if (headerView != null) headerView.setVisibility(visibility);
if (shadowView != null) shadowView.setVisibility(visibility);
if (pager != null) pager.setVisibility(visibility);
Expand Down

0 comments on commit 8f21745

Please sign in to comment.