From 116530cc3c6b5b89a58991aefeedd7d126bad776 Mon Sep 17 00:00:00 2001 From: shabinder Date: Wed, 14 Jul 2021 02:15:09 +0530 Subject: [PATCH] Code Cleanup and Formatting and i18n4k dependency --- android/build.gradle.kts | 9 +-- .../main/java/com/shabinder/spotiflyer/App.kt | 7 ++- .../com/shabinder/spotiflyer/MainActivity.kt | 57 ++++++++++--------- .../com/shabinder/spotiflyer/di/AppModule.kt | 2 +- .../spotiflyer/service/ForegroundService.kt | 16 +++--- .../shabinder/spotiflyer/service/Message.kt | 8 +-- .../spotiflyer/service/TrackStatusFlowMap.kt | 6 +- .../com/shabinder/spotiflyer/service/Utils.kt | 5 +- .../spotiflyer/ui/AnalyticsDialog.kt | 22 +++---- .../shabinder/spotiflyer/ui/NetworkDialog.kt | 39 ++++++++----- .../spotiflyer/ui/PermissionDialog.kt | 24 ++++---- .../spotiflyer/utils/SignatureVerification.kt | 7 +-- .../spotiflyer/utils/UtilFunctions.kt | 28 ++++----- .../spotiflyer/utils/autoclear/AutoClear.kt | 5 +- .../utils/autoclear/AutoClearFragment.kt | 2 +- .../autoclear/LifecycleAutoInitializer.kt | 4 +- .../LifecycleCreateAndDestroyObserver.kt | 4 +- .../LifecycleResumeAndPauseObserver.kt | 4 +- .../LifecycleStartAndStopObserver.kt | 4 +- build.gradle.kts | 5 +- .../src/main/kotlin/ktlint-setup.gradle.kts | 32 ++++------- .../shabinder/common/uikit/AndroidDialog.kt | 2 +- .../uikit/configurations/AndroidTypography.kt | 2 +- .../shabinder/common/uikit/ExpectDialog.kt | 2 +- .../shabinder/common/uikit/ExpectImages.kt | 2 +- .../common/uikit/dialogs/Donation.kt | 6 +- .../common/uikit/dialogs/ErrorInfoDialog.kt | 6 +- .../common/uikit/screens/SpotiFlyerListUi.kt | 13 +++-- .../common/uikit/screens/SpotiFlyerMainUi.kt | 4 +- .../uikit/screens/SpotiFlyerPreferenceUi.kt | 12 ++-- .../shabinder/common/uikit/DesktopDialog.kt | 2 +- .../uikit/configurations/DesktopTypography.kt | 3 +- common/data-models/build.gradle.kts | 6 +- .../kotlin/com/shabinder/common/Ext.kt | 2 +- .../com/shabinder/common/models/CorsProxy.kt | 2 +- .../common/models/SpotiFlyerException.kt | 26 ++++----- .../shabinder/common/models/event/Event.kt | 5 +- .../shabinder/common/models/event/Factory.kt | 2 +- .../common/models/event/Validation.kt | 2 +- .../event/coroutines/SuspendableEvent.kt | 10 ++-- .../event/coroutines/SuspendedValidation.kt | 3 +- .../common/di/AndroidNetworkObserver.kt | 2 - .../com/shabinder/common/di/AudioTagging.kt | 4 +- .../kotlin/com/shabinder/common/di/Dir.kt | 2 +- .../common/di/FetchPlatformQueryResult.kt | 18 +++--- .../common/di/preference/PreferenceManager.kt | 8 +-- .../common/di/providers/GaanaProvider.kt | 2 +- .../common/di/providers/ProvidersModule.kt | 2 +- .../common/di/providers/SaavnProvider.kt | 6 +- .../common/di/providers/YoutubeMp3.kt | 4 +- .../common/di/providers/YoutubeMusic.kt | 14 ++--- .../common/di/providers/YoutubeProvider.kt | 28 ++++----- .../requests/audioToMp3/AudioToMp3.kt | 14 ++--- .../providers/requests/gaana/GaanaRequests.kt | 1 - .../requests/saavn/JioSaavnRequests.kt | 24 ++++---- .../providers/requests/spotify/SpotifyAuth.kt | 2 +- .../providers/requests/youtubeMp3/Yt1sMp3.kt | 8 +-- .../root/integration/SpotiFlyerRootImpl.kt | 2 +- console-app/build.gradle.kts | 1 - console-app/src/main/java/utils/Ext.kt | 2 +- desktop/build.gradle.kts | 3 +- desktop/src/jvmMain/kotlin/Main.kt | 25 ++++---- .../src/jvmMain/kotlin/utils/AnalyticsExt.kt | 7 +-- gradle.properties | 2 +- .../src/main/java/common/ContentUpdation.kt | 8 +-- .../src/main/java/common/Date.kt | 2 +- .../src/main/java/common/GithubService.kt | 1 - maintenance-tasks/src/main/java/main.kt | 8 +-- .../src/main/java/models/github/Asset.kt | 2 +- .../src/main/java/models/github/Author.kt | 2 +- .../java/models/github/GithubFileContent.kt | 2 +- .../models/github/GithubReleaseInfoItem.kt | 2 +- .../java/models/github/GithubReleasesInfo.kt | 2 +- .../src/main/java/models/github/Reactions.kt | 4 +- .../src/main/java/models/github/Uploader.kt | 2 +- .../java/models/matomo/MatomoDownloads.kt | 2 +- .../java/models/matomo/MatomoDownloadsItem.kt | 2 +- .../main/java/scripts/UpdateAnalyticsImage.kt | 6 +- .../main/java/scripts/UpdateDownloadCards.kt | 13 ++--- maintenance-tasks/src/main/java/utils/Ext.kt | 2 +- 80 files changed, 315 insertions(+), 328 deletions(-) diff --git a/android/build.gradle.kts b/android/build.gradle.kts index c8a186db..395bc8c1 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -23,6 +23,7 @@ plugins { kotlin("android") id("kotlin-parcelize") id("org.jetbrains.compose") + id("ktlint-setup") } group = "com.shabinder" @@ -39,7 +40,7 @@ repositories { android { val props = gradleLocalProperties(rootDir) - if(props.containsKey("storeFileDir")) { + if (props.containsKey("storeFileDir")) { signingConfigs { create("release") { storeFile = file(props.getProperty("storeFileDir")) @@ -65,7 +66,7 @@ android { getByName("release") { isMinifyEnabled = true // isShrinkResources = true - if(props.containsKey("storeFileDir")){ + if (props.containsKey("storeFileDir")) { signingConfig = signingConfigs.getByName("release") } proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") @@ -134,7 +135,7 @@ dependencies { } implementation(Extras.kermit) - //implementation("com.jakewharton.timber:timber:4.7.1") + // implementation("com.jakewharton.timber:timber:4.7.1") implementation("dev.icerock.moko:parcelize:${Versions.mokoParcelize}") implementation("com.github.shabinder:storage-chooser:2.0.4.45") implementation("com.google.accompanist:accompanist-insets:0.12.0") @@ -146,4 +147,4 @@ dependencies { // Desugaring coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5") -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/App.kt b/android/src/main/java/com/shabinder/spotiflyer/App.kt index 9acee230..4d698097 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/App.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/App.kt @@ -34,7 +34,7 @@ import org.matomo.sdk.Matomo import org.matomo.sdk.Tracker import org.matomo.sdk.TrackerBuilder -class App: Application(), KoinComponent { +class App : Application(), KoinComponent { companion object { const val SIGNATURE_HEX = "53304f6d75736a2f30484230334c454b714753525763724259444d3d0a" @@ -42,7 +42,8 @@ class App: Application(), KoinComponent { val tracker: Tracker by lazy { TrackerBuilder.createDefault( - "https://matomo.spotiflyer.ml/matomo.php", 1) + "https://matomo.spotiflyer.ml/matomo.php", 1 + ) .build(Matomo.getInstance(this)).apply { if (BuildConfig.DEBUG) { /*Timber.plant(DebugTree()) @@ -96,4 +97,4 @@ class App: Application(), KoinComponent { } } } -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/MainActivity.kt b/android/src/main/java/com/shabinder/spotiflyer/MainActivity.kt index 28269c65..08e6d08e 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/MainActivity.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/MainActivity.kt @@ -98,7 +98,6 @@ import org.koin.android.ext.android.inject import org.matomo.sdk.extra.TrackHelper import java.io.File - @ExperimentalAnimationApi class MainActivity : ComponentActivity() { @@ -167,7 +166,7 @@ class MainActivity : ComponentActivity() { LaunchedEffect(view) { permissionGranted.value = checkPermissions() - if(preferenceManager.isFirstLaunch) { + if (preferenceManager.isFirstLaunch) { delay(2500) // Ask For Analytics Permission on first Dialog askForAnalyticsPermission = true @@ -187,8 +186,8 @@ class MainActivity : ComponentActivity() { * and Track Downloads for all other releases like F-Droid, * for `Github Downloads` we will track Downloads using : https://tooomm.github.io/github-release-stats/?username=Shabinder&repository=SpotiFlyer * */ - if(isGithubRelease) { checkIfLatestVersion() } - if(preferenceManager.isAnalyticsEnabled && !isGithubRelease) { + if (isGithubRelease) { checkIfLatestVersion() } + if (preferenceManager.isAnalyticsEnabled && !isGithubRelease) { // Download/App Install Event for F-Droid builds TrackHelper.track().download().with(tracker) } @@ -248,7 +247,6 @@ class MainActivity : ComponentActivity() { } /*END: Foreground Service Handlers*/ - @Composable private fun isInternetAvailableState(): State { return internetAvailability.observeAsState() @@ -258,7 +256,7 @@ class MainActivity : ComponentActivity() { android.widget.Toast.makeText( applicationContext, string, - if(long) android.widget.Toast.LENGTH_LONG else android.widget.Toast.LENGTH_SHORT + if (long) android.widget.Toast.LENGTH_LONG else android.widget.Toast.LENGTH_SHORT ).show() } @@ -270,23 +268,24 @@ class MainActivity : ComponentActivity() { private fun spotiFlyerRoot(componentContext: ComponentContext): SpotiFlyerRoot = SpotiFlyerRoot( componentContext, - dependencies = object : SpotiFlyerRoot.Dependencies{ + dependencies = object : SpotiFlyerRoot.Dependencies { override val storeFactory = LoggingStoreFactory(DefaultStoreFactory) override val database = this@MainActivity.dir.db override val fetchQuery = this@MainActivity.fetcher override val dir: Dir = this@MainActivity.dir override val preferenceManager = this@MainActivity.preferenceManager override val downloadProgressFlow: MutableSharedFlow> = trackStatusFlow - override val actions = object: Actions { + override val actions = object : Actions { override val platformActions = object : PlatformActions { override val imageCacheDir: String = applicationContext.cacheDir.absolutePath + File.separator - override val sharedPreferences = applicationContext.getSharedPreferences(SharedPreferencesKey, + override val sharedPreferences = applicationContext.getSharedPreferences( + SharedPreferencesKey, MODE_PRIVATE ) override fun addToLibrary(path: String) { - MediaScannerConnection.scanFile ( + MediaScannerConnection.scanFile( applicationContext, listOf(path).toTypedArray(), null, null ) @@ -298,14 +297,14 @@ class MainActivity : ComponentActivity() { } } - override fun showPopUpMessage(string: String, long: Boolean) = this@MainActivity.showPopUpMessage(string,long) + override fun showPopUpMessage(string: String, long: Boolean) = this@MainActivity.showPopUpMessage(string, long) override fun setDownloadDirectoryAction(callBack: (String) -> Unit) = setUpOnPrefClickListener(callBack) override fun queryActiveTracks() = this@MainActivity.queryActiveTracks() override fun giveDonation() { - openPlatform("",platformLink = "https://razorpay.com/payment-button/pl_GnKuuDBdBu0ank/view/?utm_source=payment_button&utm_medium=button&utm_campaign=payment_button") + openPlatform("", platformLink = "https://razorpay.com/payment-button/pl_GnKuuDBdBu0ank/view/?utm_source=payment_button&utm_medium=button&utm_campaign=payment_button") } override fun shareApp() { @@ -342,25 +341,25 @@ class MainActivity : ComponentActivity() { } } - override fun writeMp3Tags(trackDetails: TrackDetails) {/*IMPLEMENTED*/} + override fun writeMp3Tags(trackDetails: TrackDetails) { /*IMPLEMENTED*/ } - override val isInternetAvailable get() = internetAvailability.value ?: true + override val isInternetAvailable get() = internetAvailability.value ?: true } /* * Analytics Will Only Be Sent if User Granted us the Permission * */ - override val analytics = object: Analytics { + override val analytics = object : Analytics { override fun appLaunchEvent() { - if(preferenceManager.isAnalyticsEnabled){ + if (preferenceManager.isAnalyticsEnabled) { TrackHelper.track() - .event("events","App_Launch") + .event("events", "App_Launch") .name("App Launch").with(tracker) } } override fun homeScreenVisit() { - if(preferenceManager.isAnalyticsEnabled){ + if (preferenceManager.isAnalyticsEnabled) { // HomeScreen Visit Event TrackHelper.track().screen("/main_activity/home_screen") .title("HomeScreen").with(tracker) @@ -368,7 +367,7 @@ class MainActivity : ComponentActivity() { } override fun listScreenVisit() { - if(preferenceManager.isAnalyticsEnabled){ + if (preferenceManager.isAnalyticsEnabled) { // ListScreen Visit Event TrackHelper.track().screen("/main_activity/list_screen") .title("ListScreen").with(tracker) @@ -400,15 +399,17 @@ class MainActivity : ComponentActivity() { } @Suppress("DEPRECATION") - private fun setUpOnPrefClickListener(callBack : (String) -> Unit) { + private fun setUpOnPrefClickListener(callBack: (String) -> Unit) { // Initialize Builder val chooser = StorageChooser.Builder() .withActivity(this) .withFragmentManager(fragmentManager) .withMemoryBar(true) - .setTheme(StorageChooser.Theme(applicationContext).apply { - scheme = applicationContext.resources.getIntArray(R.array.default_dark) - }) + .setTheme( + StorageChooser.Theme(applicationContext).apply { + scheme = applicationContext.resources.getIntArray(R.array.default_dark) + } + ) .setDialogTitle(Strings.setDownloadDirectory()) .allowCustomPath(true) .setType(StorageChooser.DIRECTORY_CHOOSER) @@ -423,7 +424,7 @@ class MainActivity : ComponentActivity() { preferenceManager.setDownloadDirectory(path) callBack(path) showPopUpMessage(Strings.downloadDirectorySetTo("\n${dir.defaultDir()}")) - }else{ + } else { showPopUpMessage(Strings.noWriteAccess("\n$path ")) } } @@ -445,7 +446,7 @@ class MainActivity : ComponentActivity() { // Ignoring battery optimization permissionGranted.value = true } else { - disableDozeMode(disableDozeCode)//Again Ask For Permission!! + disableDozeMode(disableDozeCode) // Again Ask For Permission!! } } } @@ -463,12 +464,12 @@ class MainActivity : ComponentActivity() { val filterLinkRegex = """http.+\w""".toRegex() val string = it.replace("\n".toRegex(), " ") val link = filterLinkRegex.find(string)?.value.toString() - Log.i("Intent",link) + Log.i("Intent", link) lifecycleScope.launch { - while(!this@MainActivity::root.isInitialized){ + while (!this@MainActivity::root.isInitialized) { delay(100) } - if(methods.value.isInternetAvailable)callBacks.searchLink(link) + if (methods.value.isInternetAvailable)callBacks.searchLink(link) } } } diff --git a/android/src/main/java/com/shabinder/spotiflyer/di/AppModule.kt b/android/src/main/java/com/shabinder/spotiflyer/di/AppModule.kt index 54077069..7a6cd01e 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/di/AppModule.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/di/AppModule.kt @@ -18,4 +18,4 @@ package com.shabinder.spotiflyer.di import org.koin.dsl.module -fun appModule(enableLogging:Boolean = false) = module {} +fun appModule(enableLogging: Boolean = false) = module {} diff --git a/android/src/main/java/com/shabinder/spotiflyer/service/ForegroundService.kt b/android/src/main/java/com/shabinder/spotiflyer/service/ForegroundService.kt index b16369e2..e0cb154f 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/service/ForegroundService.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/service/ForegroundService.kt @@ -57,7 +57,7 @@ import java.io.File class ForegroundService : LifecycleService() { private var downloadService: AutoClear = autoClear { ParallelExecutor(Dispatchers.IO) } - val trackStatusFlowMap by autoClear { TrackStatusFlowMap(MutableSharedFlow(replay = 1),lifecycleScope) } + val trackStatusFlowMap by autoClear { TrackStatusFlowMap(MutableSharedFlow(replay = 1), lifecycleScope) } private val fetcher: FetchPlatformQueryResult by inject() private val logger: Kermit by inject() private val dir: Dir by inject() @@ -133,18 +133,18 @@ class ForegroundService : LifecycleService() { updateNotification() } - trackList.forEach { - trackStatusFlowMap[it.title] = DownloadStatus.Queued + for (track in trackList) { + trackStatusFlowMap[track.title] = DownloadStatus.Queued lifecycleScope.launch { downloadService.value.execute { - fetcher.findMp3DownloadLink(it).fold( + fetcher.findMp3DownloadLink(track).fold( success = { url -> - enqueueDownload(url, it) + enqueueDownload(url, track) }, failure = { error -> failed++ updateNotification() - trackStatusFlowMap[it.title] = DownloadStatus.Failed(error) + trackStatusFlowMap[track.title] = DownloadStatus.Failed(error) } ) } @@ -238,7 +238,7 @@ class ForegroundService : LifecycleService() { lifecycleScope.launch { logger.d(TAG) { "Killing Self" } messageList = messageList.getEmpty().apply { - set(index = 0, Message(Strings.cleaningAndExiting(),DownloadStatus.NotDownloaded)) + set(index = 0, Message(Strings.cleaningAndExiting(), DownloadStatus.NotDownloaded)) } downloadService.getOrNull()?.close() downloadService.reset() @@ -260,7 +260,7 @@ class ForegroundService : LifecycleService() { setSmallIcon(R.drawable.ic_download_arrow) setContentTitle("${Strings.total()}: $total ${Strings.completed()}:$converted ${Strings.failed()}:$failed") setSilent(true) - setProgress(total,failed+converted,false) + setProgress(total, failed + converted, false) setStyle( NotificationCompat.InboxStyle().run { addLine(messageList[messageList.size - 1].asString()) diff --git a/android/src/main/java/com/shabinder/spotiflyer/service/Message.kt b/android/src/main/java/com/shabinder/spotiflyer/service/Message.kt index af899888..6e917a96 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/service/Message.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/service/Message.kt @@ -7,7 +7,7 @@ typealias Message = Pair val Message.title: String get() = first -val Message.downloadStatus: DownloadStatus get() = second +val Message.downloadStatus: DownloadStatus get() = second val Message.progress: String get() = when (downloadStatus) { is DownloadStatus.Downloading -> "-> ${(downloadStatus as DownloadStatus.Downloading).progress}%" @@ -18,12 +18,12 @@ val Message.progress: String get() = when (downloadStatus) { is DownloadStatus.NotDownloaded -> "" } -val emptyMessage = Message("",DownloadStatus.NotDownloaded) +val emptyMessage = Message("", DownloadStatus.NotDownloaded) // `Progress` is not being shown because we don't get get consistent Updates from Download Fun , // all Progress data is emitted all together from fun fun Message.asString(): String { - val statusString = when(downloadStatus){ + val statusString = when (downloadStatus) { is DownloadStatus.Downloading -> Strings.downloading() is DownloadStatus.Converting -> Strings.processing() else -> "" @@ -31,4 +31,4 @@ fun Message.asString(): String { return "$statusString $title ${""/*progress*/}".trim() } -fun List.getEmpty(): MutableList = java.util.Collections.synchronizedList(MutableList(size) { emptyMessage }) \ No newline at end of file +fun List.getEmpty(): MutableList = java.util.Collections.synchronizedList(MutableList(size) { emptyMessage }) diff --git a/android/src/main/java/com/shabinder/spotiflyer/service/TrackStatusFlowMap.kt b/android/src/main/java/com/shabinder/spotiflyer/service/TrackStatusFlowMap.kt index be4bcab7..10027965 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/service/TrackStatusFlowMap.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/service/TrackStatusFlowMap.kt @@ -6,12 +6,12 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.launch class TrackStatusFlowMap( - val statusFlow: MutableSharedFlow>, + val statusFlow: MutableSharedFlow>, private val scope: CoroutineScope -): HashMap() { +) : HashMap() { override fun put(key: String, value: DownloadStatus): DownloadStatus? { val res = super.put(key, value) scope.launch { statusFlow.emit(this@TrackStatusFlowMap) } return res } -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/service/Utils.kt b/android/src/main/java/com/shabinder/spotiflyer/service/Utils.kt index 309e68fd..fdd75530 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/service/Utils.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/service/Utils.kt @@ -8,7 +8,7 @@ import java.io.File **/ fun cleanFiles(dir: File) { try { - Log.d("File Cleaning","Starting Cleaning in ${dir.path} ") + Log.d("File Cleaning", "Starting Cleaning in ${dir.path} ") val fList = dir.listFiles() fList?.let { for (file in fList) { @@ -16,7 +16,7 @@ fun cleanFiles(dir: File) { cleanFiles(file) } else if (file.isFile) { if (file.path.toString().substringAfterLast(".") != "mp3") { - Log.d("Files Cleaning","Cleaning ${file.path}") + Log.d("Files Cleaning", "Cleaning ${file.path}") file.delete() } } @@ -24,4 +24,3 @@ fun cleanFiles(dir: File) { } } catch (e: Exception) { e.printStackTrace() } } - diff --git a/android/src/main/java/com/shabinder/spotiflyer/ui/AnalyticsDialog.kt b/android/src/main/java/com/shabinder/spotiflyer/ui/AnalyticsDialog.kt index 63bed6b6..1f29413e 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/ui/AnalyticsDialog.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/ui/AnalyticsDialog.kt @@ -34,8 +34,8 @@ import com.shabinder.common.uikit.configurations.colorPrimary @ExperimentalAnimationApi @Composable fun AnalyticsDialog( - isVisible:Boolean, - enableAnalytics: ()->Unit, + isVisible: Boolean, + enableAnalytics: () -> Unit, dismissDialog: () -> Unit, ) { // Analytics Permission Dialog @@ -43,10 +43,10 @@ fun AnalyticsDialog( AlertDialog( onDismissRequest = dismissDialog, title = { - Row(verticalAlignment = Alignment.CenterVertically,horizontalArrangement = Arrangement.SpaceEvenly) { - Icon(Icons.Rounded.Insights,Strings.analytics(), Modifier.size(42.dp)) + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceEvenly) { + Icon(Icons.Rounded.Insights, Strings.analytics(), Modifier.size(42.dp)) Spacer(Modifier.padding(horizontal = 8.dp)) - Text(Strings.grantAnalytics(),style = SpotiFlyerTypography.h5,textAlign = TextAlign.Center) + Text(Strings.grantAnalytics(), style = SpotiFlyerTypography.h5, textAlign = TextAlign.Center) } }, backgroundColor = Color.DarkGray, @@ -60,7 +60,7 @@ fun AnalyticsDialog( shape = SpotiFlyerShapes.medium, colors = ButtonDefaults.buttonColors(backgroundColor = Color(0xFF303030)) ) { - Text(Strings.no(),color = colorPrimary,fontSize = 18.sp,textAlign = TextAlign.Center) + Text(Strings.no(), color = colorPrimary, fontSize = 18.sp, textAlign = TextAlign.Center) } Spacer(Modifier.padding(vertical = 4.dp)) TextButton( @@ -73,14 +73,14 @@ fun AnalyticsDialog( .padding(horizontal = 8.dp), shape = SpotiFlyerShapes.medium ) { - Text(Strings.yes(),color = Color.Black,fontSize = 18.sp,textAlign = TextAlign.Center) + Text(Strings.yes(), color = Color.Black, fontSize = 18.sp, textAlign = TextAlign.Center) } } }, text = { - Text(Strings.analyticsDescription(),style = SpotiFlyerTypography.body2,textAlign = TextAlign.Center) + Text(Strings.analyticsDescription(), style = SpotiFlyerTypography.body2, textAlign = TextAlign.Center) }, - properties = DialogProperties(dismissOnBackPress = false,dismissOnClickOutside = false) + properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false) ) - } -} \ No newline at end of file + } +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/ui/NetworkDialog.kt b/android/src/main/java/com/shabinder/spotiflyer/ui/NetworkDialog.kt index c5f2b7ff..9e414a00 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/ui/NetworkDialog.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/ui/NetworkDialog.kt @@ -53,10 +53,10 @@ import kotlinx.coroutines.delay @Composable fun NetworkDialog( networkAvailability: State -){ +) { var visible by remember { mutableStateOf(false) } - LaunchedEffect(Unit){ + LaunchedEffect(Unit) { delay(2600) visible = true } @@ -75,21 +75,30 @@ fun NetworkDialog( Text("Retry",color = Color.Black,fontSize = 18.sp,textAlign = TextAlign.Center) Icon(Icons.Rounded.SyncProblem,"Check Network Connection Again") } - */}, - title = { Text(Strings.noInternetConnection(), - style = SpotiFlyerTypography.h5, - textAlign = TextAlign.Center) }, + */ + }, + title = { + Text( + Strings.noInternetConnection(), + style = SpotiFlyerTypography.h5, + textAlign = TextAlign.Center + ) + }, backgroundColor = Color.DarkGray, text = { - Column(horizontalAlignment = Alignment.CenterHorizontally,verticalArrangement = Arrangement.Center){ + Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) { Spacer(modifier = Modifier.padding(8.dp)) - Row(verticalAlignment = Alignment.CenterVertically, + Row( + verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(vertical = 6.dp) ) { - Image(Icons.Rounded.CloudOff, - Strings.noInternetConnection(),Modifier.size(42.dp),colorFilter = ColorFilter.tint( - colorOffWhite - )) + Image( + Icons.Rounded.CloudOff, + Strings.noInternetConnection(), Modifier.size(42.dp), + colorFilter = ColorFilter.tint( + colorOffWhite + ) + ) Spacer(modifier = Modifier.padding(start = 16.dp)) Text( text = Strings.checkInternetConnection(), @@ -97,8 +106,8 @@ fun NetworkDialog( ) } } - } - ,shape = SpotiFlyerShapes.medium + }, + shape = SpotiFlyerShapes.medium ) } -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/ui/PermissionDialog.kt b/android/src/main/java/com/shabinder/spotiflyer/ui/PermissionDialog.kt index 4412d644..a4d29a86 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/ui/PermissionDialog.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/ui/PermissionDialog.kt @@ -38,9 +38,9 @@ import kotlinx.coroutines.delay @Composable fun PermissionDialog( permissionGranted: Boolean, - requestStoragePermission:() -> Unit, - disableDozeMode:() -> Unit, -){ + requestStoragePermission: () -> Unit, + disableDozeMode: () -> Unit, +) { var askForPermission by remember { mutableStateOf(false) } LaunchedEffect(Unit) { delay(2600) @@ -61,18 +61,20 @@ fun PermissionDialog( Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp).fillMaxWidth() .background(colorPrimary, shape = SpotiFlyerShapes.medium) .padding(horizontal = 8.dp), - ){ - Text(Strings.grantPermissions(),color = Color.Black,fontSize = 18.sp,textAlign = TextAlign.Center) + ) { + Text(Strings.grantPermissions(), color = Color.Black, fontSize = 18.sp, textAlign = TextAlign.Center) } - },title = { Text(Strings.requiredPermissions(),style = SpotiFlyerTypography.h5,textAlign = TextAlign.Center) }, + }, + title = { Text(Strings.requiredPermissions(), style = SpotiFlyerTypography.h5, textAlign = TextAlign.Center) }, backgroundColor = Color.DarkGray, text = { - Column{ + Column { Spacer(modifier = Modifier.padding(8.dp)) - Row(verticalAlignment = Alignment.CenterVertically, + Row( + verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(vertical = 6.dp) ) { - Icon(Icons.Rounded.SdStorage,Strings.storagePermission()) + Icon(Icons.Rounded.SdStorage, Strings.storagePermission()) Spacer(modifier = Modifier.padding(start = 16.dp)) Column { Text( @@ -89,7 +91,7 @@ fun PermissionDialog( modifier = Modifier.fillMaxWidth().padding(top = 6.dp), verticalAlignment = Alignment.CenterVertically ) { - Icon(Icons.Rounded.SystemSecurityUpdate,Strings.backgroundRunning()) + Icon(Icons.Rounded.SystemSecurityUpdate, Strings.backgroundRunning()) Spacer(modifier = Modifier.padding(start = 16.dp)) Column { Text( @@ -123,4 +125,4 @@ fun PermissionDialog( } ) } -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/utils/SignatureVerification.kt b/android/src/main/java/com/shabinder/spotiflyer/utils/SignatureVerification.kt index 176ae381..2cd767f9 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/utils/SignatureVerification.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/utils/SignatureVerification.kt @@ -5,7 +5,6 @@ import android.content.Context import android.content.pm.PackageInfo import android.content.pm.PackageManager import android.util.Base64 -import android.util.Log import com.shabinder.spotiflyer.App import java.security.MessageDigest @@ -22,14 +21,14 @@ fun checkAppSignature(context: Context): Boolean { // Log.d("REMOVE_ME", "Include this string as a value for SIGNATURE:$currentSignature") // Log.d("REMOVE_ME HEX", "Include this string as a value for SIGNATURE Hex:${currentSignature.toByteArray().toHEX()}") - //compare signatures + // compare signatures if (App.SIGNATURE_HEX == currentSignature.toByteArray().toHEX()) { return true } } } catch (e: Exception) { e.printStackTrace() - //assumes an issue in checking signature., but we let the caller decide on what to do. + // assumes an issue in checking signature., but we let the caller decide on what to do. } return false } @@ -40,4 +39,4 @@ fun ByteArray.toHEX(): String { builder.append(String.format("%02x", aByte)) } return builder.toString() -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/utils/UtilFunctions.kt b/android/src/main/java/com/shabinder/spotiflyer/utils/UtilFunctions.kt index 38af2bd1..d7d7c6ac 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/utils/UtilFunctions.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/utils/UtilFunctions.kt @@ -32,9 +32,9 @@ import com.github.javiersantos.appupdater.enums.Display import com.github.javiersantos.appupdater.enums.UpdateFrom fun Activity.checkIfLatestVersion() { - AppUpdater(this,0).run { + AppUpdater(this, 0).run { setDisplay(Display.NOTIFICATION) - showAppUpdated(false)//true:Show App is Updated Dialog + showAppUpdated(false) // true:Show App is Updated Dialog setUpdateFrom(UpdateFrom.XML) setUpdateXML("https://raw.githubusercontent.com/Shabinder/SpotiFlyer/Compose/app/src/main/res/xml/app_update.xml") setCancelable(false) @@ -42,24 +42,26 @@ fun Activity.checkIfLatestVersion() { } } -fun Activity.checkPermissions():Boolean = ContextCompat - .checkSelfPermission(this, - Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED - && - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ - ContextCompat.checkSelfPermission(this, - Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS) == PackageManager.PERMISSION_GRANTED - } else true - +fun Activity.checkPermissions(): Boolean = ContextCompat + .checkSelfPermission( + this, + Manifest.permission.WRITE_EXTERNAL_STORAGE + ) == PackageManager.PERMISSION_GRANTED && + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + ContextCompat.checkSelfPermission( + this, + Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS + ) == PackageManager.PERMISSION_GRANTED + } else true @SuppressLint("BatteryLife", "ObsoleteSdkInt") -fun Activity.disableDozeMode(requestCode:Int) { +fun Activity.disableDozeMode(requestCode: Int) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { val pm = this.getSystemService(Context.POWER_SERVICE) as PowerManager val isIgnoringBatteryOptimizations = pm.isIgnoringBatteryOptimizations(packageName) if (!isIgnoringBatteryOptimizations) { - val intent = Intent().apply{ + val intent = Intent().apply { action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS data = Uri.parse("package:$packageName") } diff --git a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/AutoClear.kt b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/AutoClear.kt index 1d5af9a5..0ddab1bb 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/AutoClear.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/AutoClear.kt @@ -2,7 +2,6 @@ package com.shabinder.spotiflyer.utils.autoclear import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner -import com.shabinder.common.requireNotNull import com.shabinder.spotiflyer.utils.autoclear.AutoClear.Companion.TRIGGER import com.shabinder.spotiflyer.utils.autoclear.lifecycleobservers.LifecycleCreateAndDestroyObserver import com.shabinder.spotiflyer.utils.autoclear.lifecycleobservers.LifecycleResumeAndPauseObserver @@ -34,7 +33,7 @@ class AutoClear( fun getOrNull(): T? = _value private val observer: LifecycleAutoInitializer by lazy { - when(trigger) { + when (trigger) { TRIGGER.ON_CREATE -> LifecycleCreateAndDestroyObserver(initializer) TRIGGER.ON_START -> LifecycleStartAndStopObserver(initializer) TRIGGER.ON_RESUME -> LifecycleResumeAndPauseObserver(initializer) @@ -74,4 +73,4 @@ fun LifecycleOwner.autoClear( initializer: () -> T ): AutoClear { return AutoClear(this.lifecycle, initializer, trigger) -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/AutoClearFragment.kt b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/AutoClearFragment.kt index 63c385fc..6e5c7609 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/AutoClearFragment.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/AutoClearFragment.kt @@ -59,4 +59,4 @@ class AutoClearFragment( fun Fragment.autoClear(initializer: () -> T): AutoClearFragment { return AutoClearFragment(this, initializer) -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/LifecycleAutoInitializer.kt b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/LifecycleAutoInitializer.kt index f1475372..5a41992d 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/LifecycleAutoInitializer.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/LifecycleAutoInitializer.kt @@ -2,6 +2,6 @@ package com.shabinder.spotiflyer.utils.autoclear import androidx.lifecycle.DefaultLifecycleObserver -interface LifecycleAutoInitializer: DefaultLifecycleObserver { +interface LifecycleAutoInitializer : DefaultLifecycleObserver { var value: T? -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleCreateAndDestroyObserver.kt b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleCreateAndDestroyObserver.kt index 9219b22c..81ba6d30 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleCreateAndDestroyObserver.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleCreateAndDestroyObserver.kt @@ -3,7 +3,7 @@ package com.shabinder.spotiflyer.utils.autoclear.lifecycleobservers import androidx.lifecycle.LifecycleOwner import com.shabinder.spotiflyer.utils.autoclear.LifecycleAutoInitializer -class LifecycleCreateAndDestroyObserver( +class LifecycleCreateAndDestroyObserver( private val initializer: (() -> T)? ) : LifecycleAutoInitializer { @@ -18,4 +18,4 @@ class LifecycleCreateAndDestroyObserver( super.onDestroy(owner) value = null } -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleResumeAndPauseObserver.kt b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleResumeAndPauseObserver.kt index b68feb7a..088a113e 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleResumeAndPauseObserver.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleResumeAndPauseObserver.kt @@ -3,7 +3,7 @@ package com.shabinder.spotiflyer.utils.autoclear.lifecycleobservers import androidx.lifecycle.LifecycleOwner import com.shabinder.spotiflyer.utils.autoclear.LifecycleAutoInitializer -class LifecycleResumeAndPauseObserver( +class LifecycleResumeAndPauseObserver( private val initializer: (() -> T)? ) : LifecycleAutoInitializer { @@ -18,4 +18,4 @@ class LifecycleResumeAndPauseObserver( super.onPause(owner) value = null } -} \ No newline at end of file +} diff --git a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleStartAndStopObserver.kt b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleStartAndStopObserver.kt index d7c4d079..94439f21 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleStartAndStopObserver.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/utils/autoclear/lifecycleobservers/LifecycleStartAndStopObserver.kt @@ -3,7 +3,7 @@ package com.shabinder.spotiflyer.utils.autoclear.lifecycleobservers import androidx.lifecycle.LifecycleOwner import com.shabinder.spotiflyer.utils.autoclear.LifecycleAutoInitializer -class LifecycleStartAndStopObserver( +class LifecycleStartAndStopObserver( private val initializer: (() -> T)? ) : LifecycleAutoInitializer { @@ -18,4 +18,4 @@ class LifecycleStartAndStopObserver( super.onStop(owner) value = null } -} \ No newline at end of file +} diff --git a/build.gradle.kts b/build.gradle.kts index da71da60..1e039b6d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,9 +31,8 @@ allprojects { maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") } tasks.withType().configureEach { - kotlinOptions { - jvmTarget = "1.8" - } + dependsOn(":common:data-models:generateI18n4kFiles") + kotlinOptions { jvmTarget = "1.8" } } afterEvaluate { project.extensions.findByType()?.let { kmpExt -> diff --git a/buildSrc/src/main/kotlin/ktlint-setup.gradle.kts b/buildSrc/src/main/kotlin/ktlint-setup.gradle.kts index 972eee6b..40bd7781 100644 --- a/buildSrc/src/main/kotlin/ktlint-setup.gradle.kts +++ b/buildSrc/src/main/kotlin/ktlint-setup.gradle.kts @@ -19,26 +19,14 @@ plugins { id("org.jlleitschuh.gradle.ktlint-idea") } -subprojects { - apply(plugin = "org.jlleitschuh.gradle.ktlint") - apply(plugin = "org.jlleitschuh.gradle.ktlint-idea") - repositories { - // Required to download KtLint - mavenCentral() +ktlint { + outputToConsole.set(true) + ignoreFailures.set(true) + coloredOutput.set(true) + verbose.set(true) + disabledRules.set(setOf("filename,no-wildcard-imports")) + filter { + exclude("**/generated/**") + exclude("**/build/**") } - ktlint { - android.set(true) - outputToConsole.set(true) - ignoreFailures.set(true) - coloredOutput.set(true) - verbose.set(true) - filter { - exclude("**/generated/**") - exclude("**/build/**") - } - } - // Optionally configure plugin - /*configure { - debug.set(true) - }*/ -} \ No newline at end of file +} diff --git a/common/compose/src/androidMain/kotlin/com/shabinder/common/uikit/AndroidDialog.kt b/common/compose/src/androidMain/kotlin/com/shabinder/common/uikit/AndroidDialog.kt index db9d5a46..09fec911 100644 --- a/common/compose/src/androidMain/kotlin/com/shabinder/common/uikit/AndroidDialog.kt +++ b/common/compose/src/androidMain/kotlin/com/shabinder/common/uikit/AndroidDialog.kt @@ -16,4 +16,4 @@ actual fun Dialog( content() } } -} \ No newline at end of file +} diff --git a/common/compose/src/androidMain/kotlin/com/shabinder/common/uikit/configurations/AndroidTypography.kt b/common/compose/src/androidMain/kotlin/com/shabinder/common/uikit/configurations/AndroidTypography.kt index c20dd9c7..4627e4d3 100644 --- a/common/compose/src/androidMain/kotlin/com/shabinder/common/uikit/configurations/AndroidTypography.kt +++ b/common/compose/src/androidMain/kotlin/com/shabinder/common/uikit/configurations/AndroidTypography.kt @@ -14,4 +14,4 @@ actual fun montserratFont() = FontFamily( actual fun pristineFont() = FontFamily( Font(R.font.pristine_script, FontWeight.Bold) -) \ No newline at end of file +) diff --git a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/ExpectDialog.kt b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/ExpectDialog.kt index 88d406ef..339f5f3e 100644 --- a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/ExpectDialog.kt +++ b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/ExpectDialog.kt @@ -7,4 +7,4 @@ expect fun Dialog( isVisible: Boolean, onDismiss: () -> Unit, content: @Composable () -> Unit -) \ No newline at end of file +) diff --git a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/ExpectImages.kt b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/ExpectImages.kt index 0a3a410e..d89974aa 100644 --- a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/ExpectImages.kt +++ b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/ExpectImages.kt @@ -70,4 +70,4 @@ expect fun HeartIcon(): Painter expect fun DownloadImageError(modifier: Modifier) @Composable -expect fun DownloadImageArrow(modifier: Modifier) \ No newline at end of file +expect fun DownloadImageArrow(modifier: Modifier) diff --git a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/dialogs/Donation.kt b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/dialogs/Donation.kt index a4c5f64a..bf90f8b6 100644 --- a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/dialogs/Donation.kt +++ b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/dialogs/Donation.kt @@ -35,7 +35,7 @@ import com.shabinder.common.uikit.RazorPay import com.shabinder.common.uikit.configurations.SpotiFlyerTypography import com.shabinder.common.uikit.configurations.colorAccent -typealias DonationDialogCallBacks = Triple +typealias DonationDialogCallBacks = Triple internal typealias openAction = () -> Unit internal typealias dismissAction = () -> Unit private typealias snoozeAction = () -> Unit @@ -58,7 +58,7 @@ fun DonationDialogComponent(onDismissExtra: () -> Unit): DonationDialogCallBacks onDismissExtra() isDonationDialogVisible = false } - return DonationDialogCallBacks(openDonationDialog,dismissDonationDialog,snoozeDonationDialog) + return DonationDialogCallBacks(openDonationDialog, dismissDonationDialog, snoozeDonationDialog) } @ExperimentalAnimationApi @@ -68,7 +68,7 @@ fun DonationDialog( onDismiss: () -> Unit, onSnooze: () -> Unit ) { - Dialog(isVisible,onDismiss) { + Dialog(isVisible, onDismiss) { Card( modifier = Modifier.fillMaxWidth(), border = BorderStroke(1.dp, Color.Gray) // Gray diff --git a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/dialogs/ErrorInfoDialog.kt b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/dialogs/ErrorInfoDialog.kt index 6e2a164e..639d499f 100644 --- a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/dialogs/ErrorInfoDialog.kt +++ b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/dialogs/ErrorInfoDialog.kt @@ -31,7 +31,7 @@ import com.shabinder.common.uikit.Dialog import com.shabinder.common.uikit.configurations.SpotiFlyerTypography import com.shabinder.common.uikit.configurations.colorAccent -typealias ErrorInfoDialogCallBacks = Pair +typealias ErrorInfoDialogCallBacks = Pair @Composable fun ErrorInfoDialog(error: Throwable): ErrorInfoDialogCallBacks { @@ -75,5 +75,5 @@ fun ErrorInfoDialog(error: Throwable): ErrorInfoDialogCallBacks { } } - return ErrorInfoDialogCallBacks(openErrorDialog,onDismissDialog) -} \ No newline at end of file + return ErrorInfoDialogCallBacks(openErrorDialog, onDismissDialog) +} diff --git a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerListUi.kt b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerListUi.kt index 703d9934..4df55118 100644 --- a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerListUi.kt +++ b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerListUi.kt @@ -121,7 +121,7 @@ fun SpotiFlyerListContent( ) // Donation Dialog Visibility - val (openDonationDialog,dismissDonationDialog,snoozeDonationDialog) = DonationDialogComponent { + val (openDonationDialog, dismissDonationDialog, snoozeDonationDialog) = DonationDialogComponent { component.dismissDonationDialogSetOffset() } @@ -184,11 +184,14 @@ fun TrackCard( CircularProgressIndicator() } is DownloadStatus.Failed -> { - val (openErrorDialog,dismissErrorDialog) = ErrorInfoDialog((track.downloaded as DownloadStatus.Failed).error) + val (openErrorDialog, dismissErrorDialog) = ErrorInfoDialog((track.downloaded as DownloadStatus.Failed).error) - Icon(Icons.Rounded.Info,Strings.downloadError(),tint = lightGray,modifier = Modifier.size(42.dp).clickable { - openErrorDialog() - }.padding(start = 4.dp,end = 12.dp)) + Icon( + Icons.Rounded.Info, Strings.downloadError(), tint = lightGray, + modifier = Modifier.size(42.dp).clickable { + openErrorDialog() + }.padding(start = 4.dp, end = 12.dp) + ) DownloadImageError( Modifier.clickable( diff --git a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerMainUi.kt b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerMainUi.kt index 1033d9cc..824ab801 100644 --- a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerMainUi.kt +++ b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerMainUi.kt @@ -106,7 +106,7 @@ import com.shabinder.common.uikit.rememberScrollbarAdapter fun SpotiFlyerMainContent(component: SpotiFlyerMain) { val model by component.model.subscribeAsState() - val (openDonationDialog,_,_) = DonationDialogComponent { + val (openDonationDialog, _, _) = DonationDialogComponent { component.dismissDonationDialogOffset() } @@ -253,7 +253,7 @@ fun SearchPanel( @Composable fun AboutColumn( modifier: Modifier = Modifier, - analyticsEnabled:Boolean, + analyticsEnabled: Boolean, openDonationDialog: () -> Unit, toggleAnalytics: (enabled: Boolean) -> Unit ) { diff --git a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerPreferenceUi.kt b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerPreferenceUi.kt index 9eeefaff..43422ac9 100644 --- a/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerPreferenceUi.kt +++ b/common/compose/src/commonMain/kotlin/com/shabinder/common/uikit/screens/SpotiFlyerPreferenceUi.kt @@ -47,7 +47,7 @@ import com.shabinder.common.uikit.configurations.colorOffWhite @Composable fun SpotiFlyerPreferenceContent(component: SpotiFlyerPreference) { val model by component.model.subscribeAsState() - + val stateVertical = rememberScrollState(0) Column(Modifier.fillMaxSize().padding(8.dp).verticalScroll(stateVertical)) { @@ -82,7 +82,7 @@ fun SpotiFlyerPreferenceContent(component: SpotiFlyerPreference) { save() } ) - .padding(horizontal = 16.dp,vertical = 2.dp) + .padding(horizontal = 16.dp, vertical = 2.dp) ) { RadioButton( selected = (quality == model.preferredQuality), @@ -98,7 +98,6 @@ fun SpotiFlyerPreferenceContent(component: SpotiFlyerPreference) { ) } } - } Spacer(Modifier.padding(top = 12.dp)) @@ -155,9 +154,8 @@ fun SpotiFlyerPreferenceContent(component: SpotiFlyerPreference) { } } } - Spacer(modifier = Modifier.padding(top = 8.dp)) + Spacer(modifier = Modifier.padding(top = 8.dp)) } - } @OptIn(ExperimentalAnimationApi::class) @@ -165,7 +163,7 @@ fun SpotiFlyerPreferenceContent(component: SpotiFlyerPreference) { fun SettingsRow( icon: Painter, title: String, - value:String, + value: String, editContent: @Composable ColumnScope.(() -> Unit) -> Unit ) { @@ -198,4 +196,4 @@ fun SettingsRow( } } } -} \ No newline at end of file +} diff --git a/common/compose/src/desktopMain/kotlin/com/shabinder/common/uikit/DesktopDialog.kt b/common/compose/src/desktopMain/kotlin/com/shabinder/common/uikit/DesktopDialog.kt index 6a90d3db..b521698e 100644 --- a/common/compose/src/desktopMain/kotlin/com/shabinder/common/uikit/DesktopDialog.kt +++ b/common/compose/src/desktopMain/kotlin/com/shabinder/common/uikit/DesktopDialog.kt @@ -16,4 +16,4 @@ actual fun Dialog( content() } } -} \ No newline at end of file +} diff --git a/common/compose/src/desktopMain/kotlin/com/shabinder/common/uikit/configurations/DesktopTypography.kt b/common/compose/src/desktopMain/kotlin/com/shabinder/common/uikit/configurations/DesktopTypography.kt index 9928136b..f3dd5dda 100644 --- a/common/compose/src/desktopMain/kotlin/com/shabinder/common/uikit/configurations/DesktopTypography.kt +++ b/common/compose/src/desktopMain/kotlin/com/shabinder/common/uikit/configurations/DesktopTypography.kt @@ -4,7 +4,6 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.platform.Font - actual fun montserratFont() = FontFamily( Font("font/montserrat_light.ttf", FontWeight.Light), Font("font/montserrat_regular.ttf", FontWeight.Normal), @@ -14,4 +13,4 @@ actual fun montserratFont() = FontFamily( actual fun pristineFont() = FontFamily( Font("font/pristine_script.ttf", FontWeight.Bold) -) \ No newline at end of file +) diff --git a/common/data-models/build.gradle.kts b/common/data-models/build.gradle.kts index 1abae967..40e36e2a 100644 --- a/common/data-models/build.gradle.kts +++ b/common/data-models/build.gradle.kts @@ -29,9 +29,9 @@ val statelyVersion = "1.1.7" val statelyIsoVersion = "1.1.7-a1" i18n4k { - inputDirectory = "../../translations" - packageName = "com.shabinder.common.translations" - // sourceCodeLocales = listOf("en", "de", "es", "fr", "id", "pt", "ru", "uk") + inputDirectory = "../../translations" + packageName = "com.shabinder.common.translations" + // sourceCodeLocales = listOf("en", "de", "es", "fr", "id", "pt", "ru", "uk") } kotlin { diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/Ext.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/Ext.kt index 98e0e23f..7d303800 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/Ext.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/Ext.kt @@ -1,3 +1,3 @@ package com.shabinder.common -fun T?.requireNotNull() : T = requireNotNull(this) +fun T?.requireNotNull(): T = requireNotNull(this) diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/CorsProxy.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/CorsProxy.kt index 40e57a12..c669479f 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/CorsProxy.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/CorsProxy.kt @@ -49,4 +49,4 @@ sealed class CorsProxy(open val url: String) { * */ var corsProxy: CorsProxy = CorsProxy.SelfHostedCorsProxy() -val corsApi get() = if (activePlatform is TargetPlatforms.Js) corsProxy.url else "" \ No newline at end of file +val corsApi get() = if (activePlatform is TargetPlatforms.Js) corsProxy.url else "" diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/SpotiFlyerException.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/SpotiFlyerException.kt index 19167089..eb98ca57 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/SpotiFlyerException.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/SpotiFlyerException.kt @@ -2,42 +2,42 @@ package com.shabinder.common.models import com.shabinder.common.translations.Strings -sealed class SpotiFlyerException(override val message: String): Exception(message) { +sealed class SpotiFlyerException(override val message: String) : Exception(message) { - data class FeatureNotImplementedYet(override val message: String = Strings.featureUnImplemented()): SpotiFlyerException(message) - data class NoInternetException(override val message: String = Strings.checkInternetConnection()): SpotiFlyerException(message) + data class FeatureNotImplementedYet(override val message: String = Strings.featureUnImplemented()) : SpotiFlyerException(message) + data class NoInternetException(override val message: String = Strings.checkInternetConnection()) : SpotiFlyerException(message) data class MP3ConversionFailed( - val extraInfo:String? = null, + val extraInfo: String? = null, override val message: String = "${Strings.mp3ConverterBusy()} \nCAUSE:$extraInfo" - ): SpotiFlyerException(message) + ) : SpotiFlyerException(message) data class UnknownReason( val exception: Throwable? = null, override val message: String = Strings.unknownError() - ): SpotiFlyerException(message) + ) : SpotiFlyerException(message) data class NoMatchFound( val trackName: String? = null, override val message: String = "$trackName : ${Strings.noMatchFound()}" - ): SpotiFlyerException(message) + ) : SpotiFlyerException(message) data class YoutubeLinkNotFound( val videoID: String? = null, override val message: String = "${Strings.noLinkFound()}: $videoID" - ): SpotiFlyerException(message) + ) : SpotiFlyerException(message) data class DownloadLinkFetchFailed( val trackName: String, val jioSaavnError: Throwable, val ytMusicError: Throwable, override val message: String = "${Strings.noLinkFound()}: $trackName," + - " \n YtMusic Error's StackTrace: ${ytMusicError.stackTraceToString()} \n " + - " \n JioSaavn Error's StackTrace: ${jioSaavnError.stackTraceToString()} \n " - ): SpotiFlyerException(message) + " \n YtMusic Error's StackTrace: ${ytMusicError.stackTraceToString()} \n " + + " \n JioSaavn Error's StackTrace: ${jioSaavnError.stackTraceToString()} \n " + ) : SpotiFlyerException(message) data class LinkInvalid( val link: String? = null, override val message: String = "${Strings.linkNotValid()}\n ${link ?: ""}" - ): SpotiFlyerException(message) -} \ No newline at end of file + ) : SpotiFlyerException(message) +} diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Event.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Event.kt index 0997ab96..a524fb9b 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Event.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Event.kt @@ -130,8 +130,7 @@ inline fun Event.unwrap(failure: (E) -> Nothing): V = inline fun Event.unwrapError(success: (V) -> Nothing): E = apply { component1()?.let(success) }.component2()!! - -sealed class Event: ReadOnlyProperty { +sealed class Event : ReadOnlyProperty { open operator fun component1(): V? = null open operator fun component2(): E? = null @@ -204,4 +203,4 @@ sealed class Event: ReadOnlyProperty { error(ex) } } -} \ No newline at end of file +} diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Factory.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Factory.kt index 9d47d6d7..78414af4 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Factory.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Factory.kt @@ -14,4 +14,4 @@ inline infix fun T.runCatching(block: T.() -> V): Event { } catch (e: Throwable) { Event.error(e) } -} \ No newline at end of file +} diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Validation.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Validation.kt index d302c935..f263252e 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Validation.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/Validation.kt @@ -5,4 +5,4 @@ class Validation(vararg resultSequence: Event<*, E>) { val failures: List = resultSequence.filterIsInstance>().map { it.getThrowable() } val hasFailure = failures.isNotEmpty() -} \ No newline at end of file +} diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/coroutines/SuspendableEvent.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/coroutines/SuspendableEvent.kt index 13f62b0d..af21fc85 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/coroutines/SuspendableEvent.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/coroutines/SuspendableEvent.kt @@ -19,7 +19,7 @@ infix fun SuspendableEvent.or(fallback: V) = whe else -> SuspendableEvent.Success(fallback) } -suspend inline infix fun SuspendableEvent.getOrElse(crossinline fallback:suspend (E) -> V): V { +suspend inline infix fun SuspendableEvent.getOrElse(crossinline fallback: suspend (E) -> V): V { return when (this) { is SuspendableEvent.Success -> value is SuspendableEvent.Failure -> fallback(error) @@ -93,7 +93,6 @@ suspend inline fun SuspendableEvent.fanout( ): SuspendableEvent, *> = flatMap { outer -> other().map { outer to it } } - suspend fun List>.lift(): SuspendableEvent, E> = fold( SuspendableEvent.Success, E>(mutableListOf()) as SuspendableEvent, E> ) { acc, result -> @@ -102,7 +101,7 @@ suspend fun List>.lift(): Suspe } } -sealed class SuspendableEvent: ReadOnlyProperty { +sealed class SuspendableEvent : ReadOnlyProperty { abstract operator fun component1(): V? abstract operator fun component2(): E? @@ -156,7 +155,7 @@ sealed class SuspendableEvent: ReadOnlyProperty // Factory methods fun error(ex: E) = Failure(ex) - inline fun of(value: V?,crossinline fail: (() -> Throwable) = { Throwable() }): SuspendableEvent { + inline fun of(value: V?, crossinline fail: (() -> Throwable) = { Throwable() }): SuspendableEvent { return value?.let { Success(it) } ?: error(fail()) } @@ -172,5 +171,4 @@ sealed class SuspendableEvent: ReadOnlyProperty crossinline block: suspend () -> V ): SuspendableEvent = of(block) } - -} \ No newline at end of file +} diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/coroutines/SuspendedValidation.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/coroutines/SuspendedValidation.kt index ce29ec0d..99473835 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/coroutines/SuspendedValidation.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/event/coroutines/SuspendedValidation.kt @@ -5,5 +5,4 @@ class SuspendedValidation(vararg resultSequence: SuspendableE val failures: List = resultSequence.filterIsInstance>().map { it.getThrowable() } val hasFailure = failures.isNotEmpty() - -} \ No newline at end of file +} diff --git a/common/dependency-injection/src/androidMain/kotlin/com/shabinder/common/di/AndroidNetworkObserver.kt b/common/dependency-injection/src/androidMain/kotlin/com/shabinder/common/di/AndroidNetworkObserver.kt index 3ce71701..f54010f6 100644 --- a/common/dependency-injection/src/androidMain/kotlin/com/shabinder/common/di/AndroidNetworkObserver.kt +++ b/common/dependency-injection/src/androidMain/kotlin/com/shabinder/common/di/AndroidNetworkObserver.kt @@ -28,9 +28,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import java.io.IOException import java.lang.Exception -import java.net.InetSocketAddress import java.net.URL import javax.net.ssl.HttpsURLConnection diff --git a/common/dependency-injection/src/androidMain/kotlin/com/shabinder/common/di/AudioTagging.kt b/common/dependency-injection/src/androidMain/kotlin/com/shabinder/common/di/AudioTagging.kt index 871a6361..8afc4cb6 100644 --- a/common/dependency-injection/src/androidMain/kotlin/com/shabinder/common/di/AudioTagging.kt +++ b/common/dependency-injection/src/androidMain/kotlin/com/shabinder/common/di/AudioTagging.kt @@ -40,7 +40,7 @@ fun Mp3File.setId3v1Tags(track: TrackDetails): Mp3File { album = track.albumName year = track.year comment = "Genres:${track.comment}" - if(track.trackNumber != null) + if (track.trackNumber != null) this.track = track.trackNumber.toString() } this.id3v1Tag = id3v1Tag @@ -60,7 +60,7 @@ suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails) { comment = track.comment lyrics = track.lyrics ?: "" url = track.trackUrl - if(track.trackNumber != null) + if (track.trackNumber != null) this.track = track.trackNumber.toString() } try { diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/Dir.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/Dir.kt index ee877010..bc4af7b4 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/Dir.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/Dir.kt @@ -59,7 +59,7 @@ fun Dir.createDirectories() { createDirectory(defaultDir() + "Albums/") createDirectory(defaultDir() + "Playlists/") createDirectory(defaultDir() + "YT_Downloads/") - } catch (e:Exception){} + } catch (e: Exception) {} } fun Dir.finalOutputDir(itemName: String, type: String, subFolder: String, defaultDir: String, extension: String = ".mp3"): String = diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/FetchPlatformQueryResult.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/FetchPlatformQueryResult.kt index 4442c41d..2ddf6b36 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/FetchPlatformQueryResult.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/FetchPlatformQueryResult.kt @@ -58,7 +58,7 @@ class FetchPlatformQueryResult( suspend fun authenticateSpotifyClient() = spotifyProvider.authenticateSpotifyClient() - suspend fun query(link: String): SuspendableEvent { + suspend fun query(link: String): SuspendableEvent { val result = when { // SPOTIFY link.contains("spotify", true) -> @@ -94,17 +94,17 @@ class FetchPlatformQueryResult( suspend fun findMp3DownloadLink( track: TrackDetails, preferredQuality: AudioQuality = preferenceManager.audioQuality - ): SuspendableEvent = + ): SuspendableEvent = if (track.videoID != null) { // We Already have VideoID when (track.source) { Source.JioSaavn -> { saavnProvider.getSongFromID(track.videoID.requireNotNull()).flatMap { song -> - song.media_url?.let { audioToMp3.convertToMp3(it) } ?: findMp3Link(track,preferredQuality) + song.media_url?.let { audioToMp3.convertToMp3(it) } ?: findMp3Link(track, preferredQuality) } } Source.YouTube -> { - youtubeMp3.getMp3DownloadLink(track.videoID.requireNotNull(),preferredQuality).flatMapError { + youtubeMp3.getMp3DownloadLink(track.videoID.requireNotNull(), preferredQuality).flatMapError { logger.e("Yt1sMp3 Failed") { it.message ?: "couldn't fetch link for ${track.videoID} ,trying manual extraction" } youtubeProvider.ytDownloader.getVideo(track.videoID!!).get()?.url?.let { m4aLink -> audioToMp3.convertToMp3(m4aLink) @@ -113,17 +113,17 @@ class FetchPlatformQueryResult( } else -> { /*We should never reach here for now*/ - findMp3Link(track,preferredQuality) + findMp3Link(track, preferredQuality) } } } else { - findMp3Link(track,preferredQuality) + findMp3Link(track, preferredQuality) } private suspend fun findMp3Link( track: TrackDetails, preferredQuality: AudioQuality - ):SuspendableEvent { + ): SuspendableEvent { // Try Fetching Track from Jio Saavn return saavnProvider.findMp3SongDownloadURL( trackName = track.title, @@ -132,11 +132,11 @@ class FetchPlatformQueryResult( ).flatMapError { saavnError -> logger.e { "Fetching From Saavn Failed: \n${saavnError.stackTraceToString()}" } // Saavn Failed, Lets Try Fetching Now From Youtube Music - youtubeMusic.findMp3SongDownloadURLYT(track,preferredQuality).flatMapError { ytMusicError -> + youtubeMusic.findMp3SongDownloadURLYT(track, preferredQuality).flatMapError { ytMusicError -> // If Both Failed Bubble the Exception Up with both StackTraces SuspendableEvent.error( SpotiFlyerException.DownloadLinkFetchFailed( - trackName = track.title, + trackName = track.title, ytMusicError = ytMusicError, jioSaavnError = saavnError ) diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/preference/PreferenceManager.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/preference/PreferenceManager.kt index fb173f28..dd42b689 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/preference/PreferenceManager.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/preference/PreferenceManager.kt @@ -3,7 +3,7 @@ package com.shabinder.common.di.preference import com.russhwolf.settings.Settings import com.shabinder.common.models.AudioQuality -class PreferenceManager(settings: Settings): Settings by settings { +class PreferenceManager(settings: Settings) : Settings by settings { companion object { const val DIR_KEY = "downloadDir" @@ -17,14 +17,13 @@ class PreferenceManager(settings: Settings): Settings by settings { val isAnalyticsEnabled get() = getBooleanOrNull(ANALYTICS_KEY) ?: false fun toggleAnalytics(enabled: Boolean) = putBoolean(ANALYTICS_KEY, enabled) - /* DOWNLOAD DIRECTORY */ val downloadDir get() = getStringOrNull(DIR_KEY) fun setDownloadDirectory(newBasePath: String) = putString(DIR_KEY, newBasePath) /* Preferred Audio Quality */ val audioQuality get() = AudioQuality.getQuality(getStringOrNull(PREFERRED_AUDIO_QUALITY) ?: "320") - fun setPreferredAudioQuality(quality: AudioQuality) = putString(PREFERRED_AUDIO_QUALITY,quality.kbps) + fun setPreferredAudioQuality(quality: AudioQuality) = putString(PREFERRED_AUDIO_QUALITY, quality.kbps) /* OFFSET FOR WHEN TO ASK FOR SUPPORT */ val getDonationOffset: Int get() = (getIntOrNull(DONATION_INTERVAL) ?: 3).also { @@ -33,8 +32,7 @@ class PreferenceManager(settings: Settings): Settings by settings { } fun setDonationOffset(offset: Int = 5) = putInt(DONATION_INTERVAL, offset) - /* TO CHECK IF THIS IS APP's FIRST LAUNCH */ val isFirstLaunch get() = getBooleanOrNull(FIRST_LAUNCH) ?: true fun firstLaunchDone() = putBoolean(FIRST_LAUNCH, false) -} \ No newline at end of file +} diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/GaanaProvider.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/GaanaProvider.kt index 95b3036a..c34e368a 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/GaanaProvider.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/GaanaProvider.kt @@ -37,7 +37,7 @@ class GaanaProvider( private val gaanaPlaceholderImageUrl = "https://a10.gaanacdn.com/images/social/gaana_social.jpg" - suspend fun query(fullLink: String): SuspendableEvent = SuspendableEvent { + suspend fun query(fullLink: String): SuspendableEvent = SuspendableEvent { // Link Schema: https://gaana.com/type/link val gaanaLink = fullLink.substringAfter("gaana.com/") diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/ProvidersModule.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/ProvidersModule.kt index 66734202..2fa8a2e9 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/ProvidersModule.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/ProvidersModule.kt @@ -13,4 +13,4 @@ fun providersModule() = module { single { YoutubeMp3(get(), get()) } single { YoutubeMusic(get(), get(), get(), get(), get()) } single { FetchPlatformQueryResult(get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) } -} \ No newline at end of file +} diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/SaavnProvider.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/SaavnProvider.kt index 491d1c0b..1de2cad7 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/SaavnProvider.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/SaavnProvider.kt @@ -33,7 +33,7 @@ class SaavnProvider( ).apply { val pageLink = fullLink.substringAfter("saavn.com/").substringBefore("?") when { - pageLink.contains("/song/",true) -> { + pageLink.contains("/song/", true) -> { getSong(fullLink).value.let { folderType = "Tracks" subFolder = "" @@ -42,7 +42,7 @@ class SaavnProvider( coverUrl = it.image.replace("http:", "https:") } } - pageLink.contains("/album/",true) -> { + pageLink.contains("/album/", true) -> { getAlbum(fullLink).value.let { folderType = "Albums" subFolder = removeIllegalChars(it.title) @@ -51,7 +51,7 @@ class SaavnProvider( coverUrl = it.image.replace("http:", "https:") } } - pageLink.contains("/featured/",true) -> { // Playlist + pageLink.contains("/featured/", true) -> { // Playlist getPlaylist(fullLink).value.let { folderType = "Playlists" subFolder = removeIllegalChars(it.listname) diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt index 5d674ec7..bc295135 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMp3.kt @@ -24,7 +24,7 @@ import com.shabinder.common.models.event.coroutines.SuspendableEvent import com.shabinder.common.models.event.coroutines.map import io.ktor.client.* -interface YoutubeMp3: Yt1sMp3 { +interface YoutubeMp3 : Yt1sMp3 { companion object { operator fun invoke( @@ -38,7 +38,7 @@ interface YoutubeMp3: Yt1sMp3 { } } - suspend fun getMp3DownloadLink(videoID: String,quality: AudioQuality): SuspendableEvent = getLinkFromYt1sMp3(videoID,quality).map { + suspend fun getMp3DownloadLink(videoID: String, quality: AudioQuality): SuspendableEvent = getLinkFromYt1sMp3(videoID, quality).map { corsApi + it } } diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMusic.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMusic.kt index 5d660760..e08330cc 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMusic.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeMusic.kt @@ -63,7 +63,7 @@ class YoutubeMusic constructor( ): SuspendableEvent { return getYTIDBestMatch(trackDetails).flatMap { videoID -> // As YT compress Audio hence there is no benefit of quality for more than 192 - val optimalQuality = if((preferredQuality.kbps.toIntOrNull() ?: 0) > 192) AudioQuality.KBPS192 else preferredQuality + val optimalQuality = if ((preferredQuality.kbps.toIntOrNull() ?: 0) > 192) AudioQuality.KBPS192 else preferredQuality // 1 Try getting Link from Yt1s youtubeMp3.getMp3DownloadLink(videoID, optimalQuality).flatMapError { // 2 if Yt1s failed , Extract Manually @@ -79,7 +79,7 @@ class YoutubeMusic constructor( private suspend fun getYTIDBestMatch( trackDetails: TrackDetails - ):SuspendableEvent = + ): SuspendableEvent = getYTTracks("${trackDetails.title} - ${trackDetails.artists.joinToString(",")}").map { matchList -> sortByBestMatch( matchList, @@ -89,7 +89,7 @@ class YoutubeMusic constructor( ).keys.firstOrNull() ?: throw SpotiFlyerException.NoMatchFound(trackDetails.title) } - private suspend fun getYTTracks(query: String): SuspendableEvent,Throwable> = + private suspend fun getYTTracks(query: String): SuspendableEvent, Throwable> = getYoutubeMusicResponse(query).map { youtubeResponseData -> val youtubeTracks = mutableListOf() val responseObj = Json.parseToJsonElement(youtubeResponseData) @@ -233,9 +233,9 @@ class YoutubeMusic constructor( } } } - // logger.d {youtubeTracks.joinToString("\n")} - youtubeTracks - } + // logger.d {youtubeTracks.joinToString("\n")} + youtubeTracks + } private fun sortByBestMatch( ytTracks: List, @@ -311,7 +311,7 @@ class YoutubeMusic constructor( } } - private suspend fun getYoutubeMusicResponse(query: String): SuspendableEvent = SuspendableEvent { + private suspend fun getYoutubeMusicResponse(query: String): SuspendableEvent = SuspendableEvent { httpClient.post("${corsApi}https://music.youtube.com/youtubei/v1/search?alt=json&key=$apiKey") { contentType(ContentType.Application.Json) headers { diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeProvider.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeProvider.kt index 8ae28336..b4d4cb44 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeProvider.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/YoutubeProvider.kt @@ -51,7 +51,7 @@ class YoutubeProvider( private val sampleDomain2 = "youtube.com" private val sampleDomain3 = "youtu.be" - suspend fun query(fullLink: String): SuspendableEvent { + suspend fun query(fullLink: String): SuspendableEvent { val link = fullLink.removePrefix("https://").removePrefix("http://") if (link.contains("playlist", true) || link.contains("list", true)) { // Given Link is of a Playlist @@ -86,7 +86,7 @@ class YoutubeProvider( private suspend fun getYTPlaylist( searchId: String - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { PlatformQueryResult( folderType = "", subFolder = "", @@ -102,7 +102,7 @@ class YoutubeProvider( val videos = playlist.videos coverUrl = "https://i.ytimg.com/vi/${ - videos.firstOrNull()?.videoId + videos.firstOrNull()?.videoId }/hqdefault.jpg" title = name @@ -116,11 +116,11 @@ class YoutubeProvider( albumArtURL = "https://i.ytimg.com/vi/${it.videoId}/hqdefault.jpg", downloaded = if (dir.isPresent( dir.finalOutputDir( - itemName = it.title ?: "N/A", - type = folderType, - subFolder = subFolder, - dir.defaultDir() - ) + itemName = it.title ?: "N/A", + type = folderType, + subFolder = subFolder, + dir.defaultDir() + ) ) ) DownloadStatus.Downloaded @@ -137,7 +137,7 @@ class YoutubeProvider( @Suppress("DefaultLocale") private suspend fun getYTTrack( searchId: String, - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { PlatformQueryResult( folderType = "", subFolder = "", @@ -162,11 +162,11 @@ class YoutubeProvider( albumArtURL = "https://i.ytimg.com/vi/$searchId/hqdefault.jpg", downloaded = if (dir.isPresent( dir.finalOutputDir( - itemName = name, - type = folderType, - subFolder = subFolder, - defaultDir = dir.defaultDir() - ) + itemName = name, + type = folderType, + subFolder = subFolder, + defaultDir = dir.defaultDir() + ) ) ) DownloadStatus.Downloaded diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/audioToMp3/AudioToMp3.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/audioToMp3/AudioToMp3.kt index 6e4f4261..f379a0d0 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/audioToMp3/AudioToMp3.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/audioToMp3/AudioToMp3.kt @@ -32,10 +32,10 @@ interface AudioToMp3 { suspend fun convertToMp3( URL: String, audioQuality: AudioQuality = AudioQuality.getQuality(URL.substringBeforeLast(".").takeLast(3)), - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { // Active Host ex - https://hostveryfast.onlineconverter.com/file/send // Convert Job Request ex - https://www.onlineconverter.com/convert/309a0f2bbaeb5687b04f96b6d65b47bfdd - var (activeHost,jobLink) = convertRequest(URL, audioQuality).value + var (activeHost, jobLink) = convertRequest(URL, audioQuality).value // (jobStatus.contains("d")) == COMPLETION var jobStatus: String @@ -48,7 +48,7 @@ interface AudioToMp3 { ) } catch (e: Exception) { e.printStackTrace() - if(e is ClientRequestException && e.response.status.value == 404) { + if (e is ClientRequestException && e.response.status.value == 404) { // No Need to Retry, Host/Converter is Busy throw SpotiFlyerException.MP3ConversionFailed(e.message) } @@ -74,7 +74,7 @@ interface AudioToMp3 { private suspend fun convertRequest( URL: String, audioQuality: AudioQuality = AudioQuality.KBPS160, - ): SuspendableEvent,Throwable> = SuspendableEvent { + ): SuspendableEvent, Throwable> = SuspendableEvent { val activeHost by getHost() val convertJob = client.submitFormWithBinaryData( url = activeHost, @@ -104,17 +104,17 @@ interface AudioToMp3 { }.execute() logger.i("Schedule Conversion Job") { job.status.isSuccess().toString() } - Pair(activeHost,convertJob) + Pair(activeHost, convertJob) } // Active Host free to process conversion // ex - https://hostveryfast.onlineconverter.com/file/send - private suspend fun getHost(): SuspendableEvent = SuspendableEvent { + private suspend fun getHost(): SuspendableEvent = SuspendableEvent { client.get("https://www.onlineconverter.com/get/host") { headers { header("Host", "www.onlineconverter.com") } - }//.also { logger.i("Active Host") { it } } + } // .also { logger.i("Active Host") { it } } } // Extract full Domain from URL diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/gaana/GaanaRequests.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/gaana/GaanaRequests.kt index 373945ae..7e74f114 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/gaana/GaanaRequests.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/gaana/GaanaRequests.kt @@ -25,7 +25,6 @@ import com.shabinder.common.models.gaana.GaanaSong import io.ktor.client.* import io.ktor.client.request.* - private const val TOKEN = "b2e6d7fbc136547a940516e9b77e5990" private val BASE_URL get() = "${corsApi}https://api.gaana.com" diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/saavn/JioSaavnRequests.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/saavn/JioSaavnRequests.kt index 7b53bcae..2b4af946 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/saavn/JioSaavnRequests.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/saavn/JioSaavnRequests.kt @@ -40,12 +40,12 @@ interface JioSaavnRequests { trackName: String, trackArtists: List, preferredQuality: AudioQuality - ): SuspendableEvent = searchForSong(trackName).map { songs -> + ): SuspendableEvent = searchForSong(trackName).map { songs -> val bestMatches = sortByBestMatch(songs, trackName, trackArtists) val m4aLink: String by getSongFromID(bestMatches.keys.first()).map { song -> - val optimalQuality = if(song.is320Kbps && ((preferredQuality.kbps.toIntOrNull() ?: 0) > 160)) AudioQuality.KBPS320 else AudioQuality.KBPS160 - song.media_url.requireNotNull().replaceAfterLast("_","${optimalQuality.kbps}.mp4") + val optimalQuality = if (song.is320Kbps && ((preferredQuality.kbps.toIntOrNull() ?: 0) > 160)) AudioQuality.KBPS320 else AudioQuality.KBPS160 + song.media_url.requireNotNull().replaceAfterLast("_", "${optimalQuality.kbps}.mp4") } val mp3Link by audioToMp3.convertToMp3(m4aLink) @@ -56,7 +56,7 @@ interface JioSaavnRequests { suspend fun searchForSong( query: String, includeLyrics: Boolean = false - ): SuspendableEvent,Throwable> = SuspendableEvent { + ): SuspendableEvent, Throwable> = SuspendableEvent { val searchURL = search_base_url + query val results = mutableListOf() @@ -67,12 +67,12 @@ interface JioSaavnRequests { (it as JsonObject).formatData().let { jsonObject -> results.add(globalJson.decodeFromJsonElement(SaavnSearchResult.serializer(), jsonObject)) } - } + } results } - suspend fun getLyrics(ID: String): SuspendableEvent = SuspendableEvent { + suspend fun getLyrics(ID: String): SuspendableEvent = SuspendableEvent { (Json.parseToJsonElement(httpClient.get(lyrics_base_url + ID)) as JsonObject) .getString("lyrics").requireNotNull() } @@ -80,7 +80,7 @@ interface JioSaavnRequests { suspend fun getSong( URL: String, fetchLyrics: Boolean = false - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { val id = getSongID(URL) val data = ((globalJson.parseToJsonElement(httpClient.get(song_details_base_url + id)) as JsonObject)[id] as JsonObject) .formatData(fetchLyrics) @@ -91,7 +91,7 @@ interface JioSaavnRequests { suspend fun getSongFromID( ID: String, fetchLyrics: Boolean = false - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { val data = ((globalJson.parseToJsonElement(httpClient.get(song_details_base_url + ID)) as JsonObject)[ID] as JsonObject) .formatData(fetchLyrics) @@ -112,7 +112,7 @@ interface JioSaavnRequests { suspend fun getPlaylist( URL: String, includeLyrics: Boolean = false - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { globalJson.decodeFromJsonElement( SaavnPlaylist.serializer(), (globalJson.parseToJsonElement(httpClient.get(playlist_details_base_url + getPlaylistID(URL).value)) as JsonObject) @@ -122,7 +122,7 @@ interface JioSaavnRequests { private suspend fun getPlaylistID( URL: String - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { val res = httpClient.get(URL) try { res.split("\"type\":\"playlist\",\"id\":\"")[1].split('"')[0] @@ -134,7 +134,7 @@ interface JioSaavnRequests { suspend fun getAlbum( URL: String, includeLyrics: Boolean = false - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { globalJson.decodeFromJsonElement( SaavnAlbum.serializer(), (globalJson.parseToJsonElement(httpClient.get(album_details_base_url + getAlbumID(URL).value)) as JsonObject) @@ -144,7 +144,7 @@ interface JioSaavnRequests { private suspend fun getAlbumID( URL: String - ): SuspendableEvent = SuspendableEvent { + ): SuspendableEvent = SuspendableEvent { val res = httpClient.get(URL) try { res.split("\"album_id\":\"")[1].split('"')[0] diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/spotify/SpotifyAuth.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/spotify/SpotifyAuth.kt index 4bb67403..86c8452b 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/spotify/SpotifyAuth.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/spotify/SpotifyAuth.kt @@ -31,7 +31,7 @@ import io.ktor.client.request.forms.* import io.ktor.http.* import kotlin.native.concurrent.SharedImmutable -suspend fun authenticateSpotify(): SuspendableEvent = SuspendableEvent { +suspend fun authenticateSpotify(): SuspendableEvent = SuspendableEvent { if (methods.value.isInternetAvailable) { spotifyAuthClient.post("https://accounts.spotify.com/api/token") { body = FormDataContent(Parameters.build { append("grant_type", "client_credentials") }) diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/youtubeMp3/Yt1sMp3.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/youtubeMp3/Yt1sMp3.kt index 2fbf4465..8de59ea7 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/youtubeMp3/Yt1sMp3.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/providers/requests/youtubeMp3/Yt1sMp3.kt @@ -43,7 +43,7 @@ interface Yt1sMp3 { /* * Downloadable Mp3 Link for YT videoID. * */ - suspend fun getLinkFromYt1sMp3(videoID: String,quality: AudioQuality): SuspendableEvent = getKey(videoID,quality).flatMap { key -> + suspend fun getLinkFromYt1sMp3(videoID: String, quality: AudioQuality): SuspendableEvent = getKey(videoID, quality).flatMap { key -> getConvertedMp3Link(videoID, key).map { it["dlink"].requireNotNull() .jsonPrimitive.content.replace("\"", "") @@ -54,7 +54,7 @@ interface Yt1sMp3 { * POST:https://yt1s.com/api/ajaxSearch/index * Body Form= q:yt video link ,vt:format=mp3 * */ - private suspend fun getKey(videoID: String,quality: AudioQuality): SuspendableEvent = SuspendableEvent { + private suspend fun getKey(videoID: String, quality: AudioQuality): SuspendableEvent = SuspendableEvent { val response: JsonObject = httpClient.post("${corsApi}https://yt1s.com/api/ajaxSearch/index") { body = FormDataContent( Parameters.build { @@ -67,7 +67,7 @@ interface Yt1sMp3 { val mp3Keys = response.getJsonObject("links") .getJsonObject("mp3") - val requestedKBPS = when(quality) { + val requestedKBPS = when (quality) { AudioQuality.KBPS128 -> "mp3128" else -> quality.kbps } @@ -77,7 +77,7 @@ interface Yt1sMp3 { specificQualityKey?.get("k").requireNotNull().jsonPrimitive.content } - private suspend fun getConvertedMp3Link(videoID: String, key: String): SuspendableEvent = SuspendableEvent { + private suspend fun getConvertedMp3Link(videoID: String, key: String): SuspendableEvent = SuspendableEvent { httpClient.post("${corsApi}https://yt1s.com/api/ajaxConvert/convert") { body = FormDataContent( Parameters.build { diff --git a/common/root/src/commonMain/kotlin/com/shabinder/common/root/integration/SpotiFlyerRootImpl.kt b/common/root/src/commonMain/kotlin/com/shabinder/common/root/integration/SpotiFlyerRootImpl.kt index 8b802293..31da5016 100644 --- a/common/root/src/commonMain/kotlin/com/shabinder/common/root/integration/SpotiFlyerRootImpl.kt +++ b/common/root/src/commonMain/kotlin/com/shabinder/common/root/integration/SpotiFlyerRootImpl.kt @@ -165,7 +165,7 @@ private fun spotiFlyerMain(componentContext: ComponentContext, output: Consumer< componentContext = componentContext, dependencies = object : SpotiFlyerMain.Dependencies, Dependencies by dependencies { override val mainOutput: Consumer = output - override val mainAnalytics = object : SpotiFlyerMain.Analytics , Analytics by analytics {} + override val mainAnalytics = object : SpotiFlyerMain.Analytics, Analytics by analytics {} } ) diff --git a/console-app/build.gradle.kts b/console-app/build.gradle.kts index 48966a03..d19ab1e1 100644 --- a/console-app/build.gradle.kts +++ b/console-app/build.gradle.kts @@ -28,7 +28,6 @@ dependencies { implementation(project(":common:list")) implementation(project(":common:list")) - // Decompose implementation(Decompose.decompose) implementation(Decompose.extensionsCompose) diff --git a/console-app/src/main/java/utils/Ext.kt b/console-app/src/main/java/utils/Ext.kt index 9dbb6978..8a4365a7 100644 --- a/console-app/src/main/java/utils/Ext.kt +++ b/console-app/src/main/java/utils/Ext.kt @@ -6,4 +6,4 @@ val String.byProperty: String get() = System.getenv(this) val String.byOptionalProperty: String? get() = System.getenv(this) fun debug(message: String) = println("\n::debug::$message") -fun debug(tag: String, message: String) = println("\n::debug::$tag:\n$message") \ No newline at end of file +fun debug(tag: String, message: String) = println("\n::debug::$tag:\n$message") diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts index a7034e5a..bd395f2e 100644 --- a/desktop/build.gradle.kts +++ b/desktop/build.gradle.kts @@ -20,6 +20,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { kotlin("multiplatform") id("org.jetbrains.compose") + id("ktlint-setup") } group = "com.shabinder" @@ -88,4 +89,4 @@ compose.desktop { } } } -} \ No newline at end of file +} diff --git a/desktop/src/jvmMain/kotlin/Main.kt b/desktop/src/jvmMain/kotlin/Main.kt index a327d781..8de5be1c 100644 --- a/desktop/src/jvmMain/kotlin/Main.kt +++ b/desktop/src/jvmMain/kotlin/Main.kt @@ -56,9 +56,8 @@ import java.net.URI import javax.swing.JFileChooser import javax.swing.JFileChooser.APPROVE_OPTION - private val koin = initKoin(enableNetworkLogs = true).koin -private lateinit var showToast: (String)->Unit +private lateinit var showToast: (String) -> Unit private val tracker: PiwikTracker by lazy { PiwikTracker("https://matomo.spotiflyer.ml/matomo.php") } @@ -68,7 +67,7 @@ fun main() { val lifecycle = LifecycleRegistry() lifecycle.resume() - Window("SpotiFlyer",size = IntSize(450,800)) { + Window("SpotiFlyer", size = IntSize(450, 800)) { Surface( modifier = Modifier.fillMaxSize(), color = Color.Black, @@ -80,7 +79,7 @@ fun main() { shapes = SpotiFlyerShapes ) { val root: SpotiFlyerRoot = SpotiFlyerRootContent(rememberRootComponent(factory = ::spotiFlyerRoot)) - showToast = root.callBacks::showToast + showToast = root.callBacks::showToast } } } @@ -98,11 +97,11 @@ private fun spotiFlyerRoot(componentContext: ComponentContext): SpotiFlyerRoot = override val database: Database? = dir.db override val preferenceManager: PreferenceManager = koin.get() override val downloadProgressFlow = DownloadProgressFlow - override val actions: Actions = object: Actions { + override val actions: Actions = object : Actions { override val platformActions = object : PlatformActions {} override fun showPopUpMessage(string: String, long: Boolean) { - if(::showToast.isInitialized){ + if (::showToast.isInitialized) { showToast(string) } } @@ -114,7 +113,7 @@ private fun spotiFlyerRoot(componentContext: ComponentContext): SpotiFlyerRoot = when (fileChooser.showOpenDialog(AppManager.focusedWindow?.window)) { APPROVE_OPTION -> { val directory = fileChooser.selectedFile - if(directory.canWrite()){ + if (directory.canWrite()) { preferenceManager.setDownloadDirectory(directory.absolutePath) callBack(directory.absolutePath) showPopUpMessage("${Strings.setDownloadDirectory()} \n${dir.defaultDir()}") @@ -128,7 +127,7 @@ private fun spotiFlyerRoot(componentContext: ComponentContext): SpotiFlyerRoot = } } - override fun queryActiveTracks() {/**/} + override fun queryActiveTracks() { /**/ } override fun giveDonation() { openLink("https://razorpay.com/payment-button/pl_GnKuuDBdBu0ank/view/?utm_source=payment_button&utm_medium=button&utm_campaign=payment_button") @@ -143,22 +142,22 @@ private fun spotiFlyerRoot(componentContext: ComponentContext): SpotiFlyerRoot = override fun openPlatform(packageID: String, platformLink: String) = openLink(platformLink) - fun openLink(link:String) { + fun openLink(link: String) { if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { Desktop.getDesktop().browse(URI(link)) } } - override fun writeMp3Tags(trackDetails: TrackDetails) {/*IMPLEMENTED*/} + override fun writeMp3Tags(trackDetails: TrackDetails) { /*IMPLEMENTED*/ } override val isInternetAvailable: Boolean - get() = runBlocking { + get() = runBlocking { isInternetAccessible() } } - override val analytics = object: SpotiFlyerRoot.Analytics { + override val analytics = object : SpotiFlyerRoot.Analytics { override fun appLaunchEvent() { - if(preferenceManager.isFirstLaunch) { + if (preferenceManager.isFirstLaunch) { // Enable Analytics on First Launch preferenceManager.toggleAnalytics(true) preferenceManager.firstLaunchDone() diff --git a/desktop/src/jvmMain/kotlin/utils/AnalyticsExt.kt b/desktop/src/jvmMain/kotlin/utils/AnalyticsExt.kt index 457b5639..19573ffd 100644 --- a/desktop/src/jvmMain/kotlin/utils/AnalyticsExt.kt +++ b/desktop/src/jvmMain/kotlin/utils/AnalyticsExt.kt @@ -4,9 +4,8 @@ import org.piwik.java.tracking.PiwikRequest import org.piwik.java.tracking.PiwikTracker import java.net.URL - fun PiwikTracker.trackAsync( - baseURL:String = "https://com.shabinder.spotiflyer/", + baseURL: String = "https://com.shabinder.spotiflyer/", requestBuilder: PiwikRequest.() -> Unit = {} ) { val req = PiwikRequest( @@ -18,7 +17,7 @@ fun PiwikTracker.trackAsync( } fun PiwikTracker.trackScreenAsync( - screenAddress:String, + screenAddress: String, requestBuilder: PiwikRequest.() -> Unit = {} ) { val req = PiwikRequest( @@ -27,4 +26,4 @@ fun PiwikTracker.trackScreenAsync( ).apply { requestBuilder() } // Send Request sendRequestAsync(req) -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index b2589535..2af2d0a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m +org.gradle.jvmargs=-Xmx3072m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/maintenance-tasks/src/main/java/common/ContentUpdation.kt b/maintenance-tasks/src/main/java/common/ContentUpdation.kt index 141e80c7..7eeb66f8 100644 --- a/maintenance-tasks/src/main/java/common/ContentUpdation.kt +++ b/maintenance-tasks/src/main/java/common/ContentUpdation.kt @@ -7,10 +7,10 @@ fun getUpdatedContent( oldContent: String, newInsertionText: String, tagName: String -): String{ +): String { return getReplaceableRegex(tagName).replace( oldContent, - getReplacementText(tagName,newInsertionText) + getReplacementText(tagName, newInsertionText) ) } @@ -26,5 +26,5 @@ private fun getReplacementText( ${Common.START_SECTION(tagName)} $newInsertionText ${Common.END_SECTION(tagName)} - """.trimIndent() -} \ No newline at end of file + """.trimIndent() +} diff --git a/maintenance-tasks/src/main/java/common/Date.kt b/maintenance-tasks/src/main/java/common/Date.kt index 0beec41d..c236b223 100644 --- a/maintenance-tasks/src/main/java/common/Date.kt +++ b/maintenance-tasks/src/main/java/common/Date.kt @@ -13,4 +13,4 @@ fun getTodayDate(): String { val year: Int = c.get(Calendar.YEAR) val date: Int = c.get(Calendar.DATE) return " $date $month, $year" -} \ No newline at end of file +} diff --git a/maintenance-tasks/src/main/java/common/GithubService.kt b/maintenance-tasks/src/main/java/common/GithubService.kt index 5d4496c6..e2e723fb 100644 --- a/maintenance-tasks/src/main/java/common/GithubService.kt +++ b/maintenance-tasks/src/main/java/common/GithubService.kt @@ -19,7 +19,6 @@ internal object GithubService { private const val baseURL = Common.GITHUB_API - suspend fun getGithubRepoReleasesInfo( ownerName: String, repoName: String, diff --git a/maintenance-tasks/src/main/java/main.kt b/maintenance-tasks/src/main/java/main.kt index 121abfc4..25cf79f2 100644 --- a/maintenance-tasks/src/main/java/main.kt +++ b/maintenance-tasks/src/main/java/main.kt @@ -25,8 +25,8 @@ fun main(args: Array) { updatedGithubContent, secrets ) - } catch (e:Exception) { - debug("Analytics Image Updation Failed",e.message.toString()) + } catch (e: Exception) { + debug("Analytics Image Updation Failed", e.message.toString()) } // TASK -> Update Total Downloads Card @@ -35,8 +35,8 @@ fun main(args: Array) { updatedGithubContent, secrets.copy(tagName = "DCI") ) - } catch (e:Exception) { - debug("Download Card Updation Failed",e.message.toString()) + } catch (e: Exception) { + debug("Download Card Updation Failed", e.message.toString()) } // Write New Updated README.md diff --git a/maintenance-tasks/src/main/java/models/github/Asset.kt b/maintenance-tasks/src/main/java/models/github/Asset.kt index 7ac15772..8f160aba 100644 --- a/maintenance-tasks/src/main/java/models/github/Asset.kt +++ b/maintenance-tasks/src/main/java/models/github/Asset.kt @@ -17,4 +17,4 @@ data class Asset( val updated_at: String, val uploader: Uploader, val url: String -) \ No newline at end of file +) diff --git a/maintenance-tasks/src/main/java/models/github/Author.kt b/maintenance-tasks/src/main/java/models/github/Author.kt index 44075d59..afe7dba9 100644 --- a/maintenance-tasks/src/main/java/models/github/Author.kt +++ b/maintenance-tasks/src/main/java/models/github/Author.kt @@ -22,4 +22,4 @@ data class Author( val subscriptions_url: String, val type: String, val url: String -) \ No newline at end of file +) diff --git a/maintenance-tasks/src/main/java/models/github/GithubFileContent.kt b/maintenance-tasks/src/main/java/models/github/GithubFileContent.kt index e3c52ea6..c8199c01 100644 --- a/maintenance-tasks/src/main/java/models/github/GithubFileContent.kt +++ b/maintenance-tasks/src/main/java/models/github/GithubFileContent.kt @@ -6,4 +6,4 @@ import kotlinx.serialization.Serializable data class GithubFileContent( val decryptedContent: String, val sha: String -) \ No newline at end of file +) diff --git a/maintenance-tasks/src/main/java/models/github/GithubReleaseInfoItem.kt b/maintenance-tasks/src/main/java/models/github/GithubReleaseInfoItem.kt index 4f436224..ff38a747 100644 --- a/maintenance-tasks/src/main/java/models/github/GithubReleaseInfoItem.kt +++ b/maintenance-tasks/src/main/java/models/github/GithubReleaseInfoItem.kt @@ -23,4 +23,4 @@ data class GithubReleaseInfoItem( val upload_url: String, val url: String, val zipball_url: String -) \ No newline at end of file +) diff --git a/maintenance-tasks/src/main/java/models/github/GithubReleasesInfo.kt b/maintenance-tasks/src/main/java/models/github/GithubReleasesInfo.kt index af1ea600..93625c1b 100644 --- a/maintenance-tasks/src/main/java/models/github/GithubReleasesInfo.kt +++ b/maintenance-tasks/src/main/java/models/github/GithubReleasesInfo.kt @@ -1,3 +1,3 @@ package models.github -typealias GithubReleasesInfo = ArrayList \ No newline at end of file +typealias GithubReleasesInfo = ArrayList diff --git a/maintenance-tasks/src/main/java/models/github/Reactions.kt b/maintenance-tasks/src/main/java/models/github/Reactions.kt index d493ab27..b627bf2f 100644 --- a/maintenance-tasks/src/main/java/models/github/Reactions.kt +++ b/maintenance-tasks/src/main/java/models/github/Reactions.kt @@ -1,7 +1,7 @@ package models.github -import kotlinx.serialization.json.JsonNames import kotlinx.serialization.Serializable +import kotlinx.serialization.json.JsonNames @Serializable data class Reactions( @@ -15,4 +15,4 @@ data class Reactions( val rocket: Int = 0, val total_count: Int = 0, val url: String? = null -) \ No newline at end of file +) diff --git a/maintenance-tasks/src/main/java/models/github/Uploader.kt b/maintenance-tasks/src/main/java/models/github/Uploader.kt index acd170f1..b2ac6cc7 100644 --- a/maintenance-tasks/src/main/java/models/github/Uploader.kt +++ b/maintenance-tasks/src/main/java/models/github/Uploader.kt @@ -22,4 +22,4 @@ data class Uploader( val subscriptions_url: String, val type: String, val url: String -) \ No newline at end of file +) diff --git a/maintenance-tasks/src/main/java/models/matomo/MatomoDownloads.kt b/maintenance-tasks/src/main/java/models/matomo/MatomoDownloads.kt index cc783dfc..07d48e42 100644 --- a/maintenance-tasks/src/main/java/models/matomo/MatomoDownloads.kt +++ b/maintenance-tasks/src/main/java/models/matomo/MatomoDownloads.kt @@ -1,3 +1,3 @@ package models.matomo -typealias MatomoDownloads = ArrayList \ No newline at end of file +typealias MatomoDownloads = ArrayList diff --git a/maintenance-tasks/src/main/java/models/matomo/MatomoDownloadsItem.kt b/maintenance-tasks/src/main/java/models/matomo/MatomoDownloadsItem.kt index 6af66eed..da05f460 100644 --- a/maintenance-tasks/src/main/java/models/matomo/MatomoDownloadsItem.kt +++ b/maintenance-tasks/src/main/java/models/matomo/MatomoDownloadsItem.kt @@ -9,4 +9,4 @@ data class MatomoDownloadsItem( val nb_hits: Int = 0, val nb_visits: Int = 0, val sum_time_spent: Int = 0 -) \ No newline at end of file +) diff --git a/maintenance-tasks/src/main/java/scripts/UpdateAnalyticsImage.kt b/maintenance-tasks/src/main/java/scripts/UpdateAnalyticsImage.kt index 3ca75efd..63ba3cc5 100644 --- a/maintenance-tasks/src/main/java/scripts/UpdateAnalyticsImage.kt +++ b/maintenance-tasks/src/main/java/scripts/UpdateAnalyticsImage.kt @@ -54,13 +54,13 @@ internal suspend fun getAnalyticsImage(): String { } } contentLength = req.headers["Content-Length"]?.toLong() ?: 0 - debug("Content Length for Analytics Image",contentLength.toString()) + debug("Content Length for Analytics Image", contentLength.toString()) - if(retryCount-- == 0){ + if (retryCount-- == 0) { // FAIL Gracefully throw(RETRY_LIMIT_EXHAUSTED()) } - }while (contentLength<1_20_000) + } while (contentLength <1_20_000) return analyticsImage } diff --git a/maintenance-tasks/src/main/java/scripts/UpdateDownloadCards.kt b/maintenance-tasks/src/main/java/scripts/UpdateDownloadCards.kt index 590dabec..fba8a86f 100644 --- a/maintenance-tasks/src/main/java/scripts/UpdateDownloadCards.kt +++ b/maintenance-tasks/src/main/java/scripts/UpdateDownloadCards.kt @@ -18,15 +18,15 @@ internal suspend fun updateDownloadCards( fileName = "README.md" ).decryptedContent - var totalDownloads:Int = GithubService.getGithubRepoReleasesInfo( + var totalDownloads: Int = GithubService.getGithubRepoReleasesInfo( secrets.ownerName, secrets.repoName ).let { allReleases -> var totalCount = 0 - for(release in allReleases){ + for (release in allReleases) { release.assets.forEach { - //debug("${it.name}: ${release.tag_name}" ,"Downloads: ${it.download_count}") + // debug("${it.name}: ${release.tag_name}" ,"Downloads: ${it.download_count}") totalCount += it.download_count } } @@ -75,19 +75,18 @@ private suspend fun getDownloadCard( contentLength = req.headers["Content-Length"]?.toLong() ?: 0 // debug(contentLength.toString()) - if(retryCount-- == 0){ + if (retryCount-- == 0) { // FAIL Gracefully throw(RETRY_LIMIT_EXHAUSTED()) } - }while (contentLength<40_000) + } while (contentLength <40_000) return downloadCard } - fun getDownloadCardHtml( count: Int, date: String, // ex: 06 Jun 2021 -):String { +): String { return """
diff --git a/maintenance-tasks/src/main/java/utils/Ext.kt b/maintenance-tasks/src/main/java/utils/Ext.kt index 9dbb6978..8a4365a7 100644 --- a/maintenance-tasks/src/main/java/utils/Ext.kt +++ b/maintenance-tasks/src/main/java/utils/Ext.kt @@ -6,4 +6,4 @@ val String.byProperty: String get() = System.getenv(this) val String.byOptionalProperty: String? get() = System.getenv(this) fun debug(message: String) = println("\n::debug::$message") -fun debug(tag: String, message: String) = println("\n::debug::$tag:\n$message") \ No newline at end of file +fun debug(tag: String, message: String) = println("\n::debug::$tag:\n$message")