Skip to content

Commit

Permalink
Move some audio models out of app and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Jan 13, 2024
1 parent 9aff949 commit 600b596
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import android.content.Intent
import com.quran.data.model.SuraAyah
import com.quran.labs.androidquran.R
import com.quran.labs.androidquran.common.audio.model.QariItem
import com.quran.labs.androidquran.dao.audio.AudioPathInfo
import com.quran.labs.androidquran.dao.audio.AudioRequest
import com.quran.labs.androidquran.common.audio.model.playback.AudioPathInfo
import com.quran.labs.androidquran.common.audio.model.playback.AudioRequest
import com.quran.labs.androidquran.data.QuranDisplayData
import com.quran.labs.androidquran.presenter.Presenter
import com.quran.labs.androidquran.service.QuranDownloadService
import com.quran.labs.androidquran.common.audio.model.AudioDownloadMetadata
import com.quran.labs.androidquran.common.audio.model.download.AudioDownloadMetadata
import com.quran.labs.androidquran.service.util.ServiceIntentHelper
import com.quran.labs.androidquran.ui.PagerActivity
import com.quran.labs.androidquran.util.AudioUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.quran.labs.androidquran.presenter.audio.service

import com.quran.data.core.QuranInfo
import com.quran.labs.androidquran.dao.audio.AudioPlaybackInfo
import com.quran.labs.androidquran.dao.audio.AudioRequest
import com.quran.labs.androidquran.common.audio.model.playback.AudioRequest
import com.quran.data.model.SuraAyah
import com.quran.labs.androidquran.extension.requiresBasmallah
import java.util.Locale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import com.quran.data.model.SuraAyah
import com.quran.labs.androidquran.QuranApplication
import com.quran.labs.androidquran.R
import com.quran.labs.androidquran.dao.audio.AudioPlaybackInfo
import com.quran.labs.androidquran.dao.audio.AudioRequest
import com.quran.labs.androidquran.common.audio.model.playback.AudioRequest
import com.quran.labs.androidquran.data.Constants
import com.quran.labs.androidquran.data.QuranDisplayData
import com.quran.labs.androidquran.data.QuranFileConstants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.quran.data.core.QuranInfo
import com.quran.data.di.AppScope
import com.quran.data.model.SuraAyah
import com.quran.data.model.audio.Qari
import com.quran.labs.androidquran.common.audio.model.AudioDownloadMetadata
import com.quran.labs.androidquran.common.audio.model.download.AudioDownloadMetadata
import com.quran.labs.androidquran.service.QuranDownloadService
import com.quran.labs.androidquran.util.AudioUtils
import com.quran.mobile.common.download.Downloader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import com.quran.labs.androidquran.bridge.ReadingEventPresenterBridge;
import com.quran.labs.androidquran.common.QuranAyahInfo;
import com.quran.labs.androidquran.common.audio.model.QariItem;
import com.quran.labs.androidquran.dao.audio.AudioRequest;
import com.quran.labs.androidquran.common.audio.model.playback.AudioRequest;
import com.quran.labs.androidquran.data.Constants;
import com.quran.labs.androidquran.data.QuranDataProvider;
import com.quran.labs.androidquran.data.QuranDisplayData;
Expand Down Expand Up @@ -1159,7 +1159,7 @@ private void switchToTranslation() {
endAyahMode();
}

