Skip to content

Commit

Permalink
fixes for 2.4.2 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Jun 18, 2013
1 parent d64d580 commit aed9d93
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 18 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ Open Source Projects Used

Changelog
---------
**version 2.4.2** (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

**version 2.4.1** (released 6/16/2013)
- option to disable tablet mode
- many bugfixes
Expand Down
4 changes: 2 additions & 2 deletions app/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="241"
android:versionName="2.4.1"
package="com.quran.labs.androidquran" android:versionCode="242"
android:versionName="2.4.2"
android:installLocation="auto">

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14" />
Expand Down
1 change: 1 addition & 0 deletions app/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<string name="downloadPrompt">لأداء أفضل، بعض الملفات في حاجه للتحميل على بطاقة الذاكرة الرقمية.
إذا لم تقم بذلك الاختيار فإن الصفحات ستستغرق وقت أطول للتحميل.
هل ترغب في تحميل الملفات الآن؟</string>
<string name="downloadImportantPrompt">هناك تحديث هام صغير على ملفات الصور على هاتفكم. هل تود تحميل الملف حالا؟</string>
<string name="downloadPrompt_ok">نعم</string>
<string name="downloadPrompt_no">لا</string>
<string name="downloading_title">جاري التحميل....</string>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</string>
<string name="downloadTabletPrompt">We recently added improved images for
tablets. Would you like to download these images now?</string>
<string name="downloadImportantPrompt">There is a small yet important update
for the Quran images you have on your device. Would you like to download this
patch now?</string>
<string name="downloadPrompt_ok">Yes</string>
<string name="downloadPrompt_no">No</string>
<string name="downloading_title">Downloading&#8230;</string>
Expand Down
2 changes: 1 addition & 1 deletion app/res/xml/quran_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<com.quran.labs.androidquran.widgets.SeekBarPreference
android:dependency="@string/prefs_night_mode"
android:defaultValue="98"
android:defaultValue="255"
android:key="@string/prefs_night_mode_text_brightness"
android:max="255"
android:persistent="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
Expand All @@ -27,6 +28,7 @@
import com.quran.labs.androidquran.util.QuranScreenInfo;
import net.hockeyapp.android.CrashManager;

import java.io.File;
import java.util.Date;

public class QuranDataActivity extends SherlockActivity implements
Expand All @@ -44,6 +46,7 @@ public class QuranDataActivity extends SherlockActivity implements
private DefaultDownloadReceiver mDownloadReceiver = null;
private boolean mNeedPortraitImages = false;
private boolean mNeedLandscapeImages = false;
private String mPatchUrl;

/** Called when the activity is first created. */
@Override
Expand Down Expand Up @@ -73,6 +76,34 @@ public void onCreate(Bundle savedInstanceState) {
initializeQuranScreen();
mSharedPreferences = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());

// one time upgrade to v2.4.2
if (!mSharedPreferences.contains(Constants.PREF_UPGRADE_TO_242)){
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();
}
}
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();
}
}
}

@Override
Expand Down Expand Up @@ -207,6 +238,7 @@ protected Boolean doInBackground(Void... params) {
@Override
protected void onPostExecute(Boolean result) {
mCheckPagesTask = null;
mPatchUrl = null;
if (mIsPaused){ return; }

if (result == null || !result){
Expand All @@ -228,6 +260,17 @@ else if (mSharedPreferences.getBoolean(
}
}
else {
// force a check for the 1920 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);
promptForDownload();
return;
}

long time = mSharedPreferences.getLong(
Constants.PREF_LAST_UPDATED_TRANSLATIONS, 0);
Date now = new Date();
Expand Down Expand Up @@ -294,6 +337,11 @@ else if (mNeedLandscapeImages && !mNeedPortraitImages){
}
}

// if we have a patch url, just use that
if (!TextUtils.isEmpty(mPatchUrl)){
url = mPatchUrl;
}

String destination = QuranFileUtils.getQuranBaseDirectory(
QuranDataActivity.this);

Expand All @@ -318,6 +366,11 @@ private void promptForDownload(){
message = R.string.downloadTabletPrompt;
}

if (!TextUtils.isEmpty(mPatchUrl)){
// patch message if applicable
message = R.string.downloadImportantPrompt;
}

AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setMessage(message);
dialog.setCancelable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class Constants {
public static final boolean CRASH_REPORTING_ENABLED = false;

// Numerics
public static final int DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS = 98;
public static final int DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS = 255;
public static final int DEFAULT_TEXT_SIZE = 15;

// 10 days in ms
Expand Down Expand Up @@ -58,4 +58,5 @@ public class Constants {
public static final String PREF_SORT_TAGS = "sortTags";
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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -725,19 +725,21 @@ protected boolean unzipFile(String zipFile, String destDirectory,
continue;
}

// ignore files that already exist
// delete files that already exist
File f = new File(destDirectory, entry.getName());
if (!f.exists()) {
InputStream is = zip.getInputStream(entry);
FileOutputStream ostream = new FileOutputStream(f);

int size;
byte[] buf = new byte[BUFFER_SIZE];
while ((size = is.read(buf)) > 0)
ostream.write(buf, 0, size);
is.close();
ostream.close();
if (f.exists()){
f.delete();
}

InputStream is = zip.getInputStream(entry);
FileOutputStream ostream = new FileOutputStream(f);

int size;
byte[] buf = new byte[BUFFER_SIZE];
while ((size = is.read(buf)) > 0)
ostream.write(buf, 0, size);
is.close();
ostream.close();

//android.util.Log.d(TAG, "progress: " + processedFiles +
// " from " + numberOfFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static QuranAyah getAyahFromCoordinates(
if (coords == null){ return null; }

float[] pageXY = imageView.getPageXY(xc, yc);
if (pageXY == null){ return null; }
float x = pageXY[0];
float y = pageXY[1];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ public static void debugLsDir(String dir) {
}
}

// check if the images with the given width param have a version
// that we specify (ex if version is 3, check for a .v3 file).
public static boolean isVersion(Context context,
String widthParam, int version){
String quranDirectory = getQuranDirectory(context, widthParam);
if (quranDirectory == null){ return false; }
try {
File vFile = new File(quranDirectory +
File.separator + ".v" + version);
return vFile.exists();
}
catch (Exception e){
return false;
}
}

public static boolean haveAllImages(Context context, String widthParam){
String quranDirectory = getQuranDirectory(context, widthParam);
if (quranDirectory == null){ return false; }
Expand Down Expand Up @@ -270,6 +286,11 @@ public static String getZipFileUrl(String widthParam) {
url += "images" + widthParam + ".zip";
return url;
}

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

public static String getAyaPositionFileName(){
QuranScreenInfo qsi = QuranScreenInfo.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ public AyahBounds getYBoundsForCurrentHighlight() {
}

@Override
public void setImageBitmap(Bitmap bitmap){
super.setImageBitmap(bitmap);
adjustNightMode();
public void setImageDrawable(Drawable bitmap){
super.setImageDrawable(bitmap);
if (bitmap != null){
adjustNightMode();
}
}

public void adjustNightMode() {
Expand Down

0 comments on commit aed9d93

Please sign in to comment.