From 0a023a61d763f35130a1f82431087198ca38c592 Mon Sep 17 00:00:00 2001 From: ahmedre Date: Tue, 18 Jun 2013 02:14:50 -0700 Subject: [PATCH] patch 2.4.3 :S --- README.md | 3 +- app/AndroidManifest.xml | 4 +- .../labs/androidquran/QuranDataActivity.java | 69 ++++++++++++------- .../labs/androidquran/data/Constants.java | 1 + 4 files changed, 49 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 579dff4420..e046f19c2f 100644 --- a/README.md +++ b/README.md @@ -75,10 +75,11 @@ Open Source Projects Used Changelog --------- -**version 2.4.2** (released 6/18/2013) +**version 2.4.2 and 2.4.3** (released 6/18/2013) - critical bugfix for night mode font issue - changed default font to white for night mode - patch download for 1920 resolution images to fix 3 incomplete images +- patch download for people who recently downloaded page 270 **version 2.4.1** (released 6/16/2013) - option to disable tablet mode diff --git a/app/AndroidManifest.xml b/app/AndroidManifest.xml index 39807f24dc..337a06525b 100644 --- a/app/AndroidManifest.xml +++ b/app/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.java b/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.java index 86d0ec7045..98f4ecf5e1 100644 --- a/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.java @@ -77,32 +77,37 @@ public void onCreate(Bundle savedInstanceState) { mSharedPreferences = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); - // one time upgrade to v2.4.2 - if (!mSharedPreferences.contains(Constants.PREF_UPGRADE_TO_242)){ + // one time upgrade to v2.4.3 + if (!mSharedPreferences.contains(Constants.PREF_UPGRADE_TO_243)){ String baseDir = QuranFileUtils.getQuranBaseDirectory(this); if (baseDir != null){ - // one time delete of partial downloads since the - // contents of these zip files has changed - String[] partials = new String[]{ "images_1920_1024.zip.part", - "images_1920_512.zip.part", - "images_1920.zip.part" }; - for (String p : partials){ - try { - File f = new File(baseDir + File.separator + p); - if (f.exists()){ - f.delete(); + 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){ - } } - - // update night mode preference and mark that we upgraded to 2.4.2 - mSharedPreferences.edit() - .putInt(Constants.PREF_NIGHT_MODE_TEXT_BRIGHTNESS, - Constants.DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS) - .putBoolean(Constants.PREF_UPGRADE_TO_242, true).commit(); + catch (Exception e){ + } } + + // update night mode preference and mark that we upgraded to 2.4.2 + mSharedPreferences.edit() + .putInt(Constants.PREF_NIGHT_MODE_TEXT_BRIGHTNESS, + Constants.DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS) + .remove(Constants.PREF_UPGRADE_TO_242) + .putBoolean(Constants.PREF_UPGRADE_TO_243, true).commit(); } } @@ -260,13 +265,27 @@ else if (mSharedPreferences.getBoolean( } } else { - // force a check for the 1920 images version 3, if it's not + // force a check for the images version 3, if it's not // there, download the patch. QuranScreenInfo qsi = QuranScreenInfo.getInstance(); - if ("_1920".equals(qsi.getWidthParam()) && - !QuranFileUtils.isVersion(QuranDataActivity.this, "_1920", 3)){ - // explicitly check whether we need to fix the 1920 images - mPatchUrl = QuranFileUtils.getPatchFileUrl("_1920", 3); + String widthParam = qsi.getWidthParam(); + if (qsi.isTablet(QuranDataActivity.this)){ + String tabletWidth = qsi.getTabletWidthParam(); + if ((!QuranFileUtils.isVersion(QuranDataActivity.this, + widthParam, 3)) || + (!QuranFileUtils.isVersion(QuranDataActivity.this, + tabletWidth, 3))){ + widthParam += tabletWidth; + // get patch for both landscape/portrait tablet images + mPatchUrl = QuranFileUtils.getPatchFileUrl(widthParam, 3); + promptForDownload(); + return; + } + } + else if (!QuranFileUtils.isVersion(QuranDataActivity.this, + widthParam, 3)){ + // explicitly check whether we need to fix the images + mPatchUrl = QuranFileUtils.getPatchFileUrl(widthParam, 3); promptForDownload(); return; } diff --git a/app/src/main/java/com/quran/labs/androidquran/data/Constants.java b/app/src/main/java/com/quran/labs/androidquran/data/Constants.java index 50018e22da..ddcb6351d2 100644 --- a/app/src/main/java/com/quran/labs/androidquran/data/Constants.java +++ b/app/src/main/java/com/quran/labs/androidquran/data/Constants.java @@ -59,4 +59,5 @@ public class Constants { public static final String PREF_DISPLAY_CATEGORY = "displayCategoryKey"; public static final String PREF_TABLET_ENABLED = "useTabletMode"; public static final String PREF_UPGRADE_TO_242 = "upgradeTo242"; + public static final String PREF_UPGRADE_TO_243 = "upgradeTo243"; }