mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-21 16:54:33 +01:00
Code Cleanup and Formatting and i18n4k dependency
This commit is contained in:
parent
c591842fb4
commit
116530cc3c
@ -23,6 +23,7 @@ plugins {
|
||||
kotlin("android")
|
||||
id("kotlin-parcelize")
|
||||
id("org.jetbrains.compose")
|
||||
id("ktlint-setup")
|
||||
}
|
||||
|
||||
group = "com.shabinder"
|
||||
|
@ -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())
|
||||
|
@ -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() {
|
||||
|
||||
@ -248,7 +247,6 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
/*END: Foreground Service Handlers*/
|
||||
|
||||
|
||||
@Composable
|
||||
private fun isInternetAvailableState(): State<Boolean?> {
|
||||
return internetAvailability.observeAsState()
|
||||
@ -281,7 +279,8 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
@ -406,9 +405,11 @@ class MainActivity : ComponentActivity() {
|
||||
.withActivity(this)
|
||||
.withFragmentManager(fragmentManager)
|
||||
.withMemoryBar(true)
|
||||
.setTheme(StorageChooser.Theme(applicationContext).apply {
|
||||
.setTheme(
|
||||
StorageChooser.Theme(applicationContext).apply {
|
||||
scheme = applicationContext.resources.getIntArray(R.array.default_dark)
|
||||
})
|
||||
}
|
||||
)
|
||||
.setDialogTitle(Strings.setDownloadDirectory())
|
||||
.allowCustomPath(true)
|
||||
.setType(StorageChooser.DIRECTORY_CHOOSER)
|
||||
|
@ -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)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -24,4 +24,3 @@ fun cleanFiles(dir: File) {
|
||||
}
|
||||
} catch (e: Exception) { e.printStackTrace() }
|
||||
}
|
||||
|
||||
|
@ -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(),
|
||||
*/
|
||||
},
|
||||
title = {
|
||||
Text(
|
||||
Strings.noInternetConnection(),
|
||||
style = SpotiFlyerTypography.h5,
|
||||
textAlign = TextAlign.Center) },
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
},
|
||||
backgroundColor = Color.DarkGray,
|
||||
text = {
|
||||
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(
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
@ -64,12 +64,14 @@ fun PermissionDialog(
|
||||
) {
|
||||
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 {
|
||||
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())
|
||||
|
@ -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
|
||||
|
||||
|
@ -43,15 +43,17 @@ fun Activity.checkIfLatestVersion() {
|
||||
}
|
||||
|
||||
fun Activity.checkPermissions(): Boolean = ContextCompat
|
||||
.checkSelfPermission(this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
|
||||
&&
|
||||
.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
|
||||
ContextCompat.checkSelfPermission(
|
||||
this,
|
||||
Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
} else true
|
||||
|
||||
|
||||
@SuppressLint("BatteryLife", "ObsoleteSdkInt")
|
||||
fun Activity.disableDozeMode(requestCode: Int) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
@ -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
|
||||
|
@ -31,9 +31,8 @@ allprojects {
|
||||
maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
|
||||
}
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
dependsOn(":common:data-models:generateI18n4kFiles")
|
||||
kotlinOptions { jvmTarget = "1.8" }
|
||||
}
|
||||
afterEvaluate {
|
||||
project.extensions.findByType<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension>()?.let { kmpExt ->
|
||||
|
@ -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 {
|
||||
android.set(true)
|
||||
outputToConsole.set(true)
|
||||
ignoreFailures.set(true)
|
||||
coloredOutput.set(true)
|
||||
verbose.set(true)
|
||||
disabledRules.set(setOf("filename,no-wildcard-imports"))
|
||||
filter {
|
||||
exclude("**/generated/**")
|
||||
exclude("**/build/**")
|
||||
}
|
||||
}
|
||||
// Optionally configure plugin
|
||||
/*configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
|
||||
debug.set(true)
|
||||
}*/
|
||||
}
|
@ -186,9 +186,12 @@ fun TrackCard(
|
||||
is DownloadStatus.Failed -> {
|
||||
val (openErrorDialog, dismissErrorDialog) = ErrorInfoDialog((track.downloaded as DownloadStatus.Failed).error)
|
||||
|
||||
Icon(Icons.Rounded.Info,Strings.downloadError(),tint = lightGray,modifier = Modifier.size(42.dp).clickable {
|
||||
Icon(
|
||||
Icons.Rounded.Info, Strings.downloadError(), tint = lightGray,
|
||||
modifier = Modifier.size(42.dp).clickable {
|
||||
openErrorDialog()
|
||||
}.padding(start = 4.dp,end = 12.dp))
|
||||
}.padding(start = 4.dp, end = 12.dp)
|
||||
)
|
||||
|
||||
DownloadImageError(
|
||||
Modifier.clickable(
|
||||
|
@ -98,7 +98,6 @@ fun SpotiFlyerPreferenceContent(component: SpotiFlyerPreference) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Spacer(Modifier.padding(top = 12.dp))
|
||||
@ -157,7 +156,6 @@ fun SpotiFlyerPreferenceContent(component: SpotiFlyerPreference) {
|
||||
}
|
||||
Spacer(modifier = Modifier.padding(top = 8.dp))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
|
@ -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),
|
||||
|
@ -130,7 +130,6 @@ inline fun <V, E : Throwable> Event<V, E>.unwrap(failure: (E) -> Nothing): V =
|
||||
inline fun <V, E : Throwable> Event<V, E>.unwrapError(success: (V) -> Nothing): E =
|
||||
apply { component1()?.let(success) }.component2()!!
|
||||
|
||||
|
||||
sealed class Event<out V : Any?, out E : Throwable> : ReadOnlyProperty<Any?, V> {
|
||||
|
||||
open operator fun component1(): V? = null
|
||||
|
@ -93,7 +93,6 @@ suspend inline fun <V : Any?, U : Any> SuspendableEvent<V, *>.fanout(
|
||||
): SuspendableEvent<Pair<V, U>, *> =
|
||||
flatMap { outer -> other().map { outer to it } }
|
||||
|
||||
|
||||
suspend fun <V : Any?, E : Throwable> List<SuspendableEvent<V, E>>.lift(): SuspendableEvent<List<V>, E> = fold(
|
||||
SuspendableEvent.Success<MutableList<V>, E>(mutableListOf<V>()) as SuspendableEvent<MutableList<V>, E>
|
||||
) { acc, result ->
|
||||
@ -172,5 +171,4 @@ sealed class SuspendableEvent<out V : Any?, out E : Throwable>: ReadOnlyProperty
|
||||
crossinline block: suspend () -> V
|
||||
): SuspendableEvent<V, Throwable> = of(block)
|
||||
}
|
||||
|
||||
}
|
@ -5,5 +5,4 @@ class SuspendedValidation<out E : Throwable>(vararg resultSequence: SuspendableE
|
||||
val failures: List<E> = resultSequence.filterIsInstance<SuspendableEvent.Failure<*, E>>().map { it.getThrowable() }
|
||||
|
||||
val hasFailure = failures.isNotEmpty()
|
||||
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -17,7 +17,6 @@ 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)
|
||||
@ -33,7 +32,6 @@ 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)
|
||||
|
@ -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"
|
||||
|
||||
|
@ -28,7 +28,6 @@ dependencies {
|
||||
implementation(project(":common:list"))
|
||||
implementation(project(":common:list"))
|
||||
|
||||
|
||||
// Decompose
|
||||
implementation(Decompose.decompose)
|
||||
implementation(Decompose.extensionsCompose)
|
||||
|
@ -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"
|
||||
|
@ -56,7 +56,6 @@ 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 val tracker: PiwikTracker by lazy {
|
||||
|
@ -4,7 +4,6 @@ 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/",
|
||||
requestBuilder: PiwikRequest.() -> Unit = {}
|
||||
|
@ -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
|
||||
|
@ -19,7 +19,6 @@ internal object GithubService {
|
||||
|
||||
private const val baseURL = Common.GITHUB_API
|
||||
|
||||
|
||||
suspend fun getGithubRepoReleasesInfo(
|
||||
ownerName: String,
|
||||
repoName: String,
|
||||
|
@ -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(
|
||||
|
@ -83,7 +83,6 @@ private suspend fun getDownloadCard(
|
||||
return downloadCard
|
||||
}
|
||||
|
||||
|
||||
fun getDownloadCardHtml(
|
||||
count: Int,
|
||||
date: String, // ex: 06 Jun 2021
|
||||
|
Loading…
Reference in New Issue
Block a user