diff --git a/README.md b/README.md index 700707f413..714f497872 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,9 @@ Open Source Projects Used Changelog --------- +**version 2.4.7** (released 10/8/2013) +- fix some crashes + **version 2.4.6** (released 10/6/2013) - hide actionbar on resume if it was hidden - change 14:50 to 14:49 in juz' list diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ea31aaa6ed..eae789cee8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java b/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java index d0eb1dcbd5..3f57d4b346 100644 --- a/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java @@ -15,12 +15,14 @@ import android.widget.Toast; import com.actionbarsherlock.app.SherlockPreferenceActivity; +import com.crashlytics.android.Crashlytics; import com.quran.labs.androidquran.data.Constants; import com.quran.labs.androidquran.util.QuranFileUtils; import com.quran.labs.androidquran.util.QuranScreenInfo; import com.quran.labs.androidquran.util.QuranSettings; import com.quran.labs.androidquran.util.StorageUtils; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -82,8 +84,13 @@ public boolean onPreferenceClick(Preference preference) { mListStorageOptions = (ListPreference) findPreference( getString(R.string.prefs_app_location)); - mStorageList = StorageUtils + try { + mStorageList = StorageUtils .getAllStorageLocations(getApplicationContext()); + } catch (Exception e){ + Crashlytics.logException(e); + mStorageList = new ArrayList(); + } // Hide Advanced Preferences Screen if there is no storage option // except for the normal Environment.getExternalStorageDirectory diff --git a/app/src/main/java/com/quran/labs/androidquran/database/DatabaseHandler.java b/app/src/main/java/com/quran/labs/androidquran/database/DatabaseHandler.java index ad08eb0497..76e931e00e 100644 --- a/app/src/main/java/com/quran/labs/androidquran/database/DatabaseHandler.java +++ b/app/src/main/java/com/quran/labs/androidquran/database/DatabaseHandler.java @@ -39,8 +39,15 @@ public DatabaseHandler(Context context, String databaseName) if (base == null) return; String path = base + File.separator + databaseName; Crashlytics.log("opening database file: " + path); - mDatabase = SQLiteDatabase.openDatabase(path, null, + try { + mDatabase = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS); + } catch (SQLException se){ + Crashlytics.log("database file " + path + + (new File(path).exists()? " exists" : " doesn't exist")); + throw se; + } + mSchemaVersion = getSchemaVersion(); mDatabasePath = path; mMatchString = "= 1 && mCurrentSura <= 114){ + mAyahsInThisSura = QuranInfo.SURA_NUM_AYAHS[mCurrentSura-1]; + } mRepeatInfo.setCurrentVerse(mCurrentSura, mCurrentAyah); return null; } diff --git a/app/src/main/java/com/quran/labs/androidquran/service/util/DefaultDownloadReceiver.java b/app/src/main/java/com/quran/labs/androidquran/service/util/DefaultDownloadReceiver.java index a23b27cad8..0dd9898ea8 100644 --- a/app/src/main/java/com/quran/labs/androidquran/service/util/DefaultDownloadReceiver.java +++ b/app/src/main/java/com/quran/labs/androidquran/service/util/DefaultDownloadReceiver.java @@ -62,19 +62,13 @@ public void handleMessage(Message msg){ String state = intent.getStringExtra( QuranDownloadService.ProgressIntent.STATE); if (QuranDownloadService.STATE_SUCCESS.equals(state)){ - if (mProgressDialog != null){ - mProgressDialog.dismiss(); - mProgressDialog = null; - } + dismissDialog(); mListener.handleDownloadSuccess(); } else if (QuranDownloadService.STATE_ERROR.equals(state)){ int msgId = ServiceIntentHelper. getErrorResourceFromDownloadIntent(intent, true); - if (mProgressDialog != null){ - mProgressDialog.dismiss(); - mProgressDialog = null; - } + dismissDialog(); mListener.handleDownloadFailure(msgId); } else if (QuranDownloadService.STATE_DOWNLOADING.equals(state)){ @@ -120,6 +114,17 @@ else if (QuranDownloadService } }; + private void dismissDialog(){ + if (mProgressDialog != null){ + try { + mProgressDialog.dismiss(); + } + catch (Exception e){ + } + mProgressDialog = null; + } + } + public boolean didReceieveBroadcast(){ return mDidReceiveBroadcast; } diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/helpers/QuranPageWorker.java b/app/src/main/java/com/quran/labs/androidquran/ui/helpers/QuranPageWorker.java index 0013f6adbc..0ed2935a56 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/helpers/QuranPageWorker.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/helpers/QuranPageWorker.java @@ -37,8 +37,8 @@ public QuranPageWorker(FragmentActivity activity){ Context.ACTIVITY_SERVICE)).getMemoryClass(); final int cacheSize = 1024 * 1024 * memClass / 8; final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); - Log.d(TAG, "memory class: " + memClass + ", cache size: " + - cacheSize + ", max memory: " + maxMemory); + Crashlytics.log(Log.DEBUG, TAG, "memory class: " + memClass + + ", cache size: " + cacheSize + ", max memory: " + maxMemory); mMemoryCache = new LruCache(cacheSize){ @Override protected void entryRemoved(boolean evicted, String key, @@ -56,15 +56,17 @@ protected int sizeOf(String key, BitmapDrawable bitmapDrawable){ return bitmap.getByteCount(); } - Log.d(TAG, "row bytes: " + bitmap.getRowBytes() + ", height: " + + Crashlytics.log(Log.DEBUG, TAG, "row bytes: " + + bitmap.getRowBytes() + ", height: " + bitmap.getHeight() + ", " + (bitmap.getRowBytes() * bitmap.getHeight())); return bitmap.getRowBytes() * bitmap.getHeight(); } }; fragment.mRetainedCache = mMemoryCache; - - Log.d(TAG, "initial LruCache size: " + (memClass/8)); + + Crashlytics.log(Log.DEBUG, TAG, + "initial LruCache size: " + (memClass/8)); } private void addBitmapToCache(String key, BitmapDrawable drawable) { @@ -73,10 +75,11 @@ private void addBitmapToCache(String key, BitmapDrawable drawable) { ((RecyclingBitmapDrawable)drawable).setIsCached(true); } mMemoryCache.put(key, drawable); - Log.d(TAG, "cache size: " + mMemoryCache.size()); + Crashlytics.log(Log.DEBUG, TAG, "cache size: " + mMemoryCache.size()); } - Log.d(TAG, "cache: number of puts: " + mMemoryCache.putCount() + + Crashlytics.log(Log.DEBUG, TAG, "cache: number of puts: " + + mMemoryCache.putCount() + ", number of evicts: " + mMemoryCache.evictionCount()); } @@ -128,7 +131,7 @@ protected BitmapDrawable doInBackground(Integer... params) { } if (bitmap == null){ - Crashlytics.log(Log.WARN, TAG, "items in cache: " + + Crashlytics.log(Log.WARN, TAG, "cache memory: " + mMemoryCache.size() + " vs " + mMemoryCache.maxSize()); if (QuranScreenInfo.getInstance().isTablet(mContext)){ Crashlytics.log(Log.WARN, TAG, diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/util/ImageAyahUtils.java b/app/src/main/java/com/quran/labs/androidquran/ui/util/ImageAyahUtils.java index 94aee833be..184ecb90e5 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/util/ImageAyahUtils.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/util/ImageAyahUtils.java @@ -38,7 +38,7 @@ private static QuranAyah getAyahFromKey(String key){ public static QuranAyah getAyahFromCoordinates( Map> coords, HighlightingImageView imageView, float xc, float yc) { - if (coords == null){ return null; } + if (coords == null || imageView == null){ return null; } float[] pageXY = imageView.getPageXY(xc, yc); if (pageXY == null){ return null; } diff --git a/app/src/main/java/com/quran/labs/androidquran/util/StorageUtils.java b/app/src/main/java/com/quran/labs/androidquran/util/StorageUtils.java index c9cc76f304..34e75b538e 100644 --- a/app/src/main/java/com/quran/labs/androidquran/util/StorageUtils.java +++ b/app/src/main/java/com/quran/labs/androidquran/util/StorageUtils.java @@ -6,6 +6,7 @@ import android.os.StatFs; import android.util.Log; +import com.crashlytics.android.Crashlytics; import com.quran.labs.androidquran.R; import java.io.File; @@ -213,6 +214,7 @@ private Storage(String label, String mountPoint) { } private void computeSpace() { + Crashlytics.log("computeSpace() for " + mountPoint); StatFs stat = new StatFs(mountPoint); long totalBytes = (long) stat.getBlockCount() * (long) stat.getBlockSize(); 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 f2ef8ebd3b..d9c52889b6 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 @@ -115,7 +115,9 @@ private void initResources(){ public void refresh(){ initResources(); - setAyahs(mAyat); + if (mAyat != null){ + setAyahs(mAyat); + } } public void setAyahs(List ayat){