diff --git a/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt b/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt index 3b32e10c..74c0f886 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/MainActivity.kt @@ -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()) diff --git a/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt index 78c73484..33c8973f 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt @@ -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(",")}" diff --git a/app/src/main/java/com/shabinder/spotiflyer/recyclerView/DownloadRecordAdapter.kt b/app/src/main/java/com/shabinder/spotiflyer/recyclerView/DownloadRecordAdapter.kt index 6648d542..f2cdd643 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/recyclerView/DownloadRecordAdapter.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/recyclerView/DownloadRecordAdapter.kt @@ -35,12 +35,12 @@ import kotlinx.coroutines.launch class DownloadRecordAdapter: ListAdapter(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 { + 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) diff --git a/app/src/main/java/com/shabinder/spotiflyer/ui/downloadrecord/DownloadRecordFragment.kt b/app/src/main/java/com/shabinder/spotiflyer/ui/downloadrecord/DownloadRecordFragment.kt index b48311e9..97150b71 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/ui/downloadrecord/DownloadRecordFragment.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/ui/downloadrecord/DownloadRecordFragment.kt @@ -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?) {} diff --git a/app/src/main/java/com/shabinder/spotiflyer/ui/downloadrecord/DownloadRecordViewModel.kt b/app/src/main/java/com/shabinder/spotiflyer/ui/downloadrecord/DownloadRecordViewModel.kt index 8ce7a1e8..d985d4a3 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/ui/downloadrecord/DownloadRecordViewModel.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/ui/downloadrecord/DownloadRecordViewModel.kt @@ -41,6 +41,7 @@ class DownloadRecordViewModel @ViewModelInject constructor(val databaseDAO: Data init { getDownloadRecordList() } + private fun getDownloadRecordList() { uiScope.launch { downloadRecordList.postValue(databaseDAO.getRecord().toMutableList()) diff --git a/app/src/main/java/com/shabinder/spotiflyer/ui/gaana/GaanaViewModel.kt b/app/src/main/java/com/shabinder/spotiflyer/ui/gaana/GaanaViewModel.kt index 6e81a679..15f83620 100644 --- a/app/src/main/java/com/shabinder/spotiflyer/ui/gaana/GaanaViewModel.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/ui/gaana/GaanaViewModel.kt @@ -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", diff --git a/app/src/main/java/com/shabinder/spotiflyer/ui/mainfragment/MainFragment.kt b/app/src/main/java/com/shabinder/spotiflyer/ui/mainfragment/MainFragment.kt index 6ad9a9c0..7a0033e8 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/ui/mainfragment/MainFragment.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/ui/mainfragment/MainFragment.kt @@ -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") diff --git a/app/src/main/java/com/shabinder/spotiflyer/ui/spotify/SpotifyFragment.kt b/app/src/main/java/com/shabinder/spotiflyer/ui/spotify/SpotifyFragment.kt index cc7299a8..465d7eb6 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/ui/spotify/SpotifyFragment.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/ui/spotify/SpotifyFragment.kt @@ -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( 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( 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)) diff --git a/app/src/main/java/com/shabinder/spotiflyer/ui/spotify/SpotifyViewModel.kt b/app/src/main/java/com/shabinder/spotiflyer/ui/spotify/SpotifyViewModel.kt index f6f758d7..705166f9 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/ui/spotify/SpotifyViewModel.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/ui/spotify/SpotifyViewModel.kt @@ -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() diff --git a/app/src/main/java/com/shabinder/spotiflyer/ui/youtube/YoutubeViewModel.kt b/app/src/main/java/com/shabinder/spotiflyer/ui/youtube/YoutubeViewModel.kt index e3e0e242..48d816aa 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/ui/youtube/YoutubeViewModel.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/ui/youtube/YoutubeViewModel.kt @@ -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) diff --git a/app/src/main/java/com/shabinder/spotiflyer/utils/Extensions.kt b/app/src/main/java/com/shabinder/spotiflyer/utils/Extensions.kt new file mode 100644 index 00000000..896657ca --- /dev/null +++ b/app/src/main/java/com/shabinder/spotiflyer/utils/Extensions.kt @@ -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 . + */ + +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) } +} \ No newline at end of file diff --git a/app/src/main/java/com/shabinder/spotiflyer/utils/TrackListFragment.kt b/app/src/main/java/com/shabinder/spotiflyer/utils/TrackListFragment.kt index 60e4bd56..a5080d81 100644 --- a/app/src/main/java/com/shabinder/spotiflyer/utils/TrackListFragment.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/utils/TrackListFragment.kt @@ -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 : Fragment() { @@ -50,6 +51,10 @@ abstract class TrackListFragment : 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 : 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 : Frag }) viewModel.coverUrl.observe(viewLifecycleOwner, { - if(it!="Loading") bindImage(binding.coverImage,it, source) + it?.let{bindImage(binding.coverImage,it, source)} }) viewModel.title.observe(viewLifecycleOwner, { diff --git a/app/src/main/java/com/shabinder/spotiflyer/utils/TrackListViewModel.kt b/app/src/main/java/com/shabinder/spotiflyer/utils/TrackListViewModel.kt index 1ab33bd8..4bc69340 100644 --- a/app/src/main/java/com/shabinder/spotiflyer/utils/TrackListViewModel.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/utils/TrackListViewModel.kt @@ -35,7 +35,7 @@ abstract class TrackListViewModel:ViewModel() { private val loading = "Loading!" open var title = MutableLiveData().apply { value = loading } - open var coverUrl = MutableLiveData().apply { value = loading } + open var coverUrl = MutableLiveData() override fun onCleared() { super.onCleared() diff --git a/app/src/main/java/com/shabinder/spotiflyer/utils/Utils.kt b/app/src/main/java/com/shabinder/spotiflyer/utils/Utils.kt index 887fb227..ca125bd9 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/utils/Utils.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/utils/Utils.kt @@ -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() } } diff --git a/app/src/main/java/com/shabinder/spotiflyer/worker/ForegroundService.kt b/app/src/main/java/com/shabinder/spotiflyer/worker/ForegroundService.kt index edb8b844..f6829393 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/worker/ForegroundService.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/worker/ForegroundService.kt @@ -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]) diff --git a/app/src/main/res/drawable/gaana.png b/app/src/main/res/drawable/gaana.png new file mode 100644 index 00000000..fbf81daf Binary files /dev/null and b/app/src/main/res/drawable/gaana.png differ diff --git a/app/src/main/res/drawable/ic_gaana.xml b/app/src/main/res/drawable/ic_gaana.xml new file mode 100644 index 00000000..08175bbb --- /dev/null +++ b/app/src/main/res/drawable/ic_gaana.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/layout/download_record_fragment.xml b/app/src/main/res/layout/download_record_fragment.xml index dacd85b1..29be0126 100755 --- a/app/src/main/res/layout/download_record_fragment.xml +++ b/app/src/main/res/layout/download_record_fragment.xml @@ -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" /> + + + + app:layout_constraintTop_toTopOf="@+id/btn_github" /> + app:layout_constraintTop_toBottomOf="@+id/btn_github"/> #99FFFFFF #000000 #121212 - #4BB543 + #59C351 #FF9494 \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c3b734c0..fab32e6a 100755 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -25,6 +25,8 @@ #FF5E5E @color/black @color/dark + @color/black + @color/black @color/white #FC5C7D @color/white @@ -62,11 +64,13 @@ fitCenter 8dp -