Initial Commit

This commit is contained in:
shabinder 2021-01-26 18:24:28 +05:30
commit d5007f084b
69 changed files with 2002 additions and 0 deletions

102
android/build.gradle.kts Normal file
View File

@ -0,0 +1,102 @@
import org.jetbrains.compose.compose
plugins {
id("org.jetbrains.compose")
id("com.android.application")
kotlin("android")
}
group = "com.shabinder"
version = Versions.versionName
repositories {
google()
}
android {
compileSdkVersion(29)
defaultConfig {
applicationId = "com.shabinder.android"
minSdkVersion(Versions.minSdkVersion)
targetSdkVersion(Versions.targetSdkVersion)
versionCode = Versions.versionCode
versionName = Versions.versionName
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
//isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
// Flag to enable support for the new language APIs
//coreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
configurations {
"implementation" {
exclude(group = "androidx.compose.animation")
exclude(group = "androidx.compose.foundation")
exclude(group = "androidx.compose.material")
exclude(group = "androidx.compose.runtime")
exclude(group = "androidx.compose.ui")
}
}
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
}
dependencies {
implementation(compose.material)
implementation(project(":common:database"))
implementation(project(":common:compose-ui"))
implementation(project(":common:dependency-injection"))
implementation(project(":common:data-models"))
implementation(Androidx.appCompat)
implementation(Androidx.coroutines)
implementation(Androidx.core)
implementation(Androidx.palette)
//implementation(JetBrains.Compose.materialIcon)
//Compose-Navigation
implementation(Androidx.composeNavigation)
//Lifecycle
Versions.androidLifecycle.let{
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$it")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$it")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$it")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$it")
}
//Coil-Image Loading
Versions.coilVersion.let{
implementation("dev.chrisbanes.accompanist:accompanist-coil:$it")
implementation("dev.chrisbanes.accompanist:accompanist-insets:$it")
}
Extras.Android.apply {
implementation(appUpdator)
implementation(razorpay)
implementation(fetch)
}
//Test
testImplementation("junit:junit:4.13.1")
androidTestImplementation(Androidx.junit)
androidTestImplementation(Androidx.expresso)
//Desugaring
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.1")
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs = listOf("-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check",
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"
)
}
}

21
android/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.shabinder.android">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="false"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,25 @@
package com.shabinder.android
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.platform.setContent
import com.shabinder.common.authenticateSpotify
import com.shabinder.common.ui.SpotiFlyerMain
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val scope = rememberCoroutineScope()
SpotiFlyerMain()
scope.launch(Dispatchers.IO) {
val token = authenticateSpotify()
Log.i("Spotify",token.toString())
}
}
}
}

18
build.gradle.kts Normal file
View File

@ -0,0 +1,18 @@
plugins {
`kotlin-dsl`
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven(url = "https://jitpack.io")
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21")
}
}

46
buildSrc/build.gradle.kts Normal file
View File

