diff --git a/.idea/dictionaries/shabinder.xml b/.idea/dictionaries/shabinder.xml index eae09e67..16f2713a 100644 --- a/.idea/dictionaries/shabinder.xml +++ b/.idea/dictionaries/shabinder.xml @@ -1,13 +1,17 @@ + flyer moshi musicforeveryone musicplaceholder shabinder singh + spoti + spotiflyer spotify spotifydownloader + spotifyler \ No newline at end of file diff --git a/ScreenShots/HomeScreen.png b/ScreenShots/HomeScreen.png index 48da7f45..0804cea7 100644 Binary files a/ScreenShots/HomeScreen.png and b/ScreenShots/HomeScreen.png differ diff --git a/ScreenShots/Playlist.png b/ScreenShots/Playlist.png deleted file mode 100644 index 3c83dd57..00000000 Binary files a/ScreenShots/Playlist.png and /dev/null differ diff --git a/app/build.gradle b/app/build.gradle index 5d62c3ac..8940d6bc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2020 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 . + */ + apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' @@ -15,7 +32,7 @@ android { } defaultConfig { - applicationId 'com.shabinder.musicforeveryone' + applicationId 'com.shabinder.spotiflyer' minSdkVersion 22 targetSdkVersion 29 versionCode 1 @@ -55,9 +72,9 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7" - implementation "androidx.room:room-runtime:2.2.5" - kapt "androidx.room:room-compiler:2.2.5" - implementation "androidx.room:room-ktx:2.2.5" +// implementation "androidx.room:room-runtime:2.2.5" +// kapt "androidx.room:room-compiler:2.2.5" +// implementation "androidx.room:room-ktx:2.2.5" implementation "com.github.bumptech.glide:glide:4.11.0" kapt "com.github.bumptech.glide:compiler:4.11.0" @@ -73,7 +90,7 @@ dependencies { implementation "com.squareup.moshi:moshi-kotlin:1.9.3" implementation "com.squareup.retrofit2:converter-moshi:2.9.0" - + implementation 'com.shreyaspatil:EasyUpiPayment:2.2' implementation 'com.github.sealedtx:java-youtube-downloader:2.2.2' implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava' diff --git a/app/src/androidTest/java/com/shabinder/musicForEveryone/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/shabinder/musicForEveryone/ExampleInstrumentedTest.kt deleted file mode 100644 index f28aa88a..00000000 --- a/app/src/androidTest/java/com/shabinder/musicForEveryone/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.shabinder.musicForEveryone - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry -import org.junit.Assert.assertEquals -import org.junit.Test -import org.junit.runner.RunWith - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.shabinder.spotifydownloader", appContext.packageName) - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/com/shabinder/spotiflyer/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/shabinder/spotiflyer/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..956c41db --- /dev/null +++ b/app/src/androidTest/java/com/shabinder/spotiflyer/ExampleInstrumentedTest.kt @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 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 . + */ + +package com.shabinder.spotiflyer + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.shabinder.spotifydownloader", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 71fcd374..011f3294 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,23 @@ + + + package="com.shabinder.spotiflyer"> @@ -20,7 +37,7 @@ android:requestLegacyExternalStorage="true" android:theme="@style/AppTheme"> - + @@ -28,7 +45,7 @@ - diff --git a/app/src/main/java/com/shabinder/musicForEveryone/utils/BindingAdapter.kt b/app/src/main/java/com/shabinder/musicForEveryone/utils/BindingAdapter.kt deleted file mode 100644 index 04b7d209..00000000 --- a/app/src/main/java/com/shabinder/musicForEveryone/utils/BindingAdapter.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.shabinder.musicForEveryone.utils - -import android.widget.ImageView -import androidx.core.net.toUri -import androidx.databinding.BindingAdapter -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.shabinder.musicForEveryone.R - -@BindingAdapter("imageUrl") -fun bindImage(imgView: ImageView, imgUrl: String?) { - imgUrl?.let { - val imgUri = imgUrl.toUri().buildUpon().scheme("https").build() - Glide.with(imgView.context) - .load(imgUri) - .apply(RequestOptions() - .placeholder(R.drawable.ic_song_placeholder) - .error(R.drawable.ic_musicplaceholder)) - .into(imgView) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/shabinder/musicForEveryone/MainActivity.kt b/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt similarity index 91% rename from app/src/main/java/com/shabinder/musicForEveryone/MainActivity.kt rename to app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt index abc67520..9c675e07 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/MainActivity.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone +package com.shabinder.spotiflyer import android.Manifest import android.app.DownloadManager @@ -30,11 +30,12 @@ import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.lifecycle.ViewModelProvider import com.github.kiulian.downloader.YoutubeDownloader -import com.shabinder.musicForEveryone.databinding.MainActivityBinding -import com.shabinder.musicForEveryone.downloadHelper.DownloadHelper -import com.shabinder.musicForEveryone.utils.SpotifyService -import com.shabinder.musicForEveryone.utils.SpotifyServiceToken -import com.shabinder.musicForEveryone.utils.YoutubeInterface +import com.shabinder.spotiflyer.databinding.MainActivityBinding +import com.shabinder.spotiflyer.downloadHelper.DownloadHelper +import com.shabinder.spotiflyer.utils.SpotifyService +import com.shabinder.spotiflyer.utils.SpotifyServiceToken +import com.shabinder.spotiflyer.utils.YoutubeInterface +import com.shreyaspatil.EasyUpiPayment.EasyUpiPayment import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import kotlinx.coroutines.launch @@ -45,6 +46,7 @@ import okhttp3.Response import retrofit2.Retrofit import retrofit2.converter.moshi.MoshiConverterFactory + @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() ,DownloadHelper{ private lateinit var binding: MainActivityBinding @@ -52,12 +54,12 @@ class MainActivity : AppCompatActivity() ,DownloadHelper{ private var spotifyService : SpotifyService? = null private var spotifyServiceToken : SpotifyServiceToken? = null private var downloadManager : DownloadManager? = null -// private val redirectUri = "musicforeveryone://callback" +// private val redirectUri = "spotiflyer://callback" private val clientId:String = "694d8bf4f6ec420fa66ea7fb4c68f89d" private val clientSecret:String = "02ca2d4021a7452dae2328b47a6e8fe8" private var isConnected: Boolean = false private var sharedPref :SharedPreferences? = null - + private var easyUpiPayment:EasyUpiPayment? = null private var token :String ="" private lateinit var sharedViewModel: SharedViewModel @@ -100,9 +102,22 @@ class MainActivity : AppCompatActivity() ,DownloadHelper{ Log.i("Connection Status",isConnected.toString()) + easyUpiPayment = EasyUpiPayment.Builder() + .with(this) + .setPayeeVpa("technoshab@paytm") + .setPayeeName("Shabinder Singh") + .setTransactionId("UNIQUE_TRANSACTION_ID") + .setTransactionRefId("UNIQUE_TRANSACTION_REF_ID") + .setDescription("Thanks for donating") + .setAmount("39.00") + .build() + + sharedViewModel.easyUpiPayment = easyUpiPayment + handleIntentFromExternalActivity() } + /** * Adding my own new Spotify Web Api Requests! * */ @@ -162,7 +177,7 @@ class MainActivity : AppCompatActivity() ,DownloadHelper{ } - private fun authenticateSpotify() { + fun authenticateSpotify() { if (spotifyServiceToken == null) { getSpotifyToken() } diff --git a/app/src/main/java/com/shabinder/musicForEveryone/SharedViewModel.kt b/app/src/main/java/com/shabinder/spotiflyer/SharedViewModel.kt similarity index 88% rename from app/src/main/java/com/shabinder/musicForEveryone/SharedViewModel.kt rename to app/src/main/java/com/shabinder/spotiflyer/SharedViewModel.kt index e03219b9..350f72ca 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/SharedViewModel.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/SharedViewModel.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone +package com.shabinder.spotiflyer import android.app.DownloadManager import android.content.Context @@ -24,10 +24,11 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import com.github.kiulian.downloader.YoutubeDownloader import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.shabinder.musicForEveryone.models.Album -import com.shabinder.musicForEveryone.models.Playlist -import com.shabinder.musicForEveryone.models.Track -import com.shabinder.musicForEveryone.utils.SpotifyService +import com.shabinder.spotiflyer.models.Album +import com.shabinder.spotiflyer.models.Playlist +import com.shabinder.spotiflyer.models.Track +import com.shabinder.spotiflyer.utils.SpotifyService +import com.shreyaspatil.EasyUpiPayment.EasyUpiPayment import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -39,6 +40,8 @@ class SharedViewModel : ViewModel() { var ytDownloader : YoutubeDownloader? = null var downloadManager : DownloadManager? = null var isConnected = MutableLiveData().apply { value = false } + var easyUpiPayment: EasyUpiPayment? = null + private var viewModelJob = Job() diff --git a/app/src/main/java/com/shabinder/musicForEveryone/downloadHelper/DownloadHelper.kt b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt similarity index 85% rename from app/src/main/java/com/shabinder/musicForEveryone/downloadHelper/DownloadHelper.kt rename to app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt index 0621ff89..01e8fa0e 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/downloadHelper/DownloadHelper.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.downloadHelper +package com.shabinder.spotiflyer.downloadHelper import android.app.DownloadManager import android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED @@ -25,9 +25,9 @@ import android.util.Log import com.github.kiulian.downloader.YoutubeDownloader import com.github.kiulian.downloader.model.formats.Format import com.github.kiulian.downloader.model.quality.AudioQuality -import com.shabinder.musicForEveryone.fragments.MainFragment -import com.shabinder.musicForEveryone.models.Track -import com.shabinder.musicForEveryone.utils.YoutubeInterface +import com.shabinder.spotiflyer.fragments.MainFragment +import com.shabinder.spotiflyer.models.Track +import com.shabinder.spotiflyer.utils.YoutubeInterface import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import java.io.File @@ -37,13 +37,18 @@ interface DownloadHelper { /** * Function To Download All Tracks Available in a List **/ - suspend fun downloadAllTracks(trackList : List, ytDownloader: YoutubeDownloader?, downloadManager: DownloadManager?) { - trackList.forEach { downloadTrack(null,ytDownloader,downloadManager,"${it.name} ${it.artists?.get(0)?.name ?:""}") } + suspend fun downloadAllTracks( + type:String, + subFolder: String?, + trackList: List, ytDownloader: YoutubeDownloader?, downloadManager: DownloadManager?) { + trackList.forEach { downloadTrack(null,type,subFolder,ytDownloader,downloadManager,"${it.name} ${it.artists?.get(0)?.name ?:""}") } } suspend fun downloadTrack( mainFragment: MainFragment?, + type:String, + subFolder:String?, ytDownloader: YoutubeDownloader?, downloadManager: DownloadManager?, searchQuery: String @@ -63,7 +68,7 @@ interface DownloadHelper { val audioUrl = format.url() Log.i("DHelper Link Found", audioUrl) if (audioUrl != null) { - downloadFile(audioUrl, downloadManager, details!!.title()) + downloadFile(audioUrl, downloadManager, details!!.title(),subFolder,type) withContext(Dispatchers.Main){ mainFragment?.showToast("Download Started") } @@ -77,7 +82,7 @@ interface DownloadHelper { val audioUrl = format.url() Log.i("DHelper Link Found", audioUrl) if (audioUrl != null) { - downloadFile(audioUrl, downloadManager, details!!.title()) + downloadFile(audioUrl, downloadManager, details!!.title(),subFolder,type) withContext(Dispatchers.Main){ mainFragment?.showToast("Download Started") } @@ -91,7 +96,7 @@ interface DownloadHelper { val audioUrl = format.url() Log.i("DHelper Link Found", audioUrl) if (audioUrl != null) { - downloadFile(audioUrl, downloadManager, details!!.title()) + downloadFile(audioUrl, downloadManager, details!!.title(),subFolder,type) withContext(Dispatchers.Main){ mainFragment?.showToast("Download Started") } @@ -113,11 +118,11 @@ interface DownloadHelper { /** * Downloading Using Android Download Manager * */ - suspend fun downloadFile(url: String, downloadManager: DownloadManager?, title: String) { + suspend fun downloadFile(url: String, downloadManager: DownloadManager?, title: String,subFolder: String?,type: String) { withContext(Dispatchers.IO) { val audioUri = Uri.parse(url) - val outputDir = - File.separator + "Spotify-Downloads" + File.separator + "${removeIllegalChars(title)}.mp3" + val outputDir:String = + File.separator + "SpotiFlyer" + File.separator + type + File.separator + (if(subFolder == null){""}else{subFolder + File.separator}) + "${removeIllegalChars(title)}.mp3" val request = DownloadManager.Request(audioUri) .setAllowedNetworkTypes( diff --git a/app/src/main/java/com/shabinder/musicForEveryone/fragments/MainFragment.kt b/app/src/main/java/com/shabinder/spotiflyer/fragments/MainFragment.kt similarity index 89% rename from app/src/main/java/com/shabinder/musicForEveryone/fragments/MainFragment.kt rename to app/src/main/java/com/shabinder/spotiflyer/fragments/MainFragment.kt index bd09810e..27ead4a7 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/fragments/MainFragment.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/fragments/MainFragment.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.fragments +package com.shabinder.spotiflyer.fragments import android.content.Context import android.content.Intent @@ -33,14 +33,15 @@ import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider -import com.shabinder.musicForEveryone.R -import com.shabinder.musicForEveryone.SharedViewModel -import com.shabinder.musicForEveryone.databinding.MainFragmentBinding -import com.shabinder.musicForEveryone.downloadHelper.DownloadHelper -import com.shabinder.musicForEveryone.models.Track -import com.shabinder.musicForEveryone.recyclerView.TrackListAdapter -import com.shabinder.musicForEveryone.utils.SpotifyService -import com.shabinder.musicForEveryone.utils.bindImage +import com.shabinder.spotiflyer.MainActivity +import com.shabinder.spotiflyer.R +import com.shabinder.spotiflyer.SharedViewModel +import com.shabinder.spotiflyer.databinding.MainFragmentBinding +import com.shabinder.spotiflyer.downloadHelper.DownloadHelper +import com.shabinder.spotiflyer.models.Track +import com.shabinder.spotiflyer.recyclerView.TrackListAdapter +import com.shabinder.spotiflyer.utils.SpotifyService +import com.shabinder.spotiflyer.utils.bindImage import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -73,6 +74,10 @@ class MainFragment : Fragment(),DownloadHelper { binding.usage.text = spanStringBuilder openSpotifyButton() + binding.btnDonate.setOnClickListener { + sharedViewModel.easyUpiPayment?.startPayment() + } + binding.btnSearch.setOnClickListener { sharedViewModel.isConnected.value = isOnline() spotifyLink = binding.linkSearch.text.toString() @@ -82,6 +87,10 @@ class MainFragment : Fragment(),DownloadHelper { Log.i("Fragment", "$type : $link") + if(sharedViewModel.spotifyService == null){ + (activity as MainActivity).authenticateSpotify() + } + if (type == "Error" || link == "Error") { showToast("Please Check Your Link!") } else if(sharedViewModel.isConnected.value == false){ @@ -115,6 +124,8 @@ class MainFragment : Fragment(),DownloadHelper { sharedViewModel.uiScope.launch { withContext(Dispatchers.IO) { downloadAllTracks( + "Tracks", + null, trackList, sharedViewModel.ytDownloader, sharedViewModel.downloadManager @@ -141,6 +152,8 @@ class MainFragment : Fragment(),DownloadHelper { sharedViewModel.uiScope.launch { withContext(Dispatchers.IO) { downloadAllTracks( + "Albums", + albumObject.name, trackList, sharedViewModel.ytDownloader, sharedViewModel.downloadManager @@ -167,6 +180,8 @@ class MainFragment : Fragment(),DownloadHelper { sharedViewModel.uiScope.launch { withContext(Dispatchers.IO) { downloadAllTracks( + "Playlists", + playlistObject.name, trackList, sharedViewModel.ytDownloader, sharedViewModel.downloadManager @@ -189,7 +204,8 @@ class MainFragment : Fragment(),DownloadHelper { } } handleIntent() - if(savedInstanceState != null && binding.linkSearch.text.toString() != ""){ + //Handling Device Configuration Change + if(savedInstanceState != null && savedInstanceState["searchLink"].toString() != ""){ binding.linkSearch.setText(savedInstanceState["searchLink"].toString()) binding.btnSearch.performClick() setUiVisibility() diff --git a/app/src/main/java/com/shabinder/musicForEveryone/fragments/MainViewModel.kt b/app/src/main/java/com/shabinder/spotiflyer/fragments/MainViewModel.kt similarity index 89% rename from app/src/main/java/com/shabinder/musicForEveryone/fragments/MainViewModel.kt rename to app/src/main/java/com/shabinder/spotiflyer/fragments/MainViewModel.kt index ded4fe7c..4a274e1f 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/fragments/MainViewModel.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/fragments/MainViewModel.kt @@ -15,14 +15,13 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.fragments +package com.shabinder.spotiflyer.fragments import androidx.lifecycle.ViewModel -import com.shabinder.musicForEveryone.models.Track +import com.shabinder.spotiflyer.models.Track class MainViewModel: ViewModel() { var searchLink:String = "" var trackList = mutableListOf() var coverUrl:String = "" - } \ No newline at end of file diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Album.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Album.kt similarity index 100% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Album.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Album.kt diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Artist.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Artist.kt similarity index 95% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Artist.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Artist.kt index b4f1bf5d..ba70b8a5 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/Artist.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/Artist.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class Artist( var external_urls: Map? = null, var href: String? = null, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Copyright.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Copyright.kt similarity index 94% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Copyright.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Copyright.kt index eaecc105..b10f83a5 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/Copyright.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/Copyright.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class Copyright( var text: String? = null, var type: String? = null) \ No newline at end of file diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Episodes.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Episodes.kt similarity index 96% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Episodes.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Episodes.kt index ef30b900..4cf5e834 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/Episodes.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/Episodes.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class Episodes( var audio_preview_url:String?, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Followers.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Followers.kt similarity index 94% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Followers.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Followers.kt index 0ebeb1d8..45cae186 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/Followers.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/Followers.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class Followers( var href: String? = null, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Image.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Image.kt similarity index 94% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Image.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Image.kt index 288643fa..61f67f17 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/Image.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/Image.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class Image( var width: Int? = null, var height: Int? = null, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/LinkedTrack.kt b/app/src/main/java/com/shabinder/spotiflyer/models/LinkedTrack.kt similarity index 95% rename from app/src/main/java/com/shabinder/musicForEveryone/models/LinkedTrack.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/LinkedTrack.kt index b41d2105..3efa8bb8 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/LinkedTrack.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/LinkedTrack.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class LinkedTrack( var external_urls: Map? = null, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/PagingObject.kt b/app/src/main/java/com/shabinder/spotiflyer/models/PagingObject.kt similarity index 95% rename from app/src/main/java/com/shabinder/musicForEveryone/models/PagingObject.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/PagingObject.kt index 9dad1ae9..603b4319 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/PagingObject.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/PagingObject.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class PagingObject( var href: String? = null, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Playlist.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Playlist.kt similarity index 96% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Playlist.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Playlist.kt index 4f8c4a56..1cc01e6b 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/Playlist.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/Playlist.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models import com.squareup.moshi.Json data class Playlist( diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/PlaylistTrack.kt b/app/src/main/java/com/shabinder/spotiflyer/models/PlaylistTrack.kt similarity index 94% rename from app/src/main/java/com/shabinder/musicForEveryone/models/PlaylistTrack.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/PlaylistTrack.kt index ca1c9447..0eba9d32 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/PlaylistTrack.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/PlaylistTrack.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class PlaylistTrack( var added_at: String? = null, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Token.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Token.kt similarity index 94% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Token.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Token.kt index efd4775d..0b69ef32 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/Token.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/Token.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class Token( var access_token:String, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/Track.kt b/app/src/main/java/com/shabinder/spotiflyer/models/Track.kt similarity index 96% rename from app/src/main/java/com/shabinder/musicForEveryone/models/Track.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/Track.kt index b56d8e92..b1ef82d8 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/Track.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/Track.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class Track( var artists: List? = null, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/UserPrivate.kt b/app/src/main/java/com/shabinder/spotiflyer/models/UserPrivate.kt similarity index 95% rename from app/src/main/java/com/shabinder/musicForEveryone/models/UserPrivate.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/UserPrivate.kt index 23dc8c7e..ed1db284 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/UserPrivate.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/UserPrivate.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class UserPrivate( val country:String, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/models/UserPublic.kt b/app/src/main/java/com/shabinder/spotiflyer/models/UserPublic.kt similarity index 95% rename from app/src/main/java/com/shabinder/musicForEveryone/models/UserPublic.kt rename to app/src/main/java/com/shabinder/spotiflyer/models/UserPublic.kt index dbbfe7c9..9a6b636b 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/models/UserPublic.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/models/UserPublic.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.models +package com.shabinder.spotiflyer.models data class UserPublic( var display_name: String? = null, diff --git a/app/src/main/java/com/shabinder/musicForEveryone/recyclerView/TrackListAdapter.kt b/app/src/main/java/com/shabinder/spotiflyer/recyclerView/TrackListAdapter.kt similarity index 83% rename from app/src/main/java/com/shabinder/musicForEveryone/recyclerView/TrackListAdapter.kt rename to app/src/main/java/com/shabinder/spotiflyer/recyclerView/TrackListAdapter.kt index d1e8d38e..033435e3 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/recyclerView/TrackListAdapter.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/recyclerView/TrackListAdapter.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.recyclerView +package com.shabinder.spotiflyer.recyclerView import android.view.LayoutInflater import android.view.View @@ -24,12 +24,12 @@ import android.widget.ImageButton import android.widget.ImageView import android.widget.TextView import androidx.recyclerview.widget.RecyclerView -import com.shabinder.musicForEveryone.R -import com.shabinder.musicForEveryone.SharedViewModel -import com.shabinder.musicForEveryone.downloadHelper.DownloadHelper -import com.shabinder.musicForEveryone.fragments.MainFragment -import com.shabinder.musicForEveryone.models.Track -import com.shabinder.musicForEveryone.utils.bindImage +import com.shabinder.spotiflyer.R +import com.shabinder.spotiflyer.SharedViewModel +import com.shabinder.spotiflyer.downloadHelper.DownloadHelper +import com.shabinder.spotiflyer.fragments.MainFragment +import com.shabinder.spotiflyer.models.Track +import com.shabinder.spotiflyer.utils.bindImage import kotlinx.coroutines.launch class TrackListAdapter:RecyclerView.Adapter(),DownloadHelper { @@ -60,7 +60,7 @@ class TrackListAdapter:RecyclerView.Adapter(),Downl holder.duration.text = "${item.duration_ms/1000/60} minutes, ${(item.duration_ms/1000)%60} sec" holder.downloadBtn.setOnClickListener{ sharedViewModel.uiScope.launch { - downloadTrack(mainFragment,sharedViewModel.ytDownloader,sharedViewModel.downloadManager,"${item.name} ${item.artists?.get(0)!!.name?:""}") + downloadTrack(mainFragment,"Tracks",null,sharedViewModel.ytDownloader,sharedViewModel.downloadManager,"${item.name} ${item.artists?.get(0)!!.name?:""}") } } diff --git a/app/src/main/java/com/shabinder/musicForEveryone/samples/response examples.txt b/app/src/main/java/com/shabinder/spotiflyer/samples/response examples.txt similarity index 100% rename from app/src/main/java/com/shabinder/musicForEveryone/samples/response examples.txt rename to app/src/main/java/com/shabinder/spotiflyer/samples/response examples.txt diff --git a/app/src/main/java/com/shabinder/musicForEveryone/splash/SplashScreen.kt b/app/src/main/java/com/shabinder/spotiflyer/splash/SplashScreen.kt similarity index 90% rename from app/src/main/java/com/shabinder/musicForEveryone/splash/SplashScreen.kt rename to app/src/main/java/com/shabinder/spotiflyer/splash/SplashScreen.kt index 43f60b43..66ed62b4 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/splash/SplashScreen.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/splash/SplashScreen.kt @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.splash +package com.shabinder.spotiflyer.splash import android.content.Intent import android.os.Bundle import android.os.Handler import androidx.appcompat.app.AppCompatActivity -import com.shabinder.musicForEveryone.MainActivity -import com.shabinder.musicForEveryone.R +import com.shabinder.spotiflyer.MainActivity +import com.shabinder.spotiflyer.R class SplashScreen : AppCompatActivity(){ diff --git a/app/src/main/java/com/shabinder/spotiflyer/utils/BindingAdapter.kt b/app/src/main/java/com/shabinder/spotiflyer/utils/BindingAdapter.kt new file mode 100644 index 00000000..5052ad65 --- /dev/null +++ b/app/src/main/java/com/shabinder/spotiflyer/utils/BindingAdapter.kt @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2020 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 . + */ + +package com.shabinder.spotiflyer.utils + +import android.widget.ImageView +import androidx.core.net.toUri +import androidx.databinding.BindingAdapter +import com.bumptech.glide.Glide +import com.bumptech.glide.request.RequestOptions +import com.shabinder.spotiflyer.R + +@BindingAdapter("imageUrl") +fun bindImage(imgView: ImageView, imgUrl: String?) { + imgUrl?.let { + val imgUri = imgUrl.toUri().buildUpon().scheme("https").build() + Glide.with(imgView.context) + .load(imgUri) + .apply(RequestOptions() + .placeholder(R.drawable.ic_song_placeholder) + .error(R.drawable.ic_musicplaceholder)) + .into(imgView) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/shabinder/musicForEveryone/utils/SpotifyService.kt b/app/src/main/java/com/shabinder/spotiflyer/utils/SpotifyService.kt similarity index 95% rename from app/src/main/java/com/shabinder/musicForEveryone/utils/SpotifyService.kt rename to app/src/main/java/com/shabinder/spotiflyer/utils/SpotifyService.kt index cacb9e1b..05ff0655 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/utils/SpotifyService.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/utils/SpotifyService.kt @@ -15,9 +15,9 @@ * along with this program. If not, see . */ -package com.shabinder.musicForEveryone.utils +package com.shabinder.spotiflyer.utils -import com.shabinder.musicForEveryone.models.* +import com.shabinder.spotiflyer.models.* import retrofit2.http.* /* diff --git a/app/src/main/java/com/shabinder/musicForEveryone/utils/YoutubeInterface.kt b/app/src/main/java/com/shabinder/spotiflyer/utils/YoutubeInterface.kt similarity index 73% rename from app/src/main/java/com/shabinder/musicForEveryone/utils/YoutubeInterface.kt rename to app/src/main/java/com/shabinder/spotiflyer/utils/YoutubeInterface.kt index ba1e9955..f86a47f0 100644 --- a/app/src/main/java/com/shabinder/musicForEveryone/utils/YoutubeInterface.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/utils/YoutubeInterface.kt @@ -1,4 +1,21 @@ -package com.shabinder.musicForEveryone.utils +/* + * Copyright (C) 2020 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 . + */ + +package com.shabinder.spotiflyer.utils import android.util.Log import com.google.api.client.http.HttpRequestInitializer @@ -16,7 +33,7 @@ object YoutubeInterface { fun youtubeConnector() { youtube = YouTube.Builder(NetHttpTransport(), JacksonFactory(), HttpRequestInitializer { }) - .setApplicationName("Music For Everyone").build() + .setApplicationName("spotifyler").build() try { query = youtube?.search()?.list("id,snippet") query?.key = apiKey diff --git a/app/src/main/res/font/amita.xml b/app/src/main/res/font/amita.xml new file mode 100644 index 00000000..d2f7205a --- /dev/null +++ b/app/src/main/res/font/amita.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/app/src/main/res/layout/main_fragment.xml b/app/src/main/res/layout/main_fragment.xml index adb31467..386a17e0 100644 --- a/app/src/main/res/layout/main_fragment.xml +++ b/app/src/main/res/layout/main_fragment.xml @@ -1,4 +1,21 @@ + + @@ -105,35 +122,50 @@ + + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" + app:layout_constraintTop_toBottomOf="@id/appbar"> - + - + + + + app:layout_constraintTop_toBottomOf="@+id/textView2" /> + app:layout_constraintTop_toBottomOf="@+id/textView4" /> + + + - - + + + + \ No newline at end of file diff --git a/app/src/main/res/values/preloaded_fonts.xml b/app/src/main/res/values/preloaded_fonts.xml index 9dd61011..d0d637b9 100644 --- a/app/src/main/res/values/preloaded_fonts.xml +++ b/app/src/main/res/values/preloaded_fonts.xml @@ -1,6 +1,24 @@ + + + @font/amita @font/averia_libre @font/capriola @font/raleway diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ceaca902..fb5d58e6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,22 @@ + + - musicForEveryone + SpotiFlyer Usage Instructions: 1. Paste, Your Copied Link in Search Box at Top. 2. Share directly from Spotify App to this App. diff --git a/app/src/test/java/com/shabinder/musicForEveryone/ExampleUnitTest.kt b/app/src/test/java/com/shabinder/musicForEveryone/ExampleUnitTest.kt deleted file mode 100644 index 0bbbba73..00000000 --- a/app/src/test/java/com/shabinder/musicForEveryone/ExampleUnitTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.shabinder.musicForEveryone - -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file diff --git a/app/src/test/java/com/shabinder/spotiflyer/ExampleUnitTest.kt b/app/src/test/java/com/shabinder/spotiflyer/ExampleUnitTest.kt new file mode 100644 index 00000000..534aca42 --- /dev/null +++ b/app/src/test/java/com/shabinder/spotiflyer/ExampleUnitTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 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 . + */ + +package com.shabinder.spotiflyer + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index c338a295..67bd13f5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,19 @@ +/* + * Copyright (C) 2020 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 . + */ + include ':app' -rootProject.name = "musicForEveryone" +rootProject.name = "spotiflyer"