Skip to content

Commit 7be0d2f

Browse files
committed
fix issues #17
that the activity uses android:configChanges="orientation|keyboardHidden|screenSize"
1 parent 0dbf4f6 commit 7be0d2f

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

XhsEmoticonsKeyboard/library/src/main/java/sj/keyboard/widget/AutoHeightLayout.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package sj.keyboard.widget;
22

3+
import android.app.Activity;
34
import android.content.Context;
5+
import android.content.res.Configuration;
6+
import android.graphics.Rect;
47
import android.util.AttributeSet;
58
import android.view.View;
69
import android.view.ViewGroup;
@@ -13,9 +16,10 @@ public abstract class AutoHeightLayout extends SoftKeyboardSizeWatchLayout imple
1316

1417
private static final int ID_CHILD = R.id.id_autolayout;
1518

16-
protected int mSoftKeyboardHeight;
17-
protected int mMaxParentHeight;
1819
protected Context mContext;
20+
protected int mMaxParentHeight;
21+
protected int mSoftKeyboardHeight;
22+
protected boolean mConfigurationChangedFlag = false;
1923

2024
public AutoHeightLayout(Context context, AttributeSet attrs) {
2125
super(context, attrs);
@@ -65,8 +69,26 @@ public void updateMaxParentHeight(int maxParentHeight) {
6569
}
6670
}
6771

72+
@Override
73+
protected void onConfigurationChanged(Configuration newConfig) {
74+
super.onConfigurationChanged(newConfig);
75+
mConfigurationChangedFlag = true;
76+
mScreenHeight = 0;
77+
}
78+
6879
@Override
6980
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
81+
if(mConfigurationChangedFlag){
82+
mConfigurationChangedFlag = false;
83+
Rect r = new Rect();
84+
((Activity) mContext).getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
85+
if (mScreenHeight == 0) {
86+
mScreenHeight = r.bottom;
87+
}
88+
int mNowh = mScreenHeight - r.bottom;
89+
mMaxParentHeight = mNowh;
90+
}
91+
7092
if (mMaxParentHeight != 0) {
7193
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
7294
int expandSpec = MeasureSpec.makeMeasureSpec(mMaxParentHeight, heightMode);

XhsEmoticonsKeyboard/library/src/main/java/sj/keyboard/widget/SoftKeyboardSizeWatchLayout.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
public class SoftKeyboardSizeWatchLayout extends RelativeLayout {
1414

1515
private Context mContext;
16-
private boolean mIsSoftKeyboardPop = false;
17-
private int mScreenHeight = 0;
1816
private int mOldh = -1;
1917
private int mNowh = -1;
18+
protected int mScreenHeight = 0;
19+
protected boolean mIsSoftKeyboardPop = false;
2020

2121
public SoftKeyboardSizeWatchLayout(Context context, AttributeSet attrs) {
2222
super(context, attrs);

0 commit comments

Comments
 (0)