2015-05-03 13:48:36 +02:00
|
|
|
/*
|
|
|
|
* This is the source code of Telegram for Android v. 2.x
|
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
|
|
|
* Copyright Nikolai Kudashov, 2013-2015.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui.Components;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.InputFilter;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.style.ImageSpan;
|
|
|
|
import android.util.TypedValue;
|
|
|
|
import android.view.Gravity;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
|
import android.widget.EditText;
|
2015-06-29 19:12:11 +02:00
|
|
|
import android.widget.FrameLayout;
|
2015-05-03 13:48:36 +02:00
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import org.telegram.android.AndroidUtilities;
|
|
|
|
import org.telegram.android.Emoji;
|
|
|
|
import org.telegram.android.LocaleController;
|
|
|
|
import org.telegram.android.NotificationCenter;
|
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
|
|
|
import org.telegram.messenger.FileLog;
|
|
|
|
import org.telegram.messenger.R;
|
|
|
|
import org.telegram.messenger.TLRPC;
|
|
|
|
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
|
|
|
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayoutPhoto.SizeNotifierFrameLayoutPhotoDelegate {
|
2015-05-03 13:48:36 +02:00
|
|
|
|
|
|
|
public interface PhotoViewerCaptionEnterViewDelegate {
|
|
|
|
void onCaptionEnter();
|
2015-06-29 19:12:11 +02:00
|
|
|
void onTextChanged(CharSequence text);
|
2015-05-03 13:48:36 +02:00
|
|
|
void onWindowSizeChanged(int size);
|
|
|
|
}
|
|
|
|
|
|
|
|
private EditText messageEditText;
|
|
|
|
private ImageView emojiButton;
|
|
|
|
private EmojiView emojiView;
|
2015-06-29 19:12:11 +02:00
|
|
|
private SizeNotifierFrameLayoutPhoto sizeNotifierLayout;
|
2015-05-03 13:48:36 +02:00
|
|
|
|
|
|
|
private AnimatorSetProxy runningAnimation;
|
|
|
|
private AnimatorSetProxy runningAnimation2;
|
|
|
|
private ObjectAnimatorProxy runningAnimationAudio;
|
|
|
|
private int runningAnimationType;
|
|
|
|
private int audioInterfaceState;
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private int lastSizeChangeValue1;
|
|
|
|
private boolean lastSizeChangeValue2;
|
|
|
|
|
2015-05-03 13:48:36 +02:00
|
|
|
private int keyboardHeight;
|
|
|
|
private int keyboardHeightLand;
|
|
|
|
private boolean keyboardVisible;
|
2015-06-29 19:12:11 +02:00
|
|
|
private int emojiPadding;
|
2015-05-03 13:48:36 +02:00
|
|
|
|
2015-07-22 20:56:37 +02:00
|
|
|
private boolean innerTextChange;
|
|
|
|
|
2015-05-03 13:48:36 +02:00
|
|
|
private PhotoViewerCaptionEnterViewDelegate delegate;
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public PhotoViewerCaptionEnterView(Context context, SizeNotifierFrameLayoutPhoto parent) {
|
2015-05-03 13:48:36 +02:00
|
|
|
super(context);
|
|
|
|
setBackgroundColor(0x7f000000);
|
|
|
|
setFocusable(true);
|
|
|
|
setFocusableInTouchMode(true);
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
sizeNotifierLayout = parent;
|
2015-05-03 13:48:36 +02:00
|
|
|
|
|
|
|
LinearLayout textFieldContainer = new LinearLayout(context);
|
|
|
|
textFieldContainer.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
addView(textFieldContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 2, 0, 0, 0));
|
|
|
|
|
|
|
|
FrameLayoutFixed frameLayout = new FrameLayoutFixed(context);
|
|
|
|
textFieldContainer.addView(frameLayout, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1.0f));
|
|
|
|
|
|
|
|
emojiButton = new ImageView(context);
|
|
|
|
emojiButton.setImageResource(R.drawable.ic_smile_w);
|
|
|
|
emojiButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
|
|
|
emojiButton.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(1), 0, 0);
|
|
|
|
frameLayout.addView(emojiButton, LayoutHelper.createFrame(48, 48, Gravity.BOTTOM | Gravity.LEFT));
|
|
|
|
emojiButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (!isPopupShowing()) {
|
|
|
|
showPopup(1);
|
2015-05-03 13:48:36 +02:00
|
|
|
} else {
|
2015-06-29 19:12:11 +02:00
|
|
|
openKeyboardInternal();
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
messageEditText = new EditText(context);
|
|
|
|
messageEditText.setHint(LocaleController.getString("AddCaption", R.string.AddCaption));
|
|
|
|
messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_DONE);
|
2015-06-29 19:12:11 +02:00
|
|
|
messageEditText.setInputType(EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES | EditorInfo.TYPE_CLASS_TEXT);
|
2015-05-03 13:48:36 +02:00
|
|
|
messageEditText.setMaxLines(4);
|
2015-06-29 19:12:11 +02:00
|
|
|
messageEditText.setHorizontallyScrolling(false);
|
2015-05-03 13:48:36 +02:00
|
|
|
messageEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
|
|
|
messageEditText.setGravity(Gravity.BOTTOM);
|
|
|
|
messageEditText.setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(12));
|
|
|
|
messageEditText.setBackgroundDrawable(null);
|
|
|
|
AndroidUtilities.clearCursorDrawable(messageEditText);
|
|
|
|
messageEditText.setTextColor(0xffffffff);
|
|
|
|
messageEditText.setHintTextColor(0xb2ffffff);
|
|
|
|
InputFilter[] inputFilters = new InputFilter[1];
|
|
|
|
inputFilters[0] = new InputFilter.LengthFilter(140);
|
|
|
|
messageEditText.setFilters(inputFilters);
|
|
|
|
frameLayout.addView(messageEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 52, 0, 6, 0));
|
|
|
|
messageEditText.setOnKeyListener(new OnKeyListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onKey(View view, int i, KeyEvent keyEvent) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (i == KeyEvent.KEYCODE_BACK && !keyboardVisible && isPopupShowing()) {
|
2015-05-03 13:48:36 +02:00
|
|
|
if (keyEvent.getAction() == 1) {
|
2015-06-29 19:12:11 +02:00
|
|
|
showPopup(0);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else if (i == KeyEvent.KEYCODE_ENTER && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
|
delegate.onCaptionEnter();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
messageEditText.setOnClickListener(new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (isPopupShowing()) {
|
|
|
|
showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
messageEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (i == EditorInfo.IME_ACTION_DONE || i == EditorInfo.IME_ACTION_NEXT) {
|
2015-05-03 13:48:36 +02:00
|
|
|
delegate.onCaptionEnter();
|
|
|
|
return true;
|
|
|
|
} else if (keyEvent != null && i == EditorInfo.IME_NULL && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
|
delegate.onCaptionEnter();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
messageEditText.addTextChangedListener(new TextWatcher() {
|
2015-07-22 20:56:37 +02:00
|
|
|
boolean processChange = false;
|
|
|
|
|
2015-05-03 13:48:36 +02:00
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
|
2015-07-22 20:56:37 +02:00
|
|
|
if (innerTextChange) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-03 13:48:36 +02:00
|
|
|
if (delegate != null) {
|
2015-06-29 19:12:11 +02:00
|
|
|
delegate.onTextChanged(charSequence);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2015-07-22 20:56:37 +02:00
|
|
|
|
|
|
|
if (before != count && (count - before) > 1) {
|
|
|
|
processChange = true;
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable editable) {
|
2015-07-22 20:56:37 +02:00
|
|
|
if (innerTextChange) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (processChange) {
|
|
|
|
ImageSpan[] spans = editable.getSpans(0, editable.length(), ImageSpan.class);
|
|
|
|
for (int i = 0; i < spans.length; i++) {
|
|
|
|
editable.removeSpan(spans[i]);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2015-07-22 20:56:37 +02:00
|
|
|
Emoji.replaceEmoji(editable, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
|
|
|
|
processChange = false;
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private void onWindowSizeChanged() {
|
|
|
|
int size = sizeNotifierLayout.getHeight();
|
|
|
|
if (!keyboardVisible) {
|
|
|
|
size -= emojiPadding;
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onWindowSizeChanged(size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onCreate() {
|
|
|
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
|
2015-06-29 19:12:11 +02:00
|
|
|
sizeNotifierLayout.setDelegate(this);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onDestroy() {
|
2015-06-29 19:12:11 +02:00
|
|
|
hidePopup();
|
2015-05-03 13:48:36 +02:00
|
|
|
if (isKeyboardVisible()) {
|
|
|
|
closeKeyboard();
|
|
|
|
}
|
|
|
|
keyboardVisible = false;
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
|
2015-06-29 19:12:11 +02:00
|
|
|
if (sizeNotifierLayout != null) {
|
|
|
|
sizeNotifierLayout.setDelegate(null);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDelegate(PhotoViewerCaptionEnterViewDelegate delegate) {
|
|
|
|
this.delegate = delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFieldText(CharSequence text) {
|
|
|
|
if (messageEditText == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
messageEditText.setText(text);
|
|
|
|
messageEditText.setSelection(messageEditText.getText().length());
|
|
|
|
if (delegate != null) {
|
2015-06-29 19:12:11 +02:00
|
|
|
delegate.onTextChanged(messageEditText.getText());
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCursorPosition() {
|
|
|
|
if (messageEditText == null) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return messageEditText.getSelectionStart();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void replaceWithText(int start, int len, String text) {
|
|
|
|
try {
|
|
|
|
StringBuilder builder = new StringBuilder(messageEditText.getText());
|
|
|
|
builder.replace(start, start + len, text);
|
|
|
|
messageEditText.setText(builder);
|
|
|
|
if (start + text.length() <= messageEditText.length()) {
|
|
|
|
messageEditText.setSelection(start + text.length());
|
|
|
|
} else {
|
|
|
|
messageEditText.setSelection(messageEditText.length());
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFieldFocused(boolean focus) {
|
|
|
|
if (messageEditText == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (focus) {
|
|
|
|
if (!messageEditText.isFocused()) {
|
|
|
|
messageEditText.postDelayed(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (messageEditText != null) {
|
|
|
|
try {
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 600);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (messageEditText.isFocused() && !keyboardVisible) {
|
|
|
|
messageEditText.clearFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public CharSequence getFieldCharSequence() {
|
|
|
|
return messageEditText.getText();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getEmojiPadding() {
|
|
|
|
return emojiPadding;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPopupView(View view) {
|
|
|
|
return view == emojiView;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showPopup(int show) {
|
|
|
|
if (show == 1) {
|
|
|
|
if (emojiView == null) {
|
|
|
|
emojiView = new EmojiView(false, getContext());
|
|
|
|
emojiView.setListener(new EmojiView.Listener() {
|
|
|
|
public boolean onBackspace() {
|
|
|
|
if (messageEditText.length() == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onEmojiSelected(String symbol) {
|
|
|
|
int i = messageEditText.getSelectionEnd();
|
|
|
|
if (i < 0) {
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
try {
|
2015-07-22 20:56:37 +02:00
|
|
|
innerTextChange = true;
|
|
|
|
CharSequence localCharSequence = Emoji.replaceEmoji(symbol/* + "\uFE0F"*/, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
|
2015-06-29 19:12:11 +02:00
|
|
|
messageEditText.setText(messageEditText.getText().insert(i, localCharSequence));
|
|
|
|
int j = i + localCharSequence.length();
|
|
|
|
messageEditText.setSelection(j, j);
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
2015-07-22 20:56:37 +02:00
|
|
|
} finally {
|
|
|
|
innerTextChange = false;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onStickerSelected(TLRPC.Document sticker) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
sizeNotifierLayout.addView(emojiView);
|
|
|
|
}
|
|
|
|
|
|
|
|
emojiView.setVisibility(VISIBLE);
|
|
|
|
|
|
|
|
if (keyboardHeight <= 0) {
|
|
|
|
keyboardHeight = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).getInt("kbd_height", AndroidUtilities.dp(200));
|
|
|
|
}
|
|
|
|
if (keyboardHeightLand <= 0) {
|
|
|
|
keyboardHeightLand = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).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);
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public void hidePopup() {
|
|
|
|
if (isPopupShowing()) {
|
|
|
|
showPopup(0);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private void openKeyboardInternal() {
|
|
|
|
showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2);
|
|
|
|
/*int selection = messageEditText.getSelectionStart();
|
|
|
|
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0, 0, 0);
|
|
|
|
messageEditText.onTouchEvent(event);
|
|
|
|
event.recycle();
|
|
|
|
messageEditText.setSelection(selection);*/
|
|
|
|
AndroidUtilities.showKeyboard(messageEditText);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openKeyboard() {
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
AndroidUtilities.showKeyboard(messageEditText);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPopupShowing() {
|
|
|
|
return emojiView != null && emojiView.getVisibility() == VISIBLE;
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public void closeKeyboard() {
|
|
|
|
AndroidUtilities.hideKeyboard(messageEditText);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isKeyboardVisible() {
|
2015-06-29 19:12:11 +02:00
|
|
|
return AndroidUtilities.usingHardwareInput && getLayoutParams() != null && ((FrameLayout.LayoutParams) getLayoutParams()).bottomMargin == 0 || keyboardVisible;
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSizeChanged(int height, boolean isWidthGreater) {
|
|
|
|
if (height > AndroidUtilities.dp(50) && keyboardVisible) {
|
|
|
|
if (isWidthGreater) {
|
|
|
|
keyboardHeightLand = height;
|
|
|
|
ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
|
|
|
|
} else {
|
|
|
|
keyboardHeight = height;
|
|
|
|
ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height", keyboardHeight).commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
if (isPopupShowing()) {
|
|
|
|
int newHeight;
|
2015-05-03 13:48:36 +02:00
|
|
|
if (isWidthGreater) {
|
|
|
|
newHeight = keyboardHeightLand;
|
|
|
|
} else {
|
|
|
|
newHeight = keyboardHeight;
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
|
2015-05-03 13:48:36 +02:00
|
|
|
if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
|
|
|
|
layoutParams.width = AndroidUtilities.displaySize.x;
|
|
|
|
layoutParams.height = newHeight;
|
2015-06-29 19:12:11 +02:00
|
|
|
emojiView.setLayoutParams(layoutParams);
|
|
|
|
if (sizeNotifierLayout != null) {
|
|
|
|
emojiPadding = layoutParams.height;
|
|
|
|
sizeNotifierLayout.requestLayout();
|
|
|
|
onWindowSizeChanged();
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) {
|
|
|
|
onWindowSizeChanged();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lastSizeChangeValue1 = height;
|
|
|
|
lastSizeChangeValue2 = isWidthGreater;
|
|
|
|
|
2015-05-03 13:48:36 +02:00
|
|
|
boolean oldValue = keyboardVisible;
|
|
|
|
keyboardVisible = height > 0;
|
2015-06-29 19:12:11 +02:00
|
|
|
if (keyboardVisible && isPopupShowing()) {
|
|
|
|
showPopup(0);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) {
|
|
|
|
emojiPadding = 0;
|
|
|
|
sizeNotifierLayout.requestLayout();
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
onWindowSizeChanged();
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didReceivedNotification(int id, Object... args) {
|
|
|
|
if (id == NotificationCenter.emojiDidLoaded) {
|
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|