mirror of https://github.com/NekoX-Dev/NekoX.git
50 lines
1.6 KiB
Java
50 lines
1.6 KiB
Java
/*
|
|
* This is the source code of Telegram for Android v. 1.3.2.
|
|
* 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.
|
|
*/
|
|
|
|
package org.telegram.ui.Views;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Rect;
|
|
import android.util.Log;
|
|
import android.widget.RelativeLayout;
|
|
|
|
import org.telegram.messenger.Utilities;
|
|
|
|
public class SizeNotifierRelativeLayout extends RelativeLayout {
|
|
|
|
private Rect rect = new Rect();
|
|
public SizeNotifierRelativeLayoutDelegate delegate;
|
|
|
|
public abstract interface SizeNotifierRelativeLayoutDelegate {
|
|
public abstract void onSizeChanged(int keyboardHeight);
|
|
}
|
|
|
|
public SizeNotifierRelativeLayout(Context context) {
|
|
super(context);
|
|
}
|
|
|
|
public SizeNotifierRelativeLayout(android.content.Context context, android.util.AttributeSet attrs) {
|
|
super(context, attrs);
|
|
}
|
|
|
|
public SizeNotifierRelativeLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyle) {
|
|
super(context, attrs, defStyle);
|
|
}
|
|
|
|
@Override
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
super.onLayout(changed, l, t, r, b);
|
|
if (delegate != null) {
|
|
int usableViewHeight = this.getRootView().getHeight() - Utilities.statusBarHeight;
|
|
this.getWindowVisibleDisplayFrame(rect);
|
|
int keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
|
delegate.onSizeChanged(keyboardHeight);
|
|
}
|
|
}
|
|
}
|