Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ max_line_length=off
ktlint_standard_property-naming=disabled
ktlint_standard_filename=disabled
ktlint_standard_package-name=disabled
ktlint_code_style=android_studio
ktlint_code_style=android_studio
ktlint_function_naming_ignore_when_annotated_with = Composable
2 changes: 2 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id("dagger.hilt.android.plugin")
id("com.google.firebase.crashlytics")
id("com.google.devtools.ksp")
alias(libs.plugins.compose.compiler)
}

android {
Expand Down Expand Up @@ -83,11 +84,37 @@ android {
abortOnError = false
checkReleaseBuilds = false
}

buildFeatures {
compose = true
}

namespace = "com.simplecityapps.shuttle"

dependencies {
implementation(fileTree("dir" to "libs", "include" to listOf("*.jar")))

val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

// Choose one of the following:
// Material Design 3
implementation(libs.androidx.material3)
// or Material Design 2
implementation(libs.androidx.material)
// or skip Material Design and build directly on top of foundational components
implementation(libs.androidx.foundation)
// or only import the main APIs for the underlying toolkit systems,
// such as input and measurement/layout
implementation(libs.androidx.ui)

// Android Studio Preview support
implementation(libs.androidx.ui.tooling.preview)
debugImplementation(libs.androidx.ui.tooling)

implementation(libs.androidx.lifecycle.viewmodel.compose)

// Shuttle Core
implementation(project(":android:core"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ class CustomTestRunner : AndroidJUnitRunner() {
cl: ClassLoader?,
name: String?,
context: Context?
): Application {
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
): Application = super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import kotlinx.coroutines.DEBUG_PROPERTY_VALUE_ON
import timber.log.Timber

@HiltAndroidApp
class ShuttleApplication : Application(), ActivityIntentProvider, Configuration.Provider {
class ShuttleApplication :
Application(),
ActivityIntentProvider,
Configuration.Provider {
@Inject
lateinit var workerFactory: HiltWorkerFactory

Expand Down Expand Up @@ -62,9 +65,7 @@ class ShuttleApplication : Application(), ActivityIntentProvider, Configuration.

// ActivityIntentProvider Implementation

override fun provideMainActivityIntent(): Intent {
return Intent(this, MainActivity::class.java)
}
override fun provideMainActivityIntent(): Intent = Intent(this, MainActivity::class.java)

// WorkManager

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ interface AppInitializer {
/**
* Optional priority. Higher priority intiializers will be initialized earlier
*/
fun priority(): Int {
return -1
}
fun priority(): Int = -1
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ constructor(
}
}

override fun priority(): Int {
return 1
}
override fun priority(): Int = 1
}

class CrashReportingTree : Timber.Tree() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class MediaStoreContentObserverInitializer
constructor(
@AppCoroutineScope private val appCoroutineScope: CoroutineScope,
private val mediaImporter: MediaImporter
) : ContentObserver(null), AppInitializer {
) : ContentObserver(null),
AppInitializer {
override fun init(application: Application) {
application.contentResolver.registerContentObserver(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ constructor(
}
}

override fun priority(): Int {
return 1
}
override fun priority(): Int = 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ constructor(
Timber.plant(debugLoggingTree)
}

override fun priority(): Int {
return 2
}
override fun priority(): Int = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ class LogMessage(val priority: Int, val tag: String?, val message: String, val t
return result
}

override fun toString(): String {
return "${dateFormat.format(date)}" +
"\n$priority/$tag" +
"\n$message"
}
override fun toString(): String = "${dateFormat.format(date)}" +
"\n$priority/$tag" +
"\n$message"

companion object {
@SuppressLint("SimpleDateFormat")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,27 @@ class AppModule {
fun provideDebugLoggingTree(
@ApplicationContext context: Context,
generalPreferenceManager: GeneralPreferenceManager
): DebugLoggingTree {
return DebugLoggingTree(context, generalPreferenceManager)
}
): DebugLoggingTree = DebugLoggingTree(context, generalPreferenceManager)

@Singleton
@Provides
fun provideArtworkCache(): LruCache<String, Bitmap> {
return object : LruCache<String, Bitmap>(10 * 1024 * 1024) {
override fun sizeOf(
key: String,
value: Bitmap
): Int {
return value.allocationByteCount
}
}
fun provideArtworkCache(): LruCache<String, Bitmap> = object : LruCache<String, Bitmap>(10 * 1024 * 1024) {
override fun sizeOf(
key: String,
value: Bitmap
): Int = value.allocationByteCount
}

@Singleton
@Provides
fun provideSortPreferenceManager(preference: SharedPreferences): SortPreferenceManager {
return SortPreferenceManager(preference)
}
fun provideSortPreferenceManager(preference: SharedPreferences): SortPreferenceManager = SortPreferenceManager(preference)

@Singleton
@Provides
fun provideThemeManager(preferenceManager: GeneralPreferenceManager): ThemeManager {
return ThemeManager(preferenceManager)
}
fun provideThemeManager(preferenceManager: GeneralPreferenceManager): ThemeManager = ThemeManager(preferenceManager)

@Singleton
@Provides
@Named("randomSeed")
fun provideRandomSeed(): Long {
return Random().nextLong()
}
fun provideRandomSeed(): Long = Random().nextLong()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@ class ImageLoaderModule {
@Provides
fun provideImageLoader(
@ApplicationContext context: Context
): ArtworkImageLoader {
return GlideImageLoader(context)
}
): ArtworkImageLoader = GlideImageLoader(context)

@Singleton
@Provides
fun provideAggregateRemoteArtworkProvider(
embyRemoteArtworkProvider: EmbyRemoteArtworkProvider,
jellyfinRemoteArtworkProvider: JellyfinRemoteArtworkProvider
): AggregateRemoteArtworkProvider {
return AggregateRemoteArtworkProvider(
mutableSetOf(
embyRemoteArtworkProvider,
jellyfinRemoteArtworkProvider
)
): AggregateRemoteArtworkProvider = AggregateRemoteArtworkProvider(
mutableSetOf(
embyRemoteArtworkProvider,
jellyfinRemoteArtworkProvider
)
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,23 @@ import javax.inject.Singleton
class MediaProviderModule {
@Provides
@Singleton
fun provideFileScanner(): FileScanner {
return FileScanner()
}
fun provideFileScanner(): FileScanner = FileScanner()

@Provides
@Singleton
fun provideKTagLib(): KTagLib {
return KTagLib()
}
fun provideKTagLib(): KTagLib = KTagLib()

@Provides
@Singleton
fun provideTagLibSongProvider(
@ApplicationContext context: Context,
kTagLib: KTagLib,
fileScanner: FileScanner
): TaglibMediaProvider {
return TaglibMediaProvider(context, kTagLib, fileScanner)
}
): TaglibMediaProvider = TaglibMediaProvider(context, kTagLib, fileScanner)

@Provides
@Singleton
fun provideMediaStoreSongProvider(
@ApplicationContext context: Context
): MediaStoreMediaProvider {
return MediaStoreMediaProvider(context)
}
): MediaStoreMediaProvider = MediaStoreMediaProvider(context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,14 @@ class RepositoryModule {
@Singleton
fun provideMediaDatabase(
@ApplicationContext context: Context
): MediaDatabase {
return DatabaseProvider(context).database
}
): MediaDatabase = DatabaseProvider(context).database

@Provides
@Singleton
fun provideSongRepository(
database: MediaDatabase,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): SongRepository {
return LocalSongRepository(appCoroutineScope, database.songDataDao())
}
): SongRepository = LocalSongRepository(appCoroutineScope, database.songDataDao())

@Provides
@Singleton
Expand All @@ -50,44 +46,34 @@ class RepositoryModule {
songRepository: SongRepository,
playlistRepository: PlaylistRepository,
preferenceManager: GeneralPreferenceManager
): MediaImporter {
return MediaImporter(context, songRepository, playlistRepository, preferenceManager)
}
): MediaImporter = MediaImporter(context, songRepository, playlistRepository, preferenceManager)

@Provides
@Singleton
fun provideAlbumRepository(
database: MediaDatabase,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): AlbumRepository {
return LocalAlbumRepository(appCoroutineScope, database.songDataDao())
}
): AlbumRepository = LocalAlbumRepository(appCoroutineScope, database.songDataDao())

@Provides
@Singleton
fun provideAlbumArtistRepository(
database: MediaDatabase,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): AlbumArtistRepository {
return LocalAlbumArtistRepository(appCoroutineScope, database.songDataDao())
}
): AlbumArtistRepository = LocalAlbumArtistRepository(appCoroutineScope, database.songDataDao())

@Provides
@Singleton
fun providePlaylistRepository(
@ApplicationContext context: Context,
database: MediaDatabase,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): PlaylistRepository {
return LocalPlaylistRepository(context, appCoroutineScope, database.playlistDataDao(), database.playlistSongJoinDataDao())
}
): PlaylistRepository = LocalPlaylistRepository(context, appCoroutineScope, database.playlistDataDao(), database.playlistSongJoinDataDao())

@Provides
@Singleton
fun provideGenreRepository(
songRepository: SongRepository,
@AppCoroutineScope appCoroutineScope: CoroutineScope
): GenreRepository {
return LocalGenreRepository(appCoroutineScope, songRepository)
}
): GenreRepository = LocalGenreRepository(appCoroutineScope, songRepository)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import kotlinx.coroutines.tasks.await
import kotlinx.coroutines.withTimeout

@AndroidEntryPoint
class MainActivity :
AppCompatActivity() {
class MainActivity : AppCompatActivity() {
@Inject
lateinit var preferenceManager: GeneralPreferenceManager

Expand Down Expand Up @@ -95,16 +94,12 @@ class MainActivity :

// Private

private fun hasStoragePermission(): Boolean {
return (ContextCompat.checkSelfPermission(this, getStoragePermission()) == PackageManager.PERMISSION_GRANTED)
}
private fun hasStoragePermission(): Boolean = (ContextCompat.checkSelfPermission(this, getStoragePermission()) == PackageManager.PERMISSION_GRANTED)

private fun getStoragePermission(): String {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Manifest.permission.READ_MEDIA_AUDIO
} else {
Manifest.permission.READ_EXTERNAL_STORAGE
}
private fun getStoragePermission(): String = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Manifest.permission.READ_MEDIA_AUDIO
} else {
Manifest.permission.READ_EXTERNAL_STORAGE
}

private fun handleSearchQuery(intent: Intent?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ class ThemeManager(
AppCompatDelegate.setDefaultNightMode(getDayNightMode())
}

private fun getDayNightMode(): Int {
return when (preferenceManager.themeBase) {
GeneralPreferenceManager.Theme.DayNight -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
GeneralPreferenceManager.Theme.Light -> AppCompatDelegate.MODE_NIGHT_NO
GeneralPreferenceManager.Theme.Dark -> AppCompatDelegate.MODE_NIGHT_YES
}
private fun getDayNightMode(): Int = when (preferenceManager.themeBase) {
GeneralPreferenceManager.Theme.DayNight -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
GeneralPreferenceManager.Theme.Light -> AppCompatDelegate.MODE_NIGHT_NO
GeneralPreferenceManager.Theme.Dark -> AppCompatDelegate.MODE_NIGHT_YES
}
}
Loading