Skip to content

Commit

Permalink
fix some crashes. bump version to 2.4.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Oct 8, 2013
1 parent 6cdd860 commit b5eaaf1
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 24 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.quran.labs.androidquran" android:versionCode="246"
android:versionName="2.4.6"
package="com.quran.labs.androidquran" android:versionCode="247"
android:versionName="2.4.7"
android:installLocation="auto">

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<StorageUtils.Storage>();
}

// Hide Advanced Preferences Screen if there is no storage option
// except for the normal Environment.getExternalStorageDirectory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<font color=\"" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import com.crashlytics.android.Crashlytics;

import java.io.File;

public class SuraTimingDatabaseHandler {
private SQLiteDatabase mDatabase = null;
public static class TimingsTable {
Expand All @@ -17,8 +19,14 @@ public static class TimingsTable {

public SuraTimingDatabaseHandler(String path) throws SQLException {
Crashlytics.log("opening gapless data file, " + path);
mDatabase = SQLiteDatabase.openDatabase(path, null,
try {
mDatabase = SQLiteDatabase.openDatabase(path, null,
SQLiteDatabase.NO_LOCALIZED_COLLATORS);
} catch (SQLException se){
Crashlytics.log("database at " + path +
(new File(path).exists()? " exists" : " doesn't exist"));
throw se;
}
}

public boolean validDatabase(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public QuranAyah setCurrentAyah(int sura, int ayah){
else {
mCurrentSura = sura;
mCurrentAyah = ayah;
mAyahsInThisSura = QuranInfo.SURA_NUM_AYAHS[mCurrentSura-1];
if (mCurrentSura >= 1 && mCurrentSura <= 114){
mAyahsInThisSura = QuranInfo.SURA_NUM_AYAHS[mCurrentSura-1];
}
mRepeatInfo.setCurrentVerse(mCurrentSura, mCurrentAyah);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, BitmapDrawable>(cacheSize){
@Override
protected void entryRemoved(boolean evicted, String key,
Expand All @@ -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) {
Expand All @@ -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());
}

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static QuranAyah getAyahFromKey(String key){
public static QuranAyah getAyahFromCoordinates(
Map<String, List<AyahBounds>> 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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ private void initResources(){

public void refresh(){
initResources();
setAyahs(mAyat);
if (mAyat != null){
setAyahs(mAyat);
}
}

public void setAyahs(List<QuranAyah> ayat){
Expand Down

0 comments on commit b5eaaf1

Please sign in to comment.