From bfc2c8ff3e5089a9a2bbc2a881cc208a82319da3 Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 25 Jul 2011 11:23:50 +0200 Subject: [PATCH 0001/1438] quran readers list --- res/values/readers.xml | 12 +++++++ .../labs/androidquran/QuranViewActivity.java | 32 ++++++++++++++----- .../service/QuranDataService.java | 2 +- .../androidquran/util/QuranAudioLibrary.java | 13 +++++--- 4 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 res/values/readers.xml diff --git a/res/values/readers.xml b/res/values/readers.xml new file mode 100644 index 0000000000..f9bd2420a7 --- /dev/null +++ b/res/values/readers.xml @@ -0,0 +1,12 @@ + + + + Abd El Basit + Abdullah Basfar + + + http://www.everyayah.com/data/Abdul_Basit_Murattal_192kbps/ + http://www.everyayah.com/data/Abdullah_Basfar_192kbps/ + + + diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index d1da006c59..9a06282f70 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -10,6 +10,8 @@ import android.os.Bundle; import android.os.IBinder; import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; import android.widget.Toast; import com.markupartist.android.widget.ActionBar.IntentAction; @@ -110,7 +112,7 @@ protected void onNewIntent(Intent intent) { quranAudioPlayer.resume(); else{ Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder.getCurrentPagePosition()); - final AyahItem i = QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], 2); + final AyahItem i = QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], getQuranReaderId()); // soura not totall found if(QuranUtils.isSouraAudioFound(i.getQuranReaderId(), i.getSoura()) < 0){ showDownloadDialog(i); @@ -133,16 +135,21 @@ protected void onNewIntent(Intent intent) { } private void showDownloadDialog(final AyahItem i) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage("Do you want to download sura"); - builder.setPositiveButton("download", new DialogInterface.OnClickListener() { + AlertDialog.Builder dialog = new AlertDialog.Builder(this); + LayoutInflater li = LayoutInflater.from(this); + View view = li.inflate(R.layout.dialog_download, null); + + dialog.setView(view); + //AlertDialog dialog = new DownloadDialog(this); + dialog.setMessage("Do you want to download sura"); + dialog.setPositiveButton("download", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { downloadSura(i.getQuranReaderId(), i.getSoura()); } }); - builder.setNeutralButton("Stream", new DialogInterface.OnClickListener() { + dialog.setNeutralButton("Stream", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -152,7 +159,7 @@ public void onClick(DialogInterface dialog, int which) { } }); - builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -160,7 +167,8 @@ public void onClick(DialogInterface dialog, int which) { } }); - builder.show(); + AlertDialog diag = dialog.create(); + diag.show(); } protected void initQuranPageFeeder(){ @@ -196,7 +204,7 @@ private void playAudio(AyahItem ayah){ if(quranAudioPlayer != null){ if (ayah == null) { Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder.getCurrentPagePosition()); - ayah = QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], 2); + ayah = QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], getQuranReaderId()); } quranAudioPlayer.play(ayah); } @@ -238,4 +246,12 @@ protected void onFinishDownload() { } } + // temp method to select default reader id + // we should put it in another place + we should read reader from preferences + private int getQuranReaderId() { + // TODO Auto-generated method stub + return 0; + } + + } diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 468f77a380..d828d18832 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -118,7 +118,7 @@ private void downloadSuraAudio(Intent intent) { Log.d("quran_srv", "downloadSuraAudio"); int soura = intent.getIntExtra(SOURA_KEY, 1); int startAyah = intent.getIntExtra(AYAH_KEY, 1); - int quranReader = intent.getIntExtra(READER_KEY, 1); + int quranReader = intent.getIntExtra(READER_KEY, 0); // optional end ayah int endAyah = intent.getIntExtra("endAyah", QuranInfo.SURA_NUM_AYAHS[soura - 1]); diff --git a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java index d17d997232..01c0f25fbc 100644 --- a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java +++ b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java @@ -2,6 +2,7 @@ import android.content.Context; +import com.quran.labs.androidquran.R; import com.quran.labs.androidquran.common.AyahItem; import com.quran.labs.androidquran.data.QuranInfo; @@ -17,7 +18,7 @@ public static AyahItem getAyahItem(Context context, int soura, int ayah, int rea String strSoura = fitInt(soura, 3); String strAyah = fitInt(ayah, 3); AyahItem ayahItem = new AyahItem(soura, ayah, readerId, - getAudioUrl(readerId) + strSoura + strAyah + AUDIO_EXTENSION, + getAudioUrl(context, readerId) + strSoura + strAyah + AUDIO_EXTENSION, IMAGE_URL + soura + "_" + ayah + IMAGE_EXTENSION); setAyahItemLocalPaths(context, ayahItem); return ayahItem; @@ -40,7 +41,7 @@ public static AyahItem getNextAyahItem(Context context, int currentSouraId, int ayah++; AyahItem nextAyahItem = new AyahItem(soura, ayah, quranReaderId, - getAudioUrl(quranReaderId) + fitInt(soura, 3) + fitInt(ayah, 3) + AUDIO_EXTENSION, + getAudioUrl(context, quranReaderId) + fitInt(soura, 3) + fitInt(ayah, 3) + AUDIO_EXTENSION, IMAGE_URL + soura + "_" + ayah + IMAGE_EXTENSION); setAyahItemLocalPaths(context, nextAyahItem); return nextAyahItem; @@ -83,10 +84,12 @@ protected static String fitInt(int x, int digits) { "http://www.everyayah.com/data/Abdullah_Basfar_192kbps/" }; - private static String getAudioUrl(int readerId){ - if(readerId > AUDIO_URLS.length) + private static String getAudioUrl(Context context, int readerId){ + String[] urls = + context.getResources().getStringArray(R.array.quran_readers_urls); + if(readerId > urls.length) return null; - return AUDIO_URLS[readerId - 1]; + return urls[readerId]; } } From fef860ab76a7cab2d8895027cd8a34aa63292c0c Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 25 Jul 2011 11:35:14 +0200 Subject: [PATCH 0002/1438] just adding null pointer check --- .../labs/androidquran/QuranActivity.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranActivity.java b/src/com/quran/labs/androidquran/QuranActivity.java index 056b7e6df1..79e537a65a 100644 --- a/src/com/quran/labs/androidquran/QuranActivity.java +++ b/src/com/quran/labs/androidquran/QuranActivity.java @@ -85,17 +85,19 @@ public void showSuras() { ListView list = (ListView)findViewById(R.id.suralist); EfficientAdapter suraAdapter = new EfficientAdapter(this, elements); - list.setAdapter(suraAdapter); - list.setOnItemClickListener(new OnItemClickListener(){ - - @Override - public void onItemClick(AdapterView parent, View v, int position, - long id) { - ListView p = (ListView)parent; - QuranElement elem = (QuranElement)p.getAdapter().getItem((int)id); - jumpTo(elem.page); - } - }); + if(list != null){ + list.setAdapter(suraAdapter); + list.setOnItemClickListener(new OnItemClickListener(){ + + @Override + public void onItemClick(AdapterView parent, View v, int position, + long id) { + ListView p = (ListView)parent; + QuranElement elem = (QuranElement)p.getAdapter().getItem((int)id); + jumpTo(elem.page); + } + }); + } } private class QuranElement { From 82580eaeac8583c7bd4f5d8fc61eff34ed314acb Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 25 Jul 2011 15:28:04 +0200 Subject: [PATCH 0003/1438] -- switch between multiple quran reader --- res/drawable/mic.png | Bin 0 -> 6061 bytes res/layout/dialog_download.xml | 14 +++ .../labs/androidquran/QuranViewActivity.java | 96 +++++++++++++++--- .../service/AudioServiceBinder.java | 21 ++-- 4 files changed, 111 insertions(+), 20 deletions(-) create mode 100644 res/drawable/mic.png create mode 100644 res/layout/dialog_download.xml diff --git a/res/drawable/mic.png b/res/drawable/mic.png new file mode 100644 index 0000000000000000000000000000000000000000..4f5513578a0c733ac281bcf3b456ca74b3ca431f GIT binary patch literal 6061 zcmcIo2{@E%`+r6DwTP0=7(`+=TgKRC#=eEIMQO~u##m;inUU=zT2MM971`2iS5Zoq zBxw=SZcBw66~55H$@0B3($V?)zW?=o*Y$VJ;(4F@{{4Q>{oMEcJl7oB>TDw=zD^tf z04Y0Lq8s#$;=M(Mp--8o)=wvSbG@A$u@q()f=p!wfQZO27Bmk4IP*vrnGynW zVF4hG&M<|K)!c%^=u}gp&^_9jM2QZe7*pZqX5zR=ECdh+a>=mB zuuujE8)*vX<6@!zd5@8B7~g~&VhXq95yHHkw!#QZHVD&4U=SEx3d&FqW}t`AGr$;P z^mSku6lx0+WrWm2>7ut_(HJax3+&q;+)NyXV^agMZba*EbkN8Y9>nFcut;P?L>)lkIxUFH`R?|E+DI~sPsHZi{N3|E z`z&7@MC0W2pUuOVvDGzcXW3?x%P1hid$Gqeon1~J*3txOJ`mjY07 zvbiuKoefgBOg7(k`4(aA7+f$k6q*bthuVM)-nO#nkSUE#UPOk%f^~xOol54Cc~X~Y z)FWZgSUo+gK4votjYXmO==?B3upBO#K>_WErf}#9f=;Jmjqp}hhL-wUERC$U5UtSY zEf_SxN*|9Q7+L8V5{;I-6Pc87UNS7XQ~x`67bq9#407oI1j8#N819E4@wbP`CNQCD zqj2pQflPie{b)nCq_PQgZj>o}E1OIU2l>%}{j1GZ3X=*&5p9V27O|h$5V&jzhY$@? zf?#eSD?A{SPWdUGRT!Bb>cwP3O(=wH@sq^(JGck?oB2-?3Awm*Dh0b(OZ?$tQ?U%? zE{+z5p>$p+!G@9;%Ykt~E&}#5iA#KZiGP>GlgSAW2!={{nM6F9_P1d06#NLjw3TMx z3;xIX#nBQHpL{tHkC;n`*0PLtN$LL)nIH4?uNd$`@G}iduzU@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dB&!_ zbraFdsk>8O`quQuvNh-0T538YG)K#7U26R&Ek-Om3B8HW&3)&4UXAta4Q`0YpXlhZ znG!y@zkNRKOR5ZEW$LNamISGUk9k|njE&!!v*(6q3kdDh_KkUp^JnK<$`#ijW2c{g zeA(8K*>NUgJR|*9*smAnJ~Vt>d#Ss*v3W!NgGfE}j!Dn2Bex@ZB2>oC^~tyl{0iHv zwGcFO<%|2{g0Jao)6*A(1T!aQDSEoy(0vm|v2}9-fM^W>h}#bUGYio7FaU%@ze9f5 z2>{qk08nHe^S^5i04s*=h?bJ#Fh-EQkG&tO7?-b8DOxIf7>qim<*-9h<){g!=<|`}Z8LV2YkisZV|AaW>zGP% zZ(W*|2~UIR4>V;}lLAC2UagRaLLR8=BuOlk8T8OqKwgJ(X08>)9We-^(xp9x0&p$HvAK zMIHch;RDCf)x`@6!jePgjo2^mphzJyIT zW2^n@ABxxeA^hzMyw$rN%$~P;s&AfLCTk=Ur)(wXQdvmP5{~UvyT9|Rt9 + + + diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 075c59b2d2..e44f1ec214 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -12,6 +12,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.widget.Spinner; import android.widget.Toast; import com.markupartist.android.widget.ActionBar.IntentAction; @@ -31,6 +32,7 @@ public class QuranViewActivity extends PageViewQuranActivity implements AyahStat protected static final String ACTION_PAUSE = "ACTION_PAUSE"; protected static final String ACTION_PLAY = "ACTION_PLAY"; protected static final String ACTION_STOP = "ACTION_STOP"; + protected static final String ACTION_CHANGE_READER = "ACTION_CHANGE_READER"; private static final String TAG = "QuranViewActivity"; @@ -41,8 +43,10 @@ public class QuranViewActivity extends PageViewQuranActivity implements AyahStat private static final int ACTION_BAR_ACTION_PAUSE = 1; private static final int ACTION_BAR_ACTION_STOP = 2; private static final int ACTION_BAR_ACTION_NEXT = 3; + private static final int ACTION_BAR_ACTION_CHANGE_READER = 4; private AyahItem lastAyah; + private int currentReaderId; HashMap actionBarActions = new HashMap(); @@ -81,6 +85,8 @@ protected void addActions(){ getIntentAction(ACTION_NEXT, android.R.drawable.ic_media_next)); actionBarActions.put(ACTION_STOP, getIntentAction(ACTION_STOP, R.drawable.stop)); + actionBarActions.put(ACTION_CHANGE_READER, + getIntentAction(ACTION_CHANGE_READER, R.drawable.mic)); actionBar.addAction(actionBarActions.get(ACTION_PLAY), ACTION_BAR_ACTION_PLAY); @@ -90,6 +96,8 @@ protected void addActions(){ ACTION_BAR_ACTION_STOP); actionBar.addAction(actionBarActions.get(ACTION_NEXT), ACTION_BAR_ACTION_NEXT); + actionBar.addAction(actionBarActions.get(ACTION_CHANGE_READER), + ACTION_BAR_ACTION_CHANGE_READER); } } @@ -112,7 +120,9 @@ protected void onNewIntent(Intent intent) { quranAudioPlayer.resume(); else{ Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder.getCurrentPagePosition()); - final AyahItem i = QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], getQuranReaderId()); + final AyahItem i = QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], + pageBounds[1], getQuranReaderId()); + lastAyah = i; // soura not totall found if(QuranUtils.isSouraAudioFound(i.getQuranReaderId(), i.getSoura()) < 0){ showDownloadDialog(i); @@ -130,32 +140,62 @@ protected void onNewIntent(Intent intent) { }else if (action.equalsIgnoreCase(ACTION_STOP)){ lastAyah = null; quranAudioPlayer.stop(); - } + }else if(action.equalsIgnoreCase(ACTION_CHANGE_READER)) + showChangeReaderDialog(); } } private void showDownloadDialog(final AyahItem i) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); - LayoutInflater li = LayoutInflater.from(this); - View view = li.inflate(R.layout.dialog_download, null); - - dialog.setView(view); + LayoutInflater li = LayoutInflater.from(this); + final View view = li.inflate(R.layout.dialog_download, null); + Spinner s = (Spinner) view.findViewById(R.id.spinner); + if(s != null) + s.setSelection(getQuranReaderId()); + dialog.setView(view); //AlertDialog dialog = new DownloadDialog(this); dialog.setMessage("Do you want to download sura"); dialog.setPositiveButton("download", new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) { - downloadSura(i.getQuranReaderId(), i.getSoura(), i.getAyah()); + public void onClick(DialogInterface dialog, int which) { + // get reader id + Spinner s = (Spinner) view.findViewById(R.id.spinner); + lastAyah = i; + if(s != null){ + if(s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ + // reader is not default reader + if(s.getSelectedItemPosition() != i.getQuranReaderId()){ + lastAyah = QuranAudioLibrary.getAyahItem(getApplicationContext(), i.getSoura(), + i.getAyah(), s.getSelectedItemPosition()); + currentReaderId = s.getSelectedItemPosition(); + } + } + } + downloadSura(lastAyah.getQuranReaderId(), lastAyah.getSoura(), lastAyah.getAyah()); + dialog.dismiss(); } }); dialog.setNeutralButton("Stream", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { + // get reader id quranAudioPlayer.enableRemotePlay(true); - quranAudioPlayer.play(i); + Spinner s = (Spinner) view.findViewById(R.id.spinner); + lastAyah = i; + if(s != null){ + if(s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ + // reader is not default reader + if(s.getSelectedItemPosition() != i.getQuranReaderId()){ + lastAyah = QuranAudioLibrary.getAyahItem(getApplicationContext(), i.getSoura(), + i.getAyah(), s.getSelectedItemPosition()); + currentReaderId = s.getSelectedItemPosition(); + } + } + } + quranAudioPlayer.play(lastAyah); dialog.dismiss(); } }); @@ -172,6 +212,31 @@ public void onClick(DialogInterface dialog, int which) { diag.show(); } + private void showChangeReaderDialog(){ + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); + LayoutInflater li = LayoutInflater.from(this); + final View view = li.inflate(R.layout.dialog_download, null); + Spinner s = (Spinner)view.findViewById(R.id.spinner); + s.setSelection(getQuranReaderId()); + dialogBuilder.setView(view); + dialogBuilder.setMessage("Change quran reader"); + dialogBuilder.setPositiveButton("Change", new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + Spinner s = (Spinner) view.findViewById(R.id.spinner); + if(s != null && s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ + if(currentReaderId != s.getSelectedItemPosition()){ + currentReaderId = s.getSelectedItemPosition(); + } + } + } + }); + dialogBuilder.setNegativeButton("Cancel", null); + dialogBuilder.show(); + } + + protected void initQuranPageFeeder(){ if (quranPageFeeder == null) { Log.d(TAG, "Quran Feeder instantiated..."); @@ -213,11 +278,14 @@ private void playAudio(AyahItem ayah){ @Override public void onAyahComplete(AyahItem ayah, AyahItem nextAyah) { - //String text = "Page(" + QuranInfo.getPageFromSuraAyah(nextAyah.getSoura(), nextAyah.getAyah()) + ")" + System.getProperty("line.separator"); - //text += "Soura: " + QuranInfo.getSuraName(nextAyah.getSoura()-1) + System.getProperty("line.separator"); - //text += "Ayah: " + nextAyah.getAyah() + System.getProperty("line.separator"); - //textView.setText(text); lastAyah = ayah; + if(nextAyah.getQuranReaderId() != getQuranReaderId() && + quranAudioPlayer != null && quranAudioPlayer.isPlaying()){ + quranAudioPlayer.stop(); + lastAyah = QuranAudioLibrary.getAyahItem(this, nextAyah.getSoura(), nextAyah.getAyah(), + getQuranReaderId()); + quranAudioPlayer.play(lastAyah); + } int page = QuranInfo.getPageFromSuraAyah(nextAyah.getSoura(), nextAyah.getAyah()); quranPageFeeder.jumpToPage(page); } @@ -251,7 +319,7 @@ protected void onFinishDownload() { // we should put it in another place + we should read reader from preferences private int getQuranReaderId() { // TODO Auto-generated method stub - return 0; + return currentReaderId; } diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index fcd7233cd6..eb0997c400 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -30,7 +30,7 @@ public class AudioServiceBinder extends Binder implements private AyahItem currentItem; private AyahStateListener ayahListener = null; private boolean notified; - private boolean stopped; + private boolean stopped = true; public void setAyahCompleteListener(AyahStateListener ayahListener) { this.ayahListener = ayahListener; @@ -48,8 +48,9 @@ public AudioServiceBinder(Context context){ * @see org.islam.quran.IAudioPlayer#stop() */ public void stop() { - if(mp != null && mp.isPlaying()) - mp.stop(); + if(mp != null && mp.isPlaying()){ + mp.stop(); + } paused = false; stopped = true; } @@ -61,7 +62,9 @@ public void play(AyahItem item) { this.currentItem = item; if(mp != null){ mp.stop(); - mp.release(); + try{ + mp.release(); + }catch(Exception e){} mp = null; } try { @@ -153,8 +156,10 @@ public void onCompletion(MediaPlayer mp) { ayahListener.onAyahComplete(currentItem, nextItem); if(nextItem != null){ this.currentItem = nextItem; - if(!paused && !stopped) - this.play(currentItem); + try{ + if(!paused && !stopped && mp != null && !mp.isPlaying()) + this.play(currentItem); + }catch(Exception ex){} } } @@ -226,4 +231,8 @@ private void showNotification(AyahItem item){ } + public boolean isPlaying(){ + return !paused && !stopped; + } + }; From 4438fe740731d75fa6fff1bcb509fc25c51bd522 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 25 Jul 2011 18:07:05 +0200 Subject: [PATCH 0004/1438] Handle Bassmala --- src/com/quran/labs/androidquran/data/QuranInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/data/QuranInfo.java b/src/com/quran/labs/androidquran/data/QuranInfo.java index e31c011ca3..60f962ebe6 100644 --- a/src/com/quran/labs/androidquran/data/QuranInfo.java +++ b/src/com/quran/labs/androidquran/data/QuranInfo.java @@ -1,7 +1,6 @@ package com.quran.labs.androidquran.data; import com.quran.labs.androidquran.util.QuranSettings; -import android.util.Log; public class QuranInfo { @@ -262,6 +261,7 @@ public static int getPageFromJuz(int juz){ public static int getPageFromSuraAyah(int sura, int ayah){ // basic bounds checking + if (ayah == 0) ayah = 1; if ((sura < 1) || (sura > ApplicationConstants.SURAS_COUNT) || (ayah < ApplicationConstants.AYA_MIN) || (ayah > ApplicationConstants.AYA_MAX)) return -1; From 155611d978056e3b2eecd663eb3314fa3c29e1fb Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 25 Jul 2011 18:07:20 +0200 Subject: [PATCH 0005/1438] -- clear notification -- adding basmala --- res/drawable/mic.png | Bin 6061 -> 1812 bytes .../labs/androidquran/QuranViewActivity.java | 58 +++++++++------ .../service/AudioServiceBinder.java | 7 ++ .../androidquran/util/QuranAudioLibrary.java | 70 ++++++++++++++---- .../labs/androidquran/util/QuranUtils.java | 5 ++ 5 files changed, 106 insertions(+), 34 deletions(-) diff --git a/res/drawable/mic.png b/res/drawable/mic.png index 4f5513578a0c733ac281bcf3b456ca74b3ca431f..206ca9d97ffaec89999779a4173b6b0518903296 100644 GIT binary patch literal 1812 zcmV+v2kZEWP)&ysXJ5mBnHk)@dl$pQ!|3QRV)*hUkdPSd25?GS#hIA+29uK$n4O))^z<|+n9BohGwNqgrDZfYP#};;+BCgNcd%0#G5CoSej!D@!JI85$@l=j~h2`pr@w?&CN}a%JR|Lb{cuIoE>%n5M`&Us5sxeIf_S* zW-v81N#cJACX)$Tody}1X{fC;AXA)X9{^zrU)4W&fp~o#-+w=iaiYZF-~i4L`AbTR zk-(3KPOn8`GS5B$v2ih~-V5D70NlQP3j+iFXl*_H13;C!5*#l3*#Yo)+(14*{=KlU zkciNOpP4(qIE$~Yenl$ap%tLFw+D@l4Ja)yg)m6~xk8GM_Wf;)+Cxo&Anxh+7_UuAaO9Of@^jJIK(9j^-+uNbhoPs1b2hlN6NY6;cR%Q^s{BnqZ z{sMrrv%?bu5U;{0uTR9CnEKP!KhLUbs;nxEjEtbWy9-TCjZmp7ArhZN9QOoR$0P6u z-!0!7YPFEb^Kbo62z-1NxzOn@FTM8KOHT~I;cyno6a{0aTbnHr5yuV-5)-CdPB){! zzmJq(2Xs0ulu89D!E_?O7$1GS*O(~e7o9(U4*bM;F?EKQ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Rt9 actionBarActions = new HashMap(); + HashMap actionBarActions = new HashMap(); // private TextView textView; @@ -77,27 +80,35 @@ protected void addActions(){ super.addActions(); if(actionBar != null){ //actionBar.setTitle("QuranAndroid"); - actionBarActions.put(ACTION_PLAY, + actionBarActions.put(ACTION_BAR_ACTION_PLAY, getIntentAction(ACTION_PLAY, android.R.drawable.ic_media_play)); - actionBarActions.put(ACTION_PAUSE, + actionBarActions.put(ACTION_BAR_ACTION_PAUSE, getIntentAction(ACTION_PAUSE, android.R.drawable.ic_media_pause)); - actionBarActions.put(ACTION_NEXT, + actionBarActions.put(ACTION_BAR_ACTION_NEXT, getIntentAction(ACTION_NEXT, android.R.drawable.ic_media_next)); - actionBarActions.put(ACTION_STOP, + actionBarActions.put(ACTION_BAR_ACTION_PREVIOUS, + getIntentAction(ACTION_PREVIOUS, android.R.drawable.ic_media_previous)); + actionBarActions.put(ACTION_BAR_ACTION_STOP, getIntentAction(ACTION_STOP, R.drawable.stop)); - actionBarActions.put(ACTION_CHANGE_READER, + actionBarActions.put(ACTION_BAR_ACTION_CHANGE_READER, getIntentAction(ACTION_CHANGE_READER, R.drawable.mic)); - actionBar.addAction(actionBarActions.get(ACTION_PLAY), - ACTION_BAR_ACTION_PLAY); - actionBar.addAction(actionBarActions.get(ACTION_PAUSE), - ACTION_BAR_ACTION_PAUSE); - actionBar.addAction(actionBarActions.get(ACTION_STOP), - ACTION_BAR_ACTION_STOP); - actionBar.addAction(actionBarActions.get(ACTION_NEXT), - ACTION_BAR_ACTION_NEXT); - actionBar.addAction(actionBarActions.get(ACTION_CHANGE_READER), - ACTION_BAR_ACTION_CHANGE_READER); +// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PREVIOUS), +// ACTION_BAR_ACTION_PREVIOUS); +// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PLAY), +// ACTION_BAR_ACTION_PLAY); +// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PAUSE), +// ACTION_BAR_ACTION_PAUSE); +// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_STOP), +// ACTION_BAR_ACTION_STOP); +// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_NEXT), +// ACTION_BAR_ACTION_NEXT); +// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_CHANGE_READER), +// ACTION_BAR_ACTION_CHANGE_READER); + + for (Integer actionId : actionBarActions.keySet()) { + actionBar.addAction(actionBarActions.get(actionId), actionId); + } } } @@ -137,7 +148,12 @@ protected void onNewIntent(Intent intent) { AyahItem ayah = QuranAudioLibrary.getNextAyahAudioItem(this, quranAudioPlayer.getCurrentAyah()); quranAudioPlayer.play(ayah); + }else if (action.equalsIgnoreCase(ACTION_PREVIOUS)){ + AyahItem ayah = QuranAudioLibrary.getPreviousAyahAudioItem(this, + quranAudioPlayer.getCurrentAyah()); + quranAudioPlayer.play(ayah); }else if (action.equalsIgnoreCase(ACTION_STOP)){ + lastAyah = null; quranAudioPlayer.stop(); }else if(action.equalsIgnoreCase(ACTION_CHANGE_READER)) diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index eb0997c400..d4111b792f 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -53,8 +53,15 @@ public void stop() { } paused = false; stopped = true; + clearNotification(); } + + private void clearNotification(){ + NotificationManager mgr = + (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); + mgr.cancelAll(); + } /* (non-Javadoc) * @see org.islam.quran.IAudioPlayer#play(org.islam.quran.AyahAudioItem) */ diff --git a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java index 01c0f25fbc..cf7907e9b4 100644 --- a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java +++ b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java @@ -15,11 +15,20 @@ public class QuranAudioLibrary { public final static String IMAGE_EXTENSION = ".jpg"; public static AyahItem getAyahItem(Context context, int soura, int ayah, int readerId){ - String strSoura = fitInt(soura, 3); - String strAyah = fitInt(ayah, 3); +// String strSoura = fitInt(soura, 3); +// String strAyah = fitInt(ayah, 3); + + String remoteUrl; + if(ayah == 0) + remoteUrl = getAudioUrl(context, readerId) + fitInt(1, 3) + fitInt(1, 3) + AUDIO_EXTENSION; + else + remoteUrl = getAudioUrl(context, readerId) + fitInt(soura, 3) + fitInt(ayah, 3) + AUDIO_EXTENSION; + + String remoteImagePath = IMAGE_URL + soura + "_" + ayah + IMAGE_EXTENSION; + AyahItem ayahItem = new AyahItem(soura, ayah, readerId, - getAudioUrl(context, readerId) + strSoura + strAyah + AUDIO_EXTENSION, - IMAGE_URL + soura + "_" + ayah + IMAGE_EXTENSION); + remoteUrl, + remoteImagePath); setAyahItemLocalPaths(context, ayahItem); return ayahItem; } @@ -29,19 +38,51 @@ private static void setAyahItemLocalPaths(Context context, final AyahItem ayahIt ayahItem.setLocalImageUrl(generateImageFileName(context, ayahItem)); } - public static AyahItem getNextAyahItem(Context context, int currentSouraId, int currentAyaId, int quranReaderId){ + public static AyahItem getNextAyahItem(Context context, int currentSouraId, int currentAyaId, + int quranReaderId){ try{ int ayah = currentAyaId; int soura = currentSouraId; if(currentAyaId >= QuranInfo.SURA_NUM_AYAHS[currentSouraId - 1]){ soura = (currentSouraId+1)%(QuranInfo.SURA_NUM_AYAHS.length + 1); - //ayah = soura == 9 ? 1 : 0; - ayah = 1; + ayah = soura == 9 ? 1 : 0; + //ayah = 1; }else ayah++; + String remoteUrl; + if(ayah == 0) + remoteUrl = getAudioUrl(context, quranReaderId) + fitInt(1, 3) + fitInt(1, 3) + AUDIO_EXTENSION; + else + remoteUrl = getAudioUrl(context, quranReaderId) + fitInt(soura, 3) + fitInt(ayah, 3) + AUDIO_EXTENSION; + + AyahItem nextAyahItem = new AyahItem(soura, ayah, quranReaderId, + remoteUrl, + IMAGE_URL + soura + "_" + ayah + IMAGE_EXTENSION); + setAyahItemLocalPaths(context, nextAyahItem); + return nextAyahItem; + }catch(Exception ex){ + return null; + } + } + + public static AyahItem getPreviousAyahItem(Context context, int currentSouraId, + int currentAyaId, int quranReaderId){ + try{ + int ayah = currentAyaId; + int soura = currentSouraId; + if(currentAyaId == 1){ + soura = (currentSouraId-1)%(QuranInfo.SURA_NUM_AYAHS.length + 1); + ayah = QuranInfo.SURA_NUM_AYAHS[soura - 1]; + }else + ayah--; + String remoteUrl; + if(ayah == 0) + remoteUrl = getAudioUrl(context, quranReaderId) + fitInt(1, 3) + fitInt(1, 3) + AUDIO_EXTENSION; + else + remoteUrl = getAudioUrl(context, quranReaderId) + fitInt(soura, 3) + fitInt(ayah, 3) + AUDIO_EXTENSION; AyahItem nextAyahItem = new AyahItem(soura, ayah, quranReaderId, - getAudioUrl(context, quranReaderId) + fitInt(soura, 3) + fitInt(ayah, 3) + AUDIO_EXTENSION, + remoteUrl, IMAGE_URL + soura + "_" + ayah + IMAGE_EXTENSION); setAyahItemLocalPaths(context, nextAyahItem); return nextAyahItem; @@ -49,9 +90,16 @@ public static AyahItem getNextAyahItem(Context context, int currentSouraId, int return null; } } + public static AyahItem getNextAyahAudioItem(Context context, AyahItem currentAyah){ - return getNextAyahItem(context, currentAyah.getSoura(), currentAyah.getAyah(), currentAyah.getQuranReaderId()); + return getNextAyahItem(context, currentAyah.getSoura(), currentAyah.getAyah(), + currentAyah.getQuranReaderId()); + } + + public static AyahItem getPreviousAyahAudioItem(Context context, AyahItem currentAyah){ + return getPreviousAyahItem(context, currentAyah.getSoura(), currentAyah.getAyah(), + currentAyah.getQuranReaderId()); } public static String generateAudioFileName(Context context, AyahItem ayahItem){ @@ -79,10 +127,6 @@ protected static String fitInt(int x, int digits) { return result; } - private static String[] AUDIO_URLS = { - "http://www.everyayah.com/data/Abdul_Basit_Murattal_192kbps/", - "http://www.everyayah.com/data/Abdullah_Basfar_192kbps/" - }; private static String getAudioUrl(Context context, int readerId){ String[] urls = diff --git a/src/com/quran/labs/androidquran/util/QuranUtils.java b/src/com/quran/labs/androidquran/util/QuranUtils.java index f4badfdaca..d4a6df8355 100644 --- a/src/com/quran/labs/androidquran/util/QuranUtils.java +++ b/src/com/quran/labs/androidquran/util/QuranUtils.java @@ -312,6 +312,11 @@ public static String getAyahImagePath(AyahItem ayahItem) { } public static String getAyahAudioPath(int sura, int ayah, int quranReaderId) { + // always get basmala from el fate7a + if(ayah == 0){ + ayah = 1; + sura = 1; + } return getAudioDirectory() + File.separator + quranReaderId + File.separator + sura + File.separator + ayah + QuranAudioLibrary.AUDIO_EXTENSION; From 2f86b4b5903413eb85912111dfbeaf6d607a5e89 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 25 Jul 2011 18:18:29 +0200 Subject: [PATCH 0006/1438] Readers List --- res/values-ar/readers.xml | 24 ++++++++++++++++++++++++ res/values/readers.xml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 res/values-ar/readers.xml diff --git a/res/values-ar/readers.xml b/res/values-ar/readers.xml new file mode 100644 index 0000000000..a303de3e86 --- /dev/null +++ b/res/values-ar/readers.xml @@ -0,0 +1,24 @@ + + + + عبد الباسط عبد الصمد + عبد الباسط عبد الصمد مجود + عبد الله بصفر + عبد الرحمن السديس + أبو بكر الشاطري + مشاري بن راشد العفاسي + هاني الرفاعي + الحصري + الحصري مجود + الحذيفي + إبراهيم اﻷخضر + ماهر المعيلقي + المنشاوي + المنشاوي مجود + محمد الطبلاوي + محمد أيوب + محمد جبريل + سعود الشريم + + + diff --git a/res/values/readers.xml b/res/values/readers.xml index f9bd2420a7..a4bd4ddc28 100644 --- a/res/values/readers.xml +++ b/res/values/readers.xml @@ -2,11 +2,43 @@ Abd El Basit + Abdul Basit Mujawwad Abdullah Basfar + Abdurrahmaan As-Sudais + Abu Bakr Ash-Shaatree + Alafasy + Hani Rifai + Husary + Husary Mujawwad + Hudhaify + Ibrahim Akhdar + Maher Al Muaiqly + Minshawy + Minshawy Mujawwad + Mohammad al Tablaway + Muhammad Ayyoub + Muhammad Jibreel + Saood Ash-Shuraym http://www.everyayah.com/data/Abdul_Basit_Murattal_192kbps/ + http://www.everyayah.com/data/Abdul_Basit_Mujawwad_128kbps/ http://www.everyayah.com/data/Abdullah_Basfar_192kbps/ + http://www.everyayah.com/data/Abdurrahmaan_As-Sudais_192kbps/ + http://www.everyayah.com/data/Abu Bakr Ash-Shaatree_128kbps/ + http://www.everyayah.com/data/Alafasy_128kbps/ + http://www.everyayah.com/data/Hani_Rifai_192kbps/ + http://www.everyayah.com/data/Husary_64kbps/ + http://www.everyayah.com/data/Husary_128kbps_Mujawwad/ + http://www.everyayah.com/data/Hudhaify_128kbps/ + http://www.everyayah.com/data/Ibrahim_Akhdar_64kbps/ + http://www.everyayah.com/data/Maher_AlMuaiqly_64kbps/ + http://www.everyayah.com/data/Minshawy_Murattal_128kbps/ + http://www.everyayah.com/data/Minshawy_Mujawwad_192kbps/ + http://www.everyayah.com/data/Mohammad_al_Tablaway_128kbps/ + http://www.everyayah.com/data/Muhammad_Ayyoub_128kbps/ + http://www.everyayah.com/data/Muhammad_Jibreel_128kbps/ + http://www.everyayah.com/data/Saood bin Ibraaheem Ash-Shuraym_128kbps/ From 536f9ca3000a088990823442d806a3ca0298a485 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 25 Jul 2011 18:19:34 +0200 Subject: [PATCH 0007/1438] Cancel download - Remove unused file --- res/values/strings.xml | 2 +- .../androidquran/common/InternetActivity.java | 28 +- .../service/QuranDataService.java | 64 +++- .../labs/androidquran/widgets/ActionBar.java | 308 ------------------ 4 files changed, 76 insertions(+), 326 deletions(-) delete mode 100644 src/com/quran/labs/androidquran/widgets/ActionBar.java diff --git a/res/values/strings.xml b/res/values/strings.xml index c801df9ee0..cf53c876a1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -15,7 +15,7 @@ Yes No Downloading... - Please wait for the files to download. + Please wait for the files to download. (Resume supported) Processing... Please wait the files are processed. Jump diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 5667b0aa90..1255fb12ef 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -9,7 +9,9 @@ import android.content.ServiceConnection; import android.net.ConnectivityManager; import android.os.AsyncTask; +import android.os.Bundle; import android.os.IBinder; +import android.util.Log; import com.quran.labs.androidquran.R; import com.quran.labs.androidquran.service.QuranDataService; @@ -22,6 +24,14 @@ public abstract class InternetActivity extends BaseQuranActivity { protected boolean starting = true; protected ServiceConnection serviceConnection; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + initServiceConnection(); + if (QuranDataService.isRunning) + showProgressDialog(); + } + public boolean isInternetOn() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null && cm.getActiveNetworkInfo() != null) @@ -149,7 +159,23 @@ private void showProgressDialog(){ pDialog = new ProgressDialog(this); pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pDialog.setTitle(R.string.downloading_title); - pDialog.setCancelable(false); + pDialog.setCancelable(true); + pDialog.setButton(ProgressDialog.BUTTON1, "Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Log.d("QuranAndroid", "User canceled downloading.."); + if (serviceConnection != null) { + if (downloadService != null) { + downloadService.stop(); + } + unbindService(serviceConnection); + } + stopService(new Intent(getApplicationContext(), QuranDataService.class)); + currentTask = null; + pDialog.dismiss(); + } + }); + pDialog.setMessage(getString(R.string.downloading_message)); pDialog.show(); diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 2bbf14f5ef..60a0acf1e7 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -96,6 +96,7 @@ public void handleStart(Intent intent, int startId) { return; int downloadType = intent.getIntExtra(DWONLOAD_TYPE_KEY, -1); + QuranDataService.isRunning = true; switch (downloadType) { case DOWNLOAD_QURAN_IMAGES: thread = new DownloadThread(this, new String[] { QuranUtils.getZipFileUrl() }, @@ -110,9 +111,9 @@ public void handleStart(Intent intent, int startId) { break; default: + QuranDataService.isRunning = false; return; } - QuranDataService.isRunning = true; } private void downloadSuraAudio(Intent intent) { @@ -159,10 +160,14 @@ private void downloadSuraAudio(Intent intent) { urls.add(ayah.getRemoteImageUrl()); } } - - thread = new DownloadThread(this, urls.toArray(new String[urls.size()]), - fileNames.toArray(new String[urls.size()]), directories.toArray(new String[urls.size()]), false); - thread.start(); + + if (urls.size() > 0) { + thread = new DownloadThread(this, urls.toArray(new String[urls.size()]), + fileNames.toArray(new String[urls.size()]), directories.toArray(new String[urls.size()]), false); + thread.start(); + } else { + QuranDataService.isRunning = false; + } } private void downloadTranslation(Intent intent) { @@ -172,11 +177,25 @@ private void downloadTranslation(Intent intent) { new String[] { fileName }, new String[]{QuranUtils.getQuranDatabaseDirectory()}, false); thread.start(); } + + public void stop() { + Log.d("quran_srv", "Stop Service called"); + try { + if (thread != null) { + thread.interrupt(); + } + } catch (Exception e) { + + } + progress = 0; + thread = null; + QuranDataService.isRunning = false; + } @Override public void onDestroy() { super.onDestroy(); - QuranDataService.isRunning = false; + stop(); } public void updateProgress(int progress) { @@ -246,7 +265,7 @@ private boolean resumeDownload() { File file = new File(saveToDirectories[downloadIndex], fileNames[downloadIndex] + DOWNLOAD_EXT); - URL url = new URL(downloadUrls[downloadIndex]); + URL url = new URL(escapeUrlSpecialCharacters(downloadUrls[downloadIndex])); URLConnection conn = url.openConnection(); int total = conn.getContentLength(); Log.d("quran_srv", "File to download: " + file.getName() @@ -273,19 +292,22 @@ private boolean resumeDownload() { byte[] data = new byte[DOWNLOAD_BUFFER_SIZE]; int x = 0; - while ((x = in.read(data, 0, DOWNLOAD_BUFFER_SIZE)) >= 0) { + while (isRunning && (x = in.read(data, 0, DOWNLOAD_BUFFER_SIZE)) >= 0) { bout.write(data, 0, x); downloaded += x; double percent = 100.0 * ((1.0 * downloaded) / (1.0 * total)); updateProgress((int) percent, fileNames.length, downloadIndex); } - file.renameTo(new File(saveToDirectories[downloadIndex], fileNames[downloadIndex])); - - if (zipped) - unzipFile(saveToDirectories[downloadIndex], fileNames[downloadIndex]); - - Log.d("quran_srv", "Download Completed [" + downloadUrls[downloadIndex] + "]"); + if (isRunning) { + file.renameTo(new File(saveToDirectories[downloadIndex], fileNames[downloadIndex])); + + if (zipped) + unzipFile(saveToDirectories[downloadIndex], fileNames[downloadIndex]); + + Log.d("quran_srv", "Download Completed [" + downloadUrls[downloadIndex] + "]"); + } else + return false; } } catch (IOException e) { Log.e("quran_srv", "Download paused: IO Exception", e); @@ -312,15 +334,21 @@ private void updateProgress(int percent, int totalFiles, int nDownloadedFiles) { public void run() { onDowloadStart(); try { - while (true) { + while (isRunning) { if (isInternetOn() && resumeDownload()) { - onDownloadComplete(); + if (isRunning) + onDownloadComplete(); + break; + } + if (!isRunning) { + Log.d("quran_srv", "Canceled"); break; } try { Log.d("quran_srv", "Disconnected.. Retring after " + WAIT_TIME + " seconds"); sleep(WAIT_TIME * 1000); } catch (InterruptedException e) { + } } } catch(Exception e) { @@ -393,4 +421,8 @@ private void onDownloadComplete() { QuranDataService.isRunning = false; } } + + private String escapeUrlSpecialCharacters(String url) { + return url.replace(" ", "%20"); + } } diff --git a/src/com/quran/labs/androidquran/widgets/ActionBar.java b/src/com/quran/labs/androidquran/widgets/ActionBar.java deleted file mode 100644 index 09b34f3be6..0000000000 --- a/src/com/quran/labs/androidquran/widgets/ActionBar.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (C) 2010 Johan Nilsson - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Action Bar from: http://github.com/johannilsson/android-actionbar - */ - - -package com.quran.labs.androidquran.widgets; - -import java.util.LinkedList; - -import android.content.ActivityNotFoundException; -import android.content.Context; -import android.content.Intent; -import android.content.res.TypedArray; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; -import android.widget.TextView; -import android.widget.Toast; - -import com.quran.labs.androidquran.R; - -public class ActionBar extends RelativeLayout implements OnClickListener { - - private LayoutInflater mInflater; - private RelativeLayout mBarView; - private ImageView mLogoView; - private View mBackIndicator; - //private View mHomeView; - private TextView mTitleView; - private LinearLayout mActionsView; - private ImageButton mHomeBtn; - private RelativeLayout mHomeLayout; - private ProgressBar mProgress; - - public ActionBar(Context context, AttributeSet attrs) { - super(context, attrs); - - mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - - mBarView = (RelativeLayout) mInflater.inflate(R.layout.actionbar, null); - addView(mBarView); - - mLogoView = (ImageView) mBarView.findViewById(R.id.actionbar_home_logo); - mHomeLayout = (RelativeLayout) mBarView.findViewById(R.id.actionbar_home_bg); - mHomeBtn = (ImageButton) mBarView.findViewById(R.id.actionbar_home_btn); - mBackIndicator = mBarView.findViewById(R.id.actionbar_home_is_back); - - mTitleView = (TextView) mBarView.findViewById(R.id.actionbar_title); - mActionsView = (LinearLayout) mBarView.findViewById(R.id.actionbar_actions); - - mProgress = (ProgressBar) mBarView.findViewById(R.id.actionbar_progress); - - TypedArray a = context.obtainStyledAttributes(attrs, - R.styleable.ActionBar); - CharSequence title = a.getString(R.styleable.ActionBar_title); - if (title != null) { - setTitle(title); - } - a.recycle(); - } - - public void setHomeAction(Action action) { - mHomeBtn.setOnClickListener(this); - mHomeBtn.setTag(action); - mHomeBtn.setImageResource(action.getDrawable()); - mHomeLayout.setVisibility(View.VISIBLE); - } - - public void clearHomeAction() { - mHomeLayout.setVisibility(View.GONE); - } - - /** - * Shows the provided logo to the left in the action bar. - * - * This is ment to be used instead of the setHomeAction and does not draw - * a divider to the left of the provided logo. - * - * @param resId The drawable resource id - */ - public void setHomeLogo(int resId) { - // TODO: Add possibility to add an IntentAction as well. - mLogoView.setImageResource(resId); - mLogoView.setVisibility(View.VISIBLE); - mHomeLayout.setVisibility(View.GONE); - } - - /* Emulating Honeycomb, setdisplayHomeAsUpEnabled takes a boolean - * and toggles whether the "home" view should have a little triangle - * indicating "up" */ - public void setDisplayHomeAsUpEnabled(boolean show) { - mBackIndicator.setVisibility(show? View.VISIBLE : View.GONE); - } - - - public void setTitle(CharSequence title) { - mTitleView.setText(title); - } - - public void setTitle(int resid) { - mTitleView.setText(resid); - } - - /** - * Set the enabled state of the progress bar. - * - * @param One of {@link View#VISIBLE}, {@link View#INVISIBLE}, - * or {@link View#GONE}. - */ - public void setProgressBarVisibility(int visibility) { - mProgress.setVisibility(visibility); - } - - /** - * Returns the visibility status for the progress bar. - * - * @param One of {@link View#VISIBLE}, {@link View#INVISIBLE}, - * or {@link View#GONE}. - */ - public int getProgressBarVisibility() { - return mProgress.getVisibility(); - } - - /** - * Function to set a click listener for Title TextView - * - * @param listener the onClickListener - */ - public void setOnTitleClickListener(OnClickListener listener) { - mTitleView.setOnClickListener(listener); - } - - @Override - public void onClick(View view) { - final Object tag = view.getTag(); - if (tag instanceof Action) { - final Action action = (Action) tag; - action.performAction(view); - } - } - - /** - * Adds a list of {@link Action}s. - * @param actionList the actions to add - */ - public void addActions(ActionList actionList) { - int actions = actionList.size(); - for (int i = 0; i < actions; i++) { - addAction(actionList.get(i)); - } - } - - /** - * Adds a new {@link Action}. - * @param action the action to add - */ - public void addAction(Action action) { - final int index = mActionsView.getChildCount(); - addAction(action, index); - } - - /** - * Adds a new {@link Action} at the specified index. - * @param action the action to add - * @param index the position at which to add the action - */ - public void addAction(Action action, int index) { - mActionsView.addView(inflateAction(action), index); - } - - /** - * Removes all action views from this action bar - */ - public void removeAllActions() { - mActionsView.removeAllViews(); - } - - /** - * Remove a action from the action bar. - * @param index position of action to remove - */ - public void removeActionAt(int index) { - mActionsView.removeViewAt(index); - } - - /** - * Remove a action from the action bar. - * @param action The action to remove - */ - public void removeAction(Action action) { - int childCount = mActionsView.getChildCount(); - for (int i = 0; i < childCount; i++) { - View view = mActionsView.getChildAt(i); - if (view != null) { - final Object tag = view.getTag(); - if (tag instanceof Action && tag.equals(action)) { - mActionsView.removeView(view); - } - } - } - } - - /** - * Returns the number of actions currently registered with the action bar. - * @return action count - */ - public int getActionCount() { - return mActionsView.getChildCount(); - } - - /** - * Inflates a {@link View} with the given {@link Action}. - * @param action the action to inflate - * @return a view - */ - private View inflateAction(Action action) { - View view = mInflater.inflate(R.layout.actionbar_item, mActionsView, false); - - ImageButton labelView = - (ImageButton) view.findViewById(R.id.actionbar_item); - labelView.setImageResource(action.getDrawable()); - - view.setTag(action); - view.setOnClickListener(this); - return view; - } - - /** - * A {@link LinkedList} that holds a list of {@link Action}s. - */ - @SuppressWarnings("serial") - public static class ActionList extends LinkedList { - } - - /** - * Definition of an action that could be performed, along with a icon to - * show. - */ - public interface Action { - public int getDrawable(); - public void performAction(View view); - } - - public static abstract class AbstractAction implements Action { - final private int mDrawable; - - public AbstractAction(int drawable) { - mDrawable = drawable; - } - - @Override - public int getDrawable() { - return mDrawable; - } - } - - public static class IntentAction extends AbstractAction { - private Context mContext; - private Intent mIntent; - - public IntentAction(Context context, Intent intent, int drawable) { - super(drawable); - mContext = context; - mIntent = intent; - } - - @Override - public void performAction(View view) { - try { - mContext.startActivity(mIntent); - } catch (ActivityNotFoundException e) { - Toast.makeText(mContext, - mContext.getText(R.string.actionbar_activity_not_found), - Toast.LENGTH_SHORT).show(); - } - } - } - - /* - public static abstract class SearchAction extends AbstractAction { - public SearchAction() { - super(R.drawable.actionbar_search); - } - } - */ -} From b62e2dd6f60b76309a607bb982c2bd814bc8aa9c Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 25 Jul 2011 18:46:51 +0200 Subject: [PATCH 0008/1438] -- fixing basmala --- .../labs/androidquran/QuranViewActivity.java | 16 ++++++++++------ .../androidquran/service/AudioServiceBinder.java | 2 ++ .../androidquran/util/QuranAudioLibrary.java | 6 ++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 03eace7975..f80c90bf68 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -145,13 +145,17 @@ protected void onNewIntent(Intent intent) { }else if(action.equalsIgnoreCase(ACTION_PAUSE)){ quranAudioPlayer.pause(); }else if(action.equalsIgnoreCase(ACTION_NEXT)){ - AyahItem ayah = QuranAudioLibrary.getNextAyahAudioItem(this, - quranAudioPlayer.getCurrentAyah()); - quranAudioPlayer.play(ayah); + if(quranAudioPlayer.getCurrentAyah() != null){ + AyahItem ayah = QuranAudioLibrary.getNextAyahAudioItem(this, + quranAudioPlayer.getCurrentAyah()); + quranAudioPlayer.play(ayah); + } }else if (action.equalsIgnoreCase(ACTION_PREVIOUS)){ - AyahItem ayah = QuranAudioLibrary.getPreviousAyahAudioItem(this, - quranAudioPlayer.getCurrentAyah()); - quranAudioPlayer.play(ayah); + if(quranAudioPlayer.getCurrentAyah() != null){ + AyahItem ayah = QuranAudioLibrary.getPreviousAyahAudioItem(this, + quranAudioPlayer.getCurrentAyah()); + quranAudioPlayer.play(ayah); + } }else if (action.equalsIgnoreCase(ACTION_STOP)){ lastAyah = null; diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index d4111b792f..6492580d50 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -66,6 +66,8 @@ private void clearNotification(){ * @see org.islam.quran.IAudioPlayer#play(org.islam.quran.AyahAudioItem) */ public void play(AyahItem item) { + if(item == null) + return; this.currentItem = item; if(mp != null){ mp.stop(); diff --git a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java index cf7907e9b4..62d180485d 100644 --- a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java +++ b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java @@ -45,7 +45,8 @@ public static AyahItem getNextAyahItem(Context context, int currentSouraId, int int soura = currentSouraId; if(currentAyaId >= QuranInfo.SURA_NUM_AYAHS[currentSouraId - 1]){ soura = (currentSouraId+1)%(QuranInfo.SURA_NUM_AYAHS.length + 1); - ayah = soura == 9 ? 1 : 0; + if(soura == 0) soura = 1; + ayah = soura == 9 || soura == 1 ? 1 : 0; //ayah = 1; }else ayah++; @@ -71,7 +72,8 @@ public static AyahItem getPreviousAyahItem(Context context, int currentSouraId, int ayah = currentAyaId; int soura = currentSouraId; if(currentAyaId == 1){ - soura = (currentSouraId-1)%(QuranInfo.SURA_NUM_AYAHS.length + 1); + soura--; + if(soura == 0) soura = 114; ayah = QuranInfo.SURA_NUM_AYAHS[soura - 1]; }else ayah--; From 64aa41b2b438910e8b3401bcc8161f3078887dd5 Mon Sep 17 00:00:00 2001 From: fouad Date: Tue, 26 Jul 2011 01:09:17 +0200 Subject: [PATCH 0009/1438] -- activate previous and next before playing start --- .../labs/androidquran/QuranViewActivity.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index f80c90bf68..32f44f4bf6 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -130,34 +130,26 @@ protected void onNewIntent(Intent intent) { if(quranAudioPlayer.isPaused()) quranAudioPlayer.resume(); else{ - Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder.getCurrentPagePosition()); - final AyahItem i = QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], - pageBounds[1], getQuranReaderId()); - lastAyah = i; + lastAyah = getCurrentAudioAyah(); // soura not totall found - if(QuranUtils.isSouraAudioFound(i.getQuranReaderId(), i.getSoura()) < 0){ - showDownloadDialog(i); + if(QuranUtils.isSouraAudioFound(lastAyah.getQuranReaderId(), lastAyah.getSoura()) < 0){ + showDownloadDialog(lastAyah); }else{ quranAudioPlayer.enableRemotePlay(false); - playAudio(i); + playAudio(lastAyah); } } }else if(action.equalsIgnoreCase(ACTION_PAUSE)){ quranAudioPlayer.pause(); }else if(action.equalsIgnoreCase(ACTION_NEXT)){ - if(quranAudioPlayer.getCurrentAyah() != null){ - AyahItem ayah = QuranAudioLibrary.getNextAyahAudioItem(this, - quranAudioPlayer.getCurrentAyah()); - quranAudioPlayer.play(ayah); - } + lastAyah = QuranAudioLibrary.getNextAyahAudioItem(this, getCurrentAudioAyah()); + if(quranAudioPlayer != null && quranAudioPlayer.isPlaying()) + quranAudioPlayer.play(lastAyah); }else if (action.equalsIgnoreCase(ACTION_PREVIOUS)){ - if(quranAudioPlayer.getCurrentAyah() != null){ - AyahItem ayah = QuranAudioLibrary.getPreviousAyahAudioItem(this, - quranAudioPlayer.getCurrentAyah()); - quranAudioPlayer.play(ayah); - } + lastAyah = QuranAudioLibrary.getPreviousAyahAudioItem(this, getCurrentAudioAyah()); + if(quranAudioPlayer != null && quranAudioPlayer.isPlaying()) + quranAudioPlayer.play(lastAyah); }else if (action.equalsIgnoreCase(ACTION_STOP)){ - lastAyah = null; quranAudioPlayer.stop(); }else if(action.equalsIgnoreCase(ACTION_CHANGE_READER)) @@ -342,5 +334,12 @@ private int getQuranReaderId() { return currentReaderId; } + private AyahItem getCurrentAudioAyah(){ + if(lastAyah != null){ + return lastAyah; + } + Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder.getCurrentPagePosition()); + return QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], getQuranReaderId()); + } } From 93d205364a93a480829e1bc00dcf88fa488b372d Mon Sep 17 00:00:00 2001 From: fouad Date: Tue, 26 Jul 2011 01:43:40 +0200 Subject: [PATCH 0010/1438] -- adding ids --- res/values/readers.xml | 20 ++++++++++ .../labs/androidquran/QuranViewActivity.java | 40 ++++++++++++++----- .../androidquran/util/QuranAudioLibrary.java | 11 ++++- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/res/values/readers.xml b/res/values/readers.xml index a4bd4ddc28..3ca12b3ced 100644 --- a/res/values/readers.xml +++ b/res/values/readers.xml @@ -20,6 +20,26 @@ Muhammad Jibreel Saood Ash-Shuraym + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + http://www.everyayah.com/data/Abdul_Basit_Murattal_192kbps/ http://www.everyayah.com/data/Abdul_Basit_Mujawwad_128kbps/ diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 32f44f4bf6..31a43558d4 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -164,7 +164,7 @@ private void showDownloadDialog(final AyahItem i) { final View view = li.inflate(R.layout.dialog_download, null); Spinner s = (Spinner) view.findViewById(R.id.spinner); if(s != null) - s.setSelection(getQuranReaderId()); + s.setSelection(getReaderIndex(getQuranReaderId())); dialog.setView(view); //AlertDialog dialog = new DownloadDialog(this); dialog.setMessage("Do you want to download sura"); @@ -178,10 +178,11 @@ public void onClick(DialogInterface dialog, int which) { if(s != null){ if(s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ // reader is not default reader - if(s.getSelectedItemPosition() != i.getQuranReaderId()){ + if(getReaderId() != i.getQuranReaderId()){ + setReaderId(s.getSelectedItemPosition()); lastAyah = QuranAudioLibrary.getAyahItem(getApplicationContext(), i.getSoura(), - i.getAyah(), s.getSelectedItemPosition()); - currentReaderId = s.getSelectedItemPosition(); + i.getAyah(), getReaderId()); + } } } @@ -200,10 +201,10 @@ public void onClick(DialogInterface dialog, int which) { if(s != null){ if(s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ // reader is not default reader - if(s.getSelectedItemPosition() != i.getQuranReaderId()){ + if(getReaderId() != i.getQuranReaderId()){ + setReaderId(getReaderId()); lastAyah = QuranAudioLibrary.getAyahItem(getApplicationContext(), i.getSoura(), - i.getAyah(), s.getSelectedItemPosition()); - currentReaderId = s.getSelectedItemPosition(); + i.getAyah(), getReaderId()); } } } @@ -229,7 +230,7 @@ private void showChangeReaderDialog(){ LayoutInflater li = LayoutInflater.from(this); final View view = li.inflate(R.layout.dialog_download, null); Spinner s = (Spinner)view.findViewById(R.id.spinner); - s.setSelection(getQuranReaderId()); + s.setSelection(getReaderIndex(getQuranReaderId())); dialogBuilder.setView(view); dialogBuilder.setMessage("Change quran reader"); dialogBuilder.setPositiveButton("Change", new DialogInterface.OnClickListener() { @@ -238,9 +239,7 @@ private void showChangeReaderDialog(){ public void onClick(DialogInterface dialog, int which) { Spinner s = (Spinner) view.findViewById(R.id.spinner); if(s != null && s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ - if(currentReaderId != s.getSelectedItemPosition()){ - currentReaderId = s.getSelectedItemPosition(); - } + setReaderId(s.getSelectedItemPosition()); } } }); @@ -342,4 +341,23 @@ private AyahItem getCurrentAudioAyah(){ return QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], getQuranReaderId()); } + private void setReaderId(int readerNamePosition){ + currentReaderId = getResources().getIntArray(R.array.quran_readers_id)[readerNamePosition]; + } + + private int getReaderId(){ + return currentReaderId; + } + + private int getReaderIndex(int readerId){ + int[] ids = + getResources().getIntArray(R.array.quran_readers_id); + for (int i : ids) { + if(ids[i] == readerId){ + return i; + } + } + return 0; + } + } diff --git a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java index 62d180485d..0808e823d8 100644 --- a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java +++ b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java @@ -133,9 +133,18 @@ protected static String fitInt(int x, int digits) { private static String getAudioUrl(Context context, int readerId){ String[] urls = context.getResources().getStringArray(R.array.quran_readers_urls); + int[] ids = + context.getResources().getIntArray(R.array.quran_readers_id); + int index = 0; + for (int i : ids) { + if(ids[i] == readerId){ + index = i; + break; + } + } if(readerId > urls.length) return null; - return urls[readerId]; + return urls[index]; } } From bab891489baf507c6f9e0ab2ea13610e95ff63ac Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 26 Jul 2011 02:07:18 +0200 Subject: [PATCH 0011/1438] Fixes --- src/com/quran/labs/androidquran/common/InternetActivity.java | 2 +- .../quran/labs/androidquran/service/AudioServiceBinder.java | 4 +++- src/com/quran/labs/androidquran/service/QuranDataService.java | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 1255fb12ef..87dce56437 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -159,7 +159,7 @@ private void showProgressDialog(){ pDialog = new ProgressDialog(this); pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pDialog.setTitle(R.string.downloading_title); - pDialog.setCancelable(true); + pDialog.setCancelable(false); pDialog.setButton(ProgressDialog.BUTTON1, "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index 6492580d50..4441e1ed33 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -87,8 +87,10 @@ public void play(AyahItem item) { else if(remotePlayEnabled) { url = item.getRemoteAudioUrl(); }else{ - if(ayahListener != null) + if(ayahListener != null){ + clearNotification(); ayahListener.onAyahNotFound(item); + } else { // show notification ayah not found, download it or play remotely diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 60a0acf1e7..cde18ab451 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -138,8 +138,8 @@ private void downloadSuraAudio(Intent intent) { // get ayah AyahItem ayah = QuranAudioLibrary.getAyahItem( getApplicationContext(), soura, i, quranReader); - String fileName = ayah.getAyah() + QuranAudioLibrary.AUDIO_EXTENSION; - String dir = QuranUtils.getSuraAudioPath(ayah.getQuranReaderId(), ayah.getSoura()); + String fileName = ayah.getLocalAudioUrl().substring(ayah.getLocalAudioUrl().lastIndexOf(File.separator) + 1); + String dir = ayah.getLocalAudioUrl().substring(0, ayah.getLocalAudioUrl().lastIndexOf(File.separator)); File f = new File(dir, fileName); if (f.exists()) continue; From 97757ce2243836a1ca4b85a6f961a1b4f67b2e75 Mon Sep 17 00:00:00 2001 From: fouad Date: Tue, 26 Jul 2011 12:18:07 +0200 Subject: [PATCH 0012/1438] -- audio jump to ayah (not so much testing) --- res/layout/dialog_jump_to_ayah.xml | 20 + .../labs/androidquran/QuranViewActivity.java | 506 +++++++++++------- 2 files changed, 340 insertions(+), 186 deletions(-) create mode 100644 res/layout/dialog_jump_to_ayah.xml diff --git a/res/layout/dialog_jump_to_ayah.xml b/res/layout/dialog_jump_to_ayah.xml new file mode 100644 index 0000000000..04021506a7 --- /dev/null +++ b/res/layout/dialog_jump_to_ayah.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 31a43558d4..064fb8272c 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -1,5 +1,6 @@ package com.quran.labs.androidquran; +import java.util.ArrayList; import java.util.HashMap; import android.app.AlertDialog; @@ -12,8 +13,13 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.SimpleAdapter; import android.widget.Spinner; +import android.widget.TextView; import android.widget.Toast; +import android.widget.AdapterView.OnItemSelectedListener; import com.markupartist.android.widget.ActionBar.IntentAction; import com.quran.labs.androidquran.common.AyahItem; @@ -26,7 +32,8 @@ import com.quran.labs.androidquran.util.QuranAudioLibrary; import com.quran.labs.androidquran.util.QuranUtils; -public class QuranViewActivity extends PageViewQuranActivity implements AyahStateListener { +public class QuranViewActivity extends PageViewQuranActivity implements + AyahStateListener { protected static final String ACTION_PREVIOUS = "ACTION_PREVIOUS"; protected static final String ACTION_NEXT = "ACTION_NEXT"; @@ -34,270 +41,395 @@ public class QuranViewActivity extends PageViewQuranActivity implements AyahStat protected static final String ACTION_PLAY = "ACTION_PLAY"; protected static final String ACTION_STOP = "ACTION_STOP"; protected static final String ACTION_CHANGE_READER = "ACTION_CHANGE_READER"; + protected static final String ACTION_JUMP_TO_AYAH = "ACTION_JUMP_TO_AYAH"; private static final String TAG = "QuranViewActivity"; - + private boolean bounded = false; private AudioServiceBinder quranAudioPlayer = null; - + private static final int ACTION_BAR_ACTION_CHANGE_READER = 0; - private static final int ACTION_BAR_ACTION_PREVIOUS = 1; - private static final int ACTION_BAR_ACTION_PLAY = 2; - private static final int ACTION_BAR_ACTION_PAUSE = 3; - private static final int ACTION_BAR_ACTION_STOP = 4; - private static final int ACTION_BAR_ACTION_NEXT = 5; + private static final int ACTION_BAR_ACTION_JUMP_TO_AYAH = 1; + private static final int ACTION_BAR_ACTION_PREVIOUS = 2; + private static final int ACTION_BAR_ACTION_PLAY = 3; + private static final int ACTION_BAR_ACTION_PAUSE = 4; + private static final int ACTION_BAR_ACTION_STOP = 5; + private static final int ACTION_BAR_ACTION_NEXT = 6; - private AyahItem lastAyah; private int currentReaderId; - + HashMap actionBarActions = new HashMap(); - -// private TextView textView; - - private ServiceConnection conn = new ServiceConnection() { + + // private TextView textView; + + private ServiceConnection conn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { unBindAudioService(); } - + @Override - public void onServiceConnected(ComponentName name, IBinder service) { + public void onServiceConnected(ComponentName name, IBinder service) { quranAudioPlayer = (AudioServiceBinder) service; quranAudioPlayer.setAyahCompleteListener(QuranViewActivity.this); } }; - + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); -// textView = new TextView(this); -// textView.setText(""); + // textView = new TextView(this); + // textView.setText(""); bindAudioService(); } - - protected void addActions(){ + + protected void addActions() { super.addActions(); - if(actionBar != null){ - //actionBar.setTitle("QuranAndroid"); - actionBarActions.put(ACTION_BAR_ACTION_PLAY, - getIntentAction(ACTION_PLAY, android.R.drawable.ic_media_play)); - actionBarActions.put(ACTION_BAR_ACTION_PAUSE, - getIntentAction(ACTION_PAUSE, android.R.drawable.ic_media_pause)); - actionBarActions.put(ACTION_BAR_ACTION_NEXT, - getIntentAction(ACTION_NEXT, android.R.drawable.ic_media_next)); - actionBarActions.put(ACTION_BAR_ACTION_PREVIOUS, - getIntentAction(ACTION_PREVIOUS, android.R.drawable.ic_media_previous)); - actionBarActions.put(ACTION_BAR_ACTION_STOP, - getIntentAction(ACTION_STOP, R.drawable.stop)); + if (actionBar != null) { + // actionBar.setTitle("QuranAndroid"); + actionBarActions.put(ACTION_BAR_ACTION_PLAY, getIntentAction( + ACTION_PLAY, android.R.drawable.ic_media_play)); + actionBarActions.put(ACTION_BAR_ACTION_PAUSE, getIntentAction( + ACTION_PAUSE, android.R.drawable.ic_media_pause)); + actionBarActions.put(ACTION_BAR_ACTION_NEXT, getIntentAction( + ACTION_NEXT, android.R.drawable.ic_media_next)); + actionBarActions.put(ACTION_BAR_ACTION_PREVIOUS, getIntentAction( + ACTION_PREVIOUS, android.R.drawable.ic_media_previous)); + actionBarActions.put(ACTION_BAR_ACTION_STOP, getIntentAction( + ACTION_STOP, R.drawable.stop)); actionBarActions.put(ACTION_BAR_ACTION_CHANGE_READER, getIntentAction(ACTION_CHANGE_READER, R.drawable.mic)); - -// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PREVIOUS), -// ACTION_BAR_ACTION_PREVIOUS); -// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PLAY), -// ACTION_BAR_ACTION_PLAY); -// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PAUSE), -// ACTION_BAR_ACTION_PAUSE); -// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_STOP), -// ACTION_BAR_ACTION_STOP); -// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_NEXT), -// ACTION_BAR_ACTION_NEXT); -// actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_CHANGE_READER), -// ACTION_BAR_ACTION_CHANGE_READER); - + actionBarActions.put(ACTION_BAR_ACTION_JUMP_TO_AYAH, + getIntentAction(ACTION_JUMP_TO_AYAH, R.drawable.jump)); + + // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PREVIOUS), + // ACTION_BAR_ACTION_PREVIOUS); + // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PLAY), + // ACTION_BAR_ACTION_PLAY); + // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PAUSE), + // ACTION_BAR_ACTION_PAUSE); + // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_STOP), + // ACTION_BAR_ACTION_STOP); + // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_NEXT), + // ACTION_BAR_ACTION_NEXT); + // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_CHANGE_READER), + // ACTION_BAR_ACTION_CHANGE_READER); + for (Integer actionId : actionBarActions.keySet()) { - actionBar.addAction(actionBarActions.get(actionId), actionId); + actionBar.addAction(actionBarActions.get(actionId), actionId); } - } + } } - - private IntentAction getIntentAction(String intentAction, int drawable){ - Intent i = new Intent(this, QuranViewActivity.class); - i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); - i.setAction(intentAction); - IntentAction action = new IntentAction(this, i, drawable); - return action; + + private IntentAction getIntentAction(String intentAction, int drawable) { + Intent i = new Intent(this, QuranViewActivity.class); + i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); + i.setAction(intentAction); + IntentAction action = new IntentAction(this, i, drawable); + return action; } - + @Override protected void onNewIntent(Intent intent) { // TODO Auto-generated method stub super.onNewIntent(intent); String action = intent.getAction(); - if(quranAudioPlayer != null && action != null){ - if(action.equalsIgnoreCase(ACTION_PLAY)){ - if(quranAudioPlayer.isPaused()) + if (quranAudioPlayer != null && action != null) { + if (action.equalsIgnoreCase(ACTION_PLAY)) { + if (quranAudioPlayer.isPaused()) quranAudioPlayer.resume(); - else{ + else { lastAyah = getCurrentAudioAyah(); // soura not totall found - if(QuranUtils.isSouraAudioFound(lastAyah.getQuranReaderId(), lastAyah.getSoura()) < 0){ + if (QuranUtils.isSouraAudioFound(lastAyah + .getQuranReaderId(), lastAyah.getSoura()) < 0) { showDownloadDialog(lastAyah); - }else{ + } else { quranAudioPlayer.enableRemotePlay(false); playAudio(lastAyah); } - } - }else if(action.equalsIgnoreCase(ACTION_PAUSE)){ + } + } else if (action.equalsIgnoreCase(ACTION_PAUSE)) { quranAudioPlayer.pause(); - }else if(action.equalsIgnoreCase(ACTION_NEXT)){ - lastAyah = QuranAudioLibrary.getNextAyahAudioItem(this, getCurrentAudioAyah()); - if(quranAudioPlayer != null && quranAudioPlayer.isPlaying()) + } else if (action.equalsIgnoreCase(ACTION_NEXT)) { + lastAyah = QuranAudioLibrary.getNextAyahAudioItem(this, + getCurrentAudioAyah()); + if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) quranAudioPlayer.play(lastAyah); - }else if (action.equalsIgnoreCase(ACTION_PREVIOUS)){ - lastAyah = QuranAudioLibrary.getPreviousAyahAudioItem(this, getCurrentAudioAyah()); - if(quranAudioPlayer != null && quranAudioPlayer.isPlaying()) + } else if (action.equalsIgnoreCase(ACTION_PREVIOUS)) { + lastAyah = QuranAudioLibrary.getPreviousAyahAudioItem(this, + getCurrentAudioAyah()); + if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) quranAudioPlayer.play(lastAyah); - }else if (action.equalsIgnoreCase(ACTION_STOP)){ + } else if (action.equalsIgnoreCase(ACTION_STOP)) { lastAyah = null; quranAudioPlayer.stop(); - }else if(action.equalsIgnoreCase(ACTION_CHANGE_READER)) + } else if (action.equalsIgnoreCase(ACTION_CHANGE_READER)){ showChangeReaderDialog(); + } + else if (action.equalsIgnoreCase(ACTION_JUMP_TO_AYAH)) { + showJumpToAyahDialog(); + } } } - + private void showDownloadDialog(final AyahItem i) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); LayoutInflater li = LayoutInflater.from(this); - final View view = li.inflate(R.layout.dialog_download, null); - Spinner s = (Spinner) view.findViewById(R.id.spinner); - if(s != null) - s.setSelection(getReaderIndex(getQuranReaderId())); - dialog.setView(view); - //AlertDialog dialog = new DownloadDialog(this); + final View view = li.inflate(R.layout.dialog_download, null); + Spinner s = (Spinner) view.findViewById(R.id.spinner); + if (s != null) + s.setSelection(getReaderIndex(getQuranReaderId())); + dialog.setView(view); + // AlertDialog dialog = new DownloadDialog(this); dialog.setMessage("Do you want to download sura"); - dialog.setPositiveButton("download", new DialogInterface.OnClickListener() { + dialog.setPositiveButton("download", + new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // get reader id - Spinner s = (Spinner) view.findViewById(R.id.spinner); - lastAyah = i; - if(s != null){ - if(s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ - // reader is not default reader - if(getReaderId() != i.getQuranReaderId()){ - setReaderId(s.getSelectedItemPosition()); - lastAyah = QuranAudioLibrary.getAyahItem(getApplicationContext(), i.getSoura(), - i.getAyah(), getReaderId()); - + @Override + public void onClick(DialogInterface dialog, int which) { + // get reader id + Spinner s = (Spinner) view.findViewById(R.id.spinner); + lastAyah = i; + if (s != null) { + if (s.getSelectedItemPosition() != Spinner.INVALID_POSITION) { + setReaderId(s.getSelectedItemPosition()); + // reader is not default reader + if (getReaderId() != i.getQuranReaderId()) { + lastAyah = QuranAudioLibrary.getAyahItem( + getApplicationContext(), i + .getSoura(), i.getAyah(), + getReaderId()); + } + } } + downloadSura(lastAyah.getQuranReaderId(), lastAyah + .getSoura(), lastAyah.getAyah()); + dialog.dismiss(); } - } - downloadSura(lastAyah.getQuranReaderId(), lastAyah.getSoura(), lastAyah.getAyah()); - dialog.dismiss(); - } - }); - dialog.setNeutralButton("Stream", new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - // get reader id - quranAudioPlayer.enableRemotePlay(true); - Spinner s = (Spinner) view.findViewById(R.id.spinner); - lastAyah = i; - if(s != null){ - if(s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ - // reader is not default reader - if(getReaderId() != i.getQuranReaderId()){ - setReaderId(getReaderId()); - lastAyah = QuranAudioLibrary.getAyahItem(getApplicationContext(), i.getSoura(), - i.getAyah(), getReaderId()); + }); + dialog.setNeutralButton("Stream", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + // get reader id + quranAudioPlayer.enableRemotePlay(true); + Spinner s = (Spinner) view.findViewById(R.id.spinner); + lastAyah = i; + if (s != null) { + if (s.getSelectedItemPosition() != Spinner.INVALID_POSITION) { + // reader is not default reader + if (getReaderId() != i.getQuranReaderId()) { + setReaderId(getReaderId()); + lastAyah = QuranAudioLibrary.getAyahItem( + getApplicationContext(), i + .getSoura(), i.getAyah(), + getReaderId()); + } + } } + quranAudioPlayer.play(lastAyah); + dialog.dismiss(); } - } - quranAudioPlayer.play(lastAyah); - dialog.dismiss(); - } - }); - - dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - + }); + + dialog.setNegativeButton("Cancel", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + AlertDialog diag = dialog.create(); diag.show(); } - private void showChangeReaderDialog(){ + private void showJumpToAyahDialog() { + final Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder + .getCurrentPagePosition()); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); LayoutInflater li = LayoutInflater.from(this); - final View view = li.inflate(R.layout.dialog_download, null); - Spinner s = (Spinner)view.findViewById(R.id.spinner); - s.setSelection(getReaderIndex(getQuranReaderId())); - dialogBuilder.setView(view); - dialogBuilder.setMessage("Change quran reader"); - dialogBuilder.setPositiveButton("Change", new DialogInterface.OnClickListener() { - + final View view = li.inflate(R.layout.dialog_jump_to_ayah, null); + + final Spinner ayatSpinner = (Spinner) view.findViewById(R.id.spinner_ayat); + int startAyah = pageBounds[1]; + int endAyah = pageBounds[0] == pageBounds[2]? pageBounds[3] : QuranInfo.SURA_NUM_AYAHS[pageBounds[0] - 1]; + initAyatSpinner(ayatSpinner, startAyah, endAyah); + + final Spinner surasSpinner = (Spinner) view.findViewById(R.id.spinner_suras); + initSurasSpinner(surasSpinner, pageBounds[0], pageBounds[2]); + surasSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { + + @SuppressWarnings("unchecked") @Override - public void onClick(DialogInterface dialog, int which) { - Spinner s = (Spinner) view.findViewById(R.id.spinner); - if(s != null && s.getSelectedItemPosition() != Spinner.INVALID_POSITION){ - setReaderId(s.getSelectedItemPosition()); - } + public void onItemSelected(AdapterView adapter, View view, + int position, long id) { + HashMapmap = (HashMap) adapter.getItemAtPosition(position); + int suraIndex = Integer.parseInt(map.get("suraId")); + int startAyah = suraIndex == pageBounds[0] ? pageBounds[1] : 1; + int endAyah = suraIndex == pageBounds[2]? pageBounds[3] : QuranInfo.SURA_NUM_AYAHS[suraIndex - 1]; + initAyatSpinner(ayatSpinner, startAyah, endAyah); } - }); + + @Override + public void onNothingSelected(AdapterView arg0) { + // TODO Auto-generated method stub + + } + }); + + dialogBuilder.setView(view); + dialogBuilder.setMessage("Jumo to ayah"); + dialogBuilder.setPositiveButton("Jump", + new DialogInterface.OnClickListener() { + + @SuppressWarnings("unchecked") + @Override + public void onClick(DialogInterface dialog, int which) { + // get sura + HashMap suraData = + (HashMap) surasSpinner.getSelectedItem(); + int sura = Integer.parseInt(suraData.get("suraId")); + Log.d("Ayah", "Spinner ayay values " + ayatSpinner.getSelectedItem().toString()); + Integer ayah = (Integer) ayatSpinner.getSelectedItem(); + lastAyah = QuranAudioLibrary.getAyahItem(getApplicationContext(), + sura, ayah, getQuranReaderId()); + if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()){ + quranAudioPlayer.stop(); + quranAudioPlayer.play(lastAyah); + } + + } + }); dialogBuilder.setNegativeButton("Cancel", null); dialogBuilder.show(); + + } + + + private void initSurasSpinner(final Spinner spinner, int startSura, int endSura){ + String[] from = new String[] {"suraName"}; + int[] to = new int[] {android.R.id.text1 }; + + ArrayList> data = new ArrayList>(); + for (int i = startSura; i <= endSura; i++) { + HashMap hash = new HashMap(); + hash.put("suraName", QuranInfo.getSuraName(i-1)); + hash.put("suraId", ""+i); + data.add(hash); + } + SimpleAdapter sa = new SimpleAdapter(this, data, + android.R.layout.simple_spinner_item, from, to); + sa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + SimpleAdapter.ViewBinder viewBinder = new SimpleAdapter.ViewBinder() { + + public boolean setViewValue(View view, Object data, + String textRepresentation) { + TextView textView = (TextView) view; + textView.setText(textRepresentation); + return true; + } + }; + sa.setViewBinder(viewBinder); + spinner.setAdapter(sa); + } - protected void initQuranPageFeeder(){ + private void initAyatSpinner(final Spinner spinner, int startAyah, int endAyah){ + ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item); + for(int i = startAyah; i <= endAyah; i++) + adapter.add(i); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spinner.setAdapter(adapter); + } + + private void showChangeReaderDialog() { + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); + LayoutInflater li = LayoutInflater.from(this); + final View view = li.inflate(R.layout.dialog_download, null); + Spinner s = (Spinner) view.findViewById(R.id.spinner); + s.setSelection(getReaderIndex(getQuranReaderId())); + dialogBuilder.setView(view); + dialogBuilder.setMessage("Change quran reader"); + dialogBuilder.setPositiveButton("Change", + new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + Spinner s = (Spinner) view.findViewById(R.id.spinner); + if (s != null + && s.getSelectedItemPosition() != Spinner.INVALID_POSITION) { + setReaderId(s.getSelectedItemPosition()); + } + } + }); + dialogBuilder.setNegativeButton("Cancel", null); + dialogBuilder.show(); + } + + protected void initQuranPageFeeder() { if (quranPageFeeder == null) { Log.d(TAG, "Quran Feeder instantiated..."); - quranPageFeeder = new QuranPageFeeder(this, quranPageCurler, R.layout.quran_page_layout); + quranPageFeeder = new QuranPageFeeder(this, quranPageCurler, + R.layout.quran_page_layout); } else { quranPageFeeder.setContext(this, quranPageCurler); } } - - private void unBindAudioService(){ + + private void unBindAudioService() { if (bounded) { - // Detach our existing connection. - unbindService(conn); - if(quranAudioPlayer != null) - quranAudioPlayer.setAyahCompleteListener(null); - bounded = false; - } + // Detach our existing connection. + unbindService(conn); + if (quranAudioPlayer != null) + quranAudioPlayer.setAyahCompleteListener(null); + bounded = false; + } } - - private void bindAudioService(){ - if (!bounded){ - Intent serviceIntent = new Intent(getApplicationContext(), QuranAudioService.class); + + private void bindAudioService() { + if (!bounded) { + Intent serviceIntent = new Intent(getApplicationContext(), + QuranAudioService.class); startService(serviceIntent); bounded = bindService(serviceIntent, conn, BIND_AUTO_CREATE); - if(!bounded) - Toast.makeText(this, "can not bind service", Toast.LENGTH_SHORT); + if (!bounded) + Toast + .makeText(this, "can not bind service", + Toast.LENGTH_SHORT); } } - private void playAudio(AyahItem ayah){ - if(quranAudioPlayer != null){ + private void playAudio(AyahItem ayah) { + if (quranAudioPlayer != null) { if (ayah == null) { - Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder.getCurrentPagePosition()); - ayah = QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], getQuranReaderId()); + Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder + .getCurrentPagePosition()); + ayah = QuranAudioLibrary.getAyahItem(getApplicationContext(), + pageBounds[0], pageBounds[1], getQuranReaderId()); } quranAudioPlayer.play(ayah); } } - + @Override public void onAyahComplete(AyahItem ayah, AyahItem nextAyah) { lastAyah = ayah; - if(nextAyah.getQuranReaderId() != getQuranReaderId() && - quranAudioPlayer != null && quranAudioPlayer.isPlaying()){ + if (nextAyah.getQuranReaderId() != getQuranReaderId() + && quranAudioPlayer != null && quranAudioPlayer.isPlaying()) { quranAudioPlayer.stop(); - lastAyah = QuranAudioLibrary.getAyahItem(this, nextAyah.getSoura(), nextAyah.getAyah(), - getQuranReaderId()); + lastAyah = QuranAudioLibrary.getAyahItem(this, nextAyah.getSoura(), + nextAyah.getAyah(), getQuranReaderId()); quranAudioPlayer.play(lastAyah); } - int page = QuranInfo.getPageFromSuraAyah(nextAyah.getSoura(), nextAyah.getAyah()); + int page = QuranInfo.getPageFromSuraAyah(nextAyah.getSoura(), nextAyah + .getAyah()); quranPageFeeder.jumpToPage(page); } @@ -310,13 +442,13 @@ public void onAyahNotFound(AyahItem ayah) { @Override protected void loadLastNonConfigurationInstance() { super.loadLastNonConfigurationInstance(); - Object [] saved = (Object []) getLastNonConfigurationInstance(); + Object[] saved = (Object[]) getLastNonConfigurationInstance(); if (saved != null) { Log.d("exp_v", "Adapter retrieved.."); quranPageFeeder = (QuranPageFeeder) saved[0]; } } - + @Override protected void onFinishDownload() { super.onFinishDownload(); @@ -325,39 +457,41 @@ protected void onFinishDownload() { playAudio(lastAyah); } } - + // temp method to select default reader id - // we should put it in another place + we should read reader from preferences + // we should put it in another place + we should read reader from + // preferences private int getQuranReaderId() { // TODO Auto-generated method stub return currentReaderId; } - private AyahItem getCurrentAudioAyah(){ - if(lastAyah != null){ + private AyahItem getCurrentAudioAyah() { + if (lastAyah != null) { return lastAyah; } - Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder.getCurrentPagePosition()); - return QuranAudioLibrary.getAyahItem(getApplicationContext(), pageBounds[0], pageBounds[1], getQuranReaderId()); + Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder + .getCurrentPagePosition()); + return QuranAudioLibrary.getAyahItem(getApplicationContext(), + pageBounds[0], pageBounds[1], getQuranReaderId()); } - - private void setReaderId(int readerNamePosition){ + + private void setReaderId(int readerNamePosition) { currentReaderId = getResources().getIntArray(R.array.quran_readers_id)[readerNamePosition]; } - - private int getReaderId(){ + + private int getReaderId() { return currentReaderId; } - - private int getReaderIndex(int readerId){ - int[] ids = - getResources().getIntArray(R.array.quran_readers_id); + + private int getReaderIndex(int readerId) { + int[] ids = getResources().getIntArray(R.array.quran_readers_id); for (int i : ids) { - if(ids[i] == readerId){ + if (ids[i] == readerId) { return i; } } return 0; } - + } From 67a2c2af6d427502ed58027d6b8ca9a831acafb7 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 26 Jul 2011 15:16:05 +0200 Subject: [PATCH 0013/1438] Adjust action bar for playing - Display juz in page title --- res/values-ar/readers.xml | 1 - res/values/readers.xml | 3 - .../labs/androidquran/QuranViewActivity.java | 99 ++++++++++--------- .../data/ApplicationConstants.java | 1 + .../labs/androidquran/data/QuranInfo.java | 7 +- .../labs/androidquran/util/QuranSettings.java | 11 +++ 6 files changed, 73 insertions(+), 49 deletions(-) diff --git a/res/values-ar/readers.xml b/res/values-ar/readers.xml index a303de3e86..2f3740793b 100644 --- a/res/values-ar/readers.xml +++ b/res/values-ar/readers.xml @@ -11,7 +11,6 @@ الحصري الحصري مجود الحذيفي - إبراهيم اﻷخضر ماهر المعيلقي المنشاوي المنشاوي مجود diff --git a/res/values/readers.xml b/res/values/readers.xml index 3ca12b3ced..db0b2c836f 100644 --- a/res/values/readers.xml +++ b/res/values/readers.xml @@ -11,7 +11,6 @@ Husary Husary Mujawwad Hudhaify - Ibrahim Akhdar Maher Al Muaiqly Minshawy Minshawy Mujawwad @@ -31,7 +30,6 @@ 7 8 9 - 10 11 12 13 @@ -51,7 +49,6 @@ http://www.everyayah.com/data/Husary_64kbps/ http://www.everyayah.com/data/Husary_128kbps_Mujawwad/ http://www.everyayah.com/data/Hudhaify_128kbps/ - http://www.everyayah.com/data/Ibrahim_Akhdar_64kbps/ http://www.everyayah.com/data/Maher_AlMuaiqly_64kbps/ http://www.everyayah.com/data/Minshawy_Murattal_128kbps/ http://www.everyayah.com/data/Minshawy_Mujawwad_192kbps/ diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 064fb8272c..e65267273e 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -30,6 +30,7 @@ import com.quran.labs.androidquran.service.AudioServiceBinder; import com.quran.labs.androidquran.service.QuranAudioService; import com.quran.labs.androidquran.util.QuranAudioLibrary; +import com.quran.labs.androidquran.util.QuranSettings; import com.quran.labs.androidquran.util.QuranUtils; public class QuranViewActivity extends PageViewQuranActivity implements @@ -47,19 +48,23 @@ public class QuranViewActivity extends PageViewQuranActivity implements private boolean bounded = false; private AudioServiceBinder quranAudioPlayer = null; + + // on Stop Actions + private static final int ACTION_BAR_ACTION_PLAY = 0; + // on Play Actions private static final int ACTION_BAR_ACTION_CHANGE_READER = 0; private static final int ACTION_BAR_ACTION_JUMP_TO_AYAH = 1; private static final int ACTION_BAR_ACTION_PREVIOUS = 2; - private static final int ACTION_BAR_ACTION_PLAY = 3; - private static final int ACTION_BAR_ACTION_PAUSE = 4; - private static final int ACTION_BAR_ACTION_STOP = 5; - private static final int ACTION_BAR_ACTION_NEXT = 6; + private static final int ACTION_BAR_ACTION_PAUSE = 3; + private static final int ACTION_BAR_ACTION_STOP = 4; + private static final int ACTION_BAR_ACTION_NEXT = 5; private AyahItem lastAyah; private int currentReaderId; - HashMap actionBarActions = new HashMap(); + private HashMap actionBarActions = new HashMap(); + private HashMap actionBarIndecies = new HashMap(); // private TextView textView; @@ -73,6 +78,9 @@ public void onServiceDisconnected(ComponentName name) { public void onServiceConnected(ComponentName name, IBinder service) { quranAudioPlayer = (AudioServiceBinder) service; quranAudioPlayer.setAyahCompleteListener(QuranViewActivity.this); + if (quranAudioPlayer.isPlaying()) { + onActionPlay(); + } } }; @@ -88,37 +96,30 @@ protected void addActions() { super.addActions(); if (actionBar != null) { // actionBar.setTitle("QuranAndroid"); - actionBarActions.put(ACTION_BAR_ACTION_PLAY, getIntentAction( + actionBarActions.put(ACTION_PLAY, getIntentAction( ACTION_PLAY, android.R.drawable.ic_media_play)); - actionBarActions.put(ACTION_BAR_ACTION_PAUSE, getIntentAction( + actionBarActions.put(ACTION_PAUSE, getIntentAction( ACTION_PAUSE, android.R.drawable.ic_media_pause)); - actionBarActions.put(ACTION_BAR_ACTION_NEXT, getIntentAction( + actionBarActions.put(ACTION_NEXT, getIntentAction( ACTION_NEXT, android.R.drawable.ic_media_next)); - actionBarActions.put(ACTION_BAR_ACTION_PREVIOUS, getIntentAction( + actionBarActions.put(ACTION_PREVIOUS, getIntentAction( ACTION_PREVIOUS, android.R.drawable.ic_media_previous)); - actionBarActions.put(ACTION_BAR_ACTION_STOP, getIntentAction( + actionBarActions.put(ACTION_STOP, getIntentAction( ACTION_STOP, R.drawable.stop)); - actionBarActions.put(ACTION_BAR_ACTION_CHANGE_READER, + actionBarActions.put(ACTION_CHANGE_READER, getIntentAction(ACTION_CHANGE_READER, R.drawable.mic)); - actionBarActions.put(ACTION_BAR_ACTION_JUMP_TO_AYAH, + actionBarActions.put(ACTION_JUMP_TO_AYAH, getIntentAction(ACTION_JUMP_TO_AYAH, R.drawable.jump)); - - // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PREVIOUS), - // ACTION_BAR_ACTION_PREVIOUS); - // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PLAY), - // ACTION_BAR_ACTION_PLAY); - // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_PAUSE), - // ACTION_BAR_ACTION_PAUSE); - // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_STOP), - // ACTION_BAR_ACTION_STOP); - // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_NEXT), - // ACTION_BAR_ACTION_NEXT); - // actionBar.addAction(actionBarActions.get(ACTION_BAR_ACTION_CHANGE_READER), - // ACTION_BAR_ACTION_CHANGE_READER); - - for (Integer actionId : actionBarActions.keySet()) { - actionBar.addAction(actionBarActions.get(actionId), actionId); - } + + actionBarIndecies.put(ACTION_PLAY, ACTION_BAR_ACTION_PLAY); + actionBarIndecies.put(ACTION_PAUSE, ACTION_BAR_ACTION_PAUSE); + actionBarIndecies.put(ACTION_NEXT, ACTION_BAR_ACTION_NEXT); + actionBarIndecies.put(ACTION_PREVIOUS, ACTION_BAR_ACTION_PREVIOUS); + actionBarIndecies.put(ACTION_STOP, ACTION_BAR_ACTION_STOP); + actionBarIndecies.put(ACTION_CHANGE_READER, ACTION_BAR_ACTION_CHANGE_READER); + actionBarIndecies.put(ACTION_JUMP_TO_AYAH, ACTION_BAR_ACTION_JUMP_TO_AYAH); + + onActionStop(); } } @@ -150,8 +151,10 @@ protected void onNewIntent(Intent intent) { playAudio(lastAyah); } } + onActionPlay(); } else if (action.equalsIgnoreCase(ACTION_PAUSE)) { quranAudioPlayer.pause(); + onActionStop(); } else if (action.equalsIgnoreCase(ACTION_NEXT)) { lastAyah = QuranAudioLibrary.getNextAyahAudioItem(this, getCurrentAudioAyah()); @@ -165,6 +168,7 @@ protected void onNewIntent(Intent intent) { } else if (action.equalsIgnoreCase(ACTION_STOP)) { lastAyah = null; quranAudioPlayer.stop(); + onActionStop(); } else if (action.equalsIgnoreCase(ACTION_CHANGE_READER)){ showChangeReaderDialog(); } @@ -174,6 +178,20 @@ else if (action.equalsIgnoreCase(ACTION_JUMP_TO_AYAH)) { } } + private void onActionPlay() { + actionBar.removeAllActions(); + for (String action : actionBarIndecies.keySet()) { + if (ACTION_PLAY.equals(action)) + continue; + actionBar.addAction(actionBarActions.get(action), actionBarIndecies.get(ACTION_PLAY)); + } + } + + private void onActionStop() { + actionBar.removeAllActions(); + actionBar.addAction(actionBarActions.get(ACTION_PLAY), actionBarIndecies.get(ACTION_PLAY)); + } + private void showDownloadDialog(final AyahItem i) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); @@ -185,7 +203,7 @@ private void showDownloadDialog(final AyahItem i) { dialog.setView(view); // AlertDialog dialog = new DownloadDialog(this); dialog.setMessage("Do you want to download sura"); - dialog.setPositiveButton("download", + dialog.setPositiveButton("Download", new DialogInterface.OnClickListener() { @Override @@ -197,11 +215,11 @@ public void onClick(DialogInterface dialog, int which) { if (s.getSelectedItemPosition() != Spinner.INVALID_POSITION) { setReaderId(s.getSelectedItemPosition()); // reader is not default reader - if (getReaderId() != i.getQuranReaderId()) { + if (getQuranReaderId() != i.getQuranReaderId()) { lastAyah = QuranAudioLibrary.getAyahItem( getApplicationContext(), i .getSoura(), i.getAyah(), - getReaderId()); + getQuranReaderId()); } } } @@ -222,12 +240,12 @@ public void onClick(DialogInterface dialog, int which) { if (s != null) { if (s.getSelectedItemPosition() != Spinner.INVALID_POSITION) { // reader is not default reader - if (getReaderId() != i.getQuranReaderId()) { - setReaderId(getReaderId()); + if (getQuranReaderId() != i.getQuranReaderId()) { + setReaderId(getQuranReaderId()); lastAyah = QuranAudioLibrary.getAyahItem( getApplicationContext(), i .getSoura(), i.getAyah(), - getReaderId()); + getQuranReaderId()); } } } @@ -458,12 +476,8 @@ protected void onFinishDownload() { } } - // temp method to select default reader id - // we should put it in another place + we should read reader from - // preferences private int getQuranReaderId() { - // TODO Auto-generated method stub - return currentReaderId; + return QuranSettings.getInstance().getLastReader(); } private AyahItem getCurrentAudioAyah() { @@ -478,10 +492,7 @@ private AyahItem getCurrentAudioAyah() { private void setReaderId(int readerNamePosition) { currentReaderId = getResources().getIntArray(R.array.quran_readers_id)[readerNamePosition]; - } - - private int getReaderId() { - return currentReaderId; + QuranSettings.getInstance().setLastReader(currentReaderId); } private int getReaderIndex(int readerId) { diff --git a/src/com/quran/labs/androidquran/data/ApplicationConstants.java b/src/com/quran/labs/androidquran/data/ApplicationConstants.java index 4aaba7dd00..a6c9180d95 100644 --- a/src/com/quran/labs/androidquran/data/ApplicationConstants.java +++ b/src/com/quran/labs/androidquran/data/ApplicationConstants.java @@ -46,6 +46,7 @@ public class ApplicationConstants { public static final String PREF_TRANSLATION_TEXT_SIZE = "translationTextSize"; public static final String PREF_ACTIVE_TRANSLATION = "activeTranslation"; public static final String PREF_RESHAPE_ARABIC = "reshapeArabic"; + public static final String PREF_LAST_READER = "lastReader"; // Notifications public static final int NOTIFICATION_DOWNLOAD_COMPLETED = 1; diff --git a/src/com/quran/labs/androidquran/data/QuranInfo.java b/src/com/quran/labs/androidquran/data/QuranInfo.java index 60f962ebe6..8be238f7d5 100644 --- a/src/com/quran/labs/androidquran/data/QuranInfo.java +++ b/src/com/quran/labs/androidquran/data/QuranInfo.java @@ -259,6 +259,11 @@ public static int getPageFromJuz(int juz){ return QuranInfo.JUZ_PAGE_START[juz-1]; } + public static int getJuzFromPage(int page) { + int juz = ((page -2) / 20) + 1; + return juz > 30 ? 30 : juz < 1 ? 1 : juz; + } + public static int getPageFromSuraAyah(int sura, int ayah){ // basic bounds checking if (ayah == 0) ayah = 1; @@ -297,6 +302,6 @@ public static String getPageTitleNoPrefix(int page) { public static String getPageTitle(int page) { return getPageTitle() + page + - " - " + getSuraTitle() + " " + getSuraNameFromPage(page); + " - " + getSuraTitle() + " " + getSuraNameFromPage(page) + "\n" + getJuzTitle() + " " + getJuzFromPage(page); } } diff --git a/src/com/quran/labs/androidquran/util/QuranSettings.java b/src/com/quran/labs/androidquran/util/QuranSettings.java index fbec504ea1..40e68d7f43 100644 --- a/src/com/quran/labs/androidquran/util/QuranSettings.java +++ b/src/com/quran/labs/androidquran/util/QuranSettings.java @@ -19,11 +19,20 @@ public class QuranSettings { private int lastPage = 0; private String activeTranslation = null; private boolean reshapeArabic = false; + private int lastReader = 0; private QuranSettings() { } + public int getLastReader() { + return lastReader; + } + + public void setLastReader(int lastReader) { + this.lastReader = lastReader; + } + public Integer getLastPage() { return lastPage; } @@ -115,6 +124,7 @@ public static void load(SharedPreferences preferences) { instance.lastPage = preferences.getInt(ApplicationConstants.PREF_LAST_PAGE, ApplicationConstants.NO_PAGE_SAVED); instance.activeTranslation = preferences.getString(ApplicationConstants.PREF_ACTIVE_TRANSLATION, null); instance.reshapeArabic = preferences.getBoolean(ApplicationConstants.PREF_RESHAPE_ARABIC, false); + instance.lastReader = preferences.getInt(ApplicationConstants.PREF_LAST_READER, 0); } public static void save(SharedPreferences preferences) { @@ -129,6 +139,7 @@ public static void save(SharedPreferences preferences) { editor.putInt(ApplicationConstants.PREF_LAST_PAGE, instance.lastPage); editor.putString(ApplicationConstants.PREF_ACTIVE_TRANSLATION, instance.activeTranslation); editor.putBoolean(ApplicationConstants.PREF_RESHAPE_ARABIC, instance.reshapeArabic); + editor.putInt(ApplicationConstants.PREF_LAST_READER, instance.lastReader); editor.commit(); } } From b4c8054af5d92ab615f29fcbec6a6b8fe13ca3b2 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 26 Jul 2011 16:52:15 +0200 Subject: [PATCH 0014/1438] Pause on outgoing call - Resume after call end --- .../androidquran/receivers/CallStateListener.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/receivers/CallStateListener.java b/src/com/quran/labs/androidquran/receivers/CallStateListener.java index bf420a661d..140658d977 100644 --- a/src/com/quran/labs/androidquran/receivers/CallStateListener.java +++ b/src/com/quran/labs/androidquran/receivers/CallStateListener.java @@ -12,6 +12,7 @@ public class CallStateListener extends PhoneStateListener { private int currentCallState = TelephonyManager.CALL_STATE_IDLE; private int prevCallState = TelephonyManager.CALL_STATE_IDLE; private IAudioPlayer audioService; + private boolean wasPaused = false; public CallStateListener(IAudioPlayer mediaPlayerService ) { this.audioService = mediaPlayerService; @@ -22,10 +23,18 @@ public void onCallStateChanged(int state, String incomingNumber) { prevCallState = currentCallState; currentCallState = state; switch (state) { + case TelephonyManager.CALL_STATE_OFFHOOK: case TelephonyManager.CALL_STATE_RINGING: - if(audioService != null) + if(audioService != null) { audioService.pause(); + wasPaused = true; + } break; + case TelephonyManager.CALL_STATE_IDLE: + if (wasPaused && audioService != null) { + audioService.resume(); + } + wasPaused = false; default: break; } From 0089e8ba2638db0c452517937e0d29220b128160 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 26 Jul 2011 17:02:55 +0200 Subject: [PATCH 0015/1438] Add action bar to index page --- res/layout/quran_list.xml | 16 ++++---- .../labs/androidquran/QuranActivity.java | 38 ++++++++++++++++++- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/res/layout/quran_list.xml b/res/layout/quran_list.xml index 685f324aba..98684a5424 100644 --- a/res/layout/quran_list.xml +++ b/res/layout/quran_list.xml @@ -1,7 +1,9 @@ - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/src/com/quran/labs/androidquran/QuranActivity.java b/src/com/quran/labs/androidquran/QuranActivity.java index 79e537a65a..9d022de287 100644 --- a/src/com/quran/labs/androidquran/QuranActivity.java +++ b/src/com/quran/labs/androidquran/QuranActivity.java @@ -7,6 +7,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.Window; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.BaseAdapter; @@ -15,6 +16,8 @@ import android.widget.TextView; import android.widget.AdapterView.OnItemClickListener; +import com.markupartist.android.widget.ActionBar; +import com.markupartist.android.widget.ActionBar.IntentAction; import com.quran.labs.androidquran.common.BaseQuranActivity; import com.quran.labs.androidquran.data.ApplicationConstants; import com.quran.labs.androidquran.data.QuranInfo; @@ -24,19 +27,52 @@ import com.quran.labs.androidquran.util.QuranSettings; public class QuranActivity extends BaseQuranActivity { + + private ActionBar actionBar; + private static final String ACTION_BOOKMARK = "BOOKMARK"; + private static final String ACTION_RESUME = "RESUME"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.quran_list); QuranSettings.load(prefs); + // set the asset manager to define the Arabic font ArabicStyle.setAssetManager(getAssets()); Intent i = new Intent(this, QuranDataActivity.class); - this.startActivityForResult(i, ApplicationConstants.DATA_CHECK_CODE); + startActivityForResult(i, ApplicationConstants.DATA_CHECK_CODE); + + actionBar = (ActionBar) findViewById(R.id.actionbar); + addActions(); } + protected void addActions() { + actionBar.addAction(getIntentAction(ACTION_RESUME, R.drawable.translation)); + actionBar.addAction(getIntentAction(ACTION_BOOKMARK, R.drawable.bookmarks)); + } + + protected void onNewIntent(Intent intent) { + String action = intent.getAction(); + if (ACTION_BOOKMARK.equals(action)) { + Intent i = new Intent(getApplicationContext(), BookmarksActivity.class); + startActivityForResult(i, ApplicationConstants.BOOKMARKS_CODE); + } else if (ACTION_RESUME.equals(action)) { + jumpTo(QuranSettings.getInstance().getLastPage()); + } + } + + private IntentAction getIntentAction(String intentAction, int drawable) { + Intent i = new Intent(this, QuranActivity.class); + i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); + i.setAction(intentAction); + IntentAction action = new IntentAction(this, i, drawable); + return action; + } + public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (QuranScreenInfo.getInstance() == null) From fdc34ac14f5c0e0d8f6a1d307970495d8d2f1299 Mon Sep 17 00:00:00 2001 From: fouad Date: Tue, 26 Jul 2011 20:04:57 +0200 Subject: [PATCH 0016/1438] play async --- .../androidquran/service/AudioServiceBinder.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index 4441e1ed33..43ac1a0ee3 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -98,12 +98,14 @@ else if(remotePlayEnabled) { } if(url != null){ mp.setDataSource(url); - mp.prepare(); - mp.start(); - paused = false; - stopped = false; - if(!notified) - showNotification(item); + mp.setOnPreparedListener(this); + mp.prepareAsync(); +// mp.prepare(); +// mp.start(); +// paused = false; +// stopped = false; +// if(!notified) +// showNotification(item); } } catch (IllegalArgumentException e) { From d581a557d9d174369650ac7df6f68b95d179d94e Mon Sep 17 00:00:00 2001 From: fouad Date: Tue, 26 Jul 2011 21:18:06 +0200 Subject: [PATCH 0017/1438] fixing ids --- src/com/quran/labs/androidquran/QuranViewActivity.java | 2 +- src/com/quran/labs/androidquran/util/QuranAudioLibrary.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index e65267273e..18974f9aee 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -497,7 +497,7 @@ private void setReaderId(int readerNamePosition) { private int getReaderIndex(int readerId) { int[] ids = getResources().getIntArray(R.array.quran_readers_id); - for (int i : ids) { + for (int i=0 ; i Date: Wed, 27 Jul 2011 01:29:03 +0200 Subject: [PATCH 0018/1438] -- add ability to jump to any audio ayah --- res/layout/dialog_jump_to_ayah.xml | 7 +++++++ res/values/strings.xml | 2 ++ .../labs/androidquran/QuranViewActivity.java | 18 +++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/res/layout/dialog_jump_to_ayah.xml b/res/layout/dialog_jump_to_ayah.xml index 04021506a7..e5051fad8d 100644 --- a/res/layout/dialog_jump_to_ayah.xml +++ b/res/layout/dialog_jump_to_ayah.xml @@ -9,12 +9,19 @@ android:id="@+id/spinner_suras" android:layout_width="fill_parent" android:layout_height="wrap_content" + android:prompt="@string/prompt_select_sura" android:drawSelectorOnTop="true"> + diff --git a/res/values/strings.xml b/res/values/strings.xml index cf53c876a1..bd4a692be0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -115,4 +115,6 @@ Download Remove Set Active + Select Ayah + Select Sura diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 18974f9aee..cc18ae0fa3 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -15,11 +15,14 @@ import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.SimpleAdapter; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.CompoundButton.OnCheckedChangeListener; import com.markupartist.android.widget.ActionBar.IntentAction; import com.quran.labs.androidquran.common.AyahItem; @@ -275,6 +278,7 @@ private void showJumpToAyahDialog() { final View view = li.inflate(R.layout.dialog_jump_to_ayah, null); final Spinner ayatSpinner = (Spinner) view.findViewById(R.id.spinner_ayat); + final CheckBox checkbox = (CheckBox) view.findViewById(R.id.checkbox_whole_quran); int startAyah = pageBounds[1]; int endAyah = pageBounds[0] == pageBounds[2]? pageBounds[3] : QuranInfo.SURA_NUM_AYAHS[pageBounds[0] - 1]; initAyatSpinner(ayatSpinner, startAyah, endAyah); @@ -300,7 +304,19 @@ public void onNothingSelected(AdapterView arg0) { } }); - + + checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if(isChecked){ + initSurasSpinner(surasSpinner, 1, 114); + surasSpinner.setSelection(pageBounds[0] - 1); + } + else + initSurasSpinner(surasSpinner, pageBounds[0], pageBounds[2]); + } + }); dialogBuilder.setView(view); dialogBuilder.setMessage("Jumo to ayah"); dialogBuilder.setPositiveButton("Jump", From d7a33b4f3ebc8f7dac0ac9da965ddce85be67523 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Wed, 27 Jul 2011 14:12:57 +0200 Subject: [PATCH 0019/1438] Flip page if required only --- src/com/quran/labs/androidquran/QuranViewActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index cc18ae0fa3..f610802bd8 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -464,7 +464,8 @@ public void onAyahComplete(AyahItem ayah, AyahItem nextAyah) { } int page = QuranInfo.getPageFromSuraAyah(nextAyah.getSoura(), nextAyah .getAyah()); - quranPageFeeder.jumpToPage(page); + if (quranPageFeeder.getCurrentPagePosition() != page) + quranPageFeeder.jumpToPage(page); } @Override From 7121729daedc7f8a519f293af4cb2859dc86db04 Mon Sep 17 00:00:00 2001 From: fouad Date: Wed, 27 Jul 2011 16:51:05 +0200 Subject: [PATCH 0020/1438] -- fixing a lot of audio issue like async problems -- fixing changing quran reader --- .../labs/androidquran/QuranViewActivity.java | 29 ++++- .../common/AyahStateListener.java | 3 +- .../service/AudioServiceBinder.java | 105 ++++++++++++------ 3 files changed, 96 insertions(+), 41 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index cc18ae0fa3..ae6173f8fb 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -226,7 +226,7 @@ public void onClick(DialogInterface dialog, int which) { } } } - downloadSura(lastAyah.getQuranReaderId(), lastAyah + downloadSura(getQuranReaderId(), lastAyah .getSoura(), lastAyah.getAyah()); dialog.dismiss(); } @@ -241,10 +241,10 @@ public void onClick(DialogInterface dialog, int which) { Spinner s = (Spinner) view.findViewById(R.id.spinner); lastAyah = i; if (s != null) { - if (s.getSelectedItemPosition() != Spinner.INVALID_POSITION) { + if (s.getSelectedItemPosition() != Spinner.INVALID_POSITION) { + setReaderId(s.getSelectedItemPosition()); // reader is not default reader if (getQuranReaderId() != i.getQuranReaderId()) { - setReaderId(getQuranReaderId()); lastAyah = QuranAudioLibrary.getAyahItem( getApplicationContext(), i .getSoura(), i.getAyah(), @@ -252,6 +252,8 @@ public void onClick(DialogInterface dialog, int which) { } } } + if(lastAyah.getQuranReaderId() != getQuranReaderId()) + lastAyah.setReader(getQuranReaderId()); quranAudioPlayer.play(lastAyah); dialog.dismiss(); } @@ -453,7 +455,7 @@ private void playAudio(AyahItem ayah) { } @Override - public void onAyahComplete(AyahItem ayah, AyahItem nextAyah) { + public boolean onAyahComplete(AyahItem ayah, AyahItem nextAyah) { lastAyah = ayah; if (nextAyah.getQuranReaderId() != getQuranReaderId() && quranAudioPlayer != null && quranAudioPlayer.isPlaying()) { @@ -461,10 +463,12 @@ public void onAyahComplete(AyahItem ayah, AyahItem nextAyah) { lastAyah = QuranAudioLibrary.getAyahItem(this, nextAyah.getSoura(), nextAyah.getAyah(), getQuranReaderId()); quranAudioPlayer.play(lastAyah); + return false; } int page = QuranInfo.getPageFromSuraAyah(nextAyah.getSoura(), nextAyah .getAyah()); quranPageFeeder.jumpToPage(page); + return true; } @Override @@ -508,7 +512,7 @@ private AyahItem getCurrentAudioAyah() { private void setReaderId(int readerNamePosition) { currentReaderId = getResources().getIntArray(R.array.quran_readers_id)[readerNamePosition]; - QuranSettings.getInstance().setLastReader(currentReaderId); + QuranSettings.getInstance().setLastReader(currentReaderId); } private int getReaderIndex(int readerId) { @@ -521,4 +525,19 @@ private int getReaderIndex(int readerId) { return 0; } + @Override + public void onAyahError(AyahItem ayah) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage("An error occured"); + builder.setNegativeButton("ok", new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + + } + }); + builder.show(); + } + } diff --git a/src/com/quran/labs/androidquran/common/AyahStateListener.java b/src/com/quran/labs/androidquran/common/AyahStateListener.java index d9187988d8..0f3206de7c 100644 --- a/src/com/quran/labs/androidquran/common/AyahStateListener.java +++ b/src/com/quran/labs/androidquran/common/AyahStateListener.java @@ -1,6 +1,7 @@ package com.quran.labs.androidquran.common; public interface AyahStateListener { - void onAyahComplete(AyahItem ayah, AyahItem nextAyah); + boolean onAyahComplete(AyahItem ayah, AyahItem nextAyah); void onAyahNotFound(AyahItem ayah); + void onAyahError(AyahItem ayah); } diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index 43ac1a0ee3..bacf28f028 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -9,8 +9,10 @@ import android.content.Intent; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; +import android.media.MediaPlayer.OnErrorListener; import android.media.MediaPlayer.OnPreparedListener; import android.os.Binder; +import android.util.Log; import com.quran.labs.androidquran.QuranViewActivity; import com.quran.labs.androidquran.R; @@ -21,7 +23,7 @@ import com.quran.labs.androidquran.util.QuranAudioLibrary; public class AudioServiceBinder extends Binder implements - OnCompletionListener, IAudioPlayer, OnPreparedListener{ + OnCompletionListener, IAudioPlayer, OnPreparedListener, OnErrorListener{ private MediaPlayer mp = null; private Context context; @@ -30,9 +32,11 @@ public class AudioServiceBinder extends Binder implements private AyahItem currentItem; private AyahStateListener ayahListener = null; private boolean notified; + //private boolean stopped = true; private boolean stopped = true; + private boolean preparing = false; - public void setAyahCompleteListener(AyahStateListener ayahListener) { + public synchronized void setAyahCompleteListener(AyahStateListener ayahListener) { this.ayahListener = ayahListener; } @@ -43,13 +47,18 @@ public AudioServiceBinder(Context context){ } - - /* (non-Javadoc) - * @see org.islam.quran.IAudioPlayer#stop() - */ - public void stop() { + public synchronized void stop() { + // reset enable remote play to false + enableRemotePlay(false); if(mp != null && mp.isPlaying()){ + try{ mp.stop(); + mp.release(); + mp = null; + }catch (Exception e) { + Log.d("AudioServiceBinder:stop", + "Exception on calling media player stop " + e.toString() + " " + e.getMessage()); + } } paused = false; stopped = true; @@ -65,11 +74,14 @@ private void clearNotification(){ /* (non-Javadoc) * @see org.islam.quran.IAudioPlayer#play(org.islam.quran.AyahAudioItem) */ - public void play(AyahItem item) { + public synchronized void play(AyahItem item) { + stopped = false; + paused = false; + if(item == null) return; this.currentItem = item; - if(mp != null){ + if(mp != null && mp.isPlaying()){ mp.stop(); try{ mp.release(); @@ -99,7 +111,9 @@ else if(remotePlayEnabled) { if(url != null){ mp.setDataSource(url); mp.setOnPreparedListener(this); - mp.prepareAsync(); + mp.setOnErrorListener(this); + preparing = true; + mp.prepareAsync(); // mp.prepare(); // mp.start(); // paused = false; @@ -124,10 +138,7 @@ else if(remotePlayEnabled) { } - /* (non-Javadoc) - * @see org.islam.quran.IAudioPlayer#getMediaPlayer() - */ - public MediaPlayer getMediaPlayer() { + public synchronized MediaPlayer getMediaPlayer() { if(mp == null){ mp = new MediaPlayer(); mp.setOnCompletionListener(this); @@ -136,10 +147,7 @@ public MediaPlayer getMediaPlayer() { } - /* (non-Javadoc) - * @see org.islam.quran.IAudioPlayer#pause() - */ - public void pause() { + public synchronized void pause() { if(mp != null && mp.isPlaying()){ mp.pause(); } @@ -147,31 +155,30 @@ public void pause() { paused = true; } - /* (non-Javadoc) - * @see org.islam.quran.IAudioPlayer#resume() - */ - public void resume() { + public synchronized void resume() { if(mp != null && !mp.isPlaying()){ paused = false; - mp.start(); + if(!preparing) + mp.start(); } } - public boolean isPaused() { + public synchronized boolean isPaused() { return paused; } @Override - public void onCompletion(MediaPlayer mp) { + public synchronized void onCompletion(MediaPlayer mp) { AyahItem nextItem = QuranAudioLibrary.getNextAyahAudioItem(context, this.currentItem); - if(ayahListener != null) - ayahListener.onAyahComplete(currentItem, nextItem); + boolean continuePlaying = false; + if(ayahListener != null && !stopped) + continuePlaying = ayahListener.onAyahComplete(currentItem, nextItem); if(nextItem != null){ - this.currentItem = nextItem; + //this.currentItem = nextItem; try{ - if(!paused && !stopped && mp != null && !mp.isPlaying()) - this.play(currentItem); + if(continuePlaying && !paused && !stopped && mp != null && !mp.isPlaying()) + this.play(nextItem); }catch(Exception ex){} } } @@ -186,8 +193,18 @@ public void destory(){ @Override - public void onPrepared(MediaPlayer mp) { + public synchronized void onPrepared(MediaPlayer mp) { + preparing = false; this.mp = mp; + if(stopped){ + mp.stop(); + return; + } + if(paused){ + mp.start(); + mp.pause(); + return; + } if(mp != null){ mp.start(); paused = false; @@ -198,16 +215,16 @@ public void onPrepared(MediaPlayer mp) { } - public AyahItem getCurrentAyah(){ + public synchronized AyahItem getCurrentAyah(){ return currentItem; } - public void enableRemotePlay(boolean remote){ + public synchronized void enableRemotePlay(boolean remote){ this.remotePlayEnabled = remote; } - public boolean isRemotePlayEnabled(){ + public synchronized boolean isRemotePlayEnabled(){ return this.remotePlayEnabled; } @@ -244,8 +261,26 @@ private void showNotification(AyahItem item){ } - public boolean isPlaying(){ + public synchronized boolean isPlaying(){ return !paused && !stopped; } + + + + @Override + public synchronized boolean onError(MediaPlayer mp, int what, int extra) { + if(this.mp != null && mp.isPlaying()){ + try{ + this.mp.stop(); + if(mp != this.mp && mp.isPlaying()) + mp.stop(); + }catch (Exception e) { + // TODO: handle exception + } + } + if(ayahListener != null && !stopped) + ayahListener.onAyahError(currentItem); + return true; + } }; From 071213727422f7771568045be86aeb841ec1124a Mon Sep 17 00:00:00 2001 From: ahmedre Date: Thu, 28 Jul 2011 06:44:07 +0200 Subject: [PATCH 0021/1438] update some of the ui for the actionbar --- res/drawable/ab_bg.png | Bin 0 -> 196 bytes res/drawable/ab_jump.png | Bin 0 -> 3263 bytes res/drawable/ab_next.png | Bin 0 -> 3030 bytes res/drawable/ab_pause.png | Bin 0 -> 2909 bytes res/drawable/ab_play.png | Bin 0 -> 3142 bytes res/drawable/ab_prev.png | Bin 0 -> 3022 bytes res/drawable/actionbar_btn_normal.xml | 18 +++++++++++++ res/drawable/mic.png | Bin 1812 -> 3213 bytes res/drawable/stop.png | Bin 777 -> 2863 bytes res/layout/quran_exp.xml | 14 +++++----- res/values/colors.xml | 4 +++ res/values/styles.xml | 25 +++--------------- .../labs/androidquran/QuranActivity.java | 1 + .../labs/androidquran/QuranViewActivity.java | 11 ++++---- .../labs/androidquran/data/QuranInfo.java | 6 +++-- 15 files changed, 43 insertions(+), 36 deletions(-) create mode 100644 res/drawable/ab_bg.png create mode 100644 res/drawable/ab_jump.png create mode 100644 res/drawable/ab_next.png create mode 100644 res/drawable/ab_pause.png create mode 100644 res/drawable/ab_play.png create mode 100644 res/drawable/ab_prev.png create mode 100644 res/drawable/actionbar_btn_normal.xml create mode 100644 res/values/colors.xml diff --git a/res/drawable/ab_bg.png b/res/drawable/ab_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..26360a9fc0f8253e688c8ee227bcd2865c731882 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^j6m$l!3HF|@AP~IQj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS>Jiqbq?978H@#Z0)!dq9E1rSrG`rNUi~`>k4KbhTt&u~(L# zmsk|@{j-_zWVRm$oJ>nJoqR4iDu&G6^ICNi_o5dy4NA%yb9S&5^%`E=rD+r87G?cr tNnz^lm|a4d8;{m@)Ze)I_qlKagBaI|{I{vMtbsN%c)I$ztaD0e0stJqM|J=J literal 0 HcmV?d00001 diff --git a/res/drawable/ab_jump.png b/res/drawable/ab_jump.png new file mode 100644 index 0000000000000000000000000000000000000000..5ce7683863ccb175b1414ff4237b9b24d7cff31b GIT binary patch literal 3263 zcmV;w3_$aVP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*ne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kC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0005%Nklpjg;pVKGb@p{B@WW4YOax%%TB)u*4^e5TYDF2=D z?MWV_K1P$AD8{OK7ALurHWfX6Np2MR#kvIgi;};=qa^#2T&~Cl z8*Md9!X6yJo+j^J;3>v1AA3t;Hp5PA#Db~bf+aZ8Ap3+1cz_{%E_=`65RPJQ6I~1b znCspUvM6Me_ILH zR_3F)SBlJd6XR8)Pw=4~rFeB^{u<9p(oNPlEW#;lXh$jTt(@gl<9aeRMz!=Vy x%-)BYooGt$Vh}qp@UIB;bbrmd1UgON=KxC?bxXF9e1`x4002ovPDHLkV1iXlA1MF; literal 0 HcmV?d00001 diff --git a/res/drawable/ab_next.png b/res/drawable/ab_next.png new file mode 100644 index 0000000000000000000000000000000000000000..10fc535ea416323847fb12c89bdae96aa0723495 GIT binary patch literal 3030 zcmV;{3n}!8P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=c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able/ab_play.png b/res/drawable/ab_play.png new file mode 100644 index 0000000000000000000000000000000000000000..6889900e29087dda816b56cc395571f4ae62e3e6 GIT binary patch literal 3142 zcmV-M47u}(P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*ne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kC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0004TNkla1oE&0I2j3=kTSif58l9(W%=oHKxQnSi+5ewdXhhUSOfL*3=MoKf+BsEp}(ns)qsCF6TRs``EzV z-!9p40S@-<9$w>Ksd^PZk81Z(CSeZPy^QO4hHu5{k-TW?99Y3Ad?<+*@xD|&(x+5s g@-&+Ov<>iU0Q<|TL`&)2F#rGn07*qoM6N<$f^{O|F#rGn literal 0 HcmV?d00001 diff --git a/res/drawable/ab_prev.png b/res/drawable/ab_prev.png new file mode 100644 index 0000000000000000000000000000000000000000..e3ebe181cddba37d9a7e963185512979cf2de3b0 GIT binary patch literal 3022 zcmV;<3o-PGP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ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i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0002_NklmPaBY#EcG+qXqmepbO-HRK^0xzO0*7@^V#AA0na~W6{T4L=r>JYh;?dvFUo# z3=AwY)A?}c*BbSV#S+8$)RJRrZmZ{Q5!#ynd>1rs?gQY|+!f&5ya}LuYkmq1D1ct2 z`6x8t1{{HlkLFDP!%zD<1YiR6fpZMN9oPU + + \ No newline at end of file diff --git a/res/drawable/mic.png b/res/drawable/mic.png index 206ca9d97ffaec89999779a4173b6b0518903296..260ade12c6e492b46ca65709be634beadb227787 100644 GIT binary patch delta 3210 zcmV;540ZFA4viU*BYyx1a7bBm000XU000XU0RWnu7ytkYPiaF#P*7-ZbZ>KLZ*U+< zLqi~Na&Km7Y-Iodc-oy)XH-+^7Crag^g>IBfRsybQWXdwQbLP>6pAqfylh#{fb z6;Z(vMMVS~$e@S=j*ftg6;Uh>2n?1;Gf_2w45>mM5#WQz#Kz&|EGkvK~TfD`~gdX7S-06<0ofSs5oQvjd@0AR~w zV&ec%EdXFAe}CrF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cKE* - - + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_gravity="center_vertical" /> + android:paddingBottom="10dip" android:layout_gravity="right|center_vertical" /> + \ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml new file mode 100644 index 0000000000..887a08dda7 --- /dev/null +++ b/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #0f2d4d + diff --git a/res/values/styles.xml b/res/values/styles.xml index 51be870064..2e5d93230d 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -1,25 +1,6 @@ - - - - - - \ No newline at end of file + diff --git a/src/com/quran/labs/androidquran/QuranActivity.java b/src/com/quran/labs/androidquran/QuranActivity.java index 9d022de287..59f155c112 100644 --- a/src/com/quran/labs/androidquran/QuranActivity.java +++ b/src/com/quran/labs/androidquran/QuranActivity.java @@ -51,6 +51,7 @@ public void onCreate(Bundle savedInstanceState) { } protected void addActions() { + actionBar.setTitle("Quran"); actionBar.addAction(getIntentAction(ACTION_RESUME, R.drawable.translation)); actionBar.addAction(getIntentAction(ACTION_BOOKMARK, R.drawable.bookmarks)); } diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 0d7f201a1b..88c498b465 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -99,20 +99,21 @@ protected void addActions() { super.addActions(); if (actionBar != null) { // actionBar.setTitle("QuranAndroid"); + actionBar.setTitle("Quran"); actionBarActions.put(ACTION_PLAY, getIntentAction( - ACTION_PLAY, android.R.drawable.ic_media_play)); + ACTION_PLAY, R.drawable.ab_play)); actionBarActions.put(ACTION_PAUSE, getIntentAction( - ACTION_PAUSE, android.R.drawable.ic_media_pause)); + ACTION_PAUSE, R.drawable.ab_pause)); actionBarActions.put(ACTION_NEXT, getIntentAction( - ACTION_NEXT, android.R.drawable.ic_media_next)); + ACTION_NEXT, R.drawable.ab_next)); actionBarActions.put(ACTION_PREVIOUS, getIntentAction( - ACTION_PREVIOUS, android.R.drawable.ic_media_previous)); + ACTION_PREVIOUS, R.drawable.ab_prev)); actionBarActions.put(ACTION_STOP, getIntentAction( ACTION_STOP, R.drawable.stop)); actionBarActions.put(ACTION_CHANGE_READER, getIntentAction(ACTION_CHANGE_READER, R.drawable.mic)); actionBarActions.put(ACTION_JUMP_TO_AYAH, - getIntentAction(ACTION_JUMP_TO_AYAH, R.drawable.jump)); + getIntentAction(ACTION_JUMP_TO_AYAH, R.drawable.ab_jump)); actionBarIndecies.put(ACTION_PLAY, ACTION_BAR_ACTION_PLAY); actionBarIndecies.put(ACTION_PAUSE, ACTION_BAR_ACTION_PAUSE); diff --git a/src/com/quran/labs/androidquran/data/QuranInfo.java b/src/com/quran/labs/androidquran/data/QuranInfo.java index 8be238f7d5..0398ad9802 100644 --- a/src/com/quran/labs/androidquran/data/QuranInfo.java +++ b/src/com/quran/labs/androidquran/data/QuranInfo.java @@ -301,7 +301,9 @@ public static String getPageTitleNoPrefix(int page) { } public static String getPageTitle(int page) { - return getPageTitle() + page + - " - " + getSuraTitle() + " " + getSuraNameFromPage(page) + "\n" + getJuzTitle() + " " + getJuzFromPage(page); + return getSuraTitle() + " " + getSuraNameFromPage(page) + "\n" + + getPageTitle() + page + " - " + getJuzTitle() + " " + getJuzFromPage(page); + //return getPageTitle() + page + + //" - " + getSuraTitle() + " " + getSuraNameFromPage(page) + "\n" + getJuzTitle() + " " + getJuzFromPage(page); } } From d312994515d3aa773b81fcebd085739f27d81695 Mon Sep 17 00:00:00 2001 From: fouad Date: Thu, 28 Jul 2011 15:38:39 +0200 Subject: [PATCH 0022/1438] -- fixing previous ayah --- src/com/quran/labs/androidquran/QuranViewActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 88c498b465..500babb9e9 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -165,8 +165,9 @@ protected void onNewIntent(Intent intent) { if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) quranAudioPlayer.play(lastAyah); } else if (action.equalsIgnoreCase(ACTION_PREVIOUS)) { + AyahItem ayah = quranAudioPlayer.isPlaying() ? quranAudioPlayer.getCurrentAyah() : getCurrentAudioAyah(); lastAyah = QuranAudioLibrary.getPreviousAyahAudioItem(this, - getCurrentAudioAyah()); + ayah); if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) quranAudioPlayer.play(lastAyah); } else if (action.equalsIgnoreCase(ACTION_STOP)) { From 2cbd0b3bada74b802a62e3783e3926a2234f7c1a Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Thu, 28 Jul 2011 17:28:05 +0200 Subject: [PATCH 0023/1438] audi fixes --- res/values/readers.xml | 4 +- .../labs/androidquran/QuranActivity.java | 6 ++ .../labs/androidquran/QuranViewActivity.java | 69 ++++++++++++------- .../common/AyahStateListener.java | 3 +- .../service/AudioServiceBinder.java | 11 ++- .../service/QuranDataService.java | 6 +- 6 files changed, 64 insertions(+), 35 deletions(-) diff --git a/res/values/readers.xml b/res/values/readers.xml index db0b2c836f..0256d4caf6 100644 --- a/res/values/readers.xml +++ b/res/values/readers.xml @@ -43,7 +43,7 @@ http://www.everyayah.com/data/Abdul_Basit_Mujawwad_128kbps/ http://www.everyayah.com/data/Abdullah_Basfar_192kbps/ http://www.everyayah.com/data/Abdurrahmaan_As-Sudais_192kbps/ - http://www.everyayah.com/data/Abu Bakr Ash-Shaatree_128kbps/ + http://www.everyayah.com/data/Abu\u002520Bakr\u002520Ash-Shaatree_128kbps/ http://www.everyayah.com/data/Alafasy_128kbps/ http://www.everyayah.com/data/Hani_Rifai_192kbps/ http://www.everyayah.com/data/Husary_64kbps/ @@ -55,7 +55,7 @@ http://www.everyayah.com/data/Mohammad_al_Tablaway_128kbps/ http://www.everyayah.com/data/Muhammad_Ayyoub_128kbps/ http://www.everyayah.com/data/Muhammad_Jibreel_128kbps/ - http://www.everyayah.com/data/Saood bin Ibraaheem Ash-Shuraym_128kbps/ + http://www.everyayah.com/data/Saood\u002520bin\u002520Ibraaheem\u002520Ash-Shuraym_128kbps/ diff --git a/src/com/quran/labs/androidquran/QuranActivity.java b/src/com/quran/labs/androidquran/QuranActivity.java index 59f155c112..8e37e7cc60 100644 --- a/src/com/quran/labs/androidquran/QuranActivity.java +++ b/src/com/quran/labs/androidquran/QuranActivity.java @@ -5,6 +5,7 @@ import android.content.res.Configuration; import android.os.Bundle; import android.view.LayoutInflater; +import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -66,6 +67,11 @@ protected void onNewIntent(Intent intent) { } } + public boolean onPrepareOptionsMenu(Menu menu) { + menu.findItem(R.id.menu_item_bookmarks).setVisible(false); + return super.onPrepareOptionsMenu(menu); + } + private IntentAction getIntentAction(String intentAction, int drawable) { Intent i = new Intent(this, QuranActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 88c498b465..78b3d30a7f 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -20,7 +20,6 @@ import android.widget.SimpleAdapter; import android.widget.Spinner; import android.widget.TextView; -import android.widget.Toast; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.CompoundButton.OnCheckedChangeListener; @@ -145,7 +144,7 @@ protected void onNewIntent(Intent intent) { if (quranAudioPlayer.isPaused()) quranAudioPlayer.resume(); else { - lastAyah = getCurrentAudioAyah(); + lastAyah = getLastAyah(); // soura not totall found if (QuranUtils.isSouraAudioFound(lastAyah .getQuranReaderId(), lastAyah.getSoura()) < 0) { @@ -161,12 +160,12 @@ protected void onNewIntent(Intent intent) { onActionStop(); } else if (action.equalsIgnoreCase(ACTION_NEXT)) { lastAyah = QuranAudioLibrary.getNextAyahAudioItem(this, - getCurrentAudioAyah()); + getLastAyah()); if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) quranAudioPlayer.play(lastAyah); } else if (action.equalsIgnoreCase(ACTION_PREVIOUS)) { lastAyah = QuranAudioLibrary.getPreviousAyahAudioItem(this, - getCurrentAudioAyah()); + getLastAyah()); if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) quranAudioPlayer.play(lastAyah); } else if (action.equalsIgnoreCase(ACTION_STOP)) { @@ -193,7 +192,8 @@ private void onActionPlay() { private void onActionStop() { actionBar.removeAllActions(); - actionBar.addAction(actionBarActions.get(ACTION_PLAY), actionBarIndecies.get(ACTION_PLAY)); + actionBar.addAction(actionBarActions.get(ACTION_PLAY), 0); + actionBar.addAction(actionBarActions.get(ACTION_CHANGE_READER), 1); } private void showDownloadDialog(final AyahItem i) { @@ -265,6 +265,7 @@ public void onClick(DialogInterface dialog, int which) { @Override public void onClick(DialogInterface dialog, int which) { + onActionStop(); dialog.dismiss(); } }); @@ -345,9 +346,7 @@ public void onClick(DialogInterface dialog, int which) { }); dialogBuilder.setNegativeButton("Cancel", null); dialogBuilder.show(); - } - private void initSurasSpinner(final Spinner spinner, int startSura, int endSura){ String[] from = new String[] {"suraName"}; @@ -436,10 +435,7 @@ private void bindAudioService() { QuranAudioService.class); startService(serviceIntent); bounded = bindService(serviceIntent, conn, BIND_AUTO_CREATE); - if (!bounded) - Toast - .makeText(this, "can not bind service", - Toast.LENGTH_SHORT); + Log.d("QuranView", "Audio service bounded: " + bounded); } } @@ -495,7 +491,7 @@ protected void onFinishDownload() { super.onFinishDownload(); if (quranAudioPlayer != null) { quranAudioPlayer.enableRemotePlay(false); - playAudio(lastAyah); + playAudio(getLastAyah()); } } @@ -503,16 +499,6 @@ private int getQuranReaderId() { return QuranSettings.getInstance().getLastReader(); } - private AyahItem getCurrentAudioAyah() { - if (lastAyah != null) { - return lastAyah; - } - Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder - .getCurrentPagePosition()); - return QuranAudioLibrary.getAyahItem(getApplicationContext(), - pageBounds[0], pageBounds[1], getQuranReaderId()); - } - private void setReaderId(int readerNamePosition) { currentReaderId = getResources().getIntArray(R.array.quran_readers_id)[readerNamePosition]; QuranSettings.getInstance().setLastReader(currentReaderId); @@ -529,18 +515,51 @@ private int getReaderIndex(int readerId) { } @Override - public void onAyahError(AyahItem ayah) { + public void onUnknownError(AyahItem ayah) { + lastAyah = ayah; + quranAudioPlayer.stop(); + onActionStop(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("An error occured"); - builder.setNegativeButton("ok", new DialogInterface.OnClickListener() { + builder.setNegativeButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); - } }); builder.show(); } + + private AyahItem getLastAyah() { + AyahItem last = lastAyah; + if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) { + last = quranAudioPlayer.getCurrentAyah(); + } + + if (last == null) { + Integer[] pageBounds = QuranInfo.getPageBounds(quranPageFeeder.getCurrentPagePosition()); + last = QuranAudioLibrary.getAyahItem(getApplicationContext(), + pageBounds[0], pageBounds[1], getQuranReaderId()); + } + + lastAyah = last; + return lastAyah; + } + + @Override + public void onConnectionLost(AyahItem ayah) { + lastAyah = ayah; + connect(); + } + + @Override + protected void onConnectionSuccess() { + super.onConnectionSuccess(); + if (lastAyah != null) { + quranAudioPlayer.enableRemotePlay(true); + quranAudioPlayer.play(getLastAyah()); + } + } } diff --git a/src/com/quran/labs/androidquran/common/AyahStateListener.java b/src/com/quran/labs/androidquran/common/AyahStateListener.java index 0f3206de7c..cdf793b15e 100644 --- a/src/com/quran/labs/androidquran/common/AyahStateListener.java +++ b/src/com/quran/labs/androidquran/common/AyahStateListener.java @@ -3,5 +3,6 @@ public interface AyahStateListener { boolean onAyahComplete(AyahItem ayah, AyahItem nextAyah); void onAyahNotFound(AyahItem ayah); - void onAyahError(AyahItem ayah); + void onUnknownError(AyahItem ayah); + void onConnectionLost(AyahItem ayah); } diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index bacf28f028..d09aec1132 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -98,6 +98,7 @@ public synchronized void play(AyahItem item) { url = item.getLocalAudioUrl(); else if(remotePlayEnabled) { url = item.getRemoteAudioUrl(); + Log.d("quran_audio", url); }else{ if(ayahListener != null){ clearNotification(); @@ -272,14 +273,20 @@ public synchronized boolean onError(MediaPlayer mp, int what, int extra) { if(this.mp != null && mp.isPlaying()){ try{ this.mp.stop(); + stopped = true; if(mp != this.mp && mp.isPlaying()) mp.stop(); }catch (Exception e) { // TODO: handle exception } } - if(ayahListener != null && !stopped) - ayahListener.onAyahError(currentItem); + if(ayahListener != null && !stopped) { + if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) + ayahListener.onConnectionLost(currentItem); + else + ayahListener.onUnknownError(currentItem); + } + return true; } diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index cde18ab451..59b82e97f0 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -265,7 +265,7 @@ private boolean resumeDownload() { File file = new File(saveToDirectories[downloadIndex], fileNames[downloadIndex] + DOWNLOAD_EXT); - URL url = new URL(escapeUrlSpecialCharacters(downloadUrls[downloadIndex])); + URL url = new URL(downloadUrls[downloadIndex]); URLConnection conn = url.openConnection(); int total = conn.getContentLength(); Log.d("quran_srv", "File to download: " + file.getName() @@ -421,8 +421,4 @@ private void onDownloadComplete() { QuranDataService.isRunning = false; } } - - private String escapeUrlSpecialCharacters(String url) { - return url.replace(" ", "%20"); - } } From c39ad9e6f1f6d9706bb0dc5f48cb60472511e746 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Thu, 28 Jul 2011 17:54:55 +0200 Subject: [PATCH 0024/1438] Ghamadi --- res/values/readers.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/res/values/readers.xml b/res/values/readers.xml index 0256d4caf6..2adffd04ce 100644 --- a/res/values/readers.xml +++ b/res/values/readers.xml @@ -7,6 +7,7 @@ Abdurrahmaan As-Sudais Abu Bakr Ash-Shaatree Alafasy + Ghamadi Hani Rifai Husary Husary Mujawwad @@ -26,6 +27,7 @@ 3 4 5 + 18 6 7 8 @@ -45,6 +47,7 @@ http://www.everyayah.com/data/Abdurrahmaan_As-Sudais_192kbps/ http://www.everyayah.com/data/Abu\u002520Bakr\u002520Ash-Shaatree_128kbps/ http://www.everyayah.com/data/Alafasy_128kbps/ + http://www.everyayah.com/data/Ghamadi_40kbps/ http://www.everyayah.com/data/Hani_Rifai_192kbps/ http://www.everyayah.com/data/Husary_64kbps/ http://www.everyayah.com/data/Husary_128kbps_Mujawwad/ From 9d3a5e09864446eb24afcf4d6f2411cf0c00f4e9 Mon Sep 17 00:00:00 2001 From: fouad Date: Thu, 28 Jul 2011 18:00:31 +0200 Subject: [PATCH 0025/1438] fixing checkbox --- res/layout/dialog_jump_to_ayah.xml | 2 +- src/com/quran/labs/androidquran/QuranViewActivity.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/res/layout/dialog_jump_to_ayah.xml b/res/layout/dialog_jump_to_ayah.xml index e5051fad8d..f8fa973cfd 100644 --- a/res/layout/dialog_jump_to_ayah.xml +++ b/res/layout/dialog_jump_to_ayah.xml @@ -22,6 +22,6 @@ diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 0c8084db67..548c66a4e2 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -287,7 +287,9 @@ private void showJumpToAyahDialog() { initAyatSpinner(ayatSpinner, startAyah, endAyah); final Spinner surasSpinner = (Spinner) view.findViewById(R.id.spinner_suras); - initSurasSpinner(surasSpinner, pageBounds[0], pageBounds[2]); + //initSurasSpinner(surasSpinner, pageBounds[0], pageBounds[2]); + initSurasSpinner(surasSpinner, 1, 114); + surasSpinner.setSelection(pageBounds[0] - 1); surasSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @SuppressWarnings("unchecked") @@ -312,7 +314,7 @@ public void onNothingSelected(AdapterView arg0) { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if(isChecked){ + if(!isChecked){ initSurasSpinner(surasSpinner, 1, 114); surasSpinner.setSelection(pageBounds[0] - 1); } From 452ee3327971ce7740778c07f589b51a75cb901b Mon Sep 17 00:00:00 2001 From: fouad Date: Thu, 28 Jul 2011 18:26:23 +0200 Subject: [PATCH 0026/1438] adding jump to page on jumping to ayah --- src/com/quran/labs/androidquran/QuranViewActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 548c66a4e2..302a347558 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -342,7 +342,7 @@ public void onClick(DialogInterface dialog, int which) { quranAudioPlayer.stop(); quranAudioPlayer.play(lastAyah); } - + jumpTo(QuranInfo.getPageFromSuraAyah(sura, ayah)); } }); dialogBuilder.setNegativeButton("Cancel", null); From 8abe5103ef945eaad1538a19be9ddc4e857dbf02 Mon Sep 17 00:00:00 2001 From: ahmedre Date: Sat, 30 Jul 2011 03:40:52 +0200 Subject: [PATCH 0027/1438] minor ui updates and fixes to actionbar and bookmarks page. --- res/drawable/ab_bg.png | Bin 196 -> 170 bytes res/drawable/ab_jump.png | Bin 3263 -> 3186 bytes res/drawable/ab_next.png | Bin 3030 -> 3053 bytes res/drawable/ab_pause.png | Bin 2909 -> 2880 bytes res/drawable/ab_play.png | Bin 3142 -> 3045 bytes res/drawable/ab_prev.png | Bin 3022 -> 3056 bytes res/drawable/stop.png | Bin 2863 -> 2858 bytes res/layout/quran_list.xml | 3 ++- .../labs/androidquran/BookmarksActivity.java | 8 +++++--- .../labs/androidquran/data/QuranInfo.java | 9 +++++++++ 10 files changed, 16 insertions(+), 4 deletions(-) diff --git a/res/drawable/ab_bg.png b/res/drawable/ab_bg.png index 26360a9fc0f8253e688c8ee227bcd2865c731882..954072c68a00479c4dd6994c3b5a1cea1e4bb2ff 100644 GIT binary patch delta 118 zcmV-+0Ez#^0jdFz7YZ#11^@s6Z+ij6ks&ByOi4sRRCwBaPC*X9APh3S?#@Upqa}<3nh-v$JvRwiU Y0H^?lVHV_BQ~&?~07*qoM6N<$f^-fo{Qv*} delta 144 zcmV;B0B`@Q0mK227YaoP1^@s6i``!CXQx zg&Zv^9O?&och4B2T=(-fGm{4RFbM*rDMC!rK_OI~yz3>h3!>$)x)N!z#eIl>*xCK(6JP)q3dnEmW!gIc0000W*XMtfK z>rMfOQK>zyOpJDczk>W1Fdd~T@4~c6pgAt3X%09x6Lr_s{CuZY&9aqPKihoIcR_p;5u&5_BL*zEwqKU&=%T4Tj+lc{WAcu W{iaHHP@WY40000gnx$$1}XVoA+C{=XRcZ&-vbS&OOh0dXnfQrs*)c1iA!z zr?7S@mSHnil)bOY7{&;`PMJZH-+zsPB*&6GO>4YOax%%TB)u*4^e5TYDF2=D?MWV_ zK1P$AD8{OK7ALurHWfX6Np2MR#kvIgi;};=qa^#2T&~Cl8*Md9 z!X6yJo+j^J;3>v1AA3t;Hp5PA#Db~bf+aZ8Ap3+1cz_{%E_=`65RPJQ6MtO`{^SU4|j1J?=XQM4eKXx1z&I;eScdC*H-4E zxL1nIcoXAQqEGOl9i@16W&Rq^O43c%I4r^`Y-mR*?ya0^2p=ao`7h(Aaj;I|t>b~= z^8AkX#r3VQ1~+ROhdFgT@PE28|5ipTjNvSlRR~91wwIlk1Yo)nZ-lD|*^Oo!}9%3CFY&G8orrGa3Xz1e+lK1C3h6WV09!5%CZd zgCLkpCc(It7cL3z?Jho;frZ^N?_-!Z1KTOfQf@IO!w7Vs10Co<2RhJI(GOT0;mk9X zLr>8LdLFmw@Lq21QQ!sp=;qYZU4I-Te39El?4@?ON$r!>^jJ<8^#oJ7jl9j>WHQ zX--e#7*ANsZMjV25?7eXZ6mJY5eu=#8;)zt;VuXCE7q}s=l@>mFYI6z7j-5cZwP#f zJ$y8gyl!+KTNvbU5#O%{C4s@Uc9q2#@`uF%50A7SJqv?FH2><{907*qoM6N<$f?490)c^nh delta 323 zcmV-J0lfb07uFXciBL{Q4GJ0x0000DNk~Le0000W0000W2nGNE0CReJ^synI3V#7f zL_t(|+U%D(4#F@HMPC-eB5@)_I&RDvD7gYOG!ztwErBpJMq+UciA_wAk=$6G|6d%> zSPn!4pAq6YT7bU>h=C~}Y9wE3Ccx|=Pn1rqT`eMIV<_*D7}g^qfrv~*A46S^X$N|m zx$MJEgr#4q*E0eHCG#eT5QwVi)qg#NS%ow4vnp@`VOxgQ5H9+F6@&|b!wW>wG{E2i zq66eUTJZol0ej%=>n^z0dEW=X5$FOV9{`0i9Rn-iQYATd01zqjC9qMqU!wr2GG8n6 zpvhm50t;oHH{FP=&20djnAZhxW?l#28}rB|z^F!Z*FYl zY;fRVy-@#X%Dd+l=N_=F6S%$l$%O1F-xXasTHH@gc2`WXGr-TCmrII^fq{Y7)59eQNGpIa2OE$quB!U7QE@(3eTS!uV@SoVH`lGX z8Vm$nFG|;UG<9j02ZyaY8YCc?G}*~zxqzZreuBaT_acSNW0mhaBRMB}H^eiGB~-t7 zIB9Or8;&LZ(^J?K_-n&?1DLWc78`65y}_mYL#_Y- diff --git a/res/drawable/ab_play.png b/res/drawable/ab_play.png index 6889900e29087dda816b56cc395571f4ae62e3e6..39bff61cd74cc31cc39019629ff119f2951678cb 100644 GIT binary patch delta 338 zcmV-Y0j>VV808lsiBL{Q4GJ0x0000DNk~Le0000j0000j2nGNE06H4tnz13D3V#qu zL_t(|+U(dZO9W9A2H?VzF6)iTCu$Wv7V%Rjv zA0TWT%Uv*tVZQXjdDE18c^J-|bC{y4D!FA&h6!|_10Co<2RhJA&@b4`4ZVS9++d|| zbWwB5`+jJO0WQ*W7U)?@oMD&~dViKD9ATVO_t;J!>J^rAYk3EF$1xWFdwKkn2~KdI z({NeE9Uicj+eF;OD=x8=;~1Z>dvKv==woV!Z#k651bf(N3ho2_iBqiOwyjIMERSoP z11yFia{n9CS1v5&1T!EL?iXf*>YY zs7U+>6P=jJabfkskk(0NrrX6Fxb&h5?*E>udz za1oE&0I2j3=kTSif58l9(W%=oHKxQnSi+5ewdXhhUSOfLTgkNeob-rp|S zaRCnY?H*p^Ua5K&KaXnnQ6^yy*u9MFc!qDq>XE!?>Ks_XDSRl27xBJSJ<_LCXYw?g e0JIJ8YXJMpszgia-7x?F00{s|MNUMnLSTaa+sy9( diff --git a/res/drawable/ab_prev.png b/res/drawable/ab_prev.png index e3ebe181cddba37d9a7e963185512979cf2de3b0..6a2697fdad259e1878584b1ad5a74cbd3edbcc42 100644 GIT binary patch delta 350 zcmV-k0ipiR7w{J$iBL{Q4GJ0x0000DNk~Le0000j0000j2nGNE06H4tnz13C3V#6` zNkl8&cK5$`}TXYGsCj2qA27RGct@o2RhJ!4s@UcT^4!F`N{!a7dh@C? zJ% zmPaBY#EcG+qXqmepbO-HRK^0xzO0*7@^V#AA0na~W6{T4L=r>JYh;?dvFUo#3=AwY z)A?}c*BbSV#S+8$)RJRrZmZ{Q5r5j6|9lrTZter%)Z7)|+`I{(d~1FR4Jd$KrTHi{ z;07Fli;w0_0K-rFIs{+>^nr5>z#Z5CQ-vu*0|eLsYlTQd0}{0mw+bF!Z>}41 zF&J<#ABgz%U;noK6unEQ^<)k@uHJ2|tIf>J3kGvlekVQqx-sY)vlIeUz3Gpb)dm6o gIBS7M|Nqa-U@pfJlW?`~Jdn%a>FVdQ&MBb@0H_= + android:layout_height="wrap_content" android:background="@drawable/list" + android:cacheColorHint="#00000000" /> \ No newline at end of file diff --git a/src/com/quran/labs/androidquran/BookmarksActivity.java b/src/com/quran/labs/androidquran/BookmarksActivity.java index 7b489edb49..ac8574d9a8 100644 --- a/src/com/quran/labs/androidquran/BookmarksActivity.java +++ b/src/com/quran/labs/androidquran/BookmarksActivity.java @@ -39,14 +39,16 @@ private void showBookmarks() { ArrayList bookmarks = BookmarksManager.getInstance().getBookmarks(); for (int i = 0; i < bookmarks.size(); i++) { int page = bookmarks.get(i); - String title = (i+1) + ". " + QuranInfo.getPageTitleNoPrefix(page); + String title = QuranInfo.getSuraNameString(page); + String info = QuranInfo.getSuraDetailsForBookmark(page); Map map = new HashMap(); map.put("suraname", title); + map.put("info", info); bookmarkList.add(map); } - String[] from = new String[]{ "suraname" }; - int[] to = new int[]{ R.id.sura_title }; + String[] from = new String[]{ "suraname", "info" }; + int[] to = new int[]{ R.id.sura_title, R.id.sura_info }; ListView list = (ListView)findViewById(R.id.lstBookmarks); diff --git a/src/com/quran/labs/androidquran/data/QuranInfo.java b/src/com/quran/labs/androidquran/data/QuranInfo.java index 0398ad9802..de51abdf4d 100644 --- a/src/com/quran/labs/androidquran/data/QuranInfo.java +++ b/src/com/quran/labs/androidquran/data/QuranInfo.java @@ -300,6 +300,15 @@ public static String getPageTitleNoPrefix(int page) { " - " + getSuraTitle() + " " + getSuraNameFromPage(page); } + public static String getSuraNameString(int page){ + return getSuraTitle() + " " + getSuraNameFromPage(page); + } + + public static String getSuraDetailsForBookmark(int page){ + return getPageTitle() + page + " - " + + getJuzTitle() + " " + getJuzFromPage(page); + } + public static String getPageTitle(int page) { return getSuraTitle() + " " + getSuraNameFromPage(page) + "\n" + getPageTitle() + page + " - " + getJuzTitle() + " " + getJuzFromPage(page); From 5eac8a2621571e5ef3dd7f651aad72330e969c66 Mon Sep 17 00:00:00 2001 From: ahmedre Date: Sat, 30 Jul 2011 06:28:33 +0200 Subject: [PATCH 0028/1438] al7amdulillah, initial (working) highlight ayah implementation --- res/drawable/highlight.png | Bin 0 -> 116 bytes res/layout-land/quran_page_layout.xml | 2 +- res/layout/quran_page_layout.xml | 2 +- .../labs/androidquran/common/AyahBounds.java | 79 ++++++++++ .../androidquran/common/QuranPageFeeder.java | 21 +++ .../data/AyahInfoDatabaseHandler.java | 50 ++++++ .../widgets/HighlightingImageView.java | 146 ++++++++++++++++++ 7 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 res/drawable/highlight.png create mode 100644 src/com/quran/labs/androidquran/common/AyahBounds.java create mode 100644 src/com/quran/labs/androidquran/data/AyahInfoDatabaseHandler.java create mode 100644 src/com/quran/labs/androidquran/widgets/HighlightingImageView.java diff --git a/res/drawable/highlight.png b/res/drawable/highlight.png new file mode 100644 index 0000000000000000000000000000000000000000..93c6c22396c09d30dca4b4647206ea6054c8fe8c GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^j6iJ8!3HGHnkiTUDajJoh?3y^w370~qErUQl>DSr z1<%~X^wgl##FWaylc_d9MPi;Vjv*Ddk_w`qJv(rOfn_nv6b23hhNEVT_p1}dMS&_9 NJYD@<);T3K0RT2ZA8G&q literal 0 HcmV?d00001 diff --git a/res/layout-land/quran_page_layout.xml b/res/layout-land/quran_page_layout.xml index 8e9c9ecb68..e5d6f42145 100644 --- a/res/layout-land/quran_page_layout.xml +++ b/res/layout-land/quran_page_layout.xml @@ -21,7 +21,7 @@ android:layout_height = "wrap_content" android:background = "@android:color/black" android:fillViewport="true"> - - other.minX) + this.minX = other.minX; + if (this.minY > other.minY) + this.minY = other.minY; + if (this.maxX < other.maxX) + this.maxX = other.maxX; + if (this.maxY < other.maxY) + this.maxY = other.maxY; + } + + public int getMinX() { + return minX; + } + + public void setMinX(int minX) { + this.minX = minX; + } + + public int getMinY() { + return minY; + } + + public void setMinY(int minY) { + this.minY = minY; + } + + public int getMaxX() { + return maxX; + } + + public void setMaxX(int maxX) { + this.maxX = maxX; + } + + public int getMaxY() { + return maxY; + } + + public void setMaxY(int maxY) { + this.maxY = maxY; + } + + public void setLine(int line) { + this.line = line; + } + + public int getLine() { + return line; + } + + public void setPosition(int position) { + this.position = position; + } + + public int getPosition() { + return position; + } +} diff --git a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java index 58484eb98f..4d40cd61e5 100644 --- a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java +++ b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java @@ -17,6 +17,7 @@ import com.quran.labs.androidquran.data.ApplicationConstants; import com.quran.labs.androidquran.util.QuranSettings; import com.quran.labs.androidquran.util.QuranUtils; +import com.quran.labs.androidquran.widgets.HighlightingImageView; import com.quran.labs.androidquran.widgets.QuranPageCurlView; import com.quran.labs.androidquran.widgets.QuranPageCurlView.OnPageFlipListener; @@ -102,6 +103,26 @@ public void goToPreviousPage() { */ } + public void highlightAyah(int sura, int ayah){ + View v = mQuranPage.getCurrentPage(); + HighlightingImageView iv = + (HighlightingImageView)v.findViewById(R.id.page_image); + if (iv != null){ + HighlightingImageView hi = (HighlightingImageView)iv; + hi.highlightAyah(sura, ayah); + } + } + + public void unHighlightAyah(){ + View v = mQuranPage.getCurrentPage(); + HighlightingImageView iv = + (HighlightingImageView)v.findViewById(R.id.page_image); + if (iv != null){ + HighlightingImageView hi = (HighlightingImageView)iv; + hi.unhighlight(); + } + } + public void refreshCurrent() { jumpToPage(mCurrentPageNumber); } diff --git a/src/com/quran/labs/androidquran/data/AyahInfoDatabaseHandler.java b/src/com/quran/labs/androidquran/data/AyahInfoDatabaseHandler.java new file mode 100644 index 0000000000..ec7259dc3c --- /dev/null +++ b/src/com/quran/labs/androidquran/data/AyahInfoDatabaseHandler.java @@ -0,0 +1,50 @@ +package com.quran.labs.androidquran.data; + +import java.io.File; + +import android.database.Cursor; +import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; + +import com.quran.labs.androidquran.util.QuranUtils; + +public class AyahInfoDatabaseHandler { + + private SQLiteDatabase database = null; + public static String COL_PAGE = "page_number"; + public static String COL_LINE = "line_number"; + public static String COL_SURA = "sura_number"; + public static String COL_AYAH = "ayah_number"; + public static String COL_POSITION = "position"; + public static String MIN_X = "min_x"; + public static String MIN_Y = "min_y"; + public static String MAX_X = "max_x"; + public static String MAX_Y = "max_y"; + public static String GLYPHS_TABLE = "glyphs"; + + public AyahInfoDatabaseHandler(String databaseName) throws SQLException { + String base = QuranUtils.getQuranDatabaseDirectory(); + if (base == null) return; + String path = base + File.separator + databaseName; + database = SQLiteDatabase.openDatabase(path, null, + SQLiteDatabase.NO_LOCALIZED_COLLATORS); + } + + public boolean validDatabase(){ + return (database == null)? false : database.isOpen(); + } + + public Cursor getVerseBounds(int sura, int ayah){ + if (!validDatabase()) return null; + return database.query(GLYPHS_TABLE, + new String[]{ COL_PAGE, COL_LINE, COL_SURA, COL_AYAH, COL_POSITION, + MIN_X, MIN_Y, MAX_X, MAX_Y }, + COL_SURA + "=" + sura + " and " + COL_AYAH + "=" + ayah, + null, null, null, COL_POSITION); + } + + public void closeDatabase() { + if (database != null) + database.close(); + } +} diff --git a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java new file mode 100644 index 0000000000..ba9744878f --- /dev/null +++ b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java @@ -0,0 +1,146 @@ +package com.quran.labs.androidquran.widgets; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import android.content.Context; +import android.database.Cursor; +import android.database.SQLException; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.RectF; +import android.util.AttributeSet; +import android.widget.ImageView; + +import com.quran.labs.androidquran.R; +import com.quran.labs.androidquran.common.AyahBounds; +import com.quran.labs.androidquran.data.AyahInfoDatabaseHandler; + +public class HighlightingImageView extends ImageView { + private List currentlyHighlighting = null; + + public HighlightingImageView(Context context){ + super(context); + } + + public HighlightingImageView(Context context, AttributeSet attrs){ + super(context, attrs); + } + + public HighlightingImageView(Context context, AttributeSet attrs, + int defStyle) { + super(context, attrs, defStyle); + } + + public void unhighlight(){ + this.currentlyHighlighting = null; + this.invalidate(); + } + + public void highlightAyah(int sura, int ayah){ + try { + AyahInfoDatabaseHandler handler = + new AyahInfoDatabaseHandler("ayahinfo.db"); + Cursor cursor = handler.getVerseBounds(sura, ayah); + Map lineCoords = + new HashMap(); + AyahBounds first = null, last = null, current = null; + if ((cursor == null) || (!cursor.moveToFirst())) + return; + do { + current = new AyahBounds(cursor.getInt(1), cursor.getInt(4), + cursor.getInt(5), cursor.getInt(6), cursor.getInt(7), + cursor.getInt(8)); + if (first == null) first = current; + if (!lineCoords.containsKey(current.getLine())) + lineCoords.put(current.getLine(), current); + else lineCoords.get(current.getLine()).engulf(current); + } while (cursor.moveToNext()); + + if ((first != null) && (current != null) && + (first.getPosition() != current.getPosition())) + last = current; + + handler.closeDatabase(); + doHighlightAyah(first, last, lineCoords); + } + catch (SQLException se){ + } + } + + private void doHighlightAyah(AyahBounds first, + AyahBounds last, Map lineCoordinates){ + if (first == null) return; + ArrayList rangesToDraw = new ArrayList(); + if (last == null) + rangesToDraw.add(first); + else { + if (first.getLine() == last.getLine()){ + first.engulf(last); + rangesToDraw.add(first); + } + else { + AyahBounds b = lineCoordinates.get(first.getLine()); + rangesToDraw.add(b); + + int currentLine = first.getLine() + 1; + int diff = last.getLine() - first.getLine() - 1; + for (int i = 0; i < diff; i++){ + b = lineCoordinates.get(currentLine + i); + rangesToDraw.add(b); + } + + b = lineCoordinates.get(last.getLine()); + rangesToDraw.add(b); + } + } + + /* + for (AyahBounds b : rangesToDraw){ + android.util.Log.d("ranges", "got: " + b.getMinX() + ", " + b.getMinY() + + ", " + b.getMaxX() + ", " + b.getMaxY()); + } + */ + + this.currentlyHighlighting = rangesToDraw; + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + if (this.currentlyHighlighting != null){ + for (AyahBounds b : currentlyHighlighting){ + Bitmap bm = BitmapFactory.decodeResource( + getResources(), R.drawable.highlight); + RectF rect = new RectF(b.getMinX(), b.getMinY(), + b.getMaxX(), b.getMaxY()); + if (canvas.getHeight() > canvas.getWidth()){ + /* + android.util.Log.d("highlight", "currently: " + + canvas.getHeight() + " " + + this.getHeight() + " and width: " + + canvas.getWidth() + " " + + this.getWidth()); + */ + + // portrait mode, need to adjust the rectangle + float factor = (float)((1.0 * canvas.getWidth()) / + (1.0 * canvas.getHeight())); + float maxY = (b.getMaxY() * factor); + float minY = (b.getMinY() * factor); + if (canvas.getHeight() == this.getHeight()){ + maxY += 12.5; + minY += 12.5; + } + RectF scaled = new RectF(b.getMinX() * factor, + minY, b.getMaxX() * factor, maxY); + rect = scaled; + } + canvas.drawBitmap(bm, null, rect, null); + } + } + } +} From c22f50f3d03c6fc657ed53530fb319c3ef4419a3 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sat, 30 Jul 2011 14:45:21 +0200 Subject: [PATCH 0029/1438] Fixes --- src/com/quran/labs/androidquran/QuranViewActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 302a347558..e9bc9f29b7 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -193,6 +193,7 @@ private void onActionStop() { actionBar.removeAllActions(); actionBar.addAction(actionBarActions.get(ACTION_PLAY), 0); actionBar.addAction(actionBarActions.get(ACTION_CHANGE_READER), 1); + actionBar.addAction(actionBarActions.get(ACTION_JUMP_TO_AYAH), 2); } private void showDownloadDialog(final AyahItem i) { @@ -466,8 +467,10 @@ public boolean onAyahComplete(AyahItem ayah, AyahItem nextAyah) { int page = QuranInfo.getPageFromSuraAyah(nextAyah.getSoura(), nextAyah .getAyah()); - if (quranPageFeeder.getCurrentPagePosition() != page) + if (quranPageFeeder.getCurrentPagePosition() != page) { quranPageFeeder.jumpToPage(page); + updatePageInfo(page); + } return true; } From 7fdff3d2a9765ef7da650d1c07bb1c4815a92ae5 Mon Sep 17 00:00:00 2001 From: fouad Date: Sat, 30 Jul 2011 17:00:47 +0200 Subject: [PATCH 0030/1438] -- adding repeat --- res/drawable/repeat.png | Bin 0 -> 4559 bytes .../labs/androidquran/QuranViewActivity.java | 10 +++-- .../service/AudioServiceBinder.java | 41 +++++++++++++----- 3 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 res/drawable/repeat.png diff --git a/res/drawable/repeat.png b/res/drawable/repeat.png new file mode 100644 index 0000000000000000000000000000000000000000..bbb688555d3f10baa80a27264b4abbbf236f46c0 GIT binary patch literal 4559 zcmV;=5istFP)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRa2RY^oaRCwB~npun-cb&&S|D&q!o}TXUT+Sqp;~bbH2Tq(UWE04ShgDWAY}g=P zcqS5B2_eJ-k31lRctL_^URcmZXrqJ>0wItf8OH?J#IeVTW5@A5XHQRGRrNpip{jbi zZRY?{qgK~+SJ(e{|GvNPzr>N3U*^g~2!T=x?>){rq?9=4@ZKY(LOzQ0_I=M7)A8P)ilXQk@PEdb<5J2vzlW4^v|cWQwH6^nz6RGi zG=In8y~lg6f%}Wa;-jT<`Jr;TysuO&s<2QX2m+Lp2$?VLvDT8rF~cZg(C^z`uXnQF z?>|2r4xjMezvR6)e~&EsZx!4*r?u9PRjbvnPBj__Yqc8Xa(UvqC{7qeF~cYZpjZeA zgMezSMzvN0P~N#)x4Ye2J6l_ix7+Q*y zPc^1cD*gG|W}DMzFL37U1y@>L)i4adGdnx`c(c_KT5Fv196fQ8 zSB@U%^x5pDR?>)drZ@meC^|dw5U%2q{R=fRWU|9(9 zw<{o}1h}u&YCSQ(u&@}0A?@uh&;0feymsO(q!3gqWvZ1jj1Y^B(UV&iRpIah%ZJ-e#-QMM}YE zAAW$3-L{W@zt5Ss-#)*(y7~}s;wleZL#t}D)%wZY{QPdE6i459i>ID{38^(R^&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{~_!Frd)^_cLE^gdZQIhU64FwpE>S_EKY zeVul@{dMnsG@@cA5-dr6ySlpiBV!E3LdZ=^i+Jxyj2U%j=ly7*)aB`oY^I>|4(sd) z^CZS#tQmcm@<2P~(z%pcvEJdG%ZM(Yby~+w*YBoS2a@>MXWWcC$i+qwYSb=GjHUJ=bzbZ8na{9+5ER-9vB(q3gN9a z>|I)PQ+eQoVaf!5DATdm!5t!V^s>fA+=#GK=(?x|85%` zC)U>1z96K0dU|@gIop~h(3(?cFOkGCIta*TaDm7AF?M>KS@+l8o$+HKkW=o?rlA_@ zfE$-~)10cM!e6|&vA(wU1@HZd54=Mogur=!Xmxe<5%1g+)6M4M^i+)x7Ym#@e~EUd zi<2o!CuBzGjtw~DywJq{z{GCNPEI*vao#aqud-+NJjFstk|bQdbm_v{+S;Su`$OUi zggaW|=xeWCdy_B2`_9_in$6~qTQf8Fy#v~&qPVQ(j!G-2AkM}4gsaMO)G^S`aYNN*)+U>Sq zxqSJDQ51bMkNJ1o;Co*W2qAFU_K!_zkI&SnroP>1H0~}Ii=*oY!-!6=Pq#l{FpN?R zpM}SW%@Be>D@w%z)pChirA#?v9lZB+yInTc*N=2Moo`udpOYDVlRrc8ZXWo+3gjhJ z2%&=@c&uEhe6?1q9V`}$69Y=VVUd@^d}N$pv-4plN$B_cbhfq*Z+E*tFiG;W{Fw2>DEE9&N;kSAJLvaM_WS+k2ZO;A z-ust?5N0$OWd-4bDDZbZt&){YgZD2ChQk+ny+g2_{{Y8&$Gox(* Date: Sat, 30 Jul 2011 19:46:19 +0200 Subject: [PATCH 0031/1438] fix highlighting to work in landscape, portrait, and other resolutions. thanks @wnafee for pointing out my mistake :) --- .../widgets/HighlightingImageView.java | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java index ba9744878f..1a9752c4c6 100644 --- a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java +++ b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java @@ -12,6 +12,7 @@ import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.RectF; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.ImageView; @@ -115,31 +116,19 @@ protected void onDraw(Canvas canvas) { for (AyahBounds b : currentlyHighlighting){ Bitmap bm = BitmapFactory.decodeResource( getResources(), R.drawable.highlight); - RectF rect = new RectF(b.getMinX(), b.getMinY(), - b.getMaxX(), b.getMaxY()); - if (canvas.getHeight() > canvas.getWidth()){ - /* - android.util.Log.d("highlight", "currently: " + - canvas.getHeight() + " " + - this.getHeight() + " and width: " + - canvas.getWidth() + " " + - this.getWidth()); - */ - - // portrait mode, need to adjust the rectangle - float factor = (float)((1.0 * canvas.getWidth()) / - (1.0 * canvas.getHeight())); - float maxY = (b.getMaxY() * factor); - float minY = (b.getMinY() * factor); - if (canvas.getHeight() == this.getHeight()){ - maxY += 12.5; - minY += 12.5; - } - RectF scaled = new RectF(b.getMinX() * factor, - minY, b.getMaxX() * factor, maxY); - rect = scaled; + + Drawable page = this.getDrawable(); + if (page != null){ + float widthFactor = (float)((1.0 * getWidth()) / + (1.0 * page.getIntrinsicWidth())); + float heightFactor = (float)((1.0 * getHeight()) / + (1.0 * page.getIntrinsicHeight())); + + RectF scaled = new RectF(b.getMinX() * widthFactor, + b.getMinY() * heightFactor, b.getMaxX() * widthFactor, + b.getMaxY() * heightFactor); + canvas.drawBitmap(bm, null, scaled, null); } - canvas.drawBitmap(bm, null, rect, null); } } } From e4d53f639830081a901e7d602cb32e051276dc05 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sun, 31 Jul 2011 01:08:54 +0200 Subject: [PATCH 0032/1438] Swap Next/Previous audio buttons --- .../labs/androidquran/QuranViewActivity.java | 32 ++++--------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index e9bc9f29b7..505670cf4a 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -50,23 +50,10 @@ public class QuranViewActivity extends PageViewQuranActivity implements private boolean bounded = false; private AudioServiceBinder quranAudioPlayer = null; - - // on Stop Actions - private static final int ACTION_BAR_ACTION_PLAY = 0; - - // on Play Actions - private static final int ACTION_BAR_ACTION_CHANGE_READER = 0; - private static final int ACTION_BAR_ACTION_JUMP_TO_AYAH = 1; - private static final int ACTION_BAR_ACTION_PREVIOUS = 2; - private static final int ACTION_BAR_ACTION_PAUSE = 3; - private static final int ACTION_BAR_ACTION_STOP = 4; - private static final int ACTION_BAR_ACTION_NEXT = 5; - private AyahItem lastAyah; private int currentReaderId; private HashMap actionBarActions = new HashMap(); - private HashMap actionBarIndecies = new HashMap(); // private TextView textView; @@ -114,14 +101,6 @@ protected void addActions() { actionBarActions.put(ACTION_JUMP_TO_AYAH, getIntentAction(ACTION_JUMP_TO_AYAH, R.drawable.ab_jump)); - actionBarIndecies.put(ACTION_PLAY, ACTION_BAR_ACTION_PLAY); - actionBarIndecies.put(ACTION_PAUSE, ACTION_BAR_ACTION_PAUSE); - actionBarIndecies.put(ACTION_NEXT, ACTION_BAR_ACTION_NEXT); - actionBarIndecies.put(ACTION_PREVIOUS, ACTION_BAR_ACTION_PREVIOUS); - actionBarIndecies.put(ACTION_STOP, ACTION_BAR_ACTION_STOP); - actionBarIndecies.put(ACTION_CHANGE_READER, ACTION_BAR_ACTION_CHANGE_READER); - actionBarIndecies.put(ACTION_JUMP_TO_AYAH, ACTION_BAR_ACTION_JUMP_TO_AYAH); - onActionStop(); } } @@ -159,12 +138,13 @@ protected void onNewIntent(Intent intent) { quranAudioPlayer.pause(); onActionStop(); } else if (action.equalsIgnoreCase(ACTION_NEXT)) { - lastAyah = QuranAudioLibrary.getNextAyahAudioItem(this, - getLastAyah()); + // Quick fix to switch actions + lastAyah = QuranAudioLibrary.getPreviousAyahAudioItem(this, getLastAyah()); if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) quranAudioPlayer.play(lastAyah); } else if (action.equalsIgnoreCase(ACTION_PREVIOUS)) { - lastAyah = QuranAudioLibrary.getPreviousAyahAudioItem(this, getLastAyah()); + lastAyah = QuranAudioLibrary.getNextAyahAudioItem(this, + getLastAyah()); if (quranAudioPlayer != null && quranAudioPlayer.isPlaying()) quranAudioPlayer.play(lastAyah); } else if (action.equalsIgnoreCase(ACTION_STOP)) { @@ -182,10 +162,10 @@ else if (action.equalsIgnoreCase(ACTION_JUMP_TO_AYAH)) { private void onActionPlay() { actionBar.removeAllActions(); - for (String action : actionBarIndecies.keySet()) { + for (String action : actionBarActions.keySet()) { if (ACTION_PLAY.equals(action)) continue; - actionBar.addAction(actionBarActions.get(action), actionBarIndecies.get(ACTION_PLAY)); + actionBar.addAction(actionBarActions.get(action), 0); } } From 5e67b7d84080b7e4fe34510dd210a19108711e04 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sun, 31 Jul 2011 01:39:07 +0200 Subject: [PATCH 0033/1438] Add on before ayah play event --- src/com/quran/labs/androidquran/QuranViewActivity.java | 10 ++++++++++ .../labs/androidquran/common/AyahStateListener.java | 1 + .../labs/androidquran/service/AudioServiceBinder.java | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 505670cf4a..f0e484c74a 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -546,4 +546,14 @@ protected void onConnectionSuccess() { } } + @Override + public void onAyahPlay(AyahItem ayah) { + int page = QuranInfo.getPageFromSuraAyah(ayah.getSoura(), ayah.getAyah()); + + if (quranPageFeeder.getCurrentPagePosition() != page) { + quranPageFeeder.jumpToPage(page); + updatePageInfo(page); + } + } + } diff --git a/src/com/quran/labs/androidquran/common/AyahStateListener.java b/src/com/quran/labs/androidquran/common/AyahStateListener.java index cdf793b15e..4c795e71bd 100644 --- a/src/com/quran/labs/androidquran/common/AyahStateListener.java +++ b/src/com/quran/labs/androidquran/common/AyahStateListener.java @@ -5,4 +5,5 @@ public interface AyahStateListener { void onAyahNotFound(AyahItem ayah); void onUnknownError(AyahItem ayah); void onConnectionLost(AyahItem ayah); + void onAyahPlay(AyahItem ayah); } diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index d09aec1132..786ca8f8b9 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -212,6 +212,8 @@ public synchronized void onPrepared(MediaPlayer mp) { stopped = false; if(!notified) showNotification(currentItem); + if (ayahListener != null) + ayahListener.onAyahPlay(currentItem); } } From 5424c86522be424d476641e617a0dec469522b27 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sun, 31 Jul 2011 01:41:00 +0200 Subject: [PATCH 0034/1438] Sync pages only on before playing ayah not on ayah completion --- src/com/quran/labs/androidquran/QuranViewActivity.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index f0e484c74a..b2e6237f16 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -444,13 +444,6 @@ public boolean onAyahComplete(AyahItem ayah, AyahItem nextAyah) { quranAudioPlayer.play(lastAyah); return false; } - int page = QuranInfo.getPageFromSuraAyah(nextAyah.getSoura(), nextAyah - .getAyah()); - - if (quranPageFeeder.getCurrentPagePosition() != page) { - quranPageFeeder.jumpToPage(page); - updatePageInfo(page); - } return true; } From d2d8afc9a59953c2ff568dd83fa7a71bc1417779 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sun, 31 Jul 2011 15:27:35 +0200 Subject: [PATCH 0035/1438] Pause only if was playing --- src/com/quran/labs/androidquran/common/IAudioPlayer.java | 2 ++ .../quran/labs/androidquran/receivers/CallStateListener.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/common/IAudioPlayer.java b/src/com/quran/labs/androidquran/common/IAudioPlayer.java index 51a17e7c04..7f32a059c5 100644 --- a/src/com/quran/labs/androidquran/common/IAudioPlayer.java +++ b/src/com/quran/labs/androidquran/common/IAudioPlayer.java @@ -17,5 +17,7 @@ public interface IAudioPlayer { public void enableRemotePlay(boolean remote); public boolean isRemotePlayEnabled(); + + public boolean isPlaying(); } diff --git a/src/com/quran/labs/androidquran/receivers/CallStateListener.java b/src/com/quran/labs/androidquran/receivers/CallStateListener.java index 140658d977..8645e0f830 100644 --- a/src/com/quran/labs/androidquran/receivers/CallStateListener.java +++ b/src/com/quran/labs/androidquran/receivers/CallStateListener.java @@ -25,7 +25,7 @@ public void onCallStateChanged(int state, String incomingNumber) { switch (state) { case TelephonyManager.CALL_STATE_OFFHOOK: case TelephonyManager.CALL_STATE_RINGING: - if(audioService != null) { + if(audioService != null && audioService.isPlaying()) { audioService.pause(); wasPaused = true; } From 8943236bc405f4f46cc366ad822c1425b9a252fb Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sun, 31 Jul 2011 16:59:15 +0200 Subject: [PATCH 0036/1438] If previous on basmala go to previous sura --- src/com/quran/labs/androidquran/util/QuranAudioLibrary.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java index 529f76fffa..695a1d2f64 100644 --- a/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java +++ b/src/com/quran/labs/androidquran/util/QuranAudioLibrary.java @@ -71,7 +71,7 @@ public static AyahItem getPreviousAyahItem(Context context, int currentSouraId, try{ int ayah = currentAyaId; int soura = currentSouraId; - if(currentAyaId == 1){ + if(currentAyaId <= 1){ soura--; if(soura == 0) soura = 114; ayah = QuranInfo.SURA_NUM_AYAHS[soura - 1]; From c1b553db34da84ef3517a86b7c347e8a3299cc45 Mon Sep 17 00:00:00 2001 From: fouad Date: Sun, 31 Jul 2011 17:57:24 +0200 Subject: [PATCH 0037/1438] fixing conflicts --- .../labs/androidquran/QuranViewActivity.java | 31 ++----------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 32bcc90aba..71558daf98 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -51,22 +51,8 @@ public class QuranViewActivity extends PageViewQuranActivity implements private boolean bounded = false; private AudioServiceBinder quranAudioPlayer = null; -<<<<<<< HEAD - - // on Stop Actions - private static final int ACTION_BAR_ACTION_PLAY = 0; - - // on Play Actions - private static final int ACTION_BAR_ACTION_CHANGE_READER = 0; - private static final int ACTION_BAR_ACTION_JUMP_TO_AYAH = 1; - private static final int ACTION_BAR_ACTION_PREVIOUS = 2; - private static final int ACTION_BAR_ACTION_PAUSE = 3; - private static final int ACTION_BAR_ACTION_STOP = 4; - private static final int ACTION_BAR_ACTION_NEXT = 5; - private static final int ACTION_BAR_ACTION_REPEAT = 6; - -======= ->>>>>>> origin/audio + + private AyahItem lastAyah; private int currentReaderId; @@ -119,18 +105,7 @@ protected void addActions() { getIntentAction(ACTION_JUMP_TO_AYAH, R.drawable.ab_jump)); actionBarActions.put(ACTION_REPEAT, getIntentAction(ACTION_REPEAT, R.drawable.repeat)); - -<<<<<<< HEAD - actionBarIndecies.put(ACTION_PLAY, ACTION_BAR_ACTION_PLAY); - actionBarIndecies.put(ACTION_PAUSE, ACTION_BAR_ACTION_PAUSE); - actionBarIndecies.put(ACTION_NEXT, ACTION_BAR_ACTION_NEXT); - actionBarIndecies.put(ACTION_PREVIOUS, ACTION_BAR_ACTION_PREVIOUS); - actionBarIndecies.put(ACTION_STOP, ACTION_BAR_ACTION_STOP); - actionBarIndecies.put(ACTION_CHANGE_READER, ACTION_BAR_ACTION_CHANGE_READER); - actionBarIndecies.put(ACTION_JUMP_TO_AYAH, ACTION_BAR_ACTION_JUMP_TO_AYAH); - actionBarIndecies.put(ACTION_REPEAT, ACTION_BAR_ACTION_REPEAT); -======= ->>>>>>> origin/audio + onActionStop(); } } From eecc1f0b60c5d29ac63117643d05beffd4f1bac9 Mon Sep 17 00:00:00 2001 From: fouad Date: Sun, 31 Jul 2011 18:03:53 +0200 Subject: [PATCH 0038/1438] hiding repeat now --- src/com/quran/labs/androidquran/QuranViewActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 71558daf98..e0da3c58a9 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -103,9 +103,9 @@ protected void addActions() { getIntentAction(ACTION_CHANGE_READER, R.drawable.mic)); actionBarActions.put(ACTION_JUMP_TO_AYAH, getIntentAction(ACTION_JUMP_TO_AYAH, R.drawable.ab_jump)); - actionBarActions.put(ACTION_REPEAT, - getIntentAction(ACTION_REPEAT, R.drawable.repeat)); - +// actionBarActions.put(ACTION_REPEAT, +// getIntentAction(ACTION_REPEAT, R.drawable.repeat)); +// onActionStop(); } } From b2c4a0cdd49f19c61a8cd7b2b0d282bdb7f06668 Mon Sep 17 00:00:00 2001 From: fouad Date: Sun, 31 Jul 2011 18:06:47 +0200 Subject: [PATCH 0039/1438] restoring default number of repeats to 0 --- src/com/quran/labs/androidquran/service/AudioServiceBinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index 977f204bd5..596947bd04 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -36,7 +36,7 @@ public class AudioServiceBinder extends Binder implements private boolean stopped = true; private boolean preparing = false; - private int numberOfRepeats = 2; + private int numberOfRepeats = 0; private int repeats = 0; public int getNumberOfRepeats() { From 4fd911f60eec6cd734f3ea69cc12487788f8bf19 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sun, 31 Jul 2011 18:58:06 +0200 Subject: [PATCH 0040/1438] Show sura number in notification bar --- .../labs/androidquran/service/AudioServiceBinder.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index 786ca8f8b9..2509819d63 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -40,8 +40,6 @@ public synchronized void setAyahCompleteListener(AyahStateListener ayahListener) this.ayahListener = ayahListener; } - - public AudioServiceBinder(Context context){ this.context = context; } @@ -250,8 +248,8 @@ private void showNotification(AyahItem item){ notification.setLatestEventInfo(context, context.getApplicationInfo().name, - QuranInfo.getSuraName(item.getSoura() -1) - + "(" + item.getAyah() + ")", pi); + item.getSoura() + " - " + QuranInfo.getSuraName(item.getSoura() -1) + + " (" + item.getAyah() + ")", pi); // notification.contentView = new RemoteViews("com.quran.labs.androidquran", // R.layout.audio_notification); @@ -268,8 +266,6 @@ public synchronized boolean isPlaying(){ return !paused && !stopped; } - - @Override public synchronized boolean onError(MediaPlayer mp, int what, int extra) { if(this.mp != null && mp.isPlaying()){ From d173e6b0dde423ae2d08f5dcd9e6eae11a681d33 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sun, 31 Jul 2011 19:03:01 +0200 Subject: [PATCH 0041/1438] Service fixes --- .../androidquran/service/QuranAudioService.java | 12 +++++++++--- .../androidquran/service/QuranDataService.java | 15 +++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/com/quran/labs/androidquran/service/QuranAudioService.java b/src/com/quran/labs/androidquran/service/QuranAudioService.java index 7db63d79ff..080b5afbce 100644 --- a/src/com/quran/labs/androidquran/service/QuranAudioService.java +++ b/src/com/quran/labs/androidquran/service/QuranAudioService.java @@ -15,7 +15,6 @@ public class QuranAudioService extends Service { private PhoneStateListener psl; private AudioServiceBinder mBinder; - @Override public void onCreate() { super.onCreate(); @@ -40,11 +39,18 @@ public IBinder onBind(Intent arg0) { return mBinder; } + // only runs on pre-2.0 sdks @Override public void onStart(Intent intent, int startId) { - super.onStart(intent, startId); + super.onStart(intent, startId); } - + // 2.0+ sdks + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + return START_STICKY; + } + + } diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 59b82e97f0..3144b40e36 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -96,23 +96,21 @@ public void handleStart(Intent intent, int startId) { return; int downloadType = intent.getIntExtra(DWONLOAD_TYPE_KEY, -1); - QuranDataService.isRunning = true; switch (downloadType) { case DOWNLOAD_QURAN_IMAGES: + isRunning = true; thread = new DownloadThread(this, new String[] { QuranUtils.getZipFileUrl() }, new String[] { "images.zip" }, new String[]{QuranUtils.getQuranBaseDirectory()}, true); thread.start(); break; case DOWNLOAD_SURA_AUDIO: + isRunning = true; downloadSuraAudio(intent); break; case DOWNLOAD_TRANSLATION: + isRunning = true; downloadTranslation(intent); break; - - default: - QuranDataService.isRunning = false; - return; } } @@ -166,7 +164,7 @@ private void downloadSuraAudio(Intent intent) { fileNames.toArray(new String[urls.size()]), directories.toArray(new String[urls.size()]), false); thread.start(); } else { - QuranDataService.isRunning = false; + isRunning = false; } } @@ -189,7 +187,7 @@ public void stop() { } progress = 0; thread = null; - QuranDataService.isRunning = false; + isRunning = false; } @Override @@ -332,6 +330,7 @@ private void updateProgress(int percent, int totalFiles, int nDownloadedFiles) { @Override public void run() { + isRunning = true; onDowloadStart(); try { while (isRunning) { @@ -418,7 +417,7 @@ private void onDownloadComplete() { notification); service.stopSelf(); - QuranDataService.isRunning = false; + isRunning = false; } } } From 48db23f7d260db686ebae2975d37a98f2f26dac4 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 00:31:14 +0200 Subject: [PATCH 0042/1438] fixes for action bar --- .../labs/androidquran/QuranViewActivity.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index e0da3c58a9..1a6be75602 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -55,6 +55,7 @@ public class QuranViewActivity extends PageViewQuranActivity implements private AyahItem lastAyah; private int currentReaderId; + private boolean playing = false; private HashMap actionBarActions = new HashMap(); @@ -125,6 +126,7 @@ protected void onNewIntent(Intent intent) { String action = intent.getAction(); if (quranAudioPlayer != null && action != null) { if (action.equalsIgnoreCase(ACTION_PLAY)) { + bindAudioService(); if (quranAudioPlayer.isPaused()) quranAudioPlayer.resume(); else { @@ -155,6 +157,7 @@ protected void onNewIntent(Intent intent) { } else if (action.equalsIgnoreCase(ACTION_STOP)) { lastAyah = null; quranAudioPlayer.stop(); + unBindAudioService(); onActionStop(); } else if (action.equalsIgnoreCase(ACTION_CHANGE_READER)){ showChangeReaderDialog(); @@ -172,6 +175,7 @@ private void onActionPlay() { continue; actionBar.addAction(actionBarActions.get(action), 0); } + playing =true; } private void onActionStop() { @@ -179,6 +183,7 @@ private void onActionStop() { actionBar.addAction(actionBarActions.get(ACTION_PLAY), 0); actionBar.addAction(actionBarActions.get(ACTION_CHANGE_READER), 1); actionBar.addAction(actionBarActions.get(ACTION_JUMP_TO_AYAH), 2); + playing = false; } private void showDownloadDialog(final AyahItem i) { @@ -476,6 +481,15 @@ protected void onFinishDownload() { playAudio(getLastAyah()); } } + + @Override + protected void onDownloadCanceled() { + super.onDownloadCanceled(); + if (quranAudioPlayer != null) { + quranAudioPlayer.stop(); + } + onActionStop(); + } private int getQuranReaderId() { return QuranSettings.getInstance().getLastReader(); @@ -552,6 +566,9 @@ public void onAyahPlay(AyahItem ayah) { quranPageFeeder.jumpToPage(page); updatePageInfo(page); } + + if (!playing) + onActionPlay(); } } From 0056f03f6e47c53d6fed7ac278c96c4dd9d4cbd7 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 00:43:27 +0200 Subject: [PATCH 0043/1438] Show notification for download started - Dont show progress for QVA (quick bad fix) --- .../androidquran/common/InternetActivity.java | 18 +++++++++-- .../service/QuranDataService.java | 32 +++++++++++-------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 87dce56437..5a851fcffe 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -13,6 +13,7 @@ import android.os.IBinder; import android.util.Log; +import com.quran.labs.androidquran.QuranViewActivity; import com.quran.labs.androidquran.R; import com.quran.labs.androidquran.service.QuranDataService; @@ -28,8 +29,9 @@ public abstract class InternetActivity extends BaseQuranActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initServiceConnection(); - if (QuranDataService.isRunning) - showProgressDialog(); + if (!(this instanceof QuranViewActivity)) + if (QuranDataService.isRunning) + showProgressDialog(); } public boolean isInternetOn() { @@ -153,6 +155,10 @@ public void onPostExecute(Void val){ protected void onFinishDownload() { + } + + protected void onDownloadCanceled() { + } private void showProgressDialog(){ @@ -164,6 +170,7 @@ private void showProgressDialog(){ @Override public void onClick(DialogInterface dialog, int which) { Log.d("QuranAndroid", "User canceled downloading.."); + onDownloadCanceled(); if (serviceConnection != null) { if (downloadService != null) { downloadService.stop(); @@ -175,6 +182,13 @@ public void onClick(DialogInterface dialog, int which) { pDialog.dismiss(); } }); + pDialog.setButton(ProgressDialog.BUTTON2, "Hide", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + currentTask.cancel(true); + pDialog.dismiss(); + } + }); pDialog.setMessage(getString(R.string.downloading_message)); pDialog.show(); diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 3144b40e36..80fb9a4634 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -235,19 +235,25 @@ private class DownloadThread extends Thread { } private void onDowloadStart() { -// String ns = Context.NOTIFICATION_SERVICE; -// notificationManager = (NotificationManager) getSystemService(ns); -// Context context = QuranDataService.this.getApplicationContext(); -// notification = new Notification(R.drawable.icon, "Quran Android", System.currentTimeMillis()); -// contentView = new RemoteViews(context.getPackageName(), R.layout.notification_progress_bar); -// contentView.setProgressBar(R.id.progressBar, 100, 0, false); -// contentView.setTextViewText(R.id.text, "Downloading.."); -// notification.contentView = contentView; -// -// Intent notificationIntent = new Intent(context, QuranActivity.class); -// PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); -// notification.contentIntent = contentIntent; -// notificationManager.notify(ApplicationConstants.NOTIFICATION_DOWNLOADING, notification); + String ns = Context.NOTIFICATION_SERVICE; + NotificationManager notificationManager = (NotificationManager) getSystemService(ns); + + long when = System.currentTimeMillis(); + Notification notification = new Notification(R.drawable.icon, "Downloading..", when); + notification.defaults |= Notification.FLAG_AUTO_CANCEL; + + Context context = getApplicationContext(); + CharSequence contentTitle = "Quran Android"; + CharSequence contentText = "Downloading.."; + Intent notificationIntent = new Intent(context, QuranActivity.class); + PendingIntent contentIntent = PendingIntent.getActivity(context, 0, + notificationIntent, 0); + + notification.setLatestEventInfo(context, contentTitle, contentText, + contentIntent); + + notificationManager.notify(ApplicationConstants.NOTIFICATION_DOWNLOADING, + notification); } private boolean resumeDownload() { From 8f2ea1bd2c6f43a753ed5c53793e69c6f079ee12 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 03:39:45 +0200 Subject: [PATCH 0044/1438] Partial commit --- .../labs/androidquran/QuranViewActivity.java | 4 ++++ .../labs/androidquran/common/QuranPageFeeder.java | 4 ++++ .../androidquran/service/QuranDataService.java | 15 +++++++++++++++ .../labs/androidquran/util/QuranScreenInfo.java | 6 ++++++ .../quran/labs/androidquran/util/QuranUtils.java | 9 +++++++++ 5 files changed, 38 insertions(+) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 1a6be75602..79ba141e53 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -452,6 +452,8 @@ public boolean onAyahComplete(AyahItem ayah, AyahItem nextAyah) { lastAyah = QuranAudioLibrary.getAyahItem(this, nextAyah.getSoura(), nextAyah.getAyah(), getQuranReaderId()); quranAudioPlayer.play(lastAyah); + + quranPageFeeder.unHighlightAyah(); return false; } return true; @@ -567,6 +569,8 @@ public void onAyahPlay(AyahItem ayah) { updatePageInfo(page); } + quranPageFeeder.highlightAyah(ayah.getSoura(), ayah.getAyah()); + if (!playing) onActionPlay(); } diff --git a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java index 4d40cd61e5..941507cdd6 100644 --- a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java +++ b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java @@ -110,6 +110,8 @@ public void highlightAyah(int sura, int ayah){ if (iv != null){ HighlightingImageView hi = (HighlightingImageView)iv; hi.highlightAyah(sura, ayah); + hi.invalidate(); + hi.refreshDrawableState(); } } @@ -120,6 +122,8 @@ public void unHighlightAyah(){ if (iv != null){ HighlightingImageView hi = (HighlightingImageView)iv; hi.unhighlight(); + hi.invalidate(); + hi.refreshDrawableState(); } } diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 80fb9a4634..c7b36c7463 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -4,6 +4,7 @@ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.net.HttpURLConnection; @@ -159,6 +160,18 @@ private void downloadSuraAudio(Intent intent) { } } + // Check aya info db + String base = QuranUtils.getQuranDatabaseDirectory(); + if (base == null) + QuranUtils.makeQuranDatabaseDirectory(); + String ayaPositionDb = base + File.separator + "ayahinfo.db"; + File f = new File(ayaPositionDb); + if (!f.exists()) { + urls.add(QuranUtils.getAyaPositionFileUrl()); + fileNames.add("ayahinfo.db"); + directories.add(base); + } + if (urls.size() > 0) { thread = new DownloadThread(this, urls.toArray(new String[urls.size()]), fileNames.toArray(new String[urls.size()]), directories.toArray(new String[urls.size()]), false); @@ -313,6 +326,8 @@ private boolean resumeDownload() { } else return false; } + } catch (FileNotFoundException e) { + Log.e("quran_srv", "File not found: IO Exception", e); } catch (IOException e) { Log.e("quran_srv", "Download paused: IO Exception", e); return false; diff --git a/src/com/quran/labs/androidquran/util/QuranScreenInfo.java b/src/com/quran/labs/androidquran/util/QuranScreenInfo.java index ed05efce4f..1086bbbfbc 100644 --- a/src/com/quran/labs/androidquran/util/QuranScreenInfo.java +++ b/src/com/quran/labs/androidquran/util/QuranScreenInfo.java @@ -35,6 +35,12 @@ public String getWidthParam(){ else return "_1024"; } + public String getWidthParamNoUnderScore(){ + if (this.max_width <= 480) return "480"; + else if (this.max_width <= 800) return "800"; + else return "1024"; + } + public boolean isLandscapeOrientation() { return this.orientation == Configuration.ORIENTATION_LANDSCAPE; } diff --git a/src/com/quran/labs/androidquran/util/QuranUtils.java b/src/com/quran/labs/androidquran/util/QuranUtils.java index d4a6df8355..710475721b 100644 --- a/src/com/quran/labs/androidquran/util/QuranUtils.java +++ b/src/com/quran/labs/androidquran/util/QuranUtils.java @@ -247,6 +247,15 @@ public static String getZipFileUrl() { url += "images" + qsi.getWidthParam() + ".zip"; return url; } + + public static String getAyaPositionFileUrl() { + String url = IMG_HOST; + QuranScreenInfo qsi = QuranScreenInfo.getInstance(); + if (qsi == null) + return null; + url += "databases/ayahinfo" + qsi.getWidthParamNoUnderScore() + ".db.zip"; + return url; + } public static boolean hasTranslation(String fileName) { String path = getQuranDatabaseDirectory(); From d398a42e3d1781fdeebd55bd9ca59a13bf864d1a Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 05:31:53 +0200 Subject: [PATCH 0045/1438] zip --- .../quran/labs/androidquran/service/QuranDataService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index c7b36c7463..53ba577239 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -58,7 +58,7 @@ public class QuranDataService extends Service { * Wait time in seconds.. Time to wait before re-checking for internet * connection.. */ - private static final int WAIT_TIME = 30; + private static final int WAIT_TIME = 15; public class QuranDownloadBinder extends Binder { public QuranDataService getService() { @@ -168,7 +168,7 @@ private void downloadSuraAudio(Intent intent) { File f = new File(ayaPositionDb); if (!f.exists()) { urls.add(QuranUtils.getAyaPositionFileUrl()); - fileNames.add("ayahinfo.db"); + fileNames.add("ayahinfo.db.zip"); directories.add(base); } @@ -319,7 +319,7 @@ private boolean resumeDownload() { if (isRunning) { file.renameTo(new File(saveToDirectories[downloadIndex], fileNames[downloadIndex])); - if (zipped) + if (zipped || fileNames[downloadIndex].endsWith(".zip")) unzipFile(saveToDirectories[downloadIndex], fileNames[downloadIndex]); Log.d("quran_srv", "Download Completed [" + downloadUrls[downloadIndex] + "]"); From 1f6d216dc8108a7893cf11832682093ebd3d0fd6 Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 1 Aug 2011 12:55:00 +0200 Subject: [PATCH 0046/1438] -- nothing --- src/com/quran/labs/androidquran/QuranViewActivity.java | 1 + .../quran/labs/androidquran/service/QuranAudioService.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index e0da3c58a9..439dca993e 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -476,6 +476,7 @@ protected void onFinishDownload() { playAudio(getLastAyah()); } } + private int getQuranReaderId() { return QuranSettings.getInstance().getLastReader(); diff --git a/src/com/quran/labs/androidquran/service/QuranAudioService.java b/src/com/quran/labs/androidquran/service/QuranAudioService.java index 7db63d79ff..1c734f4fe3 100644 --- a/src/com/quran/labs/androidquran/service/QuranAudioService.java +++ b/src/com/quran/labs/androidquran/service/QuranAudioService.java @@ -40,6 +40,11 @@ public IBinder onBind(Intent arg0) { return mBinder; } + @Override + public boolean onUnbind(Intent intent) { + // TODO Auto-generated method stub + return true; + } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); From 287ba204d25a294eb47465bba5040fffaeccdd86 Mon Sep 17 00:00:00 2001 From: ahmedre Date: Mon, 1 Aug 2011 14:01:42 +0200 Subject: [PATCH 0047/1438] fix highlighting to work automatically without needing a tap when switching ayahs. --- src/com/quran/labs/androidquran/common/QuranPageFeeder.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java index 941507cdd6..6e55bd1c9d 100644 --- a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java +++ b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java @@ -110,8 +110,7 @@ public void highlightAyah(int sura, int ayah){ if (iv != null){ HighlightingImageView hi = (HighlightingImageView)iv; hi.highlightAyah(sura, ayah); - hi.invalidate(); - hi.refreshDrawableState(); + mQuranPage.invalidate(); } } @@ -122,8 +121,7 @@ public void unHighlightAyah(){ if (iv != null){ HighlightingImageView hi = (HighlightingImageView)iv; hi.unhighlight(); - hi.invalidate(); - hi.refreshDrawableState(); + mQuranPage.invalidate(); } } From 083731fe4f0a9462c1804c9385b3ff572c18b619 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 14:49:22 +0200 Subject: [PATCH 0048/1438] Unzip file --- .../labs/androidquran/common/InternetActivity.java | 3 ++- .../labs/androidquran/service/QuranDataService.java | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 5a851fcffe..10e7e64671 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -185,7 +185,8 @@ public void onClick(DialogInterface dialog, int which) { pDialog.setButton(ProgressDialog.BUTTON2, "Hide", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - currentTask.cancel(true); + if (currentTask != null) + currentTask.cancel(true); pDialog.dismiss(); } }); diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 53ba577239..7ad8a35861 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -378,11 +378,11 @@ public void run() { protected void unzipFile(String saveToDirectory, String fileName) { try { + Log.d("quran_srv", "Unziping file: " + saveToDirectory + fileName); // success, unzip the file... File file = new File(saveToDirectory, fileName); FileInputStream is = new FileInputStream(file); ZipInputStream zis = new ZipInputStream(is); - String base = QuranUtils.getQuranBaseDirectory(); ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { @@ -392,10 +392,9 @@ protected void unzipFile(String saveToDirectory, String fileName) { } // ignore files that already exist - File f = new File(base + entry.getName()); + File f = new File(saveToDirectory, entry.getName()); if (!f.exists()) { - FileOutputStream ostream = new FileOutputStream(base - + entry.getName()); + FileOutputStream ostream = new FileOutputStream(f); int size; byte[] buf = new byte[DOWNLOAD_BUFFER_SIZE]; @@ -410,8 +409,9 @@ protected void unzipFile(String saveToDirectory, String fileName) { is.close(); file.delete(); + Log.d("quran_srv", "file unzipped successfully"); } catch (IOException ioe) { - Log.e("quran_srv", "io exception: ", ioe); + Log.e("quran_srv", "Error unzipping file: io exception: ", ioe); } } From f3d89e448d8b0d74c9959fa004f9b3f583d62408 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 14:51:45 +0200 Subject: [PATCH 0049/1438] Juz bounds --- src/com/quran/labs/androidquran/data/QuranInfo.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/quran/labs/androidquran/data/QuranInfo.java b/src/com/quran/labs/androidquran/data/QuranInfo.java index de51abdf4d..3a3d058c3d 100644 --- a/src/com/quran/labs/androidquran/data/QuranInfo.java +++ b/src/com/quran/labs/androidquran/data/QuranInfo.java @@ -315,4 +315,17 @@ public static String getPageTitle(int page) { //return getPageTitle() + page + //" - " + getSuraTitle() + " " + getSuraNameFromPage(page) + "\n" + getJuzTitle() + " " + getJuzFromPage(page); } + + public static int [] getJuzBounds(int juz) { + int [] results = new int [4]; + int spage = JUZ_PAGE_START[juz - 1]; + int epage = juz == 30 ? ApplicationConstants.PAGES_LAST : JUZ_PAGE_START[juz]; + Integer [] bounds = getPageBounds(spage); + results[0] = bounds[0]; + results[1] = bounds[1]; + bounds = getPageBounds(epage); + results[2] = bounds[0]; + results[3] = bounds[1]; + return results; + } } From a425cddae404c680cbf1b9142b90a722f3262a7e Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 15:09:47 +0200 Subject: [PATCH 0050/1438] return Integer --- src/com/quran/labs/androidquran/data/QuranInfo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/quran/labs/androidquran/data/QuranInfo.java b/src/com/quran/labs/androidquran/data/QuranInfo.java index 3a3d058c3d..cb1dd10152 100644 --- a/src/com/quran/labs/androidquran/data/QuranInfo.java +++ b/src/com/quran/labs/androidquran/data/QuranInfo.java @@ -316,8 +316,8 @@ public static String getPageTitle(int page) { //" - " + getSuraTitle() + " " + getSuraNameFromPage(page) + "\n" + getJuzTitle() + " " + getJuzFromPage(page); } - public static int [] getJuzBounds(int juz) { - int [] results = new int [4]; + public static Integer [] getJuzBounds(int juz) { + Integer [] results = new Integer [4]; int spage = JUZ_PAGE_START[juz - 1]; int epage = juz == 30 ? ApplicationConstants.PAGES_LAST : JUZ_PAGE_START[juz]; Integer [] bounds = getPageBounds(spage); From 5708aae411c13c464d31e75fb641d97dc725039a Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 1 Aug 2011 15:25:22 +0200 Subject: [PATCH 0051/1438] -- show download options --- src/com/quran/labs/androidquran/QuranViewActivity.java | 1 - src/com/quran/labs/androidquran/common/InternetActivity.java | 3 ++- src/com/quran/labs/androidquran/service/QuranDataService.java | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 9de18afd9c..973a2ed2e1 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -4,7 +4,6 @@ import java.util.HashMap; import android.app.AlertDialog; -import android.app.AlertDialog.Builder; import android.content.ComponentName; import android.content.DialogInterface; import android.content.Intent; diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 779e8dcece..5fc8b3e7a0 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -15,6 +15,7 @@ import com.quran.labs.androidquran.QuranViewActivity; import com.quran.labs.androidquran.R; +import com.quran.labs.androidquran.data.QuranInfo; import com.quran.labs.androidquran.service.QuranDataService; public abstract class InternetActivity extends BaseQuranActivity { @@ -121,7 +122,7 @@ protected void downloadPage(int readerId, Integer[] integers){ } protected void downloadJuza(int readerId, Integer juza){ - Intent intent = new Intent(this, QuranDataService.class); + downloadPage(readerId, QuranInfo.getJuzBounds(juza)); } private void initServiceConnection() { diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 30a7812d50..9dc06cd4b4 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -179,8 +179,7 @@ private void downloadSuraAudio(Intent intent) { urls.add(ayah.getRemoteImageUrl()); } } - } - + } if (urls.size() > 0) { thread = new DownloadThread(this, urls.toArray(new String[urls.size()]), fileNames.toArray(new String[urls.size()]), directories.toArray(new String[urls.size()]), false); From 54c1ef35b36acfc685b3903524caddb57111baa3 Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 1 Aug 2011 15:48:33 +0200 Subject: [PATCH 0052/1438] clean, format quran audio => set current ayah to null on stop reuse same media player instead of releasing it --- .../quran/labs/androidquran/DownloadActivity.java | 4 ++-- src/com/quran/labs/androidquran/SearchActivity.java | 2 +- .../androidquran/common/TranslationsDBAdapter.java | 4 ++-- .../labs/androidquran/data/QuranDataProvider.java | 6 +++--- .../androidquran/service/AudioServiceBinder.java | 12 +++++++----- .../labs/androidquran/service/QuranDataService.java | 2 +- .../labs/androidquran/widgets/SeekBarPreference.java | 4 ++-- .../widgets/SelectTranslationPreference.java | 6 +++--- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/com/quran/labs/androidquran/DownloadActivity.java b/src/com/quran/labs/androidquran/DownloadActivity.java index dc9b2c2641..acc57ef0aa 100644 --- a/src/com/quran/labs/androidquran/DownloadActivity.java +++ b/src/com/quran/labs/androidquran/DownloadActivity.java @@ -13,18 +13,18 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.os.AsyncTask; -import android.os.AsyncTask.Status; import android.os.Bundle; +import android.os.AsyncTask.Status; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.CheckBox; import android.widget.ListView; import android.widget.TextView; +import android.widget.AdapterView.OnItemClickListener; import com.google.gson.Gson; import com.quran.labs.androidquran.common.DownloadItem; diff --git a/src/com/quran/labs/androidquran/SearchActivity.java b/src/com/quran/labs/androidquran/SearchActivity.java index 5e5f7bf45b..1eb29149c7 100644 --- a/src/com/quran/labs/androidquran/SearchActivity.java +++ b/src/com/quran/labs/androidquran/SearchActivity.java @@ -14,11 +14,11 @@ import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; +import android.widget.AdapterView.OnItemClickListener; import com.quran.labs.androidquran.common.BaseQuranActivity; import com.quran.labs.androidquran.common.TranslationItem; diff --git a/src/com/quran/labs/androidquran/common/TranslationsDBAdapter.java b/src/com/quran/labs/androidquran/common/TranslationsDBAdapter.java index e5e9a7c658..2269c2e3a3 100644 --- a/src/com/quran/labs/androidquran/common/TranslationsDBAdapter.java +++ b/src/com/quran/labs/androidquran/common/TranslationsDBAdapter.java @@ -2,8 +2,6 @@ import java.util.ArrayList; -import com.quran.labs.androidquran.util.QuranSettings; - import android.content.ContentValues; import android.content.Context; import android.database.Cursor; @@ -12,6 +10,8 @@ import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; +import com.quran.labs.androidquran.util.QuranSettings; + public class TranslationsDBAdapter { private static final int DATABASE_VERSION = 2; diff --git a/src/com/quran/labs/androidquran/data/QuranDataProvider.java b/src/com/quran/labs/androidquran/data/QuranDataProvider.java index 2723e2169f..e6244fd05d 100644 --- a/src/com/quran/labs/androidquran/data/QuranDataProvider.java +++ b/src/com/quran/labs/androidquran/data/QuranDataProvider.java @@ -2,9 +2,6 @@ import java.util.List; -import com.quran.labs.androidquran.common.TranslationItem; -import com.quran.labs.androidquran.common.TranslationsDBAdapter; - import android.app.SearchManager; import android.content.ContentProvider; import android.content.ContentResolver; @@ -16,6 +13,9 @@ import android.provider.BaseColumns; import android.util.Log; +import com.quran.labs.androidquran.common.TranslationItem; +import com.quran.labs.androidquran.common.TranslationsDBAdapter; + public class QuranDataProvider extends ContentProvider { public static String AUTHORITY = diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index 707bd68e20..a4b19c05f1 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -75,6 +75,7 @@ public synchronized void stop() { } paused = false; stopped = true; + currentItem = null; clearNotification(); } @@ -96,10 +97,10 @@ public synchronized void play(AyahItem item) { this.currentItem = item; if(mp != null && mp.isPlaying()){ mp.stop(); - try{ - mp.release(); - }catch(Exception e){} - mp = null; +// try{ +// mp.release(); +// }catch(Exception e){} +// mp = null; } try { if(mp == null) @@ -296,7 +297,8 @@ public synchronized boolean onError(MediaPlayer mp, int what, int extra) { if(mp != this.mp && mp.isPlaying()) mp.stop(); }catch (Exception e) { - // TODO: handle exception + try{mp.release();}catch(Exception ex){} + mp = null; } } if(ayahListener != null && !stopped) { diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 9dc06cd4b4..09fa84f088 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -9,9 +9,9 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; +import java.util.ArrayList; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import java.util.ArrayList; import android.app.Notification; import android.app.NotificationManager; diff --git a/src/com/quran/labs/androidquran/widgets/SeekBarPreference.java b/src/com/quran/labs/androidquran/widgets/SeekBarPreference.java index 6c153e1c9c..6beef584db 100644 --- a/src/com/quran/labs/androidquran/widgets/SeekBarPreference.java +++ b/src/com/quran/labs/androidquran/widgets/SeekBarPreference.java @@ -6,8 +6,6 @@ package com.quran.labs.androidquran.widgets; -import com.quran.labs.androidquran.data.ApplicationConstants; - import android.content.Context; import android.preference.DialogPreference; import android.util.AttributeSet; @@ -17,6 +15,8 @@ import android.widget.SeekBar; import android.widget.TextView; +import com.quran.labs.androidquran.data.ApplicationConstants; + public class SeekBarPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener { private static final String androidns = "http://schemas.android.com/apk/res/android"; diff --git a/src/com/quran/labs/androidquran/widgets/SelectTranslationPreference.java b/src/com/quran/labs/androidquran/widgets/SelectTranslationPreference.java index 54452f5e72..180e92b697 100644 --- a/src/com/quran/labs/androidquran/widgets/SelectTranslationPreference.java +++ b/src/com/quran/labs/androidquran/widgets/SelectTranslationPreference.java @@ -1,12 +1,12 @@ package com.quran.labs.androidquran.widgets; -import com.quran.labs.androidquran.common.TranslationItem; -import com.quran.labs.androidquran.common.TranslationsDBAdapter; - import android.content.Context; import android.preference.ListPreference; import android.util.AttributeSet; +import com.quran.labs.androidquran.common.TranslationItem; +import com.quran.labs.androidquran.common.TranslationsDBAdapter; + public class SelectTranslationPreference extends ListPreference { public SelectTranslationPreference(Context context, AttributeSet attrs) { From 55d55105464a177fcf9b47e567c6b069ee88bded Mon Sep 17 00:00:00 2001 From: fouad Date: Mon, 1 Aug 2011 17:04:32 +0200 Subject: [PATCH 0053/1438] -- adding number of tries before throw error --- .../service/AudioServiceBinder.java | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index a4b19c05f1..098ed87959 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -36,7 +36,12 @@ public class AudioServiceBinder extends Binder implements private boolean stopped = true; private boolean preparing = false; - private int numberOfRepeats = 0; + private int numberOfRepeats = 0; + + private int errorCount = 0; + private int numberOfTries = 3; + private String url; + private int repeats = 0; public int getNumberOfRepeats() { @@ -107,7 +112,7 @@ public synchronized void play(AyahItem item) { mp = new MediaPlayer(); mp.reset(); mp.setOnCompletionListener(this); - String url = null; + url = null; if(item.isAudioFoundLocally()) url = item.getLocalAudioUrl(); else if(remotePlayEnabled) { @@ -215,6 +220,7 @@ public void destory(){ @Override public synchronized void onPrepared(MediaPlayer mp) { + errorCount = 0; preparing = false; this.mp = mp; if(stopped){ @@ -301,12 +307,30 @@ public synchronized boolean onError(MediaPlayer mp, int what, int extra) { mp = null; } } - if(ayahListener != null && !stopped) { - if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) - ayahListener.onConnectionLost(currentItem); - else - ayahListener.onUnknownError(currentItem); + if(errorCount >= numberOfTries || url == null || mp == null){ + errorCount = 0; + if(ayahListener != null && !stopped) { + if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) + ayahListener.onConnectionLost(currentItem); + else + ayahListener.onUnknownError(currentItem); + } + }else{ + try { + errorCount++; + mp.stop(); + mp.reset(); + mp.setDataSource(url); + mp.prepareAsync(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalStateException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } } + return true; } From b9de9e7e4c04efa3f136175d351610c5fa7e2e2f Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 17:44:38 +0200 Subject: [PATCH 0054/1438] Progress dialog --- .../labs/androidquran/QuranViewActivity.java | 2 +- .../androidquran/common/InternetActivity.java | 65 ++++++++++--------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 1a6be75602..a5451b5e88 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -314,7 +314,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } }); dialogBuilder.setView(view); - dialogBuilder.setMessage("Jumo to ayah"); + dialogBuilder.setMessage("Jump to ayah"); dialogBuilder.setPositiveButton("Jump", new DialogInterface.OnClickListener() { diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 5a851fcffe..c295cce1f4 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -13,7 +13,6 @@ import android.os.IBinder; import android.util.Log; -import com.quran.labs.androidquran.QuranViewActivity; import com.quran.labs.androidquran.R; import com.quran.labs.androidquran.service.QuranDataService; @@ -23,15 +22,23 @@ public abstract class InternetActivity extends BaseQuranActivity { protected QuranDataService downloadService; protected AsyncTask currentTask = null; protected boolean starting = true; - protected ServiceConnection serviceConnection; + protected ServiceConnection serviceConnection = new ServiceConnection() { + public void onServiceConnected(ComponentName name, IBinder service){ + downloadService = ((QuranDataService.QuranDownloadBinder)service).getService(); + starting = false; + if (QuranDataService.isRunning) + currentTask = new ProgressBarUpdateTask().execute(); + } + + public void onServiceDisconnected(ComponentName className) { + downloadService = null; + } + };; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - initServiceConnection(); - if (!(this instanceof QuranViewActivity)) - if (QuranDataService.isRunning) - showProgressDialog(); + startDownloadService(new Intent(this, QuranDataService.class)); } public boolean isInternetOn() { @@ -73,12 +80,10 @@ public void onClick(DialogInterface dialog, int id) { protected void startDownloadService(Intent intent) { starting = true; - initServiceConnection(); if (!QuranDataService.isRunning) startService(intent); bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); - showProgressDialog(); } protected void downloadTranslation(String url, String fileName) { @@ -108,20 +113,10 @@ protected void downloadSura(int readerId, int sura, int ayah) { startDownloadService(intent); } - private void initServiceConnection() { - serviceConnection = new ServiceConnection() { - public void onServiceConnected(ComponentName name, IBinder service){ - downloadService = ((QuranDataService.QuranDownloadBinder)service).getService(); - starting = false; - } - - public void onServiceDisconnected(ComponentName className) { - downloadService = null; - } - }; - } - - class ProgressBarUpdateTask extends AsyncTask { + class ProgressBarUpdateTask extends AsyncTask { + + private boolean callOnFinish = false; + @Override protected Void doInBackground(Void... params) { while (starting || QuranDataService.isRunning){ @@ -134,22 +129,30 @@ protected Void doInBackground(Void... params) { } catch (InterruptedException ie){} } + callOnFinish = true; return null; } @Override public void onProgressUpdate(Integer...integers){ + if (pDialog == null) + showProgressDialog(); int progress = integers[0]; pDialog.setProgress(progress); } @Override public void onPostExecute(Void val){ - pDialog.dismiss(); + try { + pDialog.dismiss(); + } catch (Exception e) { + + } pDialog = null; currentTask = null; - onFinishDownload(); + if (callOnFinish) + onFinishDownload(); } } @@ -178,22 +181,24 @@ public void onClick(DialogInterface dialog, int which) { unbindService(serviceConnection); } stopService(new Intent(getApplicationContext(), QuranDataService.class)); - currentTask = null; - pDialog.dismiss(); + if (currentTask != null) + currentTask.cancel(true); + if (pDialog != null) + pDialog.dismiss(); } }); pDialog.setButton(ProgressDialog.BUTTON2, "Hide", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - currentTask.cancel(true); - pDialog.dismiss(); + if (currentTask != null) + currentTask.cancel(true); + if (pDialog != null) + pDialog.dismiss(); } }); pDialog.setMessage(getString(R.string.downloading_message)); pDialog.show(); - - currentTask = new ProgressBarUpdateTask().execute(); } } From c27465949f85818629df8ef2d7b8b4906033a703 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Mon, 1 Aug 2011 18:09:35 +0200 Subject: [PATCH 0055/1438] Show dialog on download start --- .../androidquran/common/InternetActivity.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 1beb0d6f3f..ea82278f6c 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -85,6 +85,7 @@ protected void startDownloadService(Intent intent) { startService(intent); bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); + currentTask = new ProgressBarUpdateTask().execute(); } protected void downloadTranslation(String url, String fileName) { @@ -136,7 +137,9 @@ class ProgressBarUpdateTask extends AsyncTask { @Override protected Void doInBackground(Void... params) { + boolean wasRunning = false; while (starting || QuranDataService.isRunning){ + wasRunning = QuranDataService.isRunning; try { Thread.sleep(1000); if ((serviceConnection != null) && (downloadService != null)){ @@ -146,17 +149,19 @@ protected Void doInBackground(Void... params) { } catch (InterruptedException ie){} } - callOnFinish = true; + callOnFinish = true && wasRunning; return null; } @Override public void onProgressUpdate(Integer...integers){ - if (pDialog == null) - showProgressDialog(); - int progress = integers[0]; - pDialog.setProgress(progress); + int progress = integers[0]; + if (progress > 0) { + if (pDialog == null) + showProgressDialog(); + pDialog.setProgress(progress); + } } @Override From 4e4a60249a27cbf834d59db4611eb9f1843240c0 Mon Sep 17 00:00:00 2001 From: ahmedre Date: Tue, 2 Aug 2011 02:45:14 +0200 Subject: [PATCH 0056/1438] fix broken downloads. changed server containing files due to load and slow performance. --- .../labs/androidquran/service/QuranDataService.java | 9 +++++++-- src/com/quran/labs/androidquran/util/QuranUtils.java | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index cda3de559d..5462397286 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -291,6 +291,8 @@ private void onDowloadStart() { notification); } + // based on: + // http://stackoverflow.com/questions/6237079/resume-http-file-download-in-java private boolean resumeDownload() { BufferedInputStream in = null; FileOutputStream fos = null; @@ -298,7 +300,7 @@ private boolean resumeDownload() { try { for (; downloadIndex < fileNames.length; downloadIndex++) { - int downloaded = 0; ; + int downloaded = 0; File f = new File(saveToDirectories[downloadIndex]); f.mkdirs(); File file = new File(saveToDirectories[downloadIndex], @@ -322,7 +324,7 @@ private boolean resumeDownload() { connection.setRequestProperty("Range", "bytes=" + downloaded + "-"); connection.setDoInput(true); - in = new BufferedInputStream(connection.getInputStream()); + in = new BufferedInputStream(connection.getInputStream(), DOWNLOAD_BUFFER_SIZE); fos = (downloaded == 0) ? new FileOutputStream(file .getAbsolutePath()) : new FileOutputStream(file .getAbsolutePath(), true); @@ -337,6 +339,9 @@ private boolean resumeDownload() { double percent = 100.0 * ((1.0 * downloaded) / (1.0 * total)); updateProgress((int) percent, fileNames.length, downloadIndex); } + bout.flush(); + bout.close(); + fos.close(); if (isRunning) { file.renameTo(new File(saveToDirectories[downloadIndex], fileNames[downloadIndex])); diff --git a/src/com/quran/labs/androidquran/util/QuranUtils.java b/src/com/quran/labs/androidquran/util/QuranUtils.java index 710475721b..b73ea03542 100644 --- a/src/com/quran/labs/androidquran/util/QuranUtils.java +++ b/src/com/quran/labs/androidquran/util/QuranUtils.java @@ -17,7 +17,7 @@ public class QuranUtils { public static boolean failedToWrite = false; - public static String IMG_HOST = "http://labs.quran.com/androidquran/"; + public static String IMG_HOST = "http://downthestreetfromyou.com/androidquran/"; private static String QURAN_BASE = File.separator + "quran_android" + File.separator; private static String DATABASE_DIRECTORY = "databases"; From 3a25b3c241fa05e2ac628000146dc394a1f96d2c Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 02:49:40 +0200 Subject: [PATCH 0057/1438] Notifications --- .../service/QuranDataService.java | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 09fa84f088..72c27b2b58 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -256,16 +256,31 @@ private class DownloadThread extends Thread { } private void onDowloadStart() { + showNotification(ApplicationConstants.NOTIFICATION_DOWNLOADING, + "Downloading..", Notification.FLAG_AUTO_CANCEL); + } + + private void onDownloadPaused() { + showNotification(ApplicationConstants.NOTIFICATION_DOWNLOADING, + "Download Paused", Notification.FLAG_AUTO_CANCEL); + } + + private void onDownloadCanceled() { + showNotification(ApplicationConstants.NOTIFICATION_DOWNLOADING, + "Download Canceled", Notification.FLAG_AUTO_CANCEL); + } + + private void showNotification(int notificationId, String msg, int flags) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager notificationManager = (NotificationManager) getSystemService(ns); long when = System.currentTimeMillis(); - Notification notification = new Notification(R.drawable.icon, "Downloading..", when); - notification.defaults |= Notification.FLAG_AUTO_CANCEL; + Notification notification = new Notification(R.drawable.icon, msg, when); + notification.defaults |= flags; Context context = getApplicationContext(); CharSequence contentTitle = "Quran Android"; - CharSequence contentText = "Downloading.."; + CharSequence contentText = msg; Intent notificationIntent = new Intent(context, QuranActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); @@ -273,11 +288,11 @@ private void onDowloadStart() { notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); - notificationManager.notify(ApplicationConstants.NOTIFICATION_DOWNLOADING, - notification); + notificationManager.notify(notificationId, notification); } private boolean resumeDownload() { + onDowloadStart(); BufferedInputStream in = null; FileOutputStream fos = null; BufferedOutputStream bout = null; @@ -358,7 +373,6 @@ private void updateProgress(int percent, int totalFiles, int nDownloadedFiles) { @Override public void run() { isRunning = true; - onDowloadStart(); try { while (isRunning) { if (isInternetOn() && resumeDownload()) { @@ -367,10 +381,12 @@ public void run() { break; } if (!isRunning) { + onDownloadCanceled(); Log.d("quran_srv", "Canceled"); break; } try { + onDownloadPaused(); Log.d("quran_srv", "Disconnected.. Retring after " + WAIT_TIME + " seconds"); sleep(WAIT_TIME * 1000); } catch (InterruptedException e) { @@ -425,24 +441,12 @@ private void onDownloadComplete() { String ns = Context.NOTIFICATION_SERVICE; NotificationManager notificationManager = (NotificationManager) getSystemService(ns); notificationManager.cancel(ApplicationConstants.NOTIFICATION_DOWNLOADING); - - long when = System.currentTimeMillis(); - Notification notification = new Notification(R.drawable.icon, "Download Completed", when); - notification.defaults |= Notification.DEFAULT_SOUND | Notification.FLAG_AUTO_CANCEL; - - Context context = getApplicationContext(); - CharSequence contentTitle = "Quran Android"; - CharSequence contentText = "Download Completed"; - Intent notificationIntent = new Intent(context, QuranActivity.class); - PendingIntent contentIntent = PendingIntent.getActivity(context, 0, - notificationIntent, 0); - - notification.setLatestEventInfo(context, contentTitle, contentText, - contentIntent); - - notificationManager.notify(ApplicationConstants.NOTIFICATION_DOWNLOAD_COMPLETED, - notification); - + + showNotification(ApplicationConstants.NOTIFICATION_DOWNLOAD_COMPLETED, + "Download Completed", + Notification.DEFAULT_SOUND | Notification.FLAG_AUTO_CANCEL | + Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS); + service.stopSelf(); isRunning = false; } From 036488f451c26c5e8b28a098fea0dd7dc610aff7 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 03:14:05 +0200 Subject: [PATCH 0058/1438] Fixes - El 7amdolelah no more :) --- src/com/quran/labs/androidquran/QuranViewActivity.java | 4 +++- src/com/quran/labs/androidquran/common/InternetActivity.java | 3 ++- src/com/quran/labs/androidquran/service/QuranDataService.java | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 9e3bb61c5a..30d952744d 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -75,6 +75,8 @@ public void onServiceConnected(ComponentName name, IBinder service) { quranAudioPlayer.setAyahCompleteListener(QuranViewActivity.this); if (quranAudioPlayer.isPlaying()) { onActionPlay(); + AyahItem a = quranAudioPlayer.getCurrentAyah(); + quranPageFeeder.highlightAyah(a.getSoura(), a.getAyah()); } } }; @@ -288,7 +290,7 @@ private void initDownloadRadioButtons(View parent, AyahItem ayahItem){ radioSura.setText(QuranInfo.getSuraName(ayahItem.getSoura() - 1)); radioJuz.setText(QuranInfo.getJuzTitle() + " " + QuranInfo.getJuzFromPage(QuranInfo.getPageFromSuraAyah(ayahItem.getSoura(), ayahItem.getAyah()))); - radioPage.setText("Page" + (QuranInfo.getPageFromSuraAyah(ayahItem.getSoura(), ayahItem.getAyah()))); + radioPage.setText("Page"); } private void showJumpToAyahDialog() { diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index ea82278f6c..8df145127d 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -131,7 +131,7 @@ protected void downloadJuza(int readerId, Integer juza){ downloadPage(readerId, QuranInfo.getJuzBounds(juza)); } - class ProgressBarUpdateTask extends AsyncTask { + class ProgressBarUpdateTask extends AsyncTask { private boolean callOnFinish = false; @@ -158,6 +158,7 @@ protected Void doInBackground(Void... params) { public void onProgressUpdate(Integer...integers){ int progress = integers[0]; if (progress > 0) { + starting = false; if (pDialog == null) showProgressDialog(); pDialog.setProgress(progress); diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 49fe274389..3bcbdbb2bb 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -466,7 +466,7 @@ private void onDownloadComplete() { showNotification(ApplicationConstants.NOTIFICATION_DOWNLOAD_COMPLETED, "Download Completed", Notification.DEFAULT_SOUND | Notification.FLAG_AUTO_CANCEL | - Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS); + Notification.DEFAULT_LIGHTS); service.stopSelf(); isRunning = false; From a94d1c7a2cd47ef0ba15346220494166c271a176 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 03:38:37 +0200 Subject: [PATCH 0059/1438] Close cursor --- .../quran/labs/androidquran/widgets/HighlightingImageView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java index 1a9752c4c6..89dbb92801 100644 --- a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java +++ b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java @@ -65,6 +65,7 @@ public void highlightAyah(int sura, int ayah){ (first.getPosition() != current.getPosition())) last = current; + cursor.close(); handler.closeDatabase(); doHighlightAyah(first, last, lineCoords); } From f668c1b802be9be88a05ffc6a655631f89886db7 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 05:24:41 +0200 Subject: [PATCH 0060/1438] Credits --- res/values-ar/strings.xml | 10 +++++----- res/values/strings.xml | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 3c09652977..9146ccbba3 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -34,7 +34,9 @@ تحديث اذهب الغاء - أحمد الحلو- حسين ماهر- وائل نافع + أحمد الحلو - أحمد فؤاد + \n حسين ماهر - وائل نافع + حقوق الطبع محفوظة لجميع المسلمين ردود الفعل quran.android@gmail.com @@ -43,16 +45,14 @@ project, and the data used in the translations and Arabic comes from tanzil.net. \n\nCredits: + \n @fo2ad - audio recitation support \n @wnafee - page flip animation (based on android-page-curl project) \n @hams_rrr - arabic support for non-arabic phones \n @neo_4583 - arabic reshaper project \n @somaiagabr - graphics \n\nNew features in this release: - \n- Awesome page flip animation (thanks @wnafee). + \n- Audio Recitations (thanks to @fo2ad) \n- Minor bugfixes. - \n\nUpcoming features include: - \n- Recitation. - \nAnd more.. \n\nLa tansawna men saleh el doaa. مساعد قران اندرويد diff --git a/res/values/strings.xml b/res/values/strings.xml index 2020fb019c..c29c8fbbf3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -37,7 +37,10 @@ Refresh Go Cancel - Ahmed El-Helw - Hussein Maher - Wael Nafee + + Ahmed El-Helw - Ahmed Fouad + \nHussein Maher - Wael Nafee + Copyright All Muslims Feedback quran.android@gmail.com @@ -46,17 +49,15 @@ project, and the data used in the translations and Arabic comes from tanzil.net. \n\nCredits: + \n @fo2ad - audio recitation support \n @wnafee - page flip animation (based on android-page-curl project) \n @hams_rrr - arabic support for non-arabic phones \n @neo_4583 - arabic reshaper project \n @somaiagabr - graphics and arabic translation \n Mehmed Mahmudoglu - turkish translation \n\nNew features in this release: - \n- Awesome page flip animation (thanks @wnafee). + \n- Audio Recitations (thanks to @fo2ad) \n- Minor bugfixes. - \n\nUpcoming features include: - \n- Recitation. - \nAnd more.. \n\nLa tansawna men saleh el doaa. Quran Android Help From bdb8a895ac660602a46a254e8912dbad85d0140c Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 05:27:10 +0200 Subject: [PATCH 0061/1438] Unhighlight on stop --- src/com/quran/labs/androidquran/QuranViewActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 30d952744d..742da0fc8c 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -163,6 +163,7 @@ protected void onNewIntent(Intent intent) { quranAudioPlayer.stop(); unBindAudioService(); onActionStop(); + quranPageFeeder.unHighlightAyah(); } else if (action.equalsIgnoreCase(ACTION_CHANGE_READER)){ showChangeReaderDialog(); } From 6d7c0b4f8318413be2728f60245c472dc4d731c2 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 05:29:38 +0200 Subject: [PATCH 0062/1438] Debuggable = false --- AndroidManifest.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0d6c9ba70d..1daf58855e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,7 @@ - + From 9a25e51de2bbb4ae96e6fcce58d2d1b49cefd896 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 12:13:54 +0200 Subject: [PATCH 0063/1438] Remove old settings that caused FC on open --- AndroidManifest.xml | 2 +- .../common/PageViewQuranActivity.java | 16 +++++--------- .../data/ApplicationConstants.java | 2 -- .../labs/androidquran/util/QuranSettings.java | 22 ------------------- 4 files changed, 7 insertions(+), 35 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1daf58855e..9e6f78317c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="com.quran.labs.androidquran" android:versionName="1.6" android:versionCode="8"> diff --git a/src/com/quran/labs/androidquran/common/PageViewQuranActivity.java b/src/com/quran/labs/androidquran/common/PageViewQuranActivity.java index 6d52d2e894..71e5bcee9d 100644 --- a/src/com/quran/labs/androidquran/common/PageViewQuranActivity.java +++ b/src/com/quran/labs/androidquran/common/PageViewQuranActivity.java @@ -52,11 +52,12 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Request window feautres should be called before setting the layout requestWindowFeatures(); - setContentView(R.layout.quran_exp); - + // Adjust display settings adjustDisplaySettings(); + setContentView(R.layout.quran_exp); + // retrieve saved configurations loadLastNonConfigurationInstance(); @@ -206,14 +207,9 @@ protected void adjustBookmarkView(int position) { } protected void adjustDisplaySettings() { - if (QuranSettings.getInstance().isFullScreen()) { - requestWindowFeature(Window.FEATURE_NO_TITLE); - if (!QuranSettings.getInstance().isShowClock()) { - getWindow().setFlags( - WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - } + getWindow().setFlags( + WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); } protected int loadPageState(Bundle savedInstanceState){ diff --git a/src/com/quran/labs/androidquran/data/ApplicationConstants.java b/src/com/quran/labs/androidquran/data/ApplicationConstants.java index a6c9180d95..8d8b45974a 100644 --- a/src/com/quran/labs/androidquran/data/ApplicationConstants.java +++ b/src/com/quran/labs/androidquran/data/ApplicationConstants.java @@ -36,8 +36,6 @@ public class ApplicationConstants { // Settings Key public static final String PREF_USE_ARABIC_NAMES = "useArabicNames"; - public static final String PREF_FULL_SCREEN = "fullScreen"; - public static final String PREF_SHOW_CLOCK = "showClock"; public static final String PREF_LAST_PAGE = "lastPage"; public static final String PREF_BOOKMARKS = "bookmarks"; public static final String PREF_KEEP_SCREEN_ON = "keepScreenOn"; diff --git a/src/com/quran/labs/androidquran/util/QuranSettings.java b/src/com/quran/labs/androidquran/util/QuranSettings.java index 40e68d7f43..0e8c4da13a 100644 --- a/src/com/quran/labs/androidquran/util/QuranSettings.java +++ b/src/com/quran/labs/androidquran/util/QuranSettings.java @@ -10,8 +10,6 @@ public class QuranSettings { private static QuranSettings instance = new QuranSettings(); private boolean arabicNames = false; - private boolean showClock = false; - private boolean fullScreen = false; private boolean keepScreenOn = false; private boolean lockOrientation = false; private boolean landscapeOrientation = false; @@ -40,14 +38,6 @@ public Integer getLastPage() { public void setLastPage(Integer lastPage) { this.lastPage = (lastPage == null)? ApplicationConstants.NO_PAGE_SAVED : lastPage; } - - public boolean isFullScreen() { - return fullScreen; - } - - public void setFullScreen(boolean fullScreen) { - this.fullScreen = fullScreen; - } public static QuranSettings getInstance(){ return instance; @@ -61,14 +51,6 @@ public void setArabicNames(boolean useArabicNames) { this.arabicNames = useArabicNames; } - public boolean isShowClock() { - return showClock; - } - - public void setShowClock(boolean showClock) { - this.showClock = showClock; - } - public boolean isKeepScreenOn() { return keepScreenOn; } @@ -116,8 +98,6 @@ public void setReshapeArabic(boolean reshapeArabic) { public static void load(SharedPreferences preferences) { instance.arabicNames = preferences.getBoolean(ApplicationConstants.PREF_USE_ARABIC_NAMES, false); instance.keepScreenOn = preferences.getBoolean(ApplicationConstants.PREF_KEEP_SCREEN_ON, true); - instance.fullScreen = preferences.getBoolean(ApplicationConstants.PREF_FULL_SCREEN, false); - instance.showClock = preferences.getBoolean(ApplicationConstants.PREF_SHOW_CLOCK, false); instance.lockOrientation = preferences.getBoolean(ApplicationConstants.PREF_LOCK_ORIENTATION, false); instance.landscapeOrientation = preferences.getBoolean(ApplicationConstants.PREF_LANDSCAPE_ORIENTATION, false); instance.translationTextSize = preferences.getInt(ApplicationConstants.PREF_TRANSLATION_TEXT_SIZE, ApplicationConstants.DEFAULT_TEXT_SIZE); @@ -131,8 +111,6 @@ public static void save(SharedPreferences preferences) { Editor editor = preferences.edit(); editor.putBoolean(ApplicationConstants.PREF_USE_ARABIC_NAMES, instance.arabicNames); editor.putBoolean(ApplicationConstants.PREF_KEEP_SCREEN_ON, instance.keepScreenOn); - editor.putBoolean(ApplicationConstants.PREF_FULL_SCREEN, instance.fullScreen); - editor.putBoolean(ApplicationConstants.PREF_SHOW_CLOCK, instance.showClock); editor.putBoolean(ApplicationConstants.PREF_LOCK_ORIENTATION, instance.lockOrientation); editor.putBoolean(ApplicationConstants.PREF_LANDSCAPE_ORIENTATION, instance.landscapeOrientation); editor.putInt(ApplicationConstants.PREF_TRANSLATION_TEXT_SIZE, instance.translationTextSize); From 1a877a347c3ea469d204db589d85e70e37d0de17 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 13:18:08 +0200 Subject: [PATCH 0064/1438] Fixes --- .../quran/labs/androidquran/common/InternetActivity.java | 3 +-- .../quran/labs/androidquran/service/AudioServiceBinder.java | 6 ++++-- .../quran/labs/androidquran/service/QuranDataService.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 8df145127d..aae3c5c1d1 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -34,7 +34,7 @@ public void onServiceConnected(ComponentName name, IBinder service){ public void onServiceDisconnected(ComponentName className) { downloadService = null; } - };; + }; @Override protected void onCreate(Bundle savedInstanceState) { @@ -201,7 +201,6 @@ public void onClick(DialogInterface dialog, int which) { if (downloadService != null) { downloadService.stop(); } - unbindService(serviceConnection); } stopService(new Intent(getApplicationContext(), QuranDataService.class)); if (currentTask != null) diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index 098ed87959..45618dd056 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -195,9 +195,11 @@ public synchronized void onCompletion(MediaPlayer mp) { play(currentItem); }else{ repeats = 0; - AyahItem nextItem = QuranAudioLibrary.getNextAyahAudioItem(context, this.currentItem); + AyahItem nextItem = null; + if (this.currentItem != null) + nextItem = QuranAudioLibrary.getNextAyahAudioItem(context, this.currentItem); boolean continuePlaying = false; - if(ayahListener != null && !stopped) + if(ayahListener != null && !stopped && nextItem != null) continuePlaying = ayahListener.onAyahComplete(currentItem, nextItem); if(nextItem != null){ //this.currentItem = nextItem; diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 3bcbdbb2bb..c9f8f07c7b 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -221,7 +221,6 @@ public void stop() { } progress = 0; - thread = null; isRunning = false; } @@ -417,6 +416,7 @@ public void run() { } catch(Exception e) { Log.e("quran_srv", "Error", e); } + thread = null; } protected void unzipFile(String saveToDirectory, String fileName) { From 28100be76fbcffc5e3317a8372a8db0a2d49989b Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 14:24:01 +0200 Subject: [PATCH 0065/1438] Fixes --- AndroidManifest.xml | 2 +- res/values-ar/strings.xml | 2 -- res/values-tr/strings.xml | 2 -- res/values/strings.xml | 2 -- res/xml/quran_preferences.xml | 11 ----------- .../quran/labs/androidquran/QuranViewActivity.java | 6 ++++++ 6 files changed, 7 insertions(+), 18 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 9e6f78317c..a4cf4b485b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="com.quran.labs.androidquran" android:versionCode="8" android:versionName="1.5.1"> diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 9146ccbba3..d72392b7a7 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -74,8 +74,6 @@ اسم السورة ابقى على الشاشة useArabicNames - fullScreen - showClock keepScreenOn lockOrientation landscapeOrientation diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index ce5226de2d..ab831c765f 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -99,8 +99,6 @@ Değişebilen Ekran Döndürme açık Daha Başka Uygulamalar -fullScreen -showClock keepScreenOn lockOrientation landscapeOrientation diff --git a/res/values/strings.xml b/res/values/strings.xml index c29c8fbbf3..846fbb6dff 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -81,8 +81,6 @@ Arabic sura names. Keep screen on. useArabicNames - fullScreen - showClock keepScreenOn lockOrientation landscapeOrientation diff --git a/res/xml/quran_preferences.xml b/res/xml/quran_preferences.xml index e438e005f0..99506422ca 100644 --- a/res/xml/quran_preferences.xml +++ b/res/xml/quran_preferences.xml @@ -7,17 +7,6 @@ - - Date: Tue, 2 Aug 2011 14:27:27 +0200 Subject: [PATCH 0066/1438] partial fix for progress dilaog and service bind --- .../androidquran/common/InternetActivity.java | 37 ++++++++++++++----- .../service/QuranDataService.java | 5 +++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index aae3c5c1d1..0d398e9fb1 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -23,16 +23,18 @@ public abstract class InternetActivity extends BaseQuranActivity { protected QuranDataService downloadService; protected AsyncTask currentTask = null; protected boolean starting = true; + private boolean bounded = false; protected ServiceConnection serviceConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder service){ downloadService = ((QuranDataService.QuranDownloadBinder)service).getService(); starting = false; - if (QuranDataService.isRunning) - currentTask = new ProgressBarUpdateTask().execute(); + currentTask = new ProgressBarUpdateTask().execute(); + bounded = true; } public void onServiceDisconnected(ComponentName className) { downloadService = null; + starting = false; } }; @@ -81,11 +83,18 @@ public void onClick(DialogInterface dialog, int id) { protected void startDownloadService(Intent intent) { starting = true; - if (!QuranDataService.isRunning) +// if (!QuranDataService.isRunning) +// startService(intent); +// + if(!bounded){ startService(intent); - - bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); - currentTask = new ProgressBarUpdateTask().execute(); + bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); + } + else if (downloadService != null) { + downloadService.handleStart(intent); + if(currentTask != null) currentTask.cancel(true); + currentTask = new ProgressBarUpdateTask().execute(); + } } protected void downloadTranslation(String url, String fileName) { @@ -159,11 +168,19 @@ public void onProgressUpdate(Integer...integers){ int progress = integers[0]; if (progress > 0) { starting = false; - if (pDialog == null) - showProgressDialog(); - pDialog.setProgress(progress); + try { + pDialog.setProgress(progress); + } catch (Exception e) { + + } } } + + @Override + protected void onPreExecute() { + super.onPreExecute(); + showProgressDialog(); + } @Override public void onPostExecute(Void val){ @@ -188,7 +205,7 @@ protected void onDownloadCanceled() { } private void showProgressDialog(){ - pDialog = new ProgressDialog(this); + pDialog = new ProgressDialog(InternetActivity.this); pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pDialog.setTitle(R.string.downloading_title); pDialog.setCancelable(false); diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index c9f8f07c7b..97b25cc8f6 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -72,6 +72,7 @@ public QuranDataService getService() { @Override public IBinder onBind(Intent intent) { + handleStart(intent, 0); return binder; } @@ -93,6 +94,10 @@ public int onStartCommand(Intent intent, int flags, int startId) { handleStart(intent, startId); return START_STICKY; } + + public void handleStart(Intent intent) { + handleStart(intent, - 1); + } public void handleStart(Intent intent, int startId) { if (intent == null) From 05675dca25132576fb3a6dbaf034a599f05f4134 Mon Sep 17 00:00:00 2001 From: fouad Date: Tue, 2 Aug 2011 16:22:59 +0200 Subject: [PATCH 0067/1438] -- fixing progressbar -- fixing notification clear --- .../androidquran/common/InternetActivity.java | 26 ++++++++++++------- .../data/ApplicationConstants.java | 1 + .../service/AudioServiceBinder.java | 5 ++-- .../service/QuranDataService.java | 4 ++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 0d398e9fb1..08a576cb85 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -20,6 +20,7 @@ public abstract class InternetActivity extends BaseQuranActivity { protected ProgressDialog pDialog = null; + private static boolean hideProgressBar = false; protected QuranDataService downloadService; protected AsyncTask currentTask = null; protected boolean starting = true; @@ -86,15 +87,19 @@ protected void startDownloadService(Intent intent) { // if (!QuranDataService.isRunning) // startService(intent); // - if(!bounded){ + + int downloadType = intent.getIntExtra(QuranDataService.DWONLOAD_TYPE_KEY, -1); + if(downloadType != -1){ startService(intent); bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); + }else if(QuranDataService.isRunning && !bounded){ + bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); } - else if (downloadService != null) { - downloadService.handleStart(intent); - if(currentTask != null) currentTask.cancel(true); - currentTask = new ProgressBarUpdateTask().execute(); - } +// else if (downloadService != null) { +// downloadService.handleStart(intent); +// if(currentTask != null) currentTask.cancel(true); +// currentTask = new ProgressBarUpdateTask().execute(); +// } } protected void downloadTranslation(String url, String fileName) { @@ -166,7 +171,7 @@ protected Void doInBackground(Void... params) { @Override public void onProgressUpdate(Integer...integers){ int progress = integers[0]; - if (progress > 0) { + if (progress > 0 && !hideProgressBar) { starting = false; try { pDialog.setProgress(progress); @@ -189,6 +194,7 @@ public void onPostExecute(Void val){ } catch (Exception e) { } + hideProgressBar = false; pDialog = null; currentTask = null; if (callOnFinish) @@ -205,6 +211,9 @@ protected void onDownloadCanceled() { } private void showProgressDialog(){ + if (hideProgressBar) + return; + pDialog = new ProgressDialog(InternetActivity.this); pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pDialog.setTitle(R.string.downloading_title); @@ -229,8 +238,7 @@ public void onClick(DialogInterface dialog, int which) { pDialog.setButton(ProgressDialog.BUTTON2, "Hide", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (currentTask != null) - currentTask.cancel(true); + hideProgressBar = true; if (pDialog != null) pDialog.dismiss(); } diff --git a/src/com/quran/labs/androidquran/data/ApplicationConstants.java b/src/com/quran/labs/androidquran/data/ApplicationConstants.java index 8d8b45974a..36ba9a6f76 100644 --- a/src/com/quran/labs/androidquran/data/ApplicationConstants.java +++ b/src/com/quran/labs/androidquran/data/ApplicationConstants.java @@ -49,4 +49,5 @@ public class ApplicationConstants { // Notifications public static final int NOTIFICATION_DOWNLOAD_COMPLETED = 1; public static final int NOTIFICATION_DOWNLOADING = 2; + public static final int NOTIFICATION_AUDIO = 3; } diff --git a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java index 45618dd056..1b63629634 100644 --- a/src/com/quran/labs/androidquran/service/AudioServiceBinder.java +++ b/src/com/quran/labs/androidquran/service/AudioServiceBinder.java @@ -14,6 +14,7 @@ import android.os.Binder; import android.util.Log; +import com.quran.labs.androidquran.data.ApplicationConstants; import com.quran.labs.androidquran.QuranViewActivity; import com.quran.labs.androidquran.R; import com.quran.labs.androidquran.common.AyahItem; @@ -88,7 +89,7 @@ public synchronized void stop() { private void clearNotification(){ NotificationManager mgr = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); - mgr.cancelAll(); + mgr.cancel(ApplicationConstants.NOTIFICATION_AUDIO); } /* (non-Javadoc) * @see org.islam.quran.IAudioPlayer#play(org.islam.quran.AyahAudioItem) @@ -286,7 +287,7 @@ private void showNotification(AyahItem item){ notification.flags |= Notification.FLAG_ONGOING_EVENT; notification.icon = R.drawable.icon; - mgr.notify(1, notification); + mgr.notify(ApplicationConstants.NOTIFICATION_AUDIO, notification); //notified = true; diff --git a/src/com/quran/labs/androidquran/service/QuranDataService.java b/src/com/quran/labs/androidquran/service/QuranDataService.java index 97b25cc8f6..2ce3e3ce01 100644 --- a/src/com/quran/labs/androidquran/service/QuranDataService.java +++ b/src/com/quran/labs/androidquran/service/QuranDataService.java @@ -72,7 +72,6 @@ public QuranDataService getService() { @Override public IBinder onBind(Intent intent) { - handleStart(intent, 0); return binder; } @@ -120,6 +119,8 @@ public void handleStart(Intent intent, int startId) { downloadTranslation(intent); break; } + if(thread == null) + stopSelf(); } private void downloadSuraAudio(Intent intent) { @@ -300,6 +301,7 @@ private void showNotification(int notificationId, String msg, int flags) { CharSequence contentTitle = "Quran Android"; CharSequence contentText = msg; Intent notificationIntent = new Intent(context, QuranActivity.class); + notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); From f7b296fb1f3ec0e6904c1ad5144763fe1ff9d0b6 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 16:41:32 +0200 Subject: [PATCH 0068/1438] Remove unused code --- .../quran/labs/androidquran/common/InternetActivity.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/InternetActivity.java b/src/com/quran/labs/androidquran/common/InternetActivity.java index 08a576cb85..0a465344b1 100644 --- a/src/com/quran/labs/androidquran/common/InternetActivity.java +++ b/src/com/quran/labs/androidquran/common/InternetActivity.java @@ -84,9 +84,6 @@ public void onClick(DialogInterface dialog, int id) { protected void startDownloadService(Intent intent) { starting = true; -// if (!QuranDataService.isRunning) -// startService(intent); -// int downloadType = intent.getIntExtra(QuranDataService.DWONLOAD_TYPE_KEY, -1); if(downloadType != -1){ @@ -95,11 +92,6 @@ protected void startDownloadService(Intent intent) { }else if(QuranDataService.isRunning && !bounded){ bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); } -// else if (downloadService != null) { -// downloadService.handleStart(intent); -// if(currentTask != null) currentTask.cancel(true); -// currentTask = new ProgressBarUpdateTask().execute(); -// } } protected void downloadTranslation(String url, String fileName) { From 4b3436aee5470bfbe19c1ee5eac013a7ab986c6f Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Tue, 2 Aug 2011 16:56:04 +0200 Subject: [PATCH 0069/1438] UI fixes --- src/com/quran/labs/androidquran/QuranViewActivity.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 94a8b1cae9..b6848176a6 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -208,7 +208,7 @@ private void showDownloadDialog(final AyahItem i) { dialog.setView(view); initDownloadRadioButtons(view, getLastAyah()); // AlertDialog dialog = new DownloadDialog(this); - dialog.setMessage("Do you want to download sura"); + dialog.setMessage("Select download option.."); dialog.setPositiveButton("Download", new DialogInterface.OnClickListener() { @@ -325,9 +325,12 @@ public void onItemSelected(AdapterView adapter, View view, int position, long id) { HashMapmap = (HashMap) adapter.getItemAtPosition(position); int suraIndex = Integer.parseInt(map.get("suraId")); - int startAyah = suraIndex == pageBounds[0] ? pageBounds[1] : 1; + int startAyah = suraIndex == pageBounds[0] && checkbox.isChecked() ? pageBounds[1] : 1; int endAyah = suraIndex == pageBounds[2]? pageBounds[3] : QuranInfo.SURA_NUM_AYAHS[suraIndex - 1]; initAyatSpinner(ayatSpinner, startAyah, endAyah); + if (suraIndex == pageBounds[0]) { + ayatSpinner.setSelection(pageBounds[1] - 1); + } } @Override @@ -423,7 +426,7 @@ private void showChangeReaderDialog() { s.setSelection(getReaderIndex(getQuranReaderId())); dialogBuilder.setView(view); dialogBuilder.setMessage("Change quran reader"); - dialogBuilder.setPositiveButton("Change", + dialogBuilder.setPositiveButton("Set", new DialogInterface.OnClickListener() { @Override From 393d41fefd192f8f9921a5c874a2b9925cfe1b62 Mon Sep 17 00:00:00 2001 From: fouad Date: Wed, 3 Aug 2011 12:55:22 +0200 Subject: [PATCH 0070/1438] -- fixing array out of bounds exception on audio jump to ayah checkbox selection --- src/com/quran/labs/androidquran/QuranViewActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index b6848176a6..65eaa16e04 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -329,7 +329,8 @@ public void onItemSelected(AdapterView adapter, View view, int endAyah = suraIndex == pageBounds[2]? pageBounds[3] : QuranInfo.SURA_NUM_AYAHS[suraIndex - 1]; initAyatSpinner(ayatSpinner, startAyah, endAyah); if (suraIndex == pageBounds[0]) { - ayatSpinner.setSelection(pageBounds[1] - 1); + int selection = checkbox.isChecked()? 0 : pageBounds[1] - 1; + ayatSpinner.setSelection(selection); } } From ca9b87a3d0e182e09077090a0d07ced4422ee13c Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Wed, 3 Aug 2011 13:50:59 +0200 Subject: [PATCH 0071/1438] 1.5.2 --- AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a4cf4b485b..8234092590 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,7 +1,7 @@ - + package="com.quran.labs.androidquran" android:versionCode="9" android:versionName="1.5.2"> + From 839491b7760517bf9d4cbfbcaba057e44eaf0964 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Wed, 3 Aug 2011 14:02:30 +0200 Subject: [PATCH 0072/1438] fix null pointer exception --- .../labs/androidquran/common/QuranPageFeeder.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java index 6e55bd1c9d..e5221faf3a 100644 --- a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java +++ b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java @@ -116,12 +116,14 @@ public void highlightAyah(int sura, int ayah){ public void unHighlightAyah(){ View v = mQuranPage.getCurrentPage(); - HighlightingImageView iv = - (HighlightingImageView)v.findViewById(R.id.page_image); - if (iv != null){ - HighlightingImageView hi = (HighlightingImageView)iv; - hi.unhighlight(); - mQuranPage.invalidate(); + if (v != null) { + HighlightingImageView iv = + (HighlightingImageView)v.findViewById(R.id.page_image); + if (iv != null){ + HighlightingImageView hi = (HighlightingImageView)iv; + hi.unhighlight(); + mQuranPage.invalidate(); + } } } From e73ef6a3fb632755c80a4a346d4f198dc8ed1f16 Mon Sep 17 00:00:00 2001 From: Hussein Maher Date: Sat, 6 Aug 2011 18:00:17 +0200 Subject: [PATCH 0073/1438] Missing Sheikh in arabic --- res/values-ar/readers.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/values-ar/readers.xml b/res/values-ar/readers.xml index 2f3740793b..cb3c876f7c 100644 --- a/res/values-ar/readers.xml +++ b/res/values-ar/readers.xml @@ -7,6 +7,7 @@ عبد الرحمن السديس أبو بكر الشاطري مشاري بن راشد العفاسي + سعد الغامدي هاني الرفاعي الحصري الحصري مجود From 13cfc94d356901e5a1e8d517048ded7c9dfb0f1b Mon Sep 17 00:00:00 2001 From: Mahmoud Hossam Date: Thu, 11 Aug 2011 12:24:29 +0200 Subject: [PATCH 0074/1438] added a comment --- default.properties | 2 +- src/com/quran/labs/androidquran/QuranActivity.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/default.properties b/default.properties index f21481f6e7..ba1f430286 100644 --- a/default.properties +++ b/default.properties @@ -10,5 +10,5 @@ # Indicates whether an apk should be generated for each density. split.density=false # Project target. -target=android-7 +target=android-8 android.library.reference.1=../johannilsson-android-actionbar-1a98f28/actionbar diff --git a/src/com/quran/labs/androidquran/QuranActivity.java b/src/com/quran/labs/androidquran/QuranActivity.java index 8e37e7cc60..65005e1ddf 100644 --- a/src/com/quran/labs/androidquran/QuranActivity.java +++ b/src/com/quran/labs/androidquran/QuranActivity.java @@ -51,6 +51,10 @@ public void onCreate(Bundle savedInstanceState) { addActions(); } + /** + * Sets up the action bar. + */ + protected void addActions() { actionBar.setTitle("Quran"); actionBar.addAction(getIntentAction(ACTION_RESUME, R.drawable.translation)); @@ -157,7 +161,7 @@ public QuranElement(String text, boolean isJuz, int number, int page){ } } - // http://www.androidpeople.com/android-custom-listview-tutorial-example/ + private class EfficientAdapter extends BaseAdapter { private LayoutInflater mInflater; private QuranElement[] elements; @@ -226,6 +230,7 @@ public void onClick(View v) { return convertView; } + private void downloadSuraAudio(int suraId) { Intent intent = new Intent(QuranActivity.this, QuranDataService.class); intent.putExtra(QuranDataService.DWONLOAD_TYPE_KEY, QuranDataService.DOWNLOAD_SURA_AUDIO); From d84e62d8675dfc9d53eaaad1ed7daf3c9ae2cfd1 Mon Sep 17 00:00:00 2001 From: Mahmoud Hossam Date: Sat, 13 Aug 2011 07:01:23 +0200 Subject: [PATCH 0075/1438] added a comment, and now the app installs to sd card by default. --- AndroidManifest.xml | 40 ++++++++++++------- default.properties | 2 +- .../labs/androidquran/QuranJumpDialog.java | 4 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a4cf4b485b..c68eefe05b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,22 +1,30 @@ - - + package="com.quran.labs.androidquran" android:versionCode="8" + android:versionName="1.5.1" android:installLocation="preferExternal"> + + - - - + + + - - - - + + + + @@ -24,15 +32,17 @@ - + - + - - + + - + diff --git a/default.properties b/default.properties index ba1f430286..77d6d9a73d 100644 --- a/default.properties +++ b/default.properties @@ -11,4 +11,4 @@ split.density=false # Project target. target=android-8 -android.library.reference.1=../johannilsson-android-actionbar-1a98f28/actionbar +android.library.reference.1=../android-actionbar/actionbar diff --git a/src/com/quran/labs/androidquran/QuranJumpDialog.java b/src/com/quran/labs/androidquran/QuranJumpDialog.java index 85ace84a73..4c1dc149ed 100644 --- a/src/com/quran/labs/androidquran/QuranJumpDialog.java +++ b/src/com/quran/labs/androidquran/QuranJumpDialog.java @@ -63,8 +63,8 @@ public void jump(){ leave(); } - // http://groups.google.com/group/android-developers/browse_frm/ - // thread/17210d784766602d/d430c900a9c4019c? + //hides the soft keyboard + public void leave(){ EditText pageField = (EditText)this.findViewById(R.id.page_field); InputMethodManager imm = From 5da9224f5e4de6339d6fd8b0617622bcf5229292 Mon Sep 17 00:00:00 2001 From: Ahmed Farra Date: Sun, 14 Aug 2011 09:00:01 -0400 Subject: [PATCH 0076/1438] Issue #33 -Feature to show toast when reaching juz2, 7izb, rub3 marker -Preference to enable/disable this notification -Page<=>Rub3 data --- res/values/strings.xml | 2 + res/xml/quran_preferences.xml | 7 ++ .../androidquran/common/QuranPageFeeder.java | 31 ++++++++ .../data/ApplicationConstants.java | 1 + .../labs/androidquran/data/QuranInfo.java | 71 +++++++++++++++++++ .../labs/androidquran/util/QuranSettings.java | 11 +++ 6 files changed, 123 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index 846fbb6dff..aabae678f1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -82,6 +82,7 @@ Keep screen on. useArabicNames keepScreenOn + displayMarkerPopup lockOrientation landscapeOrientation translationTextSize @@ -101,6 +102,7 @@ No active translation set, set an active translation first (Settings > Set Active Translation) and then search again. Set Active Translation You have not got any available translations, please download a translation first (Menu > Get More Translations) and then search again. + Reading Preferences Translation Preferences Display Settings activeTranslation diff --git a/res/xml/quran_preferences.xml b/res/xml/quran_preferences.xml index 99506422ca..f8d7afdb18 100644 --- a/res/xml/quran_preferences.xml +++ b/res/xml/quran_preferences.xml @@ -21,6 +21,13 @@ + + + + 30 ? 30 : juz < 1 ? 1 : juz; } + public static int getPageFromRub3(int rub3){ + if ((rub3 < 1) || (rub3 > 8 * ApplicationConstants.JUZ2_COUNT)) return -1; + return QuranInfo.RUB3_PAGE_START[rub3-1]; + } + + public static int getRub3FromPage(int page) { + if ((page > ApplicationConstants.PAGES_LAST) || (page < 1)) return -1; + return PAGE_RUB3_START[page-1]; + } + public static int getPageFromSuraAyah(int sura, int ayah){ // basic bounds checking if (ayah == 0) ayah = 1; diff --git a/src/com/quran/labs/androidquran/util/QuranSettings.java b/src/com/quran/labs/androidquran/util/QuranSettings.java index 0e8c4da13a..0878079878 100644 --- a/src/com/quran/labs/androidquran/util/QuranSettings.java +++ b/src/com/quran/labs/androidquran/util/QuranSettings.java @@ -13,6 +13,7 @@ public class QuranSettings { private boolean keepScreenOn = false; private boolean lockOrientation = false; private boolean landscapeOrientation = false; + private boolean displayMarkerPopup = false; private int translationTextSize = ApplicationConstants.DEFAULT_TEXT_SIZE; private int lastPage = 0; private String activeTranslation = null; @@ -75,6 +76,14 @@ public void setLandscapeOrientation(boolean landscapeOrientation) { this.landscapeOrientation = landscapeOrientation; } + public boolean isDisplayMarkerPopup() { + return displayMarkerPopup; + } + + public void setMarkerPopup(boolean displayMarkerPopup) { + this.displayMarkerPopup = displayMarkerPopup; + } + public int getTranslationTextSize() { return translationTextSize; } @@ -100,6 +109,7 @@ public static void load(SharedPreferences preferences) { instance.keepScreenOn = preferences.getBoolean(ApplicationConstants.PREF_KEEP_SCREEN_ON, true); instance.lockOrientation = preferences.getBoolean(ApplicationConstants.PREF_LOCK_ORIENTATION, false); instance.landscapeOrientation = preferences.getBoolean(ApplicationConstants.PREF_LANDSCAPE_ORIENTATION, false); + instance.displayMarkerPopup = preferences.getBoolean(ApplicationConstants.PREF_DISPLAY_MARKER_POPUP, false); instance.translationTextSize = preferences.getInt(ApplicationConstants.PREF_TRANSLATION_TEXT_SIZE, ApplicationConstants.DEFAULT_TEXT_SIZE); instance.lastPage = preferences.getInt(ApplicationConstants.PREF_LAST_PAGE, ApplicationConstants.NO_PAGE_SAVED); instance.activeTranslation = preferences.getString(ApplicationConstants.PREF_ACTIVE_TRANSLATION, null); @@ -113,6 +123,7 @@ public static void save(SharedPreferences preferences) { editor.putBoolean(ApplicationConstants.PREF_KEEP_SCREEN_ON, instance.keepScreenOn); editor.putBoolean(ApplicationConstants.PREF_LOCK_ORIENTATION, instance.lockOrientation); editor.putBoolean(ApplicationConstants.PREF_LANDSCAPE_ORIENTATION, instance.landscapeOrientation); + editor.putBoolean(ApplicationConstants.PREF_DISPLAY_MARKER_POPUP, instance.displayMarkerPopup); editor.putInt(ApplicationConstants.PREF_TRANSLATION_TEXT_SIZE, instance.translationTextSize); editor.putInt(ApplicationConstants.PREF_LAST_PAGE, instance.lastPage); editor.putString(ApplicationConstants.PREF_ACTIVE_TRANSLATION, instance.activeTranslation); From 858468df41cdc58b0fc07572bf7d08bfa9cdb334 Mon Sep 17 00:00:00 2001 From: Wael Nafee Date: Sun, 14 Aug 2011 17:56:55 +0200 Subject: [PATCH 0077/1438] fixed aya highlighting bug in landscape and portrait modes for all screen resolutions hopefully inshaAllah --- .../androidquran/util/QuranScreenInfo.java | 6 +++++ .../widgets/HighlightingImageView.java | 27 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/com/quran/labs/androidquran/util/QuranScreenInfo.java b/src/com/quran/labs/androidquran/util/QuranScreenInfo.java index 1086bbbfbc..da998c8cc7 100644 --- a/src/com/quran/labs/androidquran/util/QuranScreenInfo.java +++ b/src/com/quran/labs/androidquran/util/QuranScreenInfo.java @@ -48,4 +48,10 @@ public boolean isLandscapeOrientation() { public void setOrientation(int orientation) { this.orientation = orientation; } + + public float getRatio() { + if (height > width) + return (float)(1.0*height/width); + return (float)(1.0*width/height); + } } diff --git a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java index 89dbb92801..fcaffe09dc 100644 --- a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java +++ b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java @@ -19,6 +19,7 @@ import com.quran.labs.androidquran.R; import com.quran.labs.androidquran.common.AyahBounds; import com.quran.labs.androidquran.data.AyahInfoDatabaseHandler; +import com.quran.labs.androidquran.util.QuranScreenInfo; public class HighlightingImageView extends ImageView { private List currentlyHighlighting = null; @@ -120,14 +121,38 @@ protected void onDraw(Canvas canvas) { Drawable page = this.getDrawable(); if (page != null){ + /* float widthFactor = (float)((1.0 * getWidth()) / (1.0 * page.getIntrinsicWidth())); float heightFactor = (float)((1.0 * getHeight()) / (1.0 * page.getIntrinsicHeight())); - + */ + + float screenRatio = QuranScreenInfo.getInstance().getRatio(); + float pageRatio = (float) (1.0* page.getIntrinsicHeight()/page.getIntrinsicWidth()); + + float scaledPageHeight; + float scaledPageWidth; + + // depending on whether or not you will have a top or bottom offset + if (screenRatio < pageRatio){ + scaledPageHeight = getHeight(); + scaledPageWidth = (float) (1.0*getHeight()/page.getIntrinsicHeight()*page.getIntrinsicWidth()); + } else { + scaledPageWidth = getWidth(); + scaledPageHeight = (float)(1.0*getWidth()/page.getIntrinsicWidth()*page.getIntrinsicHeight()); + } + + float widthFactor = scaledPageWidth / page.getIntrinsicWidth(); + float heightFactor = scaledPageHeight / page.getIntrinsicHeight(); + + float offsetX = (getWidth() - scaledPageWidth)/2; + float offsetY = (getHeight() - scaledPageHeight)/2; + RectF scaled = new RectF(b.getMinX() * widthFactor, b.getMinY() * heightFactor, b.getMaxX() * widthFactor, b.getMaxY() * heightFactor); + scaled.offset(offsetX, offsetY); canvas.drawBitmap(bm, null, scaled, null); } } From 20340337f723f82a4fa9b0707f5b58c112cc294b Mon Sep 17 00:00:00 2001 From: Wael Nafee Date: Sun, 14 Aug 2011 18:17:16 +0200 Subject: [PATCH 0078/1438] some refactoring to move all scale calculations outside the loop for efficiency purposes --- .../widgets/HighlightingImageView.java | 57 ++++++++----------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java index fcaffe09dc..c66efa0f0b 100644 --- a/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java +++ b/src/com/quran/labs/androidquran/widgets/HighlightingImageView.java @@ -115,40 +115,33 @@ private void doHighlightAyah(AyahBounds first, protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (this.currentlyHighlighting != null){ - for (AyahBounds b : currentlyHighlighting){ + Drawable page = this.getDrawable(); + if (page != null){ Bitmap bm = BitmapFactory.decodeResource( - getResources(), R.drawable.highlight); + getResources(), R.drawable.highlight); - Drawable page = this.getDrawable(); - if (page != null){ - /* - float widthFactor = (float)((1.0 * getWidth()) / - (1.0 * page.getIntrinsicWidth())); - float heightFactor = (float)((1.0 * getHeight()) / - (1.0 * page.getIntrinsicHeight())); - */ - - float screenRatio = QuranScreenInfo.getInstance().getRatio(); - float pageRatio = (float) (1.0* page.getIntrinsicHeight()/page.getIntrinsicWidth()); - - float scaledPageHeight; - float scaledPageWidth; - - // depending on whether or not you will have a top or bottom offset - if (screenRatio < pageRatio){ - scaledPageHeight = getHeight(); - scaledPageWidth = (float) (1.0*getHeight()/page.getIntrinsicHeight()*page.getIntrinsicWidth()); - } else { - scaledPageWidth = getWidth(); - scaledPageHeight = (float)(1.0*getWidth()/page.getIntrinsicWidth()*page.getIntrinsicHeight()); - } - - float widthFactor = scaledPageWidth / page.getIntrinsicWidth(); - float heightFactor = scaledPageHeight / page.getIntrinsicHeight(); - - float offsetX = (getWidth() - scaledPageWidth)/2; - float offsetY = (getHeight() - scaledPageHeight)/2; - + float screenRatio = QuranScreenInfo.getInstance().getRatio(); + float pageRatio = (float) (1.0* page.getIntrinsicHeight()/page.getIntrinsicWidth()); + + float scaledPageHeight; + float scaledPageWidth; + + // depending on whether or not you will have a top or bottom offset + if (screenRatio < pageRatio){ + scaledPageHeight = getHeight(); + scaledPageWidth = (float) (1.0*getHeight()/page.getIntrinsicHeight()*page.getIntrinsicWidth()); + } else { + scaledPageWidth = getWidth(); + scaledPageHeight = (float)(1.0*getWidth()/page.getIntrinsicWidth()*page.getIntrinsicHeight()); + } + + float widthFactor = scaledPageWidth / page.getIntrinsicWidth(); + float heightFactor = scaledPageHeight / page.getIntrinsicHeight(); + + float offsetX = (getWidth() - scaledPageWidth)/2; + float offsetY = (getHeight() - scaledPageHeight)/2; + + for (AyahBounds b : currentlyHighlighting){ RectF scaled = new RectF(b.getMinX() * widthFactor, b.getMinY() * heightFactor, b.getMaxX() * widthFactor, b.getMaxY() * heightFactor); From 192e4160772e6c4bb1f450045c9aabd51056e3ad Mon Sep 17 00:00:00 2001 From: Ahmed Farra Date: Sun, 14 Aug 2011 23:17:24 +0800 Subject: [PATCH 0079/1438] Fixed Issue #57 - Arabic reshaping not applied to bookmarks page Added Arabic reshaping to jump to ayah dialog (surah spinner) --- src/com/quran/labs/androidquran/BookmarksActivity.java | 5 +++-- src/com/quran/labs/androidquran/QuranViewActivity.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/quran/labs/androidquran/BookmarksActivity.java b/src/com/quran/labs/androidquran/BookmarksActivity.java index ac8574d9a8..e9d8ac4754 100644 --- a/src/com/quran/labs/androidquran/BookmarksActivity.java +++ b/src/com/quran/labs/androidquran/BookmarksActivity.java @@ -19,6 +19,7 @@ import com.quran.labs.androidquran.common.BaseQuranActivity; import com.quran.labs.androidquran.data.QuranInfo; +import com.quran.labs.androidquran.util.ArabicStyle; import com.quran.labs.androidquran.util.BookmarksManager; public class BookmarksActivity extends BaseQuranActivity { @@ -39,8 +40,8 @@ private void showBookmarks() { ArrayList bookmarks = BookmarksManager.getInstance().getBookmarks(); for (int i = 0; i < bookmarks.size(); i++) { int page = bookmarks.get(i); - String title = QuranInfo.getSuraNameString(page); - String info = QuranInfo.getSuraDetailsForBookmark(page); + String title = ArabicStyle.reshape(QuranInfo.getSuraNameString(page)); + String info = ArabicStyle.reshape(QuranInfo.getSuraDetailsForBookmark(page)); Map map = new HashMap(); map.put("suraname", title); map.put("info", info); diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 65eaa16e04..76512cdd12 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -33,6 +33,7 @@ import com.quran.labs.androidquran.data.QuranInfo; import com.quran.labs.androidquran.service.AudioServiceBinder; import com.quran.labs.androidquran.service.QuranAudioService; +import com.quran.labs.androidquran.util.ArabicStyle; import com.quran.labs.androidquran.util.QuranAudioLibrary; import com.quran.labs.androidquran.util.QuranSettings; import com.quran.labs.androidquran.util.QuranUtils; @@ -387,7 +388,7 @@ private void initSurasSpinner(final Spinner spinner, int startSura, int endSura) ArrayList> data = new ArrayList>(); for (int i = startSura; i <= endSura; i++) { HashMap hash = new HashMap(); - hash.put("suraName", QuranInfo.getSuraName(i-1)); + hash.put("suraName", ArabicStyle.reshape(QuranInfo.getSuraName(i-1))); hash.put("suraId", ""+i); data.add(hash); } From 5aca4ff82f7fe0ae101c59b5d2d0807a452e3ea4 Mon Sep 17 00:00:00 2001 From: Ahmed Farra Date: Sun, 14 Aug 2011 23:30:20 +0800 Subject: [PATCH 0080/1438] Fix: titleText/seekbar not updating when jumping to page/ayah --- .../quran/labs/androidquran/common/PageViewQuranActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/quran/labs/androidquran/common/PageViewQuranActivity.java b/src/com/quran/labs/androidquran/common/PageViewQuranActivity.java index 71e5bcee9d..c7d751a933 100644 --- a/src/com/quran/labs/androidquran/common/PageViewQuranActivity.java +++ b/src/com/quran/labs/androidquran/common/PageViewQuranActivity.java @@ -147,6 +147,7 @@ protected void onStart() { @Override public void jumpTo(int page) { quranPageFeeder.jumpToPage(page); + updatePageInfo(); } protected void goToNextPage() { From 98d516834cff2cb30ff00955d8fa5b25c1528520 Mon Sep 17 00:00:00 2001 From: Ahmed Farra Date: Mon, 15 Aug 2011 00:02:56 +0800 Subject: [PATCH 0081/1438] Added Arabic (+reshaping) to toasts from Issue #33 --- .../labs/androidquran/common/QuranPageFeeder.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java index 427dba1f1d..1ef2d5d2ef 100644 --- a/src/com/quran/labs/androidquran/common/QuranPageFeeder.java +++ b/src/com/quran/labs/androidquran/common/QuranPageFeeder.java @@ -17,6 +17,7 @@ import com.quran.labs.androidquran.R; import com.quran.labs.androidquran.data.ApplicationConstants; import com.quran.labs.androidquran.data.QuranInfo; +import com.quran.labs.androidquran.util.ArabicStyle; import com.quran.labs.androidquran.util.QuranSettings; import com.quran.labs.androidquran.util.QuranUtils; import com.quran.labs.androidquran.widgets.HighlightingImageView; @@ -166,19 +167,20 @@ public void displayMarkerPopup() { int hizb = (rub3 / 4) + 1; StringBuilder sb = new StringBuilder(); + boolean arabic = QuranSettings.getInstance().isArabicNames(); if (rub3 % 8 == 0) { - sb.append("Juz' ").append((hizb/2) + 1); + sb.append(arabic ? "الجزء" : "Juz'").append(' ').append((hizb/2) + 1); } else { - sb.append("Hizb ").append(hizb); int remainder = rub3 % 4; if (remainder == 1) - sb.insert(0, "¼ "); + sb.append(arabic ? "ربع" : "¼").append(' '); else if (remainder == 2) - sb.insert(0, "½ "); + sb.append(arabic ? "نصف" : "½").append(' '); else if (remainder == 3) - sb.insert(0, "¾ "); + sb.append(arabic ? "ثلاثة أرباع" : "¾").append(' '); + sb.append(arabic ? "الحزب" : "Hizb").append(' ').append(hizb); } - Toast.makeText(mContext, sb.toString(), Toast.LENGTH_SHORT).show(); + Toast.makeText(mContext, ArabicStyle.reshape(sb.toString()), Toast.LENGTH_SHORT).show(); lastPopupTime = System.currentTimeMillis(); } From 7fdc3e55405e1c5ae79294559bbeb8b44dd5326f Mon Sep 17 00:00:00 2001 From: Ahmed Farra Date: Mon, 15 Aug 2011 03:47:41 +0800 Subject: [PATCH 0082/1438] +one more Arabic reshaping (play dialog) --- src/com/quran/labs/androidquran/QuranViewActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/quran/labs/androidquran/QuranViewActivity.java b/src/com/quran/labs/androidquran/QuranViewActivity.java index 76512cdd12..01aa6dd33c 100644 --- a/src/com/quran/labs/androidquran/QuranViewActivity.java +++ b/src/com/quran/labs/androidquran/QuranViewActivity.java @@ -296,8 +296,9 @@ private void initDownloadRadioButtons(View parent, AyahItem ayahItem){ RadioButton radioJuz = (RadioButton) parent.findViewById(R.id.radioDownloadJuza); RadioButton radioPage = (RadioButton) parent.findViewById(R.id.radioDownloadPage); - radioSura.setText(QuranInfo.getSuraName(ayahItem.getSoura() - 1)); - radioJuz.setText(QuranInfo.getJuzTitle() + " " + QuranInfo.getJuzFromPage(QuranInfo.getPageFromSuraAyah(ayahItem.getSoura(), ayahItem.getAyah()))); + radioSura.setText(ArabicStyle.reshape(QuranInfo.getSuraName(ayahItem.getSoura() - 1))); + radioJuz.setText(ArabicStyle.reshape(QuranInfo.getJuzTitle() + " " + QuranInfo.getJuzFromPage( + QuranInfo.getPageFromSuraAyah(ayahItem.getSoura(), ayahItem.getAyah())))); radioPage.setText("Page"); } From c9fac72559043f3a2022856c425eaf8680699b31 Mon Sep 17 00:00:00 2001 From: Mahmoud Hossam Date: Sun, 21 Aug 2011 04:48:54 +0200 Subject: [PATCH 0083/1438] Cleaned up AboutUsActivity a bit. --- res/layout/about_us.xml | 2 +- .../labs/androidquran/AboutUsActivity.java | 41 ++++++------------- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/res/layout/about_us.xml b/res/layout/about_us.xml index 229c69ec10..c5ea226818 100644 --- a/res/layout/about_us.xml +++ b/res/layout/about_us.xml @@ -18,7 +18,7 @@