diff --git a/app/src/main/java/com/quran/labs/androidquran/data/AyahInfoDatabaseHandler.java b/app/src/main/java/com/quran/labs/androidquran/data/AyahInfoDatabaseHandler.java index 70bacd1dc3..74bba80f06 100644 --- a/app/src/main/java/com/quran/labs/androidquran/data/AyahInfoDatabaseHandler.java +++ b/app/src/main/java/com/quran/labs/androidquran/data/AyahInfoDatabaseHandler.java @@ -45,20 +45,33 @@ public Cursor getVersesBoundsForPage(int page){ } public Rect getPageBounds(int page) { - if (!validDatabase()) return null; - String[] colNames = new String[] { - "MIN("+MIN_X+")", "MIN("+MIN_Y+")", - "MAX("+MAX_X+")", "MAX("+MAX_Y+")"}; - Cursor c = database.query(GLYPHS_TABLE, colNames, COL_PAGE + "=" + page, - null, null, null, null); - if (!c.moveToFirst()) return null; - Rect r = new Rect(c.getInt(0), c.getInt(1), c.getInt(2), c.getInt(3)); - c.close(); - return r; - } + if (!validDatabase()){ return null; } + + Cursor c = null; + try { + String[] colNames = new String[] { + "MIN("+MIN_X+")", "MIN("+MIN_Y+")", + "MAX("+MAX_X+")", "MAX("+MAX_Y+")"}; + c = database.query(GLYPHS_TABLE, + colNames, COL_PAGE + "=" + page, null, null, null, null); + if (!c.moveToFirst()){ return null; } + Rect r = new Rect(c.getInt(0), c.getInt(1), c.getInt(2), c.getInt(3)); + return r; + } + catch (Exception e){ + return null; + } + finally { + if (c != null){ + try { c.close(); } catch (Exception e){ } + } + } + } public void closeDatabase() { - if (database != null) - database.close(); + if (database != null){ + try { database.close(); } + catch (Exception e){} + } } } diff --git a/app/src/main/java/com/quran/labs/androidquran/widgets/TranslationView.java b/app/src/main/java/com/quran/labs/androidquran/widgets/TranslationView.java index 5e29890f1d..b4ab201bac 100644 --- a/app/src/main/java/com/quran/labs/androidquran/widgets/TranslationView.java +++ b/app/src/main/java/com/quran/labs/androidquran/widgets/TranslationView.java @@ -4,6 +4,7 @@ import android.content.res.Resources; import android.graphics.Color; import android.graphics.Typeface; +import android.os.Build; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; @@ -213,6 +214,11 @@ private void addTextForAyah(QuranAyah ayah){ params.setMargins(mLeftRightMargin, mTopBottomMargin, mLeftRightMargin, mTopBottomMargin); translationView.setText(translationText); + + if (Build.VERSION.SDK_INT >= 11){ + translationView.setTextIsSelectable(true); + } + mLinearLayout.addView(translationView, params); }