Skip to content

Commit 8a4090c

Browse files
committed
fix unnecessary resize of book view - e.g. while dialog with on-screen keyboard is shown, or orientation changed during active dialog: fix №123
1 parent ed2e01d commit 8a4090c

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

android/src/org/coolreader/crengine/BaseActivity.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,21 @@ protected void onCreate(Bundle savedInstanceState) {
193193
bindCRDBService();
194194
}
195195

196+
protected BaseDialog currentDialog;
197+
public void onDialogCreated(BaseDialog dlg) {
198+
currentDialog = dlg;
199+
}
200+
public void onDialogClosed(BaseDialog dlg) {
201+
if (currentDialog == dlg) {
202+
currentDialog = null;
203+
}
204+
}
205+
public BaseDialog getCurrentDialog() {
206+
return currentDialog;
207+
}
208+
public boolean isDialogActive() {
209+
return currentDialog != null;
210+
}
196211

197212
@Override
198213
protected void onDestroy() {

android/src/org/coolreader/crengine/BaseDialog.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,16 @@ protected View createLayout( View view )
243243

244244
protected void onCreate() {
245245
// when dialog is created
246+
Log.d("DLG","BaseDialog.onCreate()");
247+
activity.onDialogCreated(this);
246248
}
247249

248250
protected void onClose() {
249251
// when dialog is closed
252+
Log.d("DLG","BaseDialog.onClose()");
253+
activity.onDialogClosed(this);
250254
}
251-
252-
255+
253256

254257
/**
255258
* Set View's gesture handlers for LTR and RTL horizontal fling

android/src/org/coolreader/crengine/OPDSUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
@SuppressLint("SimpleDateFormat")
3939
public class OPDSUtil {
4040

41-
public static final boolean EXTENDED_LOG = true; // set to false for production
41+
public static final boolean EXTENDED_LOG = false; // set to false for production
4242
public static final int CONNECT_TIMEOUT = 60000;
4343
public static final int READ_TIMEOUT = 60000;
4444
/*

android/src/org/coolreader/crengine/ReaderView.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public boolean onTrackballEvent(MotionEvent event) {
109109

110110
@Override
111111
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
112-
log.i("onSizeChanged(" + w + ", " + h + ")");
112+
log.i("onSizeChanged(" + w + ", " + h + ")" + " activity.isDialogActive=" + getActivity().isDialogActive());
113113
super.onSizeChanged(w, h, oldw, oldh);
114114
requestResize(w, h);
115115
}
@@ -119,6 +119,7 @@ public void onWindowVisibilityChanged(int visibility) {
119119
if (visibility == VISIBLE) {
120120
mActivity.einkRefresh();
121121
startStats();
122+
checkSize();
122123
} else
123124
stopStats();
124125
super.onWindowVisibilityChanged(visibility);
@@ -129,6 +130,7 @@ public void onWindowFocusChanged(boolean hasWindowFocus) {
129130
if (hasWindowFocus) {
130131
mActivity.einkRefresh();
131132
startStats();
133+
checkSize();
132134
} else
133135
stopStats();
134136
super.onWindowFocusChanged(hasWindowFocus);
@@ -3448,6 +3450,10 @@ private void checkSize() {
34483450
boolean changed = (requestedWidth != internalDX) || (requestedHeight != internalDY);
34493451
if (!changed)
34503452
return;
3453+
if (getActivity().isDialogActive()) {
3454+
log.d("checkSize() : dialog is active, skipping resize");
3455+
return;
3456+
}
34513457
// if (mIsOnFront || !mOpened) {
34523458
log.d("checkSize() : calling resize");
34533459
resize();

0 commit comments

Comments
 (0)