mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-24 18:04:33 +01:00
ViewBinding Instead of DataBinding and Image Quality Optimised in favour of Less Cache and App Load.
This commit is contained in:
parent
b3b2e6ed51
commit
b39c581458
@ -38,10 +38,7 @@ import com.github.javiersantos.appupdater.enums.UpdateFrom
|
||||
import com.shabinder.spotiflyer.databinding.MainActivityBinding
|
||||
import com.shabinder.spotiflyer.networking.SpotifyService
|
||||
import com.shabinder.spotiflyer.networking.SpotifyServiceTokenRequest
|
||||
import com.shabinder.spotiflyer.utils.NetworkInterceptor
|
||||
import com.shabinder.spotiflyer.utils.createDirectories
|
||||
import com.shabinder.spotiflyer.utils.isOnline
|
||||
import com.shabinder.spotiflyer.utils.startService
|
||||
import com.shabinder.spotiflyer.utils.*
|
||||
import com.squareup.moshi.Moshi
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
@ -160,6 +157,7 @@ class MainActivity : AppCompatActivity(){
|
||||
Log.i("Spotify Authentication","Started")
|
||||
val token = spotifyServiceTokenRequest.getToken()
|
||||
token.value?.let {
|
||||
showMessage("Success: Spotify Token Acquired",isSuccess = true)
|
||||
implementSpotifyService(it.access_token)
|
||||
}
|
||||
Log.i("Spotify Token", token.value.toString())
|
||||
|
@ -79,7 +79,7 @@ object DownloadHelper {
|
||||
showMessage("Download Started, Now You can leave the App!")
|
||||
}
|
||||
startService(mainActivity,downloadList)
|
||||
},5000)
|
||||
},3000)
|
||||
}
|
||||
}else{
|
||||
val searchQuery = "${it.title} - ${it.artists.joinToString(",")}"
|
||||
|
@ -35,12 +35,12 @@ import kotlinx.coroutines.launch
|
||||
class DownloadRecordAdapter: ListAdapter<DownloadRecord,DownloadRecordAdapter.ViewHolder>(DownloadRecordDiffCallback()) {
|
||||
|
||||
private val adapterScope = CoroutineScope(Dispatchers.Default)
|
||||
//Remember To change when Submitting a Different List / Or Use New Submit List Fun
|
||||
//Remember To change when Submitting a Different List / Or Use New Submit List Function
|
||||
var source:Source = Source.Spotify
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val binding =DownloadRecordItemBinding.inflate(layoutInflater)
|
||||
val binding = DownloadRecordItemBinding.inflate(layoutInflater)
|
||||
return ViewHolder(binding)
|
||||
}
|
||||
|
||||
@ -53,11 +53,17 @@ class DownloadRecordAdapter: ListAdapter<DownloadRecord,DownloadRecordAdapter.Vi
|
||||
holder.binding.totalItems.text = "Tracks: ${item.totalFiles}"
|
||||
holder.binding.type.text = item.type
|
||||
holder.binding.btnAction.setOnClickListener {
|
||||
if (item.link.contains("spotify",true)){
|
||||
it.findNavController().navigate(DownloadRecordFragmentDirections.actionDownloadRecordToSpotifyFragment((item.link)))
|
||||
}else if(item.link.contains("youtube.com",true) || item.link.contains("youtu.be",true) ){
|
||||
it.findNavController().navigate(DownloadRecordFragmentDirections.actionDownloadRecordToYoutubeFragment(item.link))
|
||||
}
|
||||
when {
|
||||
item.link.contains("spotify",true) -> {
|
||||
it.findNavController().navigate(DownloadRecordFragmentDirections.actionDownloadRecordToSpotifyFragment((item.link)))
|
||||
}
|
||||
item.link.contains("youtube.com",true) || item.link.contains("youtu.be",true) -> {
|
||||
it.findNavController().navigate(DownloadRecordFragmentDirections.actionDownloadRecordToYoutubeFragment(item.link))
|
||||
}
|
||||
item.link.contains("gaana",true) -> {
|
||||
it.findNavController().navigate(DownloadRecordFragmentDirections.actionDownloadRecordToGaanaFragment((item.link)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class ViewHolder(val binding: DownloadRecordItemBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
|
@ -57,7 +57,8 @@ class DownloadRecordFragment : Fragment() {
|
||||
}
|
||||
when(binding.tabLayout.selectedTabPosition){
|
||||
0-> adapter.submitList(downloadRecordViewModel.spotifyList,Source.Spotify)
|
||||
1-> adapter.submitList(downloadRecordViewModel.ytList,Source.YouTube)
|
||||
1-> adapter.submitList(downloadRecordViewModel.gaanaList,Source.Gaana)
|
||||
2-> adapter.submitList(downloadRecordViewModel.ytList,Source.YouTube)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -67,7 +68,8 @@ class DownloadRecordFragment : Fragment() {
|
||||
override fun onTabSelected(tab: TabLayout.Tab?) {
|
||||
when(tab?.position){
|
||||
0-> adapter.submitList(downloadRecordViewModel.spotifyList,Source.Spotify)
|
||||
1-> adapter.submitList(downloadRecordViewModel.ytList,Source.YouTube)
|
||||
1-> adapter.submitList(downloadRecordViewModel.gaanaList,Source.Gaana)
|
||||
2-> adapter.submitList(downloadRecordViewModel.ytList,Source.YouTube)
|
||||
}
|
||||
}
|
||||
override fun onTabReselected(tab: TabLayout.Tab?) {}
|
||||
|
@ -41,6 +41,7 @@ class DownloadRecordViewModel @ViewModelInject constructor(val databaseDAO: Data
|
||||
init {
|
||||
getDownloadRecordList()
|
||||
}
|
||||
|
||||
private fun getDownloadRecordList() {
|
||||
uiScope.launch {
|
||||
downloadRecordList.postValue(databaseDAO.getRecord().toMutableList())
|
||||
|
@ -40,6 +40,7 @@ class GaanaViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO)
|
||||
override var folderType:String = ""
|
||||
override var subFolder:String = ""
|
||||
var gaanaInterface : GaanaInterface? = null
|
||||
val gaanaPlaceholderImageUrl = "https://a10.gaanacdn.com/images/social/gaana_social.jpg"
|
||||
|
||||
fun gaanaSearch(type:String,link:String){
|
||||
when(type){
|
||||
@ -109,6 +110,7 @@ class GaanaViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO)
|
||||
trackList.value = it.tracks.toTrackDetailsList()
|
||||
title.value = link
|
||||
//coverUrl.value = "TODO"
|
||||
coverUrl.value = gaanaPlaceholderImageUrl
|
||||
withContext(Dispatchers.IO){
|
||||
databaseDAO.insert(DownloadRecord(
|
||||
type = "Playlist",
|
||||
|
@ -17,9 +17,6 @@
|
||||
|
||||
package com.shabinder.spotiflyer.ui.mainfragment
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.view.LayoutInflater
|
||||
@ -32,10 +29,7 @@ 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.utils.Provider
|
||||
import com.shabinder.spotiflyer.utils.isOnline
|
||||
import com.shabinder.spotiflyer.utils.showMessage
|
||||
import com.shabinder.spotiflyer.utils.showNoConnectionAlert
|
||||
import com.shabinder.spotiflyer.utils.*
|
||||
import com.shreyaspatil.easyupipayment.EasyUpiPayment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -122,82 +116,22 @@ class MainFragment : Fragment() {
|
||||
private fun initializeAll() {
|
||||
mainViewModel = ViewModelProvider(this).get(MainViewModel::class.java)
|
||||
sharedViewModel = ViewModelProvider(this.requireActivity()).get(SharedViewModel::class.java)
|
||||
openYTButton()
|
||||
openSpotifyButton()
|
||||
openGithubButton()
|
||||
openInstaButton()
|
||||
openLinkedInButton()
|
||||
historyButton()
|
||||
binding.usage.text = usageText()
|
||||
binding.btnDonate.setOnClickListener {
|
||||
easyUpiPayment.startPayment()
|
||||
binding.apply {
|
||||
btnGaana.openPlatformOnClick("com.gaana","http://gaana.com")
|
||||
btnSpotify.openPlatformOnClick("com.spotify.music","http://open.spotify.com")
|
||||
btnYoutube.openPlatformOnClick("com.google.android.youtube","http://m.youtube.com")
|
||||
btnGithub.openPlatformOnClick("http://github.com/Shabinder/SpotiFlyer")
|
||||
btnInsta.openPlatformOnClick("http://www.instagram.com/mr.shabinder")
|
||||
btnHistory.setOnClickListener {
|
||||
findNavController().navigate(MainFragmentDirections.actionMainFragmentToDownloadRecord())
|
||||
}
|
||||
usage.text = usageText()
|
||||
btnDonate.setOnClickListener {
|
||||
easyUpiPayment.startPayment()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementing buttons
|
||||
**/
|
||||
private fun historyButton() {
|
||||
binding.btnHistory.setOnClickListener {
|
||||
findNavController().navigate(MainFragmentDirections.actionMainFragmentToDownloadRecord())
|
||||
}
|
||||
}
|
||||
private fun openSpotifyButton() {
|
||||
val manager: PackageManager = requireActivity().packageManager
|
||||
try {
|
||||
val i = manager.getLaunchIntentForPackage("com.spotify.music")
|
||||
?: throw PackageManager.NameNotFoundException()
|
||||
i.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
binding.btnSpotify.setOnClickListener { startActivity(i) }
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
val uri: Uri =
|
||||
Uri.parse("http://open.spotify.com")
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
binding.btnSpotify.setOnClickListener {
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun openYTButton() {
|
||||
val manager: PackageManager = requireActivity().packageManager
|
||||
try {
|
||||
val i = manager.getLaunchIntentForPackage("com.google.android.youtube")
|
||||
?: throw PackageManager.NameNotFoundException()
|
||||
i.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
binding.btnYoutube.setOnClickListener { startActivity(i) }
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
val uri: Uri =
|
||||
Uri.parse("http://m.youtube.com")
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
binding.btnYoutube.setOnClickListener {
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun openGithubButton() {
|
||||
val uri: Uri =
|
||||
Uri.parse("http://github.com/Shabinder/SpotiFlyer")
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
binding.btnGithubSpotify.setOnClickListener {
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
private fun openLinkedInButton() {
|
||||
val uri: Uri =
|
||||
Uri.parse("https://in.linkedin.com/in/shabinder")
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
binding.btnLinkedin.setOnClickListener {
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
private fun openInstaButton() {
|
||||
val uri: Uri =
|
||||
Uri.parse("http://www.instagram.com/mr.shabinder")
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
binding.developerInstaSpotify.setOnClickListener {
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
private fun usageText(): SpannableStringBuilder {
|
||||
return SpannableStringBuilder()
|
||||
.append(getText(R.string.d_one)).append("\n")
|
||||
|
@ -26,7 +26,6 @@ import android.view.ViewGroup
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator
|
||||
import com.shabinder.spotiflyer.MainActivity
|
||||
import com.shabinder.spotiflyer.downloadHelper.DownloadHelper
|
||||
import com.shabinder.spotiflyer.models.DownloadStatus
|
||||
import com.shabinder.spotiflyer.models.spotify.Source
|
||||
@ -63,8 +62,9 @@ class SpotifyFragment : TrackListFragment<SpotifyViewModel,SpotifyFragmentArgs>(
|
||||
|
||||
Log.i("Spotify Fragment", "$type : $link")
|
||||
|
||||
|
||||
if(sharedViewModel.spotifyService.value == null){//Authentication pending!!
|
||||
(activity as MainActivity).authenticateSpotify()
|
||||
if(isOnline()) mainActivity.authenticateSpotify()
|
||||
}
|
||||
|
||||
when{
|
||||
@ -89,7 +89,7 @@ class SpotifyFragment : TrackListFragment<SpotifyViewModel,SpotifyFragmentArgs>(
|
||||
binding.downloadingFab.visibility = View.VISIBLE
|
||||
|
||||
rotateAnim(binding.downloadingFab)
|
||||
for (track in this.viewModel.trackList.value!!){
|
||||
for (track in this.viewModel.trackList.value ?: listOf()){
|
||||
if(track.downloaded != DownloadStatus.Downloaded){
|
||||
track.downloaded = DownloadStatus.Downloading
|
||||
adapter.notifyItemChanged(this.viewModel.trackList.value!!.indexOf(track))
|
||||
|
@ -52,7 +52,7 @@ class SpotifyViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO
|
||||
}
|
||||
trackList.value = listOf(it).toTrackDetailsList()
|
||||
title.value = it.name
|
||||
coverUrl.value = it.album!!.images?.get(0)!!.url!!
|
||||
coverUrl.value = it.album!!.images?.elementAtOrNull(1)?.url ?: it.album!!.images?.elementAtOrNull(0)?.url
|
||||
withContext(Dispatchers.IO){
|
||||
databaseDAO.insert(DownloadRecord(
|
||||
type = "Track",
|
||||
@ -77,11 +77,11 @@ class SpotifyViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO
|
||||
if(File(finalOutputDir(it.name!!,folderType,subFolder)).exists()){//Download Already Present!!
|
||||
it.downloaded = DownloadStatus.Downloaded
|
||||
}
|
||||
it.album = Album(images = listOf(Image(url = albumObject.images?.get(0)?.url)))
|
||||
it.album = Album(images = listOf(Image(url = albumObject.images?.elementAtOrNull(1)?.url ?: albumObject.images?.elementAtOrNull(0)?.url )))
|
||||
}
|
||||
trackList.value = albumObject?.tracks?.items?.toTrackDetailsList()
|
||||
title.value = albumObject?.name
|
||||
coverUrl.value = albumObject?.images?.get(0)?.url
|
||||
coverUrl.value = albumObject?.images?.elementAtOrNull(1)?.url ?: albumObject?.images?.elementAtOrNull(0)?.url
|
||||
withContext(Dispatchers.IO){
|
||||
databaseDAO.insert(DownloadRecord(
|
||||
type = "Album",
|
||||
@ -124,7 +124,7 @@ class SpotifyViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO
|
||||
Log.i("Total Tracks Fetched",tempTrackList.size.toString())
|
||||
trackList.value = tempTrackList.toTrackDetailsList()
|
||||
title.value = playlistObject?.name
|
||||
coverUrl.value = playlistObject?.images?.get(0)?.url.toString()
|
||||
coverUrl.value = playlistObject?.images?.elementAtOrNull(1)?.url ?: playlistObject?.images?.firstOrNull()?.url.toString()
|
||||
withContext(Dispatchers.IO){
|
||||
databaseDAO.insert(DownloadRecord(
|
||||
type = "Playlist",
|
||||
@ -153,14 +153,14 @@ class SpotifyViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO
|
||||
durationSec = (it.duration_ms/1000).toInt(),
|
||||
albumArt = File(
|
||||
Environment.getExternalStorageDirectory(),
|
||||
Provider.defaultDir +".Images/" + (it.album?.images?.get(0)?.url.toString()).substringAfterLast('/') + ".jpeg"),
|
||||
Provider.defaultDir +".Images/" + (it.album?.images?.elementAtOrNull(1)?.url ?: it.album?.images?.firstOrNull()?.url.toString()).substringAfterLast('/') + ".jpeg"),
|
||||
albumName = it.album?.name,
|
||||
year = it.album?.release_date,
|
||||
comment = "Genres:${it.album?.genres?.joinToString()}",
|
||||
trackUrl = it.href,
|
||||
downloaded = it.downloaded,
|
||||
source = Source.Spotify,
|
||||
albumArtURL = it.album?.images?.get(0)?.url.toString()
|
||||
albumArtURL = it.album?.images?.elementAtOrNull(1)?.url ?: it.album?.images?.firstOrNull()?.url.toString()
|
||||
)
|
||||
}.toMutableList()
|
||||
|
||||
|
@ -27,11 +27,8 @@ import com.shabinder.spotiflyer.database.DownloadRecord
|
||||
import com.shabinder.spotiflyer.models.DownloadStatus
|
||||
import com.shabinder.spotiflyer.models.TrackDetails
|
||||
import com.shabinder.spotiflyer.models.spotify.Source
|
||||
import com.shabinder.spotiflyer.utils.*
|
||||
import com.shabinder.spotiflyer.utils.Provider.defaultDir
|
||||
import com.shabinder.spotiflyer.utils.TrackListViewModel
|
||||
import com.shabinder.spotiflyer.utils.finalOutputDir
|
||||
import com.shabinder.spotiflyer.utils.removeIllegalChars
|
||||
import com.shabinder.spotiflyer.utils.showMessage
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@ -48,6 +45,7 @@ class YoutubeViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO
|
||||
override var subFolder = ""
|
||||
|
||||
fun getYTPlaylist(searchId:String, ytDownloader:YoutubeDownloader){
|
||||
if(!isOnline())return
|
||||
try{
|
||||
uiScope.launch(Dispatchers.IO) {
|
||||
Log.i("YT Playlist",searchId)
|
||||
@ -105,6 +103,7 @@ class YoutubeViewModel @ViewModelInject constructor(val databaseDAO: DatabaseDAO
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
fun getYTTrack(searchId:String, ytDownloader:YoutubeDownloader) {
|
||||
if(!isOnline())return
|
||||
try{
|
||||
uiScope.launch(Dispatchers.IO) {
|
||||
Log.i("YT Video",searchId)
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.spotiflyer.utils
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.view.View
|
||||
import com.shabinder.spotiflyer.utils.Provider.mainActivity
|
||||
|
||||
fun View.openPlatformOnClick(packageName:String, websiteAddress:String){
|
||||
val manager: PackageManager = mainActivity.packageManager
|
||||
try {
|
||||
val i = manager.getLaunchIntentForPackage(packageName)
|
||||
?: throw PackageManager.NameNotFoundException()
|
||||
i.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
this.setOnClickListener { mainActivity.startActivity(i) }
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
val uri: Uri =
|
||||
Uri.parse(websiteAddress)
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
this.setOnClickListener { mainActivity.startActivity(intent) }
|
||||
}
|
||||
}
|
||||
fun View.openPlatformOnClick(websiteAddress:String){
|
||||
val uri: Uri =
|
||||
Uri.parse(websiteAddress)
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
this.setOnClickListener { mainActivity.startActivity(intent) }
|
||||
}
|
@ -36,6 +36,7 @@ import com.shabinder.spotiflyer.models.DownloadStatus
|
||||
import com.shabinder.spotiflyer.models.TrackDetails
|
||||
import com.shabinder.spotiflyer.models.spotify.Source
|
||||
import com.shabinder.spotiflyer.recyclerView.TrackListAdapter
|
||||
import com.shabinder.spotiflyer.utils.Provider.mainActivity
|
||||
|
||||
abstract class TrackListFragment<VM : TrackListViewModel , args: NavArgs> : Fragment() {
|
||||
|
||||
@ -50,6 +51,10 @@ abstract class TrackListFragment<VM : TrackListViewModel , args: NavArgs> : Frag
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if(!isOnline()){
|
||||
showNoConnectionAlert()
|
||||
mainActivity.onBackPressed()
|
||||
}
|
||||
sharedViewModel = ViewModelProvider(this.requireActivity()).get(SharedViewModel::class.java)
|
||||
}
|
||||
|
||||
@ -72,7 +77,7 @@ abstract class TrackListFragment<VM : TrackListViewModel , args: NavArgs> : Frag
|
||||
**/
|
||||
private fun initializeLiveDataObservers() {
|
||||
viewModel.trackList.observe(viewLifecycleOwner, {
|
||||
if (it.isNotEmpty()){
|
||||
if (!it.isNullOrEmpty()){
|
||||
Log.i("GaanaFragment","TrackList Updated")
|
||||
adapter.submitList(it, source)
|
||||
checkIfAllDownloaded()
|
||||
@ -80,7 +85,7 @@ abstract class TrackListFragment<VM : TrackListViewModel , args: NavArgs> : Frag
|
||||
})
|
||||
|
||||
viewModel.coverUrl.observe(viewLifecycleOwner, {
|
||||
if(it!="Loading") bindImage(binding.coverImage,it, source)
|
||||
it?.let{bindImage(binding.coverImage,it, source)}
|
||||
})
|
||||
|
||||
viewModel.title.observe(viewLifecycleOwner, {
|
||||
|
@ -35,7 +35,7 @@ abstract class TrackListViewModel:ViewModel() {
|
||||
|
||||
private val loading = "Loading!"
|
||||
open var title = MutableLiveData<String>().apply { value = loading }
|
||||
open var coverUrl = MutableLiveData<String>().apply { value = loading }
|
||||
open var coverUrl = MutableLiveData<String>()
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
|
@ -96,7 +96,7 @@ fun isOnline(): Boolean {
|
||||
return result
|
||||
}
|
||||
|
||||
fun showMessage(message: String, long: Boolean = false){
|
||||
fun showMessage(message: String, long: Boolean = false,isSuccess:Boolean = false , isError:Boolean = false){
|
||||
CoroutineScope(Dispatchers.Main).launch{
|
||||
Snackbar.make(
|
||||
mainActivity.snackBarAnchor,
|
||||
@ -106,6 +106,11 @@ fun showMessage(message: String, long: Boolean = false){
|
||||
setAction("Ok") {
|
||||
dismiss()
|
||||
}
|
||||
setActionTextColor(ContextCompat.getColor(mainActivity,R.color.black))
|
||||
when{
|
||||
isSuccess -> setBackgroundTint(ContextCompat.getColor(mainActivity,R.color.successGreen))
|
||||
isError -> setBackgroundTint(ContextCompat.getColor(mainActivity,R.color.errorRed))
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ class ForegroundService : Service(){
|
||||
}
|
||||
}
|
||||
speed = 0
|
||||
updateNotification()
|
||||
// updateNotification()
|
||||
}
|
||||
|
||||
override fun onDeleted(download: Download) {
|
||||
@ -343,7 +343,7 @@ class ForegroundService : Service(){
|
||||
val track = requestMap[download.request]
|
||||
Log.i(tag,"${track?.title} ETA: ${etaInMilliSeconds/1000} sec")
|
||||
speed = (downloadedBytesPerSecond/1000)
|
||||
updateNotification()
|
||||
// updateNotification()
|
||||
}
|
||||
|
||||
}
|
||||
@ -448,7 +448,7 @@ class ForegroundService : Service(){
|
||||
.setSubText("Total: $total Completed:$converted")
|
||||
.setNotificationSilent()
|
||||
.setStyle(NotificationCompat.InboxStyle()
|
||||
.setBigContentTitle("Speed: $speed KB/s")
|
||||
// .setBigContentTitle("Speed: $speed KB/s")
|
||||
.addLine(messageList[0])
|
||||
.addLine(messageList[1])
|
||||
.addLine(messageList[2])
|
||||
@ -540,7 +540,7 @@ class ForegroundService : Service(){
|
||||
.setNotificationSilent()
|
||||
.setSubText("Total: $total Completed:$converted")
|
||||
.setStyle(NotificationCompat.InboxStyle()
|
||||
.setBigContentTitle("Speed: $speed KB/s")
|
||||
// .setBigContentTitle("Speed: $speed KB/s")
|
||||
.addLine(messageList[0])
|
||||
.addLine(messageList[1])
|
||||
.addLine(messageList[2])
|
||||
|
BIN
app/src/main/res/drawable/gaana.png
Normal file
BIN
app/src/main/res/drawable/gaana.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
27
app/src/main/res/drawable/ic_gaana.xml
Normal file
27
app/src/main/res/drawable/ic_gaana.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<!--
|
||||
~ 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 <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="83dp"
|
||||
android:height="45dp"
|
||||
android:viewportWidth="83"
|
||||
android:viewportHeight="33">
|
||||
<path
|
||||
android:fillColor="#F42C30"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M58.7,19.8c0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5 1.2,-6.7C74.5,6.9 74.6,6.3 74.7,5.7z"/>
|
||||
</vector>
|
@ -26,7 +26,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
style="@style/Widget.AppCompat.EditText.Gradient"
|
||||
style="@style/Widget.AppCompat.TextView.Gradient"
|
||||
android:drawablePadding="5dp"
|
||||
android:fontFamily="@font/raleway_semibold"
|
||||
android:text=" Download History "
|
||||
@ -56,6 +56,11 @@
|
||||
android:icon="@drawable/ic_spotify_logo"
|
||||
android:text="Spotify" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:icon="@drawable/gaana"
|
||||
android:text="Gaana" />
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -20,7 +20,6 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/mainActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<View
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
<EditText
|
||||
android:id="@+id/linkSearch"
|
||||
style="@style/Widget.AppCompat.EditText.Gradient"
|
||||
style="@style/Widget.AppCompat.TextView.Gradient"
|
||||
android:layout_height="46dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:ems="10"
|
||||
@ -113,7 +113,7 @@
|
||||
android:layout_marginEnd="2dp"
|
||||
android:contentDescription="Open Spotify App Button"
|
||||
android:src="@drawable/ic_spotify_logo"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn_youtube"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn_Gaana"
|
||||
android:padding="6dp"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="@+id/appSubTitle"
|
||||
@ -122,11 +122,22 @@
|
||||
<ImageButton
|
||||
android:id="@+id/btn_youtube"
|
||||
style="@style/Widget.AppCompat.ImageButton.platformIcon"
|
||||
android:contentDescription="Open Youtube App Button"
|
||||
android:src="@drawable/ic_youtube"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/btn_spotify"
|
||||
android:contentDescription="Open Youtube App Button"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_spotify"
|
||||
app:layout_constraintEnd_toEndOf="@+id/appSubTitle"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_Gaana"
|
||||
app:layout_constraintTop_toTopOf="@+id/btn_spotify"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_Gaana"
|
||||
style="@style/Widget.AppCompat.ImageButton.platformIcon"
|
||||
android:contentDescription="Open Gaana App Button"
|
||||
android:padding="6dp"
|
||||
android:src="@drawable/gaana"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/btn_spotify"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn_youtube"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_spotify"
|
||||
app:layout_constraintTop_toTopOf="@+id/btn_spotify" />
|
||||
|
||||
<TextView
|
||||
@ -139,10 +150,10 @@
|
||||
android:textAlignment="center"
|
||||
android:textColor="#D0838383"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/developer_insta_spotify"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/btn_Insta"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_linkedin"
|
||||
app:layout_constraintTop_toTopOf="@+id/btn_github_spotify" />
|
||||
app:layout_constraintTop_toTopOf="@+id/btn_github" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btn_donate"
|
||||
@ -177,7 +188,7 @@
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_github_spotify"
|
||||
android:id="@+id/btn_github"
|
||||
style="@style/Widget.AppCompat.ImageButton.platformIcon"
|
||||
android:src="@drawable/ic_github"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btn_linkedin"
|
||||
@ -190,13 +201,13 @@
|
||||
android:id="@+id/btn_linkedin"
|
||||
style="@style/Widget.AppCompat.ImageButton.platformIcon"
|
||||
android:src="@drawable/ic_linkedin"
|
||||
app:layout_constraintBottom_toTopOf="@+id/developer_insta_spotify"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btn_Insta"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:contentDescription="Open LinkedIN App Button"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btn_github_spotify"/>
|
||||
app:layout_constraintTop_toBottomOf="@+id/btn_github"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/developer_insta_spotify"
|
||||
android:id="@+id/btn_Insta"
|
||||
style="@style/Widget.AppCompat.ImageButton.platformIcon"
|
||||
android:src="@drawable/ic_instagram"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btn_donate"
|
||||
|
@ -25,7 +25,7 @@
|
||||
<color name="grey">#99FFFFFF</color>
|
||||
<color name="black">#000000</color>
|
||||
<color name="dark">#121212</color>
|
||||
<color name="successGreen">#4BB543</color>
|
||||
<color name="successGreen">#59C351</color>
|
||||
<color name="errorRed">#FF9494</color>
|
||||
|
||||
</resources>
|
@ -25,6 +25,8 @@
|
||||
<item name="colorError">#FF5E5E</item>
|
||||
<item name="colorOnError">@color/black</item>
|
||||
<item name="colorSurface">@color/dark</item>
|
||||
<item name="statusBarScrim">@color/black</item>
|
||||
<item name="android:statusBarColor">@color/black</item>
|
||||
<item name="colorOnSurface">@color/white</item>
|
||||
<item name="colorPrimary">#FC5C7D</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
@ -62,11 +64,13 @@
|
||||
<item name="android:scaleType">fitCenter</item>
|
||||
<item name="android:layout_margin">8dp</item>
|
||||
</style>
|
||||
<style name="Widget.AppCompat.EditText.Gradient" parent="Widget.AppCompat.EditText">
|
||||
<style name="Widget.AppCompat.TextView.Gradient">
|
||||
<item name="android:background">@drawable/text_background_accented</item>
|
||||
<item name="android:textAlignment">center</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:inputType">text</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:layout_gravity">center</item>
|
||||
<item name="android:padding">8dp</item>
|
||||
<item name="android:textSize">18sp</item>
|
||||
<item name="android:textColor">@color/white</item>
|
||||
|
Loading…
Reference in New Issue
Block a user