@ -0,0 +1,46 @@
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
group = "com.shabinder"
version = "2.1"
buildscript{
repositories {
// TODO: remove after new build is published
mavenLocal()
google()
jcenter()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
dependencies {
classpath("com.android.tools.build:gradle:4.0.2")
classpath(JetBrains.Compose.gradlePlugin)
classpath(JetBrains.Kotlin.gradlePlugin)
}
}
repositories {
jcenter()
mavenLocal()
google()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
dependencies {
implementation("com.android.tools.build:gradle:4.0.2")
implementation(JetBrains.Compose.gradlePlugin)
implementation(JetBrains.Kotlin.gradlePlugin)
implementation(JetBrains.Kotlin.serialization)
implementation(SqlDelight.gradlePlugin)
}
kotlinDslPluginOptions {
experimentalWarning.set(false)
}
kotlin {
// Add Deps to compilation, so it will become available in main project
sourceSets.getByName("main").kotlin.srcDir("buildSrc/src/main/kotlin")
}

View File

@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}
repositories {
jcenter()
}

View File

@ -0,0 +1,33 @@
object Deps {
object ArkIvanov {
object MVIKotlin {
private const val VERSION = "2.0.0"
const val rx = "com.arkivanov.mvikotlin:rx:$VERSION"
const val mvikotlin = "com.arkivanov.mvikotlin:mvikotlin:$VERSION"
const val mvikotlinMain = "com.arkivanov.mvikotlin:mvikotlin-main:$VERSION"
const val mvikotlinMainIosX64 = "com.arkivanov.mvikotlin:mvikotlin-main-iosx64:$VERSION"
const val mvikotlinMainIosArm64 = "com.arkivanov.mvikotlin:mvikotlin-main-iosarm64:$VERSION"
const val mvikotlinLogging = "com.arkivanov.mvikotlin:mvikotlin-logging:$VERSION"
const val mvikotlinTimeTravel = "com.arkivanov.mvikotlin:mvikotlin-timetravel:$VERSION"
const val mvikotlinExtensionsReaktive = "com.arkivanov.mvikotlin:mvikotlin-extensions-reaktive:$VERSION"
}
object Decompose {
private const val VERSION = "0.1.6"
const val decompose = "com.arkivanov.decompose:decompose:$VERSION"
const val decomposeIosX64 = "com.arkivanov.decompose:decompose-iosx64:$VERSION"
const val decomposeIosArm64 = "com.arkivanov.decompose:decompose-iosarm64:$VERSION"
const val extensionsCompose = "com.arkivanov.decompose:extensions-compose-jetbrains:$VERSION"
}
}
object Badoo {
object Reaktive {
private const val VERSION = "1.1.19"
const val reaktive = "com.badoo.reaktive:reaktive:$VERSION"
const val reaktiveTesting = "com.badoo.reaktive:reaktive-testing:$VERSION"
const val utils = "com.badoo.reaktive:utils:$VERSION"
const val coroutinesInterop = "com.badoo.reaktive:coroutines-interop:$VERSION"
}
}
}

View File

@ -0,0 +1,103 @@
@file:Suppress("MayBeConstant", "SpellCheckingInspection")
object Versions {
const val versionName = "2.2"
const val kotlinVersion = "1.4.21"
const val coroutinesVersion = "1.4.2"
const val composeVersion = "1.0.0-alpha10"
const val coilVersion = "0.4.1"
//DI
const val kodein = "7.2.0"
//Internet
const val ktor = "1.5.0"
const val kotlinxSerialization = "1.0.1"
//Database
const val sqlDelight = "1.4.4"
const val sqliteJdbcDriver = "3.30.1"
const val slf4j = "1.7.30"
//Android
const val versionCode = 15
const val minSdkVersion = 24
const val compileSdkVersion = 30
const val targetSdkVersion = 29
const val androidLifecycle = "2.3.0-rc01"
}
object Androidx{
const val appCompat = "androidx.appcompat:appcompat:1.2.0"
const val core = "androidx.core:core-ktx:1.5.0-beta01"
const val palette = "androidx.palette:palette-ktx:1.0.0"
const val composeNavigation = "androidx.navigation:navigation-compose:1.0.0-alpha05"
const val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutinesVersion}"
const val junit = "androidx.test.ext:junit:1.1.2"
const val expresso = "androidx.test.espresso:espresso-core:3.3.0"
}
object JetBrains {
object Kotlin {
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlinVersion}"
const val serialization = "org.jetbrains.kotlin:kotlin-serialization:${Versions.kotlinVersion}"
const val testCommon = "org.jetbrains.kotlin:kotlin-test-common:${Versions.kotlinVersion}"
const val testJunit = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlinVersion}"
const val testAnnotationsCommon = "org.jetbrains.kotlin:kotlin-test-annotations-common:${Versions.kotlinVersion}"
}
object Compose {
// __LATEST_COMPOSE_RELEASE_VERSION__
private const val VERSION = "0.3.0-build140"
const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"
const val materialIcon = "androidx.compose.material:material-icons-extended:${Versions.composeVersion}"
}
}
object Ktor {
val clientCore = "io.ktor:ktor-client-core:${Versions.ktor}"
val clientJson = "io.ktor:ktor-client-json:${Versions.ktor}"
val clientLogging = "io.ktor:ktor-client-logging:${Versions.ktor}"
val clientSerialization = "io.ktor:ktor-client-serialization:${Versions.ktor}"
val auth = "io.ktor:ktor-client-auth:${Versions.ktor}"
val clientAndroid = "io.ktor:ktor-client-android:${Versions.ktor}"
val clientDesktop = "io.ktor:ktor-client-curl:${Versions.ktor}"
val clientApache = "io.ktor:ktor-client-apache:${Versions.ktor}"
val slf4j = "org.slf4j:slf4j-simple:${Versions.slf4j}"
val clientIos = "io.ktor:ktor-client-ios:${Versions.ktor}"
val clientCio = "io.ktor:ktor-client-cio:${Versions.ktor}"
val clientJs = "io.ktor:ktor-client-js:${Versions.ktor}"
}
object Extras {
val youtubeDownloader = "com.github.sealedtx:java-youtube-downloader:2.4.6"
val fuzzyWuzzy = "me.xdrop:fuzzywuzzy:1.3.1"
val mp3agic = "com.mpatric:mp3agic:0.9.1"
val jsonKlaxon = "com.beust:klaxon:5.4"
object Android {
val razorpay = "com.razorpay:checkout:1.6.4"
val fetch = "androidx.tonyodev.fetch2:xfetch2:3.1.5"
val appUpdator = "com.github.amitbd1508:AppUpdater:4.1.0"
}
}
object JetpackDataStore {
val dep = "androidx.datastore:datastore-preferences-core:1.0.0-alpha05"
}
object Serialization {
val core = "org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.kotlinxSerialization}"
}
object SqlDelight {
val runtime = "com.squareup.sqldelight:runtime:${Versions.sqlDelight}"
val coroutineExtensions = "com.squareup.sqldelight:coroutines-extensions:${Versions.sqlDelight}"
const val gradlePlugin = "com.squareup.sqldelight:gradle-plugin:${Versions.sqlDelight}"
const val androidDriver = "com.squareup.sqldelight:android-driver:${Versions.sqlDelight}"
const val sqliteDriver = "com.squareup.sqldelight:sqlite-driver:${Versions.sqlDelight}"
const val nativeDriver = "com.squareup.sqldelight:native-driver:${Versions.sqlDelight}"
val nativeDriverMacos = "com.squareup.sqldelight:native-driver-macosx64:${Versions.sqlDelight}"
val jdbcDriver = "org.xerial:sqlite-jdbc:${Versions.sqliteJdbcDriver}"
}

