Skip to content

Commit

Permalink
Improve support for Android Auto
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Oct 6, 2024
1 parent a5656bf commit 86184b2
Show file tree
Hide file tree
Showing 45 changed files with 172 additions and 382 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ dependencies {
implementation(project(":feature:downloadmanager"))
implementation(project(":feature:qarilist"))

// android auto support
implementation(project(":feature:autoquran"))

implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.coroutines.android)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.quran.labs.androidquran.data
import android.content.Context
import android.text.TextUtils
import androidx.annotation.StringRes

import com.quran.data.core.QuranInfo
import com.quran.data.di.AppScope
import com.quran.data.model.SuraAyah
Expand All @@ -12,9 +11,9 @@ import com.quran.labs.androidquran.R
import com.quran.labs.androidquran.util.QuranUtils
import com.quran.page.common.data.QuranNaming
import com.squareup.anvil.annotations.ContributesBinding

import timber.log.Timber
import javax.inject.Inject
import com.quran.mobile.common.ui.core.R as UiCoreR

@ContributesBinding(AppScope::class)
class QuranDisplayData @Inject constructor(private val quranInfo: QuranInfo): QuranNaming {
Expand Down Expand Up @@ -52,14 +51,14 @@ class QuranDisplayData @Inject constructor(private val quranInfo: QuranInfo): Qu
if (sura < Constants.SURA_FIRST || sura > Constants.SURA_LAST) return ""

val builder = StringBuilder()
val suraNames = context.resources.getStringArray(R.array.sura_names)
val suraNames = context.resources.getStringArray(UiCoreR.array.sura_names)
if (wantPrefix) {
builder.append(context.getString(R.string.quran_sura_title, suraNames[sura - 1]))
} else {
builder.append(suraNames[sura - 1])
}
if (wantTranslation) {
val translation = context.resources.getStringArray(R.array.sura_names_translation)[sura - 1]
val translation = context.resources.getStringArray(UiCoreR.array.sura_names_translation)[sura - 1]
if (!TextUtils.isEmpty(translation)) {
// Some sura names may not have translation
builder.append(" (")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.shawnlin.numberpicker.NumberPicker
import java.text.NumberFormat
import java.util.Locale
import javax.inject.Inject
import com.quran.mobile.common.ui.core.R as UiCoreR

class AyahPlaybackFragment : AyahActionFragment() {
private val defaultVerseRepeat = 1
Expand Down Expand Up @@ -230,7 +231,7 @@ class AyahPlaybackFragment : AyahActionFragment() {
spinner: QuranSpinner,
ayahAdapter: ArrayAdapter<CharSequence>?
) {
val suras = context.resources.getStringArray(R.array.sura_names)
val suras = context.resources.getStringArray(UiCoreR.array.sura_names)
for (i in suras.indices) {
suras[i] = QuranUtils.getLocalizedNumber(context, i + 1) +
". " + suras[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.quran.labs.androidquran.util.QuranUtils
import com.quran.labs.androidquran.view.ForceCompleteTextView
import timber.log.Timber
import javax.inject.Inject
import com.quran.mobile.common.ui.core.R as UiCoreR

/**
* [DialogFragment] of a dialog for quickly selecting and jumping to a particular location in the
Expand Down Expand Up @@ -58,7 +59,7 @@ class JumpFragment : DialogFragment() {

// Sura chooser
suraInput = layout.findViewById(R.id.sura_spinner)
val suras = activity.resources.getStringArray(R.array.sura_names)
val suras = activity.resources.getStringArray(UiCoreR.array.sura_names)
.mapIndexed { index: Int, sura: String? ->
QuranUtils.getLocalizedNumber(activity, index + 1) + ". " + sura
}
Expand Down
1 change: 0 additions & 1 deletion autoquran/.gitignore

This file was deleted.

22 changes: 11 additions & 11 deletions autoquran/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ anvil {
}

android {
compileSdk 34
compileSdk 35

defaultConfig {
applicationId "com.quran.labs.autoquran"
minSdk 28
targetSdk 33
targetSdk 35
versionCode 1
versionName "1.0"

Expand All @@ -38,22 +38,22 @@ android {
android.namespace = "com.quran.labs.autoquran"

dependencies {
implementation project(":feature:autoquran")

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.media:media:1.6.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation project(":common:data")
implementation project(":common:di")
implementation project(":common:data")
implementation project(":common:pages")
implementation project(':pages:madani')
implementation project(':common:upgrade')
// should be api in modules that implement LocalDataUpgrade
implementation project(":common:upgrade")

ksp libs.dagger.compiler
kspTest libs.dagger.compiler

implementation libs.dagger.runtime

if (new File(rootDir, "extras/extras.gradle").exists()) {
implementation project(":extras:pages:default")
} else {
implementation project(":pages:madani")
}
}
21 changes: 0 additions & 21 deletions autoquran/proguard-rules.pro

This file was deleted.

This file was deleted.

26 changes: 2 additions & 24 deletions autoquran/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,7 @@
android:label="@string/app_name"
android:roundIcon="@drawable/icon"
android:supportsRtl="true"
android:theme="@style/Theme.Quran_android">
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<!--
Main music service, provides media browsing and media playback services to
consumers through MediaBrowserService and MediaSession. Consumers connect to it through
MediaBrowser (for browsing) and MediaController (for playback control)
-->
<service
android:name=".QuranAudioService"
android:exported="true">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>

<receiver android:name="androidx.media.session.MediaButtonReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
</application>
android:theme="@style/Theme.Quran_android"
android:name=".QuranAutoApplication" />

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.quran.labs.autoquran

import android.app.Application
import com.quran.labs.autoquran.di.DaggerServiceComponent
import com.quran.labs.feature.autoquran.QuranAudioService
import com.quran.labs.feature.autoquran.di.QuranAutoInjector
import com.quran.mobile.di.QuranApplicationComponent
import com.quran.mobile.di.QuranApplicationComponentProvider

class QuranAutoApplication : Application(), QuranApplicationComponentProvider {
private lateinit var quranAutoApplicationComponent: QuranApplicationComponent

override fun onCreate() {
super.onCreate()
quranAutoApplicationComponent = object : QuranApplicationComponent, QuranAutoInjector {
private val serviceComponent by lazy { DaggerServiceComponent.create() }

override fun inject(service: QuranAudioService) {
serviceComponent.inject(service)
}
}
}

override fun provideQuranApplicationComponent(): QuranApplicationComponent {
return quranAutoApplicationComponent
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.quran.labs.autoquran.di
import com.quran.data.page.provider.QuranDataModule
import com.quran.data.source.PageProvider
import com.quran.data.source.QuranDataSource
import com.quran.labs.autoquran.QuranAudioService
import com.quran.labs.feature.autoquran.QuranAudioService
import dagger.Component
import dagger.Module
import dagger.Provides
Expand Down
Binary file removed autoquran/src/main/res/raw/sample.mp3
Binary file not shown.
1 change: 0 additions & 1 deletion autoquran/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<resources>
<string name="app_name">Quran</string>
<string name="quran_sura_title">Surah %1$s</string>
</resources>
Loading

0 comments on commit 86184b2

Please sign in to comment.