Skip to content

Commit

Permalink
Catch rare error; Prepare release 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mjdenham committed Jan 30, 2016
1 parent 54bc98c commit 260c563
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 48 deletions.
2 changes: 1 addition & 1 deletion AndBible/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.bible.android.activity"
android:installLocation="auto"
android:versionName="20160127" android:versionCode="179">
android:versionName="2.3.0" android:versionCode="180">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Expand Down
99 changes: 52 additions & 47 deletions AndBible/src/net/bible/android/view/util/buttongrid/ButtonGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,54 +238,59 @@ private boolean isInside(ButtonInfo but, float x, float y) {
}

private void showPreview(ButtonInfo buttonInfo) {
if (!buttonInfo.equals(mCurrentPreview)) {
Log.d(TAG, "Previewing "+buttonInfo.name);
mCurrentPreview = buttonInfo;
mPreviewText.setText(buttonInfo.name);

int popupHeight = mPreviewHeight;
mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), buttonInfo.button.getWidth() + mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());

ViewGroup.LayoutParams lp = mPreviewText.getLayoutParams();
if (lp != null) {
lp.width = popupWidth;
lp.height = popupHeight;
}

// where to place the popup
int popupPreviewX;
int popupPreviewY;
if (buttonInfo.rowNo<2) {
int horizontalOffset = (2*buttonInfo.button.getWidth());
// if in top 2 rows then show off to right/left to avoid popup going off the screen
if (buttonInfo.colNo<mRowColLayout.cols/2.0) {
// key is on left so show to right of key
popupPreviewX = buttonInfo.left - mPreviewText.getPaddingLeft() + horizontalOffset;
} else {
// key is on right so show to right of key
popupPreviewX = buttonInfo.left - mPreviewText.getPaddingLeft() - horizontalOffset;
}
popupPreviewY = buttonInfo.bottom;
} else {
// show above the key above the one currently pressed
popupPreviewX = buttonInfo.left - mPreviewText.getPaddingLeft();
popupPreviewY = buttonInfo.top /*- popupHeight*/+ mPreviewOffset;
}

if (mPreviewPopup.isShowing()) {
mPreviewPopup.update(popupPreviewX, popupPreviewY, popupWidth, popupHeight);
} else {
mPreviewPopup.setWidth(popupWidth);
mPreviewPopup.setHeight(popupHeight);
mPreviewPopup.showAtLocation(this, Gravity.NO_GRAVITY, popupPreviewX, popupPreviewY);
}
mPreviewText.setVisibility(VISIBLE);
} else {
// could be returning to this view via Back or Finish and the user represses same button
if (mPreviewText.getVisibility()!=VISIBLE) {
mPreviewText.setVisibility(VISIBLE);
try {
if (!buttonInfo.equals(mCurrentPreview)) {
Log.d(TAG, "Previewing "+buttonInfo.name);
mCurrentPreview = buttonInfo;
mPreviewText.setText(buttonInfo.name);

int popupHeight = mPreviewHeight;
mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), buttonInfo.button.getWidth() + mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());

ViewGroup.LayoutParams lp = mPreviewText.getLayoutParams();
if (lp != null) {
lp.width = popupWidth;
lp.height = popupHeight;
}

// where to place the popup
int popupPreviewX;
int popupPreviewY;
if (buttonInfo.rowNo<2) {
int horizontalOffset = (2*buttonInfo.button.getWidth());
// if in top 2 rows then show off to right/left to avoid popup going off the screen
if (buttonInfo.colNo<mRowColLayout.cols/2.0) {
// key is on left so show to right of key
popupPreviewX = buttonInfo.left - mPreviewText.getPaddingLeft() + horizontalOffset;
} else {
// key is on right so show to right of key
popupPreviewX = buttonInfo.left - mPreviewText.getPaddingLeft() - horizontalOffset;
}
popupPreviewY = buttonInfo.bottom;
} else {
// show above the key above the one currently pressed
popupPreviewX = buttonInfo.left - mPreviewText.getPaddingLeft();
popupPreviewY = buttonInfo.top /*- popupHeight*/+ mPreviewOffset;
}

if (mPreviewPopup.isShowing()) {
mPreviewPopup.update(popupPreviewX, popupPreviewY, popupWidth, popupHeight);
} else {
mPreviewPopup.setWidth(popupWidth);
mPreviewPopup.setHeight(popupHeight);
mPreviewPopup.showAtLocation(this, Gravity.NO_GRAVITY, popupPreviewX, popupPreviewY);
}
mPreviewText.setVisibility(VISIBLE);
} else {
// could be returning to this view via Back or Finish and the user represses same button
if (mPreviewText.getVisibility()!=VISIBLE) {
mPreviewText.setVisibility(VISIBLE);
}
}
} catch (Exception e) {
// avoid very occasional NPE deep in Android code by catching and ignoring because showing preview is optional
Log.e(TAG, "Error showing button grid preview", e);
}
}

Expand Down

0 comments on commit 260c563

Please sign in to comment.