View File

@ -0,0 +1,29 @@
//import gradle.kotlin.dsl.accessors._2e8a70bdda5e56ec477a6ff432ddf9d7.android
plugins {
id("com.android.library")
}
android {
compileSdkVersion(29)
defaultConfig {
minSdkVersion(Versions.minSdkVersion)
targetSdkVersion(Versions.targetSdkVersion)
}
composeOptions {
kotlinCompilerExtensionVersion = Versions.composeVersion
kotlinCompilerVersion = Versions.kotlinVersion
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceSets {
named("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
res.srcDirs("src/androidMain/res")
}
}
}

View File

@ -0,0 +1,39 @@
import org.jetbrains.compose.compose
plugins {
id("com.android.library")
id("kotlin-multiplatform")
id("org.jetbrains.compose")
}
kotlin {
jvm("desktop")
android()
sourceSets {
named("commonMain") {
dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
}
}
named("androidMain") {
dependencies {
implementation(Androidx.appCompat)
implementation(Androidx.core)
}
}
named("desktopMain") {
dependencies {
implementation(compose.desktop.common)
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}

View File

@ -0,0 +1,34 @@
plugins {
id("com.android.library")
id("kotlin-multiplatform")
}
kotlin {
jvm("desktop")
android()
//ios()
sourceSets {
named("commonTest") {
dependencies {
implementation(JetBrains.Kotlin.testCommon)
implementation(JetBrains.Kotlin.testAnnotationsCommon)
}
}
named("androidTest") {
dependencies {
implementation(JetBrains.Kotlin.testJunit)
}
}
named("desktopTest") {
dependencies {
implementation(JetBrains.Kotlin.testJunit)
}
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}

View File

@ -0,0 +1,15 @@
plugins {
id("multiplatform-compose-setup")
id("android-setup")
}
kotlin {
sourceSets {
named("commonMain") {
dependencies {
implementation(Deps.ArkIvanov.Decompose.decompose)
implementation(Deps.ArkIvanov.Decompose.extensionsCompose)
}
}
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.shabinder.common.ui"/>

View File

@ -0,0 +1,12 @@
package com.shabinder.common.ui
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@Composable
fun SpotiFlyerMain(){
Column {
Text("Hello World")
}
}

View File

@ -0,0 +1,15 @@
plugins {
id("multiplatform-compose-setup")
id("android-setup")
kotlin("plugin.serialization")
}
kotlin {
sourceSets {
named("commonMain") {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
}
}
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.shabinder.common.ui"/>

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common
import com.shabinder.common.spotify.Source
import kotlinx.serialization.Serializable
@Serializable
data class TrackDetails(
var title:String,
var artists:List<String>,
var durationSec:Int,
var albumName:String?=null,
var year:String?=null,
var comment:String?=null,
var lyrics:String?=null,
var trackUrl:String?=null,
//TODO var albumArt: File,
var albumArtURL: String,
var source: Source,
var downloaded: DownloadStatus = DownloadStatus.NotDownloaded,
var progress: Int = 2,//2 for visual progress bar hint
var outputFile: String,
var videoID:String? = null
)
enum class DownloadStatus{
Downloaded,
Downloading,
Queued,
NotDownloaded,
Converting,
Failed
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common
import kotlinx.serialization.Serializable
@Serializable
data class Optional<T>(val value: T?)

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common
import com.shabinder.common.spotify.Source
import kotlinx.serialization.Serializable
@Serializable
data class PlatformQueryResult(
var folderType: String,
var subFolder: String,
var title: String,
var coverUrl: String,
var trackList: List<TrackDetails>,
var source: Source
)

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common
import kotlinx.serialization.Serializable
@Serializable
data class YoutubeTrack(
var name: String? = null,
var type: String? = null, // Song / Video
var artist: String? = null,
var duration:String? = null,
var videoId: String? = null
)

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class Artist (
val popularity : Int,
val seokey : String,
val name : String,
@SerialName("artwork_175x175")var artworkLink :String?
)

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
import kotlinx.serialization.SerialName
data class CustomArtworks (
@SerialName("40x40") val size_40p : String,
@SerialName("80x80") val size_80p : String,
@SerialName("110x110")val size_110p : String,
@SerialName("175x175")val size_175p : String,
@SerialName("480x480")val size_480p : String,
)

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
data class GaanaAlbum (
val tracks : List<GaanaTrack>,
val count : Int,
val custom_artworks : CustomArtworks,
val release_year : Int,
val favorite_count : Int,
)

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
data class GaanaArtistDetails(
val artist : List<Artist>,
val count : Int,
)

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
data class GaanaArtistTracks(
val count : Int,
val tracks : List<GaanaTrack>
)

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
data class GaanaPlaylist (
val modified_on : String,
val count : Int,
val created_on : String,
val favorite_count : Int,
val tracks : List<GaanaTrack>,
)

View File

@ -0,0 +1,21 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
data class GaanaSong(
val tracks : List<GaanaTrack>
)

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
import com.shabinder.common.DownloadStatus
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class GaanaTrack (
val tags : List<Tags?>?,
val seokey : String,
val albumseokey : String?,
val track_title : String,
val album_title : String?,
val language : String?,
val duration: Int,
@SerialName("artwork_large") val artworkLink : String,
val artist : List<Artist?>,
@SerialName("gener") val genre : List<Genre?>?,
val lyrics_url : String?,
val youtube_id : String?,
val total_favourite_count : Int?,
val release_date : String?,
val play_ct : String?,
val secondary_language : String?,
var downloaded: DownloadStatus? = DownloadStatus.NotDownloaded
)

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
import kotlinx.serialization.Serializable
@Serializable
data class Genre (
val genre_id : Int,
val name : String
)

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.gaana
import kotlinx.serialization.Serializable
@Serializable
data class Tags (
val tag_id : Int,
val tag_name : String
)

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class Album(
var album_type: String? = null,
var artists: List<Artist?>? = null,
var available_markets: List<String?>? = null,
var copyrights: List<Copyright?>? = null,
var external_ids: Map<String?, String?>? = null,
var external_urls: Map<String?, String?>? = null,
var genres: List<String?>? = null,
var href: String? = null,
var id: String? = null,
var images: List<Image?>? = null,
var label :String? = null,
var name: String? = null,
var popularity: Int? = null,
var release_date: String? = null,
var release_date_precision: String? = null,
var tracks: PagingObjectTrack? = null,
var type: String? = null,
var uri: String? = null)

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class Artist(
var external_urls: Map<String?, String?>? = null,
var href: String? = null,
var id: String? = null,
var name: String? = null,
var type: String? = null,
var uri: String? = null)

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class Copyright(
var text: String? = null,
var type: String? = null)

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class Episodes(
var audio_preview_url:String?,
var description:String?,
var duration_ms:Int?,
var explicit:Boolean?,
var external_urls:Map<String,String>?,
var href:String?,
var id:String?,
var images:List<Image?>?,
var is_externally_hosted:Boolean?,
var is_playable:Boolean?,
var language:String?,
var languages:List<String?>?,
var name:String?,
var release_date:String?,
var release_date_precision:String?,
var type:String?,
var uri:String
)

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class Followers(
var href: String? = null,
var total: Int? = null)

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class Image(
var width: Int? = null,
var height: Int? = null,
var url: String? = null)

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class LinkedTrack(
var external_urls: Map<String?, String?>? = null,
var href: String? = null,
var id: String? = null,
var type: String? = null,
var uri: String? = null)

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class PagingObjectPlaylistTrack(
var href: String? = null,
var items: List<PlaylistTrack>? = null,
var limit: Int = 0,
var next: String? = null,
var offset: Int = 0,
var previous: String? = null,
var total: Int = 0)

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class PagingObjectTrack(
var href: String? = null,
var items: List<Track>? = null,
var limit: Int = 0,
var next: String? = null,
var offset: Int = 0,
var previous: String? = null,
var total: Int = 0)

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class Playlist(
@SerialName("collaborative")var is_collaborative: Boolean? = null,
var description: String? = null,
var external_urls: Map<String?, String?>? = null,
var followers: Followers? = null,
var href: String? = null,
var id: String? = null,
var images: List<Image?>? = null,
var name: String? = null,
var owner: UserPublic? = null,
@SerialName("public")var is_public: Boolean? = null,
var snapshot_id: String? = null,
var tracks: PagingObjectPlaylistTrack? = null,
var type: String? = null,
var uri: String? = null)

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class PlaylistTrack(
var added_at: String? = null,
var added_by: UserPublic? = null,
var track: Track? = null,
var is_local: Boolean? = null)

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
enum class Source {
Spotify,
YouTube,
Gaana,
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class Token(
var access_token:String?,
var token_type:String?,
@SerialName("expires_in") var expiry:Long?
)

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import com.shabinder.common.DownloadStatus
import kotlinx.serialization.Serializable
@Serializable
data class Track(
var artists: List<Artist?>? = null,
var available_markets: List<String?>? = null,
var is_playable: Boolean? = null,
var linked_from: LinkedTrack? = null,
var disc_number: Int = 0,
var duration_ms: Long = 0,
var explicit: Boolean? = null,
var external_urls: Map<String?, String?>? = null,
var href: String? = null,
var name: String? = null,
var preview_url: String? = null,
var track_number: Int = 0,
var type: String? = null,
var uri: String? = null,
var album: Album? = null,
var external_ids: Map<String?, String?>? = null,
var popularity: Int? = null,
var downloaded: DownloadStatus = DownloadStatus.NotDownloaded
)

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class UserPrivate(
val country:String,
var display_name: String,
val email:String,
var external_urls: Map<String?, String?>? = null,
var followers: Followers? = null,
var href: String? = null,
var id: String? = null,
var images: List<Image?>? = null,
var product:String,
var type: String? = null,
var uri: String? = null)

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2021 Shabinder Singh
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.shabinder.common.spotify
import kotlinx.serialization.Serializable
@Serializable
data class UserPublic(
var display_name: String? = null,
var external_urls: Map<String?, String?>? = null,
var followers: Followers? = null,
var href: String? = null,
var id: String? = null,
var images: List<Image?>? = null,
var type: String? = null,
var uri: String? = null)

View File

@ -0,0 +1,40 @@
plugins {
id("multiplatform-setup")
id("android-setup")
id("com.squareup.sqldelight")
}
sqldelight {
database("TodoDatabase") {
packageName = "com.shabinder.database"
}
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation(Deps.Badoo.Reaktive.reaktive)
}
}
androidMain {
dependencies {
implementation(SqlDelight.androidDriver)
implementation(SqlDelight.sqliteDriver)
}
}
desktopMain {
dependencies {
implementation(SqlDelight.sqliteDriver)
}
}
/*iosMain {
dependencies {
implementation(Deps.Squareup.SQLDelight.nativeDriver)
}
}*/
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.shabinder.common.database"/>

View File

@ -0,0 +1,13 @@
package com.shabinder.common.database
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver
import com.shabinder.database.TodoDatabase
@Suppress("FunctionName") // FactoryFunction
actual fun TestDatabaseDriver(): SqlDriver {
val driver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
TodoDatabase.Schema.create(driver)
return driver
}

View File

@ -0,0 +1,14 @@
package com.shabinder.common.database
import android.content.Context
import com.squareup.sqldelight.android.AndroidSqliteDriver
import com.squareup.sqldelight.db.SqlDriver
import com.shabinder.database.TodoDatabase
@Suppress("FunctionName") // FactoryFunction
fun TodoDatabaseDriver(context: Context): SqlDriver =
AndroidSqliteDriver(
schema = TodoDatabase.Schema,
context = context,
name = "TodoDatabase.db"
)

View File

@ -0,0 +1,28 @@
package com.shabinder.common.database
import com.badoo.reaktive.base.setCancellable
import com.badoo.reaktive.observable.Observable
import com.badoo.reaktive.observable.map
import com.badoo.reaktive.observable.observable
import com.badoo.reaktive.observable.observeOn
import com.badoo.reaktive.scheduler.ioScheduler
import com.squareup.sqldelight.Query
fun <T : Any, R> Query<T>.asObservable(execute: (Query<T>) -> R): Observable<R> =
asObservable()
.observeOn(ioScheduler)
.map(execute)
fun <T : Any> Query<T>.asObservable(): Observable<Query<T>> =
observable { emitter ->
val listener =
object : Query.Listener {
override fun queryResultsChanged() {
emitter.onNext(this@asObservable)
}
}
emitter.onNext(this@asObservable)
addListener(listener)
emitter.setCancellable { removeListener(listener) }
}

View File

@ -0,0 +1,6 @@
package com.shabinder.common.database
import com.squareup.sqldelight.db.SqlDriver
@Suppress("FunctionName")
expect fun TestDatabaseDriver(): SqlDriver

View File

@ -0,0 +1,39 @@
CREATE TABLE IF NOT EXISTS TodoItemEntity (
id INTEGER PRIMARY KEY AUTOINCREMENT,
orderNum INTEGER NOT NULL,
text TEXT NOT NULL,
isDone INTEGER AS Boolean NOT NULL DEFAULT 0
);
selectAll:
SELECT *
FROM TodoItemEntity;
select:
SELECT *
FROM TodoItemEntity
WHERE id = :id;
add:
INSERT INTO TodoItemEntity (orderNum, text)
VALUES ((CASE (SELECT COUNT(*) FROM TodoItemEntity) WHEN 0 THEN 1 ELSE (SELECT MAX(orderNum)+1 FROM TodoItemEntity) END), :text);
setText:
UPDATE TodoItemEntity
SET text = :text
WHERE id = :id;
setDone:
UPDATE TodoItemEntity
SET isDone = :isDone
WHERE id = :id;
delete:
DELETE FROM TodoItemEntity
WHERE id = :id;
getLastInsertId:
SELECT last_insert_rowid();
clear:
DELETE FROM TodoItemEntity;

View File

@ -0,0 +1,13 @@
package com.shabinder.common.database
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver
import com.shabinder.database.TodoDatabase
@Suppress("FunctionName") // FactoryFunction
actual fun TestDatabaseDriver(): SqlDriver {
val driver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
TodoDatabase.Schema.create(driver)
return driver
}

View File

@ -0,0 +1,15 @@
package com.shabinder.common.database
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver
import com.shabinder.database.TodoDatabase
import java.io.File
@Suppress("FunctionName") // FactoryFunction
fun TodoDatabaseDriver(): SqlDriver {
val databasePath = File(System.getProperty("java.io.tmpdir"), "ComposeTodoDatabase.db")
val driver = JdbcSqliteDriver(url = "jdbc:sqlite:${databasePath.absolutePath}")
TodoDatabase.Schema.create(driver)
return driver
}

View File

@ -0,0 +1,34 @@
plugins {
id("multiplatform-compose-setup")
id("android-setup")
kotlin("plugin.serialization")
}
kotlin {
sourceSets {
named("commonMain") {
dependencies {
implementation(project(":common:data-models"))
implementation(project(":common:database"))
implementation("org.kodein.di:kodein-di:${Versions.kodein}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
implementation(Ktor.clientCore)
implementation(Ktor.clientCio)
implementation(Ktor.clientJson)
implementation(Ktor.clientSerialization)
implementation(Ktor.auth)
}
}
named("androidMain"){
dependencies{
implementation(Ktor.clientAndroid)
}
}
named("desktopMain"){
dependencies{
//implementation(Ktor.clientDesktop)
}
}
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.shabinder.common.ui"/>

View File

@ -0,0 +1,2 @@
package com.shabinder.common

View File

@ -0,0 +1,16 @@
package com.shabinder.common
import com.shabinder.common.spotify.Token
import io.ktor.client.*
import io.ktor.client.features.auth.*
import io.ktor.client.features.auth.providers.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.*
import io.ktor.http.*
import org.kodein.di.DI
val networking = DI.Module("Networking"){
}

View File

@ -0,0 +1,38 @@
package com.shabinder.common
import com.shabinder.common.spotify.Token
import io.ktor.client.*
import io.ktor.client.features.auth.*
import io.ktor.client.features.auth.providers.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.*
import io.ktor.http.*
suspend fun authenticateSpotify(): Token {
return spotifyAuthClient.post("https://accounts.spotify.com/api/token"){
body = FormDataContent(Parameters.build { append("grant_type","client_credentials") })
}
}
private val spotifyAuthClient = HttpClient {
val clientId = "694d8bf4f6ec420fa66ea7fb4c68f89d"
val clientSecret = "02ca2d4021a7452dae2328b47a6e8fe8"
install(Auth) {
basic {
sendWithoutRequest = true
username = clientId
password = clientSecret
}
}
install(JsonFeature) {
serializer = kotlinxSerializer
}
}
val kotlinxSerializer = KotlinxSerializer( kotlinx.serialization.json.Json {
isLenient = true
ignoreUnknownKeys = true
})

38
desktop/build.gradle.kts Normal file
View File

@ -0,0 +1,38 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}
group = "com.shabinder"
version = Versions.versionName
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
sourceSets {
val jvmMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation(project(":common:database"))
implementation(project(":common:compose-ui"))
}
}
val jvmTest by getting
}
}
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "SpotiFlyer"
}
}
}

View File

@ -0,0 +1,5 @@
import androidx.compose.desktop.Window
fun main() = Window {
//TODO
}

5
gradle.properties Normal file
View File

@ -0,0 +1,5 @@
kotlin.code.style=official
android.useAndroidX=true
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.8-rc-4-bin.zip

185
gradlew vendored Normal file
View File

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

89
gradlew.bat vendored Normal file
View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

19
settings.gradle.kts Normal file
View File

@ -0,0 +1,19 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}
rootProject.name = "spotiflyer"
enableFeaturePreview("GRADLE_METADATA")
include(
":common:database",
":common:compose-ui",
":common:data-models",
":common:dependency-injection",
":android",
":desktop"
)