From 9491beac2679c229813a1a407c7b5726f931faea Mon Sep 17 00:00:00 2001 From: ahmedre Date: Sun, 6 Oct 2013 19:59:40 -0700 Subject: [PATCH] fix an audio and search bug. added sheikh qatami. added some logging. bumped the version number. --- README.md | 6 + app/src/main/AndroidManifest.xml | 4 +- .../quran/labs/androidquran/HelpActivity.java | 77 ++---- .../androidquran/QuranPreferenceActivity.java | 13 +- .../labs/androidquran/SearchActivity.java | 5 + .../database/DatabaseHandler.java | 2 + .../database/SuraTimingDatabaseHandler.java | 3 + .../service/util/AudioRequest.java | 1 + .../ui/fragment/JumpFragment.java | 8 +- .../ui/helpers/QuranPageWorker.java | 29 +- app/src/main/res/layout/help.xml | 60 ++-- app/src/main/res/values-ar/strings.xml | 10 +- app/src/main/res/values-de/strings.xml | 9 +- app/src/main/res/values-fa/strings.xml | 9 +- app/src/main/res/values-fr/strings.xml | 11 +- app/src/main/res/values-id/strings.xml | 259 ++++++++++++++++++ app/src/main/res/values-ku/strings.xml | 7 +- app/src/main/res/values-ru/strings.xml | 8 +- app/src/main/res/values-tr/strings.xml | 211 ++++++++++++++ app/src/main/res/values-ug/strings.xml | 7 +- app/src/main/res/values-zh/strings.xml | 7 +- app/src/main/res/values/strings.xml | 22 +- utils/writeTimingDatabase.php | 40 +++ 23 files changed, 647 insertions(+), 161 deletions(-) create mode 100644 app/src/main/res/values-id/strings.xml create mode 100644 app/src/main/res/values-tr/strings.xml create mode 100644 utils/writeTimingDatabase.php diff --git a/README.md b/README.md index ec64e9f316..f322c31ee4 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ App localization * German by [Armin Supuk](http://github.com/ArminSupuk). * Chinese by Bo Li * Uyghur by Abduqadir Abliz [Sahran](http://github.com/Sahran) +* Indonesian by [Saiful Khaliq](http://twitter.com/saifious) Terms of use @@ -91,6 +92,11 @@ Changelog - improve highlighting of search results - fix issues with app being in a confused language state - Russian translation updates +- added Turkish and Indonesian translations +- added sheikh Nasser al Qatami +- fix an issue where search results weren't highlighting in some cases +- fix an issue where next sura wasn't playing in some cases +- improve the jump to dialog - switch build to gradle **version 2.4.5** (released 7/9/2013) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ddad88548d..ea31aaa6ed 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/HelpActivity.java b/app/src/main/java/com/quran/labs/androidquran/HelpActivity.java index fc4c7ff107..61f187f118 100644 --- a/app/src/main/java/com/quran/labs/androidquran/HelpActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/HelpActivity.java @@ -1,73 +1,32 @@ package com.quran.labs.androidquran; -import android.content.Intent; -import android.content.pm.PackageInfo; import android.os.Bundle; import android.text.Html; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; import android.widget.TextView; import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.view.MenuItem; -public class HelpActivity extends SherlockActivity implements OnClickListener { - protected Button mEmailButton; - protected TextView mHelpText; +public class HelpActivity extends SherlockActivity { + public void onCreate(Bundle savedInstanceState) { + setTheme(R.style.Theme_Sherlock); + super.onCreate(savedInstanceState); - public void onCreate(Bundle savedInstanceState) { - setTheme(R.style.Theme_Sherlock); - super.onCreate(savedInstanceState); + getSupportActionBar().setDisplayShowHomeEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setDisplayShowHomeEnabled(true); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); + setContentView(R.layout.help); - setContentView(R.layout.help); - mEmailButton = (Button)findViewById(R.id.btnEmailUs); - mEmailButton.setOnClickListener(this); + TextView helpText = (TextView) findViewById(R.id.txtHelp); + helpText.setText(Html.fromHtml(getString(R.string.help))); + } - mHelpText = (TextView)findViewById(R.id.txtHelp); - mHelpText.setText(Html.fromHtml(getString(R.string.help))); - } - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.btnEmailUs: - Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); - emailIntent.setType("plain/text"); - String body = "\n\n"; - try { - PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); - body = pInfo.packageName + " Version: " + pInfo.versionName; - } catch (Exception e) {} - - try { - body += "\nPhone: " + android.os.Build.MANUFACTURER + " " + android.os.Build.MODEL; - body += "\nAndroid Version: " + android.os.Build.VERSION.CODENAME + " " - + android.os.Build.VERSION.RELEASE; - } catch (Exception e) {} - - emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); - emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, - getString(R.string.email_subject)); - emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, - new String[] { getString(R.string.email_to) }); - startActivity(Intent.createChooser(emailIntent, - getString(R.string.send_email))); - break; - default: - break; - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home){ - finish(); - return true; - } - return false; - } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + finish(); + return true; + } + return false; + } } 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 a05b87ddde..d0eb1dcbd5 100644 --- a/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java @@ -3,7 +3,6 @@ import android.app.ProgressDialog; import android.content.Intent; import android.content.SharedPreferences; -import android.content.pm.PackageInfo; import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; @@ -14,12 +13,14 @@ import android.text.TextUtils; import android.util.Log; import android.widget.Toast; + import com.actionbarsherlock.app.SherlockPreferenceActivity; import com.quran.labs.androidquran.data.Constants; -import com.quran.labs.androidquran.util.*; +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.io.BufferedReader; -import java.io.InputStreamReader; import java.util.HashMap; import java.util.List; @@ -30,7 +31,7 @@ public class QuranPreferenceActivity extends SherlockPreferenceActivity private ListPreference mListStorageOptions; private MoveFilesAsyncTask mMoveFilesTask; - private ReadLogsTask mReadLogsTask; + //private ReadLogsTask mReadLogsTask; private List mStorageList; private LoadStorageOptionsTask mLoadStorageOptionsTask; private int mAppSize; @@ -266,6 +267,7 @@ protected void onPostExecute(Void aVoid) { } } + /* private class ReadLogsTask extends AsyncTask { @Override @@ -325,4 +327,5 @@ protected void onPostExecute(String logs) { getString(R.string.send_email))); } } + */ } diff --git a/app/src/main/java/com/quran/labs/androidquran/SearchActivity.java b/app/src/main/java/com/quran/labs/androidquran/SearchActivity.java index 1a62c6150c..6be9eec7ca 100644 --- a/app/src/main/java/com/quran/labs/androidquran/SearchActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/SearchActivity.java @@ -282,6 +282,11 @@ private void handleIntent(Intent intent) { } } + if (total == 0){ + sura--; + total = QuranInfo.getNumAyahs(sura); + } + jumpToResult(sura, total); finish(); } 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 ed74147081..ad08eb0497 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 @@ -5,6 +5,7 @@ import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; +import com.crashlytics.android.Crashlytics; import com.quran.labs.androidquran.R; import com.quran.labs.androidquran.util.QuranFileUtils; @@ -37,6 +38,7 @@ public DatabaseHandler(Context context, String databaseName) String base = QuranFileUtils.getQuranDatabaseDirectory(context); if (base == null) return; String path = base + File.separator + databaseName; + Crashlytics.log("opening database file: " + path); mDatabase = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS); mSchemaVersion = getSchemaVersion(); diff --git a/app/src/main/java/com/quran/labs/androidquran/database/SuraTimingDatabaseHandler.java b/app/src/main/java/com/quran/labs/androidquran/database/SuraTimingDatabaseHandler.java index 6e2fdc2235..124341866a 100644 --- a/app/src/main/java/com/quran/labs/androidquran/database/SuraTimingDatabaseHandler.java +++ b/app/src/main/java/com/quran/labs/androidquran/database/SuraTimingDatabaseHandler.java @@ -4,6 +4,8 @@ import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; +import com.crashlytics.android.Crashlytics; + public class SuraTimingDatabaseHandler { private SQLiteDatabase mDatabase = null; public static class TimingsTable { @@ -14,6 +16,7 @@ public static class TimingsTable { } public SuraTimingDatabaseHandler(String path) throws SQLException { + Crashlytics.log("opening gapless data file, " + path); mDatabase = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS); } diff --git a/app/src/main/java/com/quran/labs/androidquran/service/util/AudioRequest.java b/app/src/main/java/com/quran/labs/androidquran/service/util/AudioRequest.java index 9a4087550a..27090e077d 100644 --- a/app/src/main/java/com/quran/labs/androidquran/service/util/AudioRequest.java +++ b/app/src/main/java/com/quran/labs/androidquran/service/util/AudioRequest.java @@ -86,6 +86,7 @@ public QuranAyah setCurrentAyah(int sura, int ayah){ else { mCurrentSura = sura; mCurrentAyah = ayah; + mAyahsInThisSura = QuranInfo.SURA_NUM_AYAHS[mCurrentSura-1]; mRepeatInfo.setCurrentVerse(mCurrentSura, mCurrentAyah); return null; } diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/JumpFragment.java b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/JumpFragment.java index f3733a4bfe..4b610dbefd 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/JumpFragment.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/JumpFragment.java @@ -7,6 +7,7 @@ import android.os.Build; import android.os.Bundle; import android.support.v4.app.FragmentActivity; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.widget.AdapterView; @@ -120,7 +121,12 @@ public void onNothingSelected(AdapterView arg0) { public void onClick(DialogInterface dialog, int which) { try { dialog.dismiss(); - int page = Integer.parseInt(input.getText().toString()); + String text = input.getText().toString(); + if (TextUtils.isEmpty(text)){ + text = input.getHint().toString(); + } + + int page = Integer.parseInt(text); if (page >= Constants.PAGES_FIRST && page <= Constants.PAGES_LAST) { Activity activity = getActivity(); 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 afd9df3509..0013f6adbc 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 @@ -10,6 +10,8 @@ import android.support.v4.util.LruCache; import android.util.Log; import android.widget.ImageView; + +import com.crashlytics.android.Crashlytics; import com.quran.labs.androidquran.ui.fragment.ImageCacheFragment; import com.quran.labs.androidquran.util.AsyncTask; import com.quran.labs.androidquran.util.QuranScreenInfo; @@ -112,23 +114,35 @@ public QuranPageWorkerTask(String widthParam, ImageView imageView) { @Override protected BitmapDrawable doInBackground(Integer... params) { data = params[0]; - Bitmap bitmap = QuranDisplayHelper.getQuranPage( + Bitmap bitmap = null; + OutOfMemoryError oom = null; + + try { + bitmap = QuranDisplayHelper.getQuranPage( mContext, mWidthParam, data); + } catch (OutOfMemoryError me){ + Crashlytics.log(Log.WARN, TAG, + "out of memory exception loading page " + + data + ", " + mWidthParam); + oom = me; + } + if (bitmap == null){ - Log.w(TAG, "null bitmap. items in cache: " + mMemoryCache.size() + - " vs " + mMemoryCache.maxSize()); + Crashlytics.log(Log.WARN, TAG, "items in cache: " + + mMemoryCache.size() + " vs " + mMemoryCache.maxSize()); if (QuranScreenInfo.getInstance().isTablet(mContext)){ - Log.w(TAG, "tablet got bitmap null, trying alternate width..."); + Crashlytics.log(Log.WARN, TAG, + "tablet got bitmap null, trying alternate width..."); String param = QuranScreenInfo.getInstance().getWidthParam(); if (param.equals(mWidthParam)){ param = QuranScreenInfo.getInstance().getTabletWidthParam(); } bitmap = QuranDisplayHelper.getQuranPage(mContext, param, data); if (bitmap == null){ - Log.w(TAG, "bitmap still null, giving up..."); + Crashlytics.log(Log.WARN, TAG, "bitmap still null, giving up..."); } } - Log.w(TAG, "got bitmap back as null..."); + Crashlytics.log(Log.WARN, TAG, "got bitmap back as null..."); } BitmapDrawable drawable = null; @@ -141,6 +155,9 @@ protected BitmapDrawable doInBackground(Integer... params) { } addBitmapToCache(data + mWidthParam, drawable); + } else if (oom != null){ + // throw the exception since we couldn't handle it + throw oom; } return drawable; diff --git a/app/src/main/res/layout/help.xml b/app/src/main/res/layout/help.xml index 72e71ffd2c..0eec592643 100644 --- a/app/src/main/res/layout/help.xml +++ b/app/src/main/res/layout/help.xml @@ -1,36 +1,36 @@ - + - + - - + + - -