diff --git a/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.java b/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.java index 7a5035c59e..5bba98f2fc 100644 --- a/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/QuranDataActivity.java @@ -13,6 +13,7 @@ import android.annotation.TargetApi; import android.app.AlertDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; @@ -289,27 +290,28 @@ private void removeErrorPreferences(){ } class CheckPagesAsyncTask extends AsyncTask { + private final Context mAppContext; + public CheckPagesAsyncTask() { + mAppContext = getApplicationContext(); + } @Override protected Boolean doInBackground(Void... params) { // intentionally not sleeping because waiting // for the splash screen is not cool. - QuranFileUtils.migrateAudio(QuranDataActivity.this); + QuranFileUtils.migrateAudio(mAppContext); - if (QuranScreenInfo.getInstance().isTablet(QuranDataActivity.this)){ - boolean haveLandscape = QuranFileUtils.haveAllImages( - QuranDataActivity.this, + if (QuranScreenInfo.getInstance().isTablet(mAppContext)){ + boolean haveLandscape = QuranFileUtils.haveAllImages(mAppContext, QuranScreenInfo.getInstance().getTabletWidthParam()); - boolean havePortrait = QuranFileUtils.haveAllImages( - QuranDataActivity.this, + boolean havePortrait = QuranFileUtils.haveAllImages(mAppContext, QuranScreenInfo.getInstance().getWidthParam()); mNeedPortraitImages = !havePortrait; mNeedLandscapeImages = !haveLandscape; return haveLandscape && havePortrait; } else { - boolean haveAll = QuranFileUtils.haveAllImages( - QuranDataActivity.this, + boolean haveAll = QuranFileUtils.haveAllImages(mAppContext, QuranScreenInfo.getInstance().getWidthParam()); mNeedPortraitImages = !haveAll; mNeedLandscapeImages = false; diff --git a/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java b/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java index 47d8e8ed25..f2b2cda06b 100644 --- a/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/QuranPreferenceActivity.java @@ -111,12 +111,17 @@ public boolean onPreferenceClick(Preference preference) { s = new StorageUtils.Storage( getString(R.string.prefs_sdcard_internal), mInternalSdcardLocation); - } else { + } else if (mountPoints[i] != null) { s = new StorageUtils.Storage( getString(R.string.prefs_sdcard_external), mountPoints[i].getAbsolutePath()); + } else { + s = null; + } + + if (s != null) { + mStorageList.add(s); } - mStorageList.add(s); } } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { try { diff --git a/app/src/main/java/com/quran/labs/androidquran/service/AudioService.java b/app/src/main/java/com/quran/labs/androidquran/service/AudioService.java index db60510cee..4899c99c10 100644 --- a/app/src/main/java/com/quran/labs/androidquran/service/AudioService.java +++ b/app/src/main/java/com/quran/labs/androidquran/service/AudioService.java @@ -285,7 +285,7 @@ public void onCreate() { public int onStartCommand(Intent intent, int flags, int startId) { String action = intent.getAction(); - if (action.equals(ACTION_CONNECT)){ + if (ACTION_CONNECT.equals(action)){ if (mState == State.Stopped){ processStopRequest(true); } @@ -317,7 +317,7 @@ public int onStartCommand(Intent intent, int flags, int startId) { mBroadcastManager.sendBroadcast(updateIntent); } } - else if (action.equals(ACTION_PLAYBACK)){ + else if (ACTION_PLAYBACK.equals(action)){ Serializable playInfo = intent.getSerializableExtra(EXTRA_PLAY_INFO); if (playInfo != null && playInfo instanceof AudioRequest){ if (mState == State.Stopped || @@ -333,12 +333,12 @@ else if (action.equals(ACTION_PLAYBACK)){ processTogglePlaybackRequest(); } - else if (action.equals(ACTION_PLAY)){ processPlayRequest(); } - else if (action.equals(ACTION_PAUSE)){ processPauseRequest(); } - else if (action.equals(ACTION_SKIP)){ processSkipRequest(); } - else if (action.equals(ACTION_STOP)){ processStopRequest(); } - else if (action.equals(ACTION_REWIND)){ processRewindRequest(); } - else if (action.equals(ACTION_UPDATE_REPEAT)){ + else if (ACTION_PLAY.equals(action)){ processPlayRequest(); } + else if (ACTION_PAUSE.equals(action)){ processPauseRequest(); } + else if (ACTION_SKIP.equals(action)){ processSkipRequest(); } + else if (ACTION_STOP.equals(action)){ processStopRequest(); } + else if (ACTION_REWIND.equals(action)){ processRewindRequest(); } + else if (ACTION_UPDATE_REPEAT.equals(action)){ Serializable repeatInfo = intent.getSerializableExtra( EXTRA_REPEAT_INFO); if (repeatInfo != null && mAudioRequest != null){ diff --git a/app/src/main/java/com/quran/labs/androidquran/service/util/AudioIntentReceiver.java b/app/src/main/java/com/quran/labs/androidquran/service/util/AudioIntentReceiver.java index 92845286a2..ef541726ce 100644 --- a/app/src/main/java/com/quran/labs/androidquran/service/util/AudioIntentReceiver.java +++ b/app/src/main/java/com/quran/labs/androidquran/service/util/AudioIntentReceiver.java @@ -20,13 +20,13 @@ package com.quran.labs.androidquran.service.util; +import com.quran.labs.androidquran.service.AudioService; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.view.KeyEvent; -import com.quran.labs.androidquran.service.AudioService; - /** * Receives broadcasted intents. In particular, we are interested in the * android.media.AUDIO_BECOMING_NOISY and android.intent.action.MEDIA_BUTTON @@ -48,7 +48,8 @@ public void onReceive(Context context, Intent intent) { } else if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) { KeyEvent keyEvent = (KeyEvent) intent.getExtras().get( Intent.EXTRA_KEY_EVENT); - if (keyEvent.getAction() != KeyEvent.ACTION_DOWN){ + if (keyEvent == null || + keyEvent.getAction() != KeyEvent.ACTION_DOWN){ return; } diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/PagerActivity.java b/app/src/main/java/com/quran/labs/androidquran/ui/PagerActivity.java index 5464c7a181..0bd0048ccb 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/PagerActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/PagerActivity.java @@ -1756,6 +1756,7 @@ public void updateAyahStartSelection( clearAyahModeHighlights(); mStart = mEnd = suraAyah; if (mAyahToolBar.isShowing()) { + mAyahToolBar.resetMenu(); updateToolbarPosition(suraAyah, tracker); } if (mSlidingPanel.isPaneVisible()) { diff --git a/app/src/main/java/com/quran/labs/androidquran/widgets/AyahToolBar.java b/app/src/main/java/com/quran/labs/androidquran/widgets/AyahToolBar.java index 5886f2e1cd..28c126b71c 100644 --- a/app/src/main/java/com/quran/labs/androidquran/widgets/AyahToolBar.java +++ b/app/src/main/java/com/quran/labs/androidquran/widgets/AyahToolBar.java @@ -218,6 +218,10 @@ public boolean isShowing() { return mIsShowing; } + public void resetMenu() { + showMenu(mMenu); + } + public void showMenu() { showMenu(mMenu); setVisibility(VISIBLE);