if (translations.size() == 0) {
if (translations.isEmpty()) {
startTranslationManager();
} else {
int page = getCurrentPage();
Expand Down Expand Up @@ -1204,14 +1204,6 @@ public List<LocalTranslation> getTranslations() {
return translations;
}

public String[] getTranslationNames() {
return translationNames;
}

public Set<String> getActiveTranslationsFilesNames() {
return activeTranslationsFilesNames;
}

@Override
public void onAddTagSelected() {
FragmentManager fm = getSupportFragmentManager();
Expand Down Expand Up @@ -1852,7 +1844,7 @@ private void shareAyah(SuraAyah start, SuraAyah end, final boolean isCopy) {
compositeDisposable.add(
arabicDatabaseUtils
.getVerses(start, end)
.filter(quranAyahs -> quranAyahs.size() > 0)
.filter(quranAyahs -> !quranAyahs.isEmpty())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(quranAyahs -> {
if (isCopy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import android.widget.CheckBox
import com.quran.data.core.QuranInfo
import com.quran.data.model.SuraAyah
import com.quran.labs.androidquran.R
import com.quran.labs.androidquran.dao.audio.AudioRequest
import com.quran.labs.androidquran.common.audio.model.playback.AudioRequest
import com.quran.labs.androidquran.ui.PagerActivity
import com.quran.labs.androidquran.ui.helpers.SlidingPagerAdapter
import com.quran.labs.androidquran.ui.util.TypefaceManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.quran.labs.androidquran.common.audio.extension

import com.quran.data.model.SuraAyah
import com.quran.data.model.audio.Qari
import com.quran.labs.androidquran.common.audio.model.PartiallyDownloadedSura
import com.quran.labs.androidquran.common.audio.model.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.model.download.PartiallyDownloadedSura
import com.quran.labs.androidquran.common.audio.model.download.QariDownloadInfo
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.quran.labs.androidquran.common.audio.cache

import com.quran.data.core.QuranFileManager
import com.quran.labs.androidquran.common.audio.cache.command.AudioInfoCommand
import com.quran.labs.androidquran.common.audio.model.AudioDownloadMetadata
import com.quran.labs.androidquran.common.audio.model.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.model.download.AudioDownloadMetadata
import com.quran.labs.androidquran.common.audio.model.download.QariDownloadInfo
import com.quran.mobile.common.download.DownloadInfo
import com.quran.mobile.common.download.DownloadInfoStreams
import kotlinx.coroutines.CoroutineScope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.quran.labs.androidquran.common.audio.cache

import com.quran.labs.androidquran.common.audio.model.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.model.download.QariDownloadInfo
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.quran.labs.androidquran.common.audio.cache.command

import com.quran.data.model.audio.Qari
import com.quran.labs.androidquran.common.audio.model.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.model.download.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.util.QariUtil
import javax.inject.Inject
import okio.FileSystem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.quran.labs.androidquran.common.audio.cache.command

import com.quran.data.core.QuranInfo
import com.quran.labs.androidquran.common.audio.model.PartiallyDownloadedSura
import com.quran.labs.androidquran.common.audio.model.download.PartiallyDownloadedSura
import com.quran.labs.androidquran.common.audio.util.AudioFileUtil
import okio.FileSystem
import okio.Path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.quran.labs.androidquran.common.audio.extension

import com.quran.labs.androidquran.common.audio.model.PartiallyDownloadedSura
import com.quran.labs.androidquran.common.audio.model.download.PartiallyDownloadedSura

fun PartiallyDownloadedSura.didDownloadAyat(currentSura: Int, start: Int, end: Int): Boolean {
val ayat = IntRange(start, end)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.quran.labs.androidquran.common.audio.extension

import com.quran.data.model.SuraAyah
import com.quran.labs.androidquran.common.audio.model.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.model.download.QariDownloadInfo

/**
* Determine whether the range of verses is downloaded
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.quran.labs.androidquran.common.audio.model
package com.quran.labs.androidquran.common.audio.model.download

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.quran.labs.androidquran.common.audio.model
package com.quran.labs.androidquran.common.audio.model.download

data class PartiallyDownloadedSura(val sura: Int, val expectedAyahCount: Int, val downloadedAyat: List<Int>)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.quran.labs.androidquran.common.audio.model
package com.quran.labs.androidquran.common.audio.model.download

import com.quran.data.model.audio.Qari

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.quran.labs.androidquran.dao.audio
package com.quran.labs.androidquran.common.audio.model.playback

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.quran.labs.androidquran.dao.audio
package com.quran.labs.androidquran.common.audio.model.playback

import android.os.Parcelable
import com.quran.data.model.SuraAyah
Expand All @@ -14,7 +14,8 @@ data class AudioRequest(val start: SuraAyah,
val enforceBounds: Boolean,
val playbackSpeed: Float = 1f,
val shouldStream: Boolean,
val audioPathInfo: AudioPathInfo) : Parcelable {
val audioPathInfo: AudioPathInfo
) : Parcelable {
fun isGapless() = qari.isGapless
fun needsIsti3athaAudio() =
!isGapless() || audioPathInfo.gaplessDatabase?.contains("minshawi_murattal") ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.quran.labs.androidquran.common.audio.cache.command
import com.google.common.truth.Truth
import com.quran.data.core.QuranInfo
import com.quran.data.pageinfo.common.MadaniDataSource
import com.quran.labs.androidquran.common.audio.model.PartiallyDownloadedSura
import com.quran.labs.androidquran.common.audio.model.download.PartiallyDownloadedSura
import okio.Path.Companion.toPath
import okio.fakefilesystem.FakeFileSystem
import org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ReadingEventPresenter @Inject constructor(private val quranInfo: QuranInfo
)
private val quranClickInternalFlow = MutableSharedFlow<QuranId>(
replay = 0, extraBufferCapacity = 1, onBufferOverflow = DROP_OLDEST)
private val detailsPanelInternalFlow = MutableStateFlow<Boolean>(false)
private val detailsPanelInternalFlow = MutableStateFlow(false)
private val ayahSelectionInternalFlow = MutableStateFlow<AyahSelection>(AyahSelection.None)

val clicksFlow: Flow<Unit> = clicksInternalFlow.asSharedFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.quran.data.core.QuranFileManager
import com.quran.data.di.ActivityScope
import com.quran.labs.androidquran.common.audio.cache.AudioCacheInvalidator
import com.quran.labs.androidquran.common.audio.cache.QariDownloadInfoManager
import com.quran.labs.androidquran.common.audio.model.AudioDownloadMetadata
import com.quran.labs.androidquran.common.audio.model.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.model.download.AudioDownloadMetadata
import com.quran.labs.androidquran.common.audio.model.download.QariDownloadInfo
import com.quran.mobile.common.download.DownloadConstants
import com.quran.mobile.common.download.DownloadInfo
import com.quran.mobile.common.download.DownloadInfoStreams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.quran.data.model.SuraAyah
import com.quran.data.model.audio.Qari
import com.quran.labs.androidquran.common.audio.cache.QariDownloadInfoManager
import com.quran.labs.androidquran.common.audio.extension.isRangeDownloaded
import com.quran.labs.androidquran.common.audio.model.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.model.download.QariDownloadInfo
import com.quran.labs.androidquran.common.audio.model.QariItem
import com.quran.mobile.feature.qarilist.R
import com.quran.mobile.feature.qarilist.model.QariUiModel
Expand Down

0 comments on commit 600b596

Please sign in to comment.