Skip to content

Commit

Permalink
Fix broken basmala. Fixes #529.
Browse files Browse the repository at this point in the history
Introduce image patch 4. This patch set fixes the shadda on the basmala
for pages 597 and 598. Also, for many of the existing widths, it fixes
the sura header being too close to the suras for pages 1 and 2. For
some of the widths, it also fixes the relative size of some of the pages
as seen in pages like 213, 270, 565, 576.

This also moves the directory to be /patches/v[version]/ instead of just
putting everything directly in /patches/.

A future patch will update the original download zip to be correct as well,
since, until then, a user with no data will have to download the images zip,
followed by the patch.
  • Loading branch information
ahmedre committed May 25, 2015
1 parent 98625b0 commit 5df317f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;

import java.io.File;

public class QuranDataActivity extends Activity implements
DefaultDownloadReceiver.SimpleDownloadListener {

public static final String TAG = "QuranDataActivity";
public static final String PAGES_DOWNLOAD_KEY = "PAGES_DOWNLOAD_KEY";

private static final int LATEST_IMAGE_VERSION = 4;

private boolean mIsPaused = false;
private AsyncTask<Void, Void, Boolean> mCheckPagesTask;
private AlertDialog mErrorDialog = null;
Expand All @@ -50,33 +50,13 @@ public void onCreate(Bundle savedInstanceState) {
QuranUtils.debugLsDir(QuranUtils.getQuranBaseDirectory());
*/

initializeQuranScreen();
QuranScreenInfo.getOrMakeInstance(this);
mSharedPreferences = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());

// one time upgrade to v2.4.3
if (!mSharedPreferences.contains(Constants.PREF_UPGRADE_TO_243)) {
String baseDir = QuranFileUtils.getQuranBaseDirectory(this);
if (baseDir != null) {
baseDir = baseDir + File.separator;
try {
File f = new File(baseDir);
if (f.exists() && f.isDirectory()) {
String[] files = f.list();
if (files != null) {
for (String file : files) {
if (file.endsWith(".part")) {
try {
new File(baseDir + file).delete();
} catch (Exception e) {
}
}
}
}
}
} catch (Exception e) {
}
}
QuranFileUtils.clearPendingPageDownloads(this);

// update night mode preference and mark that we upgraded to 2.4.2ts
mSharedPreferences.edit()
Expand Down Expand Up @@ -238,8 +218,8 @@ protected Boolean doInBackground(Void... params) {
mNeedLandscapeImages = !haveLandscape;
if (haveLandscape && havePortrait) {
// if we have the images, see if we need a patch set or not
if (!QuranFileUtils.isVersion(mAppContext, width, 3) ||
!QuranFileUtils.isVersion(mAppContext, tabletWidth, 3)) {
if (!QuranFileUtils.isVersion(mAppContext, width, LATEST_IMAGE_VERSION) ||
!QuranFileUtils.isVersion(mAppContext, tabletWidth, LATEST_IMAGE_VERSION)) {
mPatchParam = width + tabletWidth;
}
}
Expand All @@ -249,7 +229,7 @@ protected Boolean doInBackground(Void... params) {
QuranScreenInfo.getInstance().getWidthParam());
mNeedPortraitImages = !haveAll;
mNeedLandscapeImages = false;
if (haveAll && !QuranFileUtils.isVersion(mAppContext, width, 3)) {
if (haveAll && !QuranFileUtils.isVersion(mAppContext, width, LATEST_IMAGE_VERSION)) {
mPatchParam = width;
}
return haveAll;
Expand Down Expand Up @@ -281,7 +261,7 @@ protected void onPostExecute(@NonNull Boolean result) {
}
} else {
if (!TextUtils.isEmpty(mPatchParam)) {
mPatchUrl = QuranFileUtils.getPatchFileUrl(mPatchParam, 3);
mPatchUrl = QuranFileUtils.getPatchFileUrl(mPatchParam, LATEST_IMAGE_VERSION);
promptForDownload();
return;
}
Expand Down Expand Up @@ -403,10 +383,6 @@ public void onClick(DialogInterface dialog, int id) {
mPromptForDownloadDialog.show();
}

protected void initializeQuranScreen() {
QuranScreenInfo.getOrMakeInstance(this);
}

protected void runListView(boolean showTranslations) {
Intent i = new Intent(this, QuranActivity.class);
if (showTranslations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.util.Log;

import java.io.Closeable;
Expand Down Expand Up @@ -115,9 +116,6 @@ public static boolean haveAllImages(Context context, String widthParam) {
File dir = new File(quranDirectory + File.separator);
if (dir.isDirectory()) {
String[] fileList = dir.list();
if (fileList == null) {
return false;
}
int files = fileList.length;
if (files >= PAGES_LAST) {
// ideally, we should loop for each page and ensure
Expand Down Expand Up @@ -298,6 +296,26 @@ public static String getQuranBaseDirectory(Context context) {
return null;
}

public static void clearPendingPageDownloads(@NonNull Context context) {
String baseDir = QuranFileUtils.getQuranBaseDirectory(context);
if (baseDir != null) {
baseDir = baseDir + File.separator;
try {
final File f = new File(baseDir);
if (f.exists() && f.isDirectory()) {
final String[] files = f.list();
for (String file : files) {
if (file.endsWith(".part")) {
new File(baseDir + file).delete();
}
}
}
} catch (Exception e) {
// no op
}
}
}

/**
* Returns the app used space in megabytes
*/
Expand Down Expand Up @@ -353,7 +371,7 @@ public static String getZipFileUrl(String widthParam) {
}

public static String getPatchFileUrl(String widthParam, int toVersion) {
return IMG_HOST + "patches/patch" +
return IMG_HOST + "patches/v" + toVersion + "/patch" +
widthParam + "_v" + toVersion + ".zip";
}

Expand Down

0 comments on commit 5df317f

Please sign in to